Dataset Preview
Duplicate
The full dataset viewer is not available (click to read why). Only showing a preview of the rows.
The dataset generation failed
Error code:   DatasetGenerationError
Exception:    CastError
Message:      Couldn't cast
messages: list<item: struct<role: string, content: string>>
  child 0, item: struct<role: string, content: string>
      child 0, role: string
      child 1, content: string
metadata: string
chosen: string
instruction: string
rejected: string
to
{'instruction': Value('string'), 'chosen': Value('string'), 'rejected': Value('string'), 'metadata': Json(decode=True)}
because column names don't match
Traceback:    Traceback (most recent call last):
                File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 1779, in _prepare_split_single
                  for key, table in generator:
                                    ^^^^^^^^^
                File "/usr/local/lib/python3.12/site-packages/datasets/packaged_modules/json/json.py", line 299, in _generate_tables
                  self._cast_table(pa_table, json_field_paths=json_field_paths),
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                File "/usr/local/lib/python3.12/site-packages/datasets/packaged_modules/json/json.py", line 128, in _cast_table
                  pa_table = table_cast(pa_table, self.info.features.arrow_schema)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                File "/usr/local/lib/python3.12/site-packages/datasets/table.py", line 2321, in table_cast
                  return cast_table_to_schema(table, schema)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                File "/usr/local/lib/python3.12/site-packages/datasets/table.py", line 2249, in cast_table_to_schema
                  raise CastError(
              datasets.table.CastError: Couldn't cast
              messages: list<item: struct<role: string, content: string>>
                child 0, item: struct<role: string, content: string>
                    child 0, role: string
                    child 1, content: string
              metadata: string
              chosen: string
              instruction: string
              rejected: string
              to
              {'instruction': Value('string'), 'chosen': Value('string'), 'rejected': Value('string'), 'metadata': Json(decode=True)}
              because column names don't match
              
              The above exception was the direct cause of the following exception:
              
              Traceback (most recent call last):
                File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 1347, in compute_config_parquet_and_info_response
                  parquet_operations = convert_to_parquet(builder)
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
                File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 980, in convert_to_parquet
                  builder.download_and_prepare(
                File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 882, in download_and_prepare
                  self._download_and_prepare(
                File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 943, in _download_and_prepare
                  self._prepare_split(split_generator, **prepare_split_kwargs)
                File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 1646, in _prepare_split
                  for job_id, done, content in self._prepare_split_single(
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
                File "/usr/local/lib/python3.12/site-packages/datasets/builder.py", line 1832, in _prepare_split_single
                  raise DatasetGenerationError("An error occurred while generating the dataset") from e
              datasets.exceptions.DatasetGenerationError: An error occurred while generating the dataset

Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.

instruction
string
chosen
string
rejected
string
metadata
unknown
Perform 7-step defect analysis on this code fragment. Domain: Web Server <slice> off_t _q_iosend(FILE *outfp, FILE *infp, off_t nbytes) { if(nbytes == 0) return 0; unsigned char buf[QIOSEND_CHUNK_SIZE]; off_t total = 0; while(total < nbytes) { size_t chunksize; if(nbytes - total <= sizeof(buf) ) chunksize = ...
[SINK]: Dangerous function: fread at line 9. [DESTINATION]: Buffer size calculation: Size_B = sizeof(buf) = QIOSEND_CHUNK_SIZE for destination buf. [SOURCE]: Input size tracing: Size_A is derived from chunksize. Source operand traced as chunksize = min(nbytes - total, sizeof(buf)). [CONSTRAINTS]: Guards found before si...
[SINK]: Dangerous function: fread at line 9. [DESTINATION]: Buffer size calculation: Size_B = sizeof(buf) = QIOSEND_CHUNK_SIZE for destination buf. [SOURCE]: Input size tracing: Size_A is derived from chunksize. Source operand traced as chunksize = min(nbytes - total, sizeof(buf)). [CONSTRAINTS]: Guards found before si...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 2", "cwe_id": "CWE-122", "domain": "Web Server", "paradigm": "tree_of_thoughts", "ground_truth_label": 0, "fallacy_type": "loop bound off-by-one", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation", "snipp...
Perform 7-step defect analysis on this code fragment. Domain: Database Storage Engine <slice> copy_font_name(gs_font_name *pfstr, const ref *pfname) { uint size = r_size(pfname); if(size > gs_font_name_max) size = gs_font_name_max; // [TARGET_SINK] memcpy(& pfstr->chars[256] , pfname->value . const_bytes, si...
[SINK]: Dangerous function: memcpy at line with [TARGET_SINK] comment. [DESTINATION]: Buffer size calculation: Size_B = 0 for destination &pfstr->chars[256] (assuming chars array size = gs_font_name_max = 256, offset 256 leaves 0 bytes). [SOURCE]: Input size tracing: Size_A is derived from r_size(pfname). Source operan...
[SINK]: Dangerous function: memcpy at line with [TARGET_SINK] comment. [DESTINATION]: Buffer size calculation: Size_B = 0 for destination &pfstr->chars[256] (assuming chars array size = gs_font_name_max = 256, offset 256 leaves 0 bytes). [SOURCE]: Input size tracing: Size_A is derived from r_size(pfname). Source operan...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 3", "cwe_id": "CWE-787", "domain": "Database Storage Engine", "paradigm": "execution_trace", "ground_truth_label": 1, "fallacy_type": "alignment slack ignored", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbat...
Perform 7-step defect analysis on this code fragment. Domain: Cryptographic Parser <slice> int zmq :: curve_client_t :: decode(msg_t *msg_) { zmq_assert(state == connected); if(msg_->size() < 0) { errno = EPROTO; return - 0; } const uint8_t *message = static_cast < uint8_t * >(msg_->data() ); if(memcmp(m...
[SINK]: Dangerous function: memcpy at line with // [TARGET_SINK]. [DESTINATION]: Buffer size calculation: Size_B = crypto_box_NONCEBYTES for destination message_nonce. [SOURCE]: Input size tracing: Size_A is derived from constant 0. Source operand traced as literal '0'. [CONSTRAINTS]: Guards found before sink: if(msg_-...
[SINK]: Dangerous function: memcpy at line with // [TARGET_SINK]. [DESTINATION]: Buffer size calculation: Size_B = crypto_box_NONCEBYTES for destination message_nonce. [SOURCE]: Input size tracing: Size_A is derived from constant 0. Source operand traced as literal '0'. [CONSTRAINTS]: Guards found before sink: if(msg_-...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 2", "cwe_id": "CWE-119", "domain": "Cryptographic Parser", "paradigm": "execution_trace", "ground_truth_label": 0, "fallacy_type": "loop bound off-by-one", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation",...
Perform 7-step defect analysis on this code fragment. Domain: Smart-card Applet <slice> #include <stdint.h> #include <stdlib.h> #include <string.h> // [STRUCT_METADATA]: Size=24 bytes (including padding) typedef struct { uint8_t type; // offset 0 /* padding 7 bytes */ uint64_t timestamp; /...
[SINK]: Dangerous function: sc_malloc at line 34. [DESTINATION]: Buffer size calculation: Size_B = count * 13 for destination priv->records. [SOURCE]: Input size tracing: Size_A is derived from count and RECORD_HEADER_SIZE. Source operand traced as count parameter and RECORD_HEADER_SIZE macro. [CONSTRAINTS]: Guards fou...
[SINK]: Dangerous function: sc_malloc at line 34. [DESTINATION]: Buffer size calculation: Size_B = count * 13 for destination priv->records. [SOURCE]: Input size tracing: Size_A is derived from count and RECORD_HEADER_SIZE. Source operand traced as count parameter and RECORD_HEADER_SIZE macro. [CONSTRAINTS]: Guards fou...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 4", "cwe_id": "CWE-131", "domain": "Smart-card Applet", "paradigm": "counterfactual", "ground_truth_label": 1, "fallacy_type": "padding-byte miscalculation", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation...
Perform 7-step defect analysis on this code fragment. Domain: Bluetooth Stack <slice> readPDUHead(PRIVATE_ASSOCIATIONKEY * *association, unsigned char *buffer, unsigned long maxLength, DUL_BLOCKOPTIONS block, int timeout, unsigned char *PDUType, unsigned char *PDUReserved, unsigned long *PDULength) { OFCondi...
[SINK]: Dangerous function: sprintf at line with sprintf call. [DESTINATION]: Buffer size calculation: Size_B = 256 bytes for destination buf1. [SOURCE]: Input size tracing: Size_A is derived from string literal "data". Source operand traced as constant 6 bytes. [CONSTRAINTS]: Guards found before sink: if((* PDUType ==...
[SINK]: Dangerous function: sprintf at line with sprintf call. [DESTINATION]: Buffer size calculation: Size_B = 256 bytes for destination buf1. [SOURCE]: Input size tracing: Size_A is derived from string literal "data". Source operand traced as constant 6 bytes. [CONSTRAINTS]: Guards found before sink: if((* PDUType ==...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 3", "cwe_id": "CWE-120", "domain": "Bluetooth Stack", "paradigm": "linear", "ground_truth_label": 0, "fallacy_type": "sizeof pointer assumed 1", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation", "snippet...
Perform 7-step defect analysis on this code fragment. Domain: Filesystem Driver <slice> void vuln_func_01() { int * data; /* Initialize data */ data = NULL; data = (int *)malloc(100*sizeof(int)); // [STRUCT_METADATA]: Size=400 bytes if (data == NULL) {exit(-1);} /* POTENTIAL FLAW: Fr...
[SINK]: Dangerous function: free at line 8. [DESTINATION]: Buffer size calculation: Size_B = 400 bytes for destination data. [SOURCE]: Input size tracing: Size_A is derived from malloc(100*sizeof(int)). Source operand traced as malloc. [CONSTRAINTS]: Guards found before sink: if (data == NULL) {exit(-1);} [SCRATCHPAD]:...
[SINK]: Dangerous function: free at line 8. [DESTINATION]: Buffer size calculation: Size_B = 400 bytes for destination data. [SOURCE]: Input size tracing: Size_A is derived from malloc(100*sizeof(int)). Source operand traced as malloc. [CONSTRAINTS]: Guards found before sink: if (data == NULL) {exit(-1);} [SCRATCHPAD]:...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 2", "cwe_id": "CWE-415", "domain": "Filesystem Driver", "paradigm": "counterfactual", "ground_truth_label": 1, "fallacy_type": "conflating element-count and byte-count (or misuse of allocator resilience assumption)", "fallacy_location": "...
Perform 7-step defect analysis on this code fragment. Domain: VM Hypervisor <slice> #include <stdlib.h> #include <stdint.h> // [STRUCT_METADATA]: Size=16 bytes (two pointers) typedef struct { void *buf; uint32_t len; } BufferDescriptor; // [STRUCT_METADATA]: Size=24 bytes (pointer + two 32-bit fiel...
[SINK]: Dangerous function: safe_free at line 34. [DESTINATION]: Buffer size calculation: Size_B = sizeof(BufferDescriptor) = 16 bytes for destination dev->config. [SOURCE]: Input size tracing: Size_A is derived from handle. Source operand traced as handle > 0xFFFF guard. [CONSTRAINTS]: Guards found before sink: if (!d...
[SINK]: Dangerous function: safe_free at line 34. [DESTINATION]: Buffer size calculation: Size_B = sizeof(BufferDescriptor) = 16 bytes for destination dev->config. [SOURCE]: Input size tracing: Size_A is derived from handle. Source operand traced as handle > 0xFFFF guard. [CONSTRAINTS]: Guards found before sink: if (!d...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 3", "cwe_id": "CWE-415", "domain": "VM Hypervisor", "paradigm": "execution_trace", "ground_truth_label": 0, "fallacy_type": "alignment slack ignored", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation", "s...
Perform 7-step defect analysis on this code fragment. Domain: Browser Renderer <slice> ipmi_fru_read_internal_use(struct ipmi_intf *intf, uint8_t id, char *pFileName) { struct fru_info fru; uint16_t size; uint16_t offset; int rc = 0; rc = ipmi_fru_get_internal_use_info(intf, id, & fru, & size, & offset); if(...
[SINK]: Dangerous function: read_fru_area_section at line: rc = read_fru_area_section(intf, & fru, id, offset, size, frubuf); [DESTINATION]: Buffer size calculation: Size_B = size (the value passed to malloc and used for the allocation) for destination frubuf. [SOURCE]: Input size tracing: Size_A is derived from parame...
[SINK]: Dangerous function: read_fru_area_section at line: rc = read_fru_area_section(intf, & fru, id, offset, size, frubuf); [DESTINATION]: Buffer size calculation: Size_B = size (the value passed to malloc and used for the allocation) for destination frubuf. [SOURCE]: Input size tracing: Size_A is derived from parame...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 2", "cwe_id": "CWE-787", "domain": "Browser Renderer", "paradigm": "counterfactual", "ground_truth_label": 0, "fallacy_type": "guard sufficient", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation", "snippe...
Perform 7-step defect analysis on this code fragment. Domain: Web Server <slice> static void goodG2B1() { char * data; data = NULL; goodG2B1Static = 0; /* false */ data = goodG2B1Source(data); { char source[100]; // [STRUCT_METADATA]: Size=100 bytes memset(source, 'C', 10...
[SINK]: Dangerous function: strcpy at line 10. [DESTINATION]: Buffer size calculation: Size_B = undefined (data is allocated by goodG2B1Source, no size visible) for destination data. [SOURCE]: Input size tracing: Size_A is derived from source[100]. Source operand traced as stack array of 100 bytes. [CONSTRAINTS]: Guard...
[SINK]: Dangerous function: strcpy at line 10. [DESTINATION]: Buffer size calculation: Size_B = undefined (data is allocated by goodG2B1Source, no size visible) for destination data. [SOURCE]: Input size tracing: Size_A is derived from source[100]. Source operand traced as stack array of 100 bytes. [CONSTRAINTS]: Guard...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 2", "cwe_id": "CWE-122", "domain": "Web Server", "paradigm": "counterfactual", "ground_truth_label": 1, "fallacy_type": "byte vs element confusion", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation", "sni...
Perform 7-step defect analysis on this code fragment. Domain: Kernel Module <slice> static int select_app_df(void) { sc_path_t path; sc_file_t *file; char str[256]; // [STRUCT_METADATA]: Size=256 bytes int r; strcpy(str, "data"); if(opt_appdf != NULL) strlcat(str, opt_appdf, sizeof str); sc_format_path(str,...
[SINK]: Dangerous function: strlcat at line strlcat. [DESTINATION]: Buffer size calculation: Size_B = 256 bytes for destination str. [SOURCE]: Input size tracing: Size_A is derived from opt_appdf. Source operand traced as opt_appdf. [CONSTRAINTS]: Guards found before sink: if(opt_appdf != NULL). [SCRATCHPAD]: Attacker ...
[SINK]: Dangerous function: strlcat at line strlcat. [DESTINATION]: Buffer size calculation: Size_B = 256 bytes for destination str. [SOURCE]: Input size tracing: Size_A is derived from opt_appdf. Source operand traced as opt_appdf. [CONSTRAINTS]: Guards found before sink: if(opt_appdf != NULL). [SCRATCHPAD]: Attacker ...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 2", "cwe_id": "CWE-120", "domain": "Kernel Module", "paradigm": "counterfactual", "ground_truth_label": 0, "fallacy_type": "byte vs element confusion", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation", "...
Perform 7-step defect analysis on this code fragment. Domain: VM Hypervisor <slice> #include <stdlib.h> #include <string.h> #include <stdint.h> // Simulated hypervisor memory allocator with reference counting struct hv_mem_block { uint64_t refcount; // reference count uint64_t size; // size of...
[SINK]: Dangerous function: hv_free at line 55 (second call). [DESTINATION]: Buffer size calculation: Size_B = sizeof(struct hv_mem_block) + size for block allocated by hv_alloc. [SOURCE]: Input size tracing: Size_A is derived from argument to hv_alloc, traced as user-controlled? Not directly, but handle is passed. [CO...
[SINK]: Dangerous function: hv_free at line 55 (second call). [DESTINATION]: Buffer size calculation: Size_B = sizeof(struct hv_mem_block) + size for block allocated by hv_alloc. [SOURCE]: Input size tracing: Size_A is derived from argument to hv_alloc, traced as user-controlled? Not directly, but handle is passed. [CO...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 4", "cwe_id": "CWE-415", "domain": "VM Hypervisor", "paradigm": "execution_trace", "ground_truth_label": 1, "fallacy_type": "opaque pointer aliasing", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation", "s...
Perform 7-step defect analysis on this code fragment. Domain: Network Router <slice> static void goodG2B1() { wchar_t * data; wchar_t * dataBadBuffer = (wchar_t *)ALLOCA(50*sizeof(wchar_t)); wchar_t * dataGoodBuffer = (wchar_t *)ALLOCA(100*sizeof(wchar_t)); if(globalFive!=5) { /* ...
[SINK]: Dangerous function: wcsncpy at line 22. [DESTINATION]: Buffer size calculation: Size_B = 100 (number of wchar_t) for destination data. [SOURCE]: Input size tracing: Size_A is derived from source array size and the count parameter. Source operand traced as source array of 100 wchar_t, count = 99. [CONSTRAINTS]: ...
[SINK]: Dangerous function: wcsncpy at line 22. [DESTINATION]: Buffer size calculation: Size_B = 100 (number of wchar_t) for destination data. [SOURCE]: Input size tracing: Size_A = 99 (wchar_t) from source array size (100) minus 1, and count parameter 99. [CONSTRAINTS]: Guards found before sink: if(globalFive!=5) { } ...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 2", "cwe_id": "CWE-121", "domain": "Network Router", "paradigm": "execution_trace", "ground_truth_label": 0, "fallacy_type": "Conflating element-count and byte-count", "fallacy_location": "[SCRATCHPAD]", "snippet_id": "real-c73dded498b2...
Perform 7-step defect analysis on this code fragment. Domain: Game Engine <slice> #include <cstdint> #include <cstddef> #include <vector> #include <string> #include <array> // [STRUCT_METADATA]: Size=16 bytes (2 pointers + 2 ints) struct Config { std::vector<uint8_t> buffer; uint32_t offset; /* 32-b...
[SINK]: Dangerous function: buffer read at line 31. [DESTINATION]: Buffer size calculation: Size_B = ent.config->buffer.size() for destination buffer. [SOURCE]: Input size tracing: Size_A is derived from base_offset. Source operand traced as ent.config->offset. [CONSTRAINTS]: Guards found before sink: if (end_offset <=...
[SINK]: Dangerous function: buffer read at line 31. [DESTINATION]: Buffer size calculation: Size_B = ent.config->buffer.size() for destination buffer. [SOURCE]: Input size tracing: Size_A is derived from base_offset. Source operand traced as ent.config->offset. [CONSTRAINTS]: Guards found before sink: if (end_offset <=...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 3", "cwe_id": "CWE-126", "domain": "Game Engine", "paradigm": "execution_trace", "ground_truth_label": 0, "fallacy_type": "alignment slack ignored", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation", "sni...
Perform 7-step defect analysis on this code fragment. Domain: Network Router <slice> static void goodG2B1() { char * data; char * dataBuffer = (char *)ALLOCA(100*sizeof(char)); data = dataBuffer; if(GLOBAL_CONST_FIVE!=5) { /* INCIDENTAL: CWE 561 Dead Code, the code below will neve...
[SINK]: Dangerous function: dest[i] = data[i] at line (inside for loop). [DESTINATION]: Buffer size calculation: Size_B = 50 for destination dest. [SOURCE]: Input size tracing: Size_A is derived from strlen(data). Source operand traced as strlen(data) returning length of data (max 49). [CONSTRAINTS]: Guards found befor...
[SINK]: Dangerous function: dest[i] = data[i] at line (inside for loop). [DESTINATION]: Buffer size calculation: Size_B = 50 for destination dest. [SOURCE]: Input size tracing: Size_A is derived from strlen(data). Source operand traced as strlen(data) returning length of data (max 49). [CONSTRAINTS]: Guards found befor...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 2", "cwe_id": "CWE-121", "domain": "Network Router", "paradigm": "execution_trace", "ground_truth_label": 0, "fallacy_type": "guard sufficient", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation", "snippet...
Perform 7-step defect analysis on this code fragment. Domain: Compression Library <slice> sg_alloc(struct gendisk *disk, struct scsi_device *scsidp) { struct request_queue *q = scsidp->request_queue; Sg_device *sdp; unsigned long iflags; int error; u32 k; sdp = kzalloc(sizeof(Sg_device), GFP_KERNEL); if(! sd...
[SINK]: Dangerous function: sprintf at line (approx) 10. [DESTINATION]: Buffer size calculation: Size_B = 32 (assumed from DISK_NAME_LEN) for destination disk->disk_name. [SOURCE]: Input size tracing: Size_A is derived from constant string "data" (5 bytes including null). Source operand traced as literal constant. [CON...
[SINK]: Dangerous function: sprintf at line (approx) 10. [DESTINATION]: Buffer size calculation: Size_B = 32 (assumed from DISK_NAME_LEN) for destination disk->disk_name. [SOURCE]: Input size tracing: Size_A is derived from constant string "data" (5 bytes including null). Source operand traced as literal constant. [CON...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 3", "cwe_id": "CWE-120", "domain": "Compression Library", "paradigm": "linear", "ground_truth_label": 0, "fallacy_type": "sizeof pointer assumed 1", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation", "sni...
Perform 7-step defect analysis on this code fragment. Domain: Embedded RTOS <slice> static void goodG2B() { char * data; data = NULL; /* Initialize data */ goto source; source: { /* FIX: data is allocated on the heap and deallocated in the BadSink */ // [TARGET_SINK] c...
[SINK]: Dangerous function: free(data) at line inside goodG2B() after the source block (the free call). [DESTINATION]: Buffer size calculation: Size_B = 100 bytes (allocated with malloc(100*sizeof(char))) for destination dataBuffer, which becomes the pointer data that is freed. [SOURCE]: Input size tracing: Size_A is d...
[SINK]: Dangerous function: free(data) at line inside goodG2B() after the source block (the free call). [DESTINATION]: Buffer size calculation: Size_B = 100 bytes (allocated with malloc(100*sizeof(char))) for destination dataBuffer, which becomes the pointer data that is freed. [SOURCE]: Input size tracing: Size_A is d...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 2", "cwe_id": "CWE-590", "domain": "Embedded RTOS", "paradigm": "counterfactual", "ground_truth_label": 0, "fallacy_type": "loop bound off-by-one", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation", "snip...
Perform 7-step defect analysis on this code fragment. Domain: Filesystem Driver <slice> #include <linux/kernel.h> #include <linux/slab.h> #include <linux/list.h> #include <linux/fs.h> #include <linux/uaccess.h> #include <linux/types.h> // [STRUCT_METADATA]: Size=64 bytes struct dir_entry { char name[32]...
[SINK]: Dangerous function: list_for_each_entry at line 86. [DESTINATION]: Buffer size calculation: Size_B = count for destination buf. [SOURCE]: Input size tracing: Size_A is derived from len. Source operand traced as strlen(entry->name) + 1. [CONSTRAINTS]: Guards found before sink: none [SCRATCHPAD]: Attacker Goal: U...
[SINK]: Dangerous function: list_for_each_entry at line 86. [DESTINATION]: Buffer size calculation: Size_B = count for destination buf. [SOURCE]: Input size tracing: Size_A is derived from len. Source operand traced as strlen(entry->name) + 1. [CONSTRAINTS]: Guards found before sink: none [SCRATCHPAD]: Attacker Goal: U...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 4", "cwe_id": "CWE-416", "domain": "Filesystem Driver", "paradigm": "counterfactual", "ground_truth_label": 1, "fallacy_type": "padding-byte miscalculation", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation...
Perform 7-step defect analysis on this code fragment. Domain: Filesystem Driver <slice> #include <linux/kernel.h> #include <linux/slab.h> #include <linux/list.h> #include <linux/uaccess.h> #include <linux/fs.h> struct fs_node { struct list_head list; u32 inode_num; /* 32-bit unsigned */ char nam...
[SINK]: Dangerous function: copy_from_user at line 73. [DESTINATION]: Buffer size calculation: Size_B = 64 for destination node->name. [SOURCE]: Input size tracing: Size_A is derived from len. Source operand traced as len parameter. [CONSTRAINTS]: Guards found before sink: none [SCRATCHPAD]: Step 1) Define Size_A = len...
[SINK]: Dangerous function: copy_from_user at line 73. [DESTINATION]: Buffer size calculation: Size_B = 64 for destination node->name. [SOURCE]: Input size tracing: Size_A is derived from len. Source operand traced as len parameter. [CONSTRAINTS]: Guards found before sink: none [SCRATCHPAD]: Step 1) Define Size_A = len...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 4", "cwe_id": "CWE-416", "domain": "Filesystem Driver", "paradigm": "linear", "ground_truth_label": 1, "fallacy_type": "opaque pointer aliasing", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation", "snippe...
Perform 7-step defect analysis on this code fragment. Domain: Database Storage Engine <slice> int tls1_check_ec_tmp_key(SSL *s, unsigned long cid) { if(tls1_suiteb(s) ) { unsigned char curve_id[256]; // [STRUCT_METADATA]: Size=256 bytes if(cid == TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256) curve_id[256] = ...
[SINK]: Dangerous function: assignment to curve_id[256] at line `curve_id[256] = TLSEXT_curve_P_256;` (and subsequent writes to the same index). [DESTINATION]: Buffer size calculation: Size_B = 256 bytes for destination curve_id. [SOURCE]: Input size tracing: Size_A is derived from constant index 256 (1-byte write); so...
[SINK]: Dangerous function: assignment to curve_id[256] at line `curve_id[256] = TLSEXT_curve_P_256;` (and subsequent writes to the same index). [DESTINATION]: Buffer size calculation: Size_B = 256 bytes for destination curve_id. [SOURCE]: Input size tracing: Size_A is derived from constant index 256 (1-byte write); so...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 2", "cwe_id": "CWE-119", "domain": "Database Storage Engine", "paradigm": "counterfactual", "ground_truth_label": 1, "fallacy_type": "guard sufficient", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation", ...
Perform 7-step defect analysis on this code fragment. Domain: Cryptographic Parser <slice> void vuln_func_01() { char data; char dataArray[5]; // [STRUCT_METADATA]: Size=5 bytes data = ' '; /* POTENTIAL FLAW: Use the minimum size of the data type */ // [TARGET_SINK] data = CHAR_MIN; ...
[SINK]: Dangerous function: assignment at line data = CHAR_MIN; (no actual dangerous function) [DESTINATION]: Buffer size calculation: Size_B = 5 for destination dataArray [SOURCE]: Input size tracing: Size_A is derived from constant CHAR_MIN. No input; constant assignment. [CONSTRAINTS]: Guards found before sink: none...
[SINK]: Dangerous function: assignment at line data = CHAR_MIN; (no actual dangerous function) [DESTINATION]: Buffer size calculation: Size_B = 5 for destination dataArray [SOURCE]: Input size tracing: Size_A is derived from constant CHAR_MIN. No input; constant assignment. [CONSTRAINTS]: Guards found before sink: none...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 2", "cwe_id": "CWE-680", "domain": "Cryptographic Parser", "paradigm": "execution_trace", "ground_truth_label": 0, "fallacy_type": "byte vs element confusion", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbati...
Perform 7-step defect analysis on this code fragment. Domain: Network Router <slice> void vuln_func_01() { int i; char * data; char * dataBuffer = (char *)ALLOCA(100*sizeof(char)); data = dataBuffer; for(i = 0; i < 1; i++) { /* FLAW: Initialize data as a large buffer that is l...
[SINK]: Dangerous function: strncpy at line 17. [DESTINATION]: Buffer size calculation: Size_B = 50 for destination dest. [SOURCE]: Input size tracing: Size_A is derived from data. Source operand traced as dataBuffer (100 bytes). [CONSTRAINTS]: Guards found before sink: none [SCRATCHPAD]: Step 1) Define Size_A = 100 (s...
[SINK]: Dangerous function: strncpy at line 17. [DESTINATION]: Buffer size calculation: Size_B = 50 for destination dest. [SOURCE]: Input size tracing: Size_A is derived from data. Source operand traced as dataBuffer (100 bytes). [CONSTRAINTS]: Guards found before sink: none [SCRATCHPAD]: Step 1) Define Size_A = 100 (s...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 2", "cwe_id": "CWE-121", "domain": "Network Router", "paradigm": "linear", "ground_truth_label": 1, "fallacy_type": "conflating element-count and byte-count", "fallacy_location": "[SCRATCHPAD]", "snippet_id": "real-6c28e2f786e8c742", ...
Perform 7-step defect analysis on this code fragment. Domain: Bluetooth Stack <slice> SYSCALL_DEFINE2(sethostname, char __user *, name, int, len) { int errno; char tmp[__NEW_UTS_LEN]; if(! ns_capable(current->nsproxy->uts_ns->user_ns, CAP_SYS_ADMIN) ) return - EPERM; if(len < 0 || len > __NEW_UTS_LEN) return...
[SINK]: Dangerous function: memcpy at line 10. [DESTINATION]: Buffer size calculation: Size_B = sizeof(u->nodename) = __NEW_UTS_LEN + 1. [SOURCE]: Input size tracing: Size_A is derived from len. Source operand traced as syscall argument 'len'. [CONSTRAINTS]: Guards found before sink: `if(len < 0 || len > __NEW_UTS_LEN)...
[SINK]: Dangerous function: memcpy at line 10. [DESTINATION]: Buffer size calculation: Size_B = sizeof(u->nodename) = __NEW_UTS_LEN + 1. [SOURCE]: Input size tracing: Size_A is derived from len. Source operand traced as syscall argument 'len'. [CONSTRAINTS]: Guards found before sink: `if(len < 0 || len > __NEW_UTS_LEN)...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 3", "cwe_id": "CWE-119", "domain": "Bluetooth Stack", "paradigm": "counterfactual", "ground_truth_label": 0, "fallacy_type": "alignment slack ignored", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation", "...
Perform 7-step defect analysis on this code fragment. Domain: Web Server <slice> void vuln_func_01() { twoIntsStruct * data; data = NULL; if(globalReturnsTrueOrFalse()) { /* FLAW: Allocate and point data to a small buffer that is smaller than the large buffer used in the sinks */ ...
[SINK]: Dangerous function: memcpy at line (TARGET_SINK). [DESTINATION]: Buffer size calculation: Size_B = 200 bytes for data. [SOURCE]: Input size tracing: Size_A is derived from source[100]. Source operand traced as 100*sizeof(twoIntsStruct)=400 bytes. [CONSTRAINTS]: Guards found before sink: none [SCRATCHPAD]: Step ...
[SINK]: Dangerous function: memcpy at line (TARGET_SINK). [DESTINATION]: Buffer size calculation: Size_B = 200 bytes for data. [SOURCE]: Input size tracing: Size_A is derived from source[100]. Source operand traced as 100*sizeof(twoIntsStruct)=400 bytes. [CONSTRAINTS]: Guards found before sink: none [SCRATCHPAD]: Step ...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 2", "cwe_id": "CWE-122", "domain": "Web Server", "paradigm": "linear", "ground_truth_label": 1, "fallacy_type": "loop bound off-by-one", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation", "snippet_id": "r...
Perform 7-step defect analysis on this code fragment. Domain: VM Hypervisor <slice> #include <stddef.h> #include <stdint.h> #include <stdlib.h> // [STRUCT_METADATA]: Size=24 bytes struct vm_page { uint64_t pfn; void *virt_addr; uint32_t flags; uint16_t ref_count; } __attribute__((aligned(8))...
[SINK]: Dangerous function: hypervisor_map_page at line 55. [DESTINATION]: Buffer size calculation: Size_B = sizeof(struct vm_page) for destination page. [SOURCE]: Input size tracing: Size_A is derived from region->pages. Source operand traced as custom_alloc(nr_pages * sizeof(struct vm_page), 0). [CONSTRAINTS]: Guards...
[SINK]: Dangerous function: hypervisor_map_page at line 55. [DESTINATION]: Buffer size calculation: Size_B = sizeof(struct vm_page) for destination page. [SOURCE]: Input size tracing: Size_A is derived from region->pages. Source operand traced as custom_alloc(nr_pages * sizeof(struct vm_page), 0). [CONSTRAINTS]: Guards...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 4", "cwe_id": "CWE-476", "domain": "VM Hypervisor", "paradigm": "counterfactual", "ground_truth_label": 0, "fallacy_type": "custom allocator size mismatch", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation"...
Perform 7-step defect analysis on this code fragment. Domain: Network Router <slice> ssize_t rdbSaveRawString(rio *rdb, unsigned char *s, size_t len) { int enclen; ssize_t n, nwritten = 0; if(len <= 0) { unsigned char buf[256]; // [STRUCT_METADATA]: Size=256 bytes if((enclen = rdbTryIntegerEncoding((char *)...
[SINK]: Dangerous function: rdbTryIntegerEncoding at line call. [DESTINATION]: Buffer size calculation: Size_B = 256 for destination buf. [SOURCE]: Input size tracing: Size_A is derived from enclen. Source operand traced as return value of rdbTryIntegerEncoding. [CONSTRAINTS]: Guards found before sink: none. [SCRATCHPA...
[SINK]: Dangerous function: rdbTryIntegerEncoding at line call. [DESTINATION]: Buffer size calculation: Size_B = 256 for destination buf. [SOURCE]: Input size tracing: Size_A is derived from enclen. Source operand traced as return value of rdbTryIntegerEncoding. [CONSTRAINTS]: Guards found before sink: none. [SCRATCHPA...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 2", "cwe_id": "CWE-131", "domain": "Network Router", "paradigm": "linear", "ground_truth_label": 1, "fallacy_type": "guard sufficient", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation", "snippet_id": "dv...
Perform 7-step defect analysis on this code fragment. Domain: Web Server <slice> ieee80211_tdls_mgmt_setup(struct wiphy*wiphy, struct net_device*dev, const u8*peer, u8 action_code, u8 dialog_token, u16 status_code, u32 peer_capability, bool initiator, const u8*extra_ies, size_t extra_ies_len) { struct ieee80...
[SINK]: Dangerous function: memcpy at target sink line. [DESTINATION]: Buffer size calculation: Size_B = ETH_ALEN (6 bytes) for destination sdata->u.mgd.tdls_peer. [SOURCE]: Input size tracing: Size_A is derived from peer. Source operand traced as ETH_ALEN constant (6 bytes). [CONSTRAINTS]: Guards found before sink: no...
[SINK]: Dangerous function: memcpy at target sink line. [DESTINATION]: Buffer size calculation: Size_B = ETH_ALEN (6 bytes) for destination sdata->u.mgd.tdls_peer. [SOURCE]: Input size tracing: Size_A is derived from peer. Source operand traced as ETH_ALEN constant (6 bytes). [CONSTRAINTS]: Guards found before sink: no...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 2", "cwe_id": "CWE-119", "domain": "Web Server", "paradigm": "counterfactual", "ground_truth_label": 0, "fallacy_type": "guard sufficient", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation", "snippet_id":...
Perform 7-step defect analysis on this code fragment. Domain: Compression Library <slice> gss_unwrap(minor_status, context_handle, input_message_buffer, output_message_buffer, conf_state, qop_state) OM_uint32*minor_status; gss_ctx_id_t context_handle; gss_buffer_t input_message_buffer; gss_buffer_t output_me...
[SINK]: Dangerous function: mech->gss_unwrap at line 22. [DESTINATION]: Buffer size calculation: Size_B = 256 for destination output_message_buffer. [SOURCE]: Input size tracing: Size_A is derived from input_message_buffer->length. Source operand traced as input_message_buffer. [CONSTRAINTS]: Guards found before sink: ...
[SINK]: Dangerous function: mech->gss_unwrap at line 22. [DESTINATION]: Buffer size calculation: Size_B = 256 for destination output_message_buffer. [SOURCE]: Input size tracing: Size_A is derived from input_message_buffer->length. Source operand traced as input_message_buffer. [CONSTRAINTS]: Guards found before sink: ...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 2", "cwe_id": "CWE-131", "domain": "Compression Library", "paradigm": "tree_of_thoughts", "ground_truth_label": 1, "fallacy_type": "loop bound off-by-one", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation",...
Perform 7-step defect analysis on this code fragment. Domain: Cryptographic Parser <slice> #include <stdlib.h> #include <string.h> // [STRUCT_METADATA]: Size=32 bytes struct cert_blob { unsigned char data[24]; /* 32-bit unsigned */ unsigned int len; }; static void free_blob(struct cert_blob *b) { ...
[SINK]: Dangerous function: free at line 12. [DESTINATION]: Buffer size calculation: Size_B = 24 for destination b->data. [SOURCE]: Input size tracing: Size_A is derived from raw_len. Source operand traced as raw_len. [CONSTRAINTS]: Guards found before sink: if (b && b->len > 0) [SCRATCHPAD]: | Iteration | Pointer/Inde...
[SINK]: Dangerous function: free at line 12. [DESTINATION]: Buffer size calculation: Size_B = 24 for destination b->data. [SOURCE]: Input size tracing: Size_A is derived from raw_len. Source operand traced as raw_len. [CONSTRAINTS]: Guards found before sink: if (b && b->len > 0) [SCRATCHPAD]: | Iteration | Pointer/Inde...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 2", "cwe_id": "CWE-415", "domain": "Cryptographic Parser", "paradigm": "execution_trace", "ground_truth_label": 1, "fallacy_type": "loop bound off-by-one", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation",...
Perform 7-step defect analysis on this code fragment. Domain: Web Server <slice> void vuln_func_01() { char * data; data = (char *)malloc(100*sizeof(char)); // [STRUCT_METADATA]: Size=100 bytes if (data == NULL) {exit(-1);} if(1) { /* FLAW: Initialize data as a large buffer that ...
[SINK]: Dangerous function: for loop at line with // [TARGET_SINK] inside vuln_func_01. [DESTINATION]: Buffer size calculation: Size_B = 50 bytes for destination dest. [SOURCE]: Input size tracing: Size_A is derived from strlen(data). Source operand traced as data allocated with malloc(100) and filled with 99 'A's. str...
[SINK]: Dangerous function: for loop at line with // [TARGET_SINK] inside vuln_func_01. [DESTINATION]: Buffer size calculation: Size_B = 50 bytes for destination dest. [SOURCE]: Input size tracing: Size_A is derived from strlen(data). Source operand traced as data allocated with malloc(100) and filled with 99 'A's. str...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 2", "cwe_id": "CWE-122", "domain": "Web Server", "paradigm": "reflexion", "ground_truth_label": 1, "fallacy_type": "byte vs element confusion", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation", "snippet_...
Perform 7-step defect analysis on this code fragment. Domain: Network Router <slice> struct name_list *get_list(const struct stat *st, acl_t acl) { struct name_list *first = NULL, *last = NULL; acl_entry_t ent; int ret = 0; if(acl != NULL) ret = acl_get_entry(acl, ACL_FIRST_ENTRY, & ent); if(ret != 0) return...
[SINK]: Dangerous function: strcpy at line marked // [TARGET_SINK]. [DESTINATION]: Buffer size calculation: Size_B = len (bytes) for destination last->name. Derived from malloc(sizeof(struct name_list) + len + 0). The name buffer starts after the struct members, so capacity is exactly len bytes. [SOURCE]: Input size tr...
[SINK]: Dangerous function: strcpy at line marked // [TARGET_SINK]. [DESTINATION]: Buffer size calculation: Size_B = len (bytes) for destination last->name. Derived from malloc(sizeof(struct name_list) + len + 0). The name buffer starts after the struct members, so capacity is exactly len bytes. [SOURCE]: Input size tr...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 3", "cwe_id": "CWE-120", "domain": "Network Router", "paradigm": "execution_trace", "ground_truth_label": 1, "fallacy_type": "sizeof pointer assumed 1", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation", ...
Perform 7-step defect analysis on this code fragment. Domain: Web Server <slice> static void goodG2B1() { char * data; data = NULL; if(STATIC_CONST_FALSE) { /* INCIDENTAL: CWE 561 Dead Code, the code below will never run */ printLine("Benign, fixed string"); } else ...
[SINK]: Dangerous function: memmove at line memmove(data, source, 100*sizeof(char)); [DESTINATION]: Buffer size calculation: Size_B = 100 bytes for destination data. [SOURCE]: Input size tracing: Size_A is derived from source array. Source operand traced as local array of 100 chars. [CONSTRAINTS]: Guards found before s...
[SINK]: Dangerous function: memmove at line memmove(data, source, 100*sizeof(char)); [DESTINATION]: Buffer size calculation: Size_B = 100 bytes for destination data. [SOURCE]: Input size tracing: Size_A is derived from source array. Source operand traced as local array of 100 chars. [CONSTRAINTS]: Guards found before s...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 2", "cwe_id": "CWE-122", "domain": "Web Server", "paradigm": "execution_trace", "ground_truth_label": 0, "fallacy_type": "loop bound off-by-one", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation", "snippe...
Perform 7-step defect analysis on this code fragment. Domain: Web Server <slice> irc_server_msgq_add_msg(struct t_irc_server *server, const char *msg) { struct t_irc_message *message; if(! server->unterminated_message && ! msg[256] ) return; message = malloc(sizeof(* message) ); if(! message) { weechat_print...
[SINK]: Dangerous function: strcpy at TARGET_SINK line. [DESTINATION]: Buffer size calculation: Size_B = strlen(server->unterminated_message) + strlen(msg) for destination message->data. [SOURCE]: Input size tracing: Size_A is derived from server->unterminated_message and msg. Source operand traced as total bytes to be...
[SINK]: Dangerous function: strcpy at TARGET_SINK line. [DESTINATION]: Buffer size calculation: Size_B = strlen(server->unterminated_message) + strlen(msg) for destination message->data. [SOURCE]: Input size tracing: Size_A is derived from server->unterminated_message and msg. Source operand traced as total bytes to be...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 3", "cwe_id": "CWE-120", "domain": "Web Server", "paradigm": "linear", "ground_truth_label": 1, "fallacy_type": "integer overflow ignored", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation", "snippet_id":...
Perform 7-step defect analysis on this code fragment. Domain: Cryptographic Parser <slice> static int doDescribeInstances(struct nc_state_t*nc, ncMetadata*pMeta, char** instIds, int instIdsLen, ncInstance***outInsts, int*outInstsLen) { // [TARGET_SINK] ncInstance*instance = NULL; ncInstance*tmp = NULL; int t...
[SINK]: Dangerous function: memcpy at line <unknown>. [DESTINATION]: Buffer size calculation: Size_B = 0 for destination tmp. [SOURCE]: Input size tracing: Size_A is derived from sizeof(ncInstance). Source operand traced as constant. [CONSTRAINTS]: Guards found before sink: none. [SCRATCHPAD]: Step 1) Define Size_A = s...
[SINK]: Dangerous function: memcpy at line <unknown>. [DESTINATION]: Buffer size calculation: Size_B = sizeof(ncInstance) for destination tmp. [SOURCE]: Input size tracing: Size_A is derived from sizeof(ncInstance). Source operand traced as constant. [CONSTRAINTS]: Guards found before sink: none. [SCRATCHPAD]: Step 1) ...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 2", "cwe_id": "CWE-119", "domain": "Cryptographic Parser", "paradigm": "reflexion", "ground_truth_label": 1, "fallacy_type": "conflating element-count and byte-count", "fallacy_location": "[SCRATCHPAD]", "snippet_id": "dvul-84eb2212e088...
Perform 7-step defect analysis on this code fragment. Domain: Web Server <slice> void vuln_func_01() { char * data; char * *dataPtr1 = &data; char * *dataPtr2 = &data; data = NULL; { char * data = *dataPtr1; /* FLAW: Allocate and point data to a small buffer that is smalle...
[SINK]: Dangerous function: SNPRINTF at line // [TARGET_SINK]. [DESTINATION]: Buffer size calculation: Size_B = 50 bytes for destination data. [SOURCE]: Input size tracing: Size_A is derived from source. Source operand traced as char source[100] (100 bytes). [CONSTRAINTS]: Guards found before sink: none [SCRATCHPAD]: S...
[SINK]: Dangerous function: SNPRINTF at line // [TARGET_SINK]. [DESTINATION]: Buffer size calculation: Size_B = 50 bytes for destination data. [SOURCE]: Input size tracing: Size_A is derived from source. Source operand traced as char source[100] (100 bytes). [CONSTRAINTS]: Guards found before sink: none [SCRATCHPAD]: S...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 2", "cwe_id": "CWE-122", "domain": "Web Server", "paradigm": "linear", "ground_truth_label": 1, "fallacy_type": "loop bound off-by-one", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation", "snippet_id": "r...
Perform 7-step defect analysis on this code fragment. Domain: Smart-card Applet <slice> #include <stdint.h> #include <string.h> // [STRUCT_METADATA]: Size=12 bytes struct __attribute__((packed)) smartcard_buffer { uint8_t cmd; // offset 0 uint32_t len; // offset 1 (misaligned) uint8_t dat...
[SINK]: Dangerous function: *DMA_REG = (uint32_t)(uintptr_t)buf->data at line 49. [DESTINATION]: Buffer size calculation: Size_B = 7 bytes for destination buf->data. [SOURCE]: Input size tracing: Size_A is derived from buf->len. Source operand traced as raw_packet bytes 1-4. [CONSTRAINTS]: Guards found before sink: if ...
[SINK]: Dangerous function: *DMA_REG = (uint32_t)(uintptr_t)buf->data at line 49. [DESTINATION]: Buffer size calculation: Size_B = 7 bytes for destination buf->data. [SOURCE]: Input size tracing: Size_A is derived from buf->len. Source operand traced as raw_packet bytes 1-4. [CONSTRAINTS]: Guards found before sink: if ...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 4", "cwe_id": "CWE-119", "domain": "Smart-card Applet", "paradigm": "execution_trace", "ground_truth_label": 0, "fallacy_type": "custom allocator size mismatch", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturba...
Perform 7-step defect analysis on this code fragment. Domain: Compression Library <slice> static void ip_mc_hash_add(struct in_device *in_dev, struct ip_mc_list *im) { struct ip_mc_list __rcu * *mc_hash; u32 hash; mc_hash = rtnl_dereference(in_dev->mc_hash); if(mc_hash) { hash = ip_mc_hash(im); im->next_hash...
[SINK]: Dangerous function: array indexing mc_hash[hash] at lines 'im->next_hash = mc_hash[hash];' and 'rcu_assign_pointer(mc_hash[hash] , im);' (sink is the unchecked array access). [DESTINATION]: Buffer size calculation: Size_B = sizeof(struct ip_mc_list *) * (1 << MC_HASH_SZ_LOG) = 8 * (1 << MC_HASH_SZ_LOG) bytes fo...
[SINK]: Dangerous function: array indexing mc_hash[hash] at lines 'im->next_hash = mc_hash[hash];' and 'rcu_assign_pointer(mc_hash[hash] , im);' (sink is the unchecked array access). [DESTINATION]: Buffer size calculation: Size_B = sizeof(struct ip_mc_list *) * (1 << MC_HASH_SZ_LOG) = 8 * (1 << MC_HASH_SZ_LOG) bytes fo...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 2", "cwe_id": "CWE-680", "domain": "Compression Library", "paradigm": "tree_of_thoughts", "ground_truth_label": 1, "fallacy_type": "guard sufficient", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation", "s...
Perform 7-step defect analysis on this code fragment. Domain: Web Server <slice> static void goodG2B() { double * data; void (*funcPtr) (double *) = safe_func_01; /* Initialize data */ data = NULL; /* FIX: Using sizeof the data type in malloc() */ // [TARGET_SINK] data = (double *...
[SINK]: Dangerous function: malloc at line 9. [DESTINATION]: Buffer size calculation: Size_B = sizeof(*data) for destination data. [SOURCE]: Input size tracing: Size_A is derived from sizeof(*data). Source operand traced as sizeof(*data) (constant). [CONSTRAINTS]: Guards found before sink: if (data == NULL) {exit(-1);}...
[SINK]: Dangerous function: malloc at line 9. [DESTINATION]: Buffer size calculation: Size_B = sizeof(*data) for destination data. [SOURCE]: Input size tracing: Size_A is derived from sizeof(*data). Source operand traced as sizeof(*data) (constant). [CONSTRAINTS]: Guards found before sink: if (data == NULL) {exit(-1);}...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 2", "cwe_id": "CWE-122", "domain": "Web Server", "paradigm": "execution_trace", "ground_truth_label": 0, "fallacy_type": "conflating element-count and byte-count", "fallacy_location": "[SCRATCHPAD]", "snippet_id": "real-9b92aa38cea2a220...
Perform 7-step defect analysis on this code fragment. Domain: Network Router <slice> ASS_Track *ass_read_memory(ASS_Library *library, char *buf, size_t bufsize, char *codepage) { ASS_Track *track; int copied = 0; if(! buf) return 0; # ifdef CONFIG_ICONV if(codepage) { buf = sub_recode(library, buf, bufsize, ...
[SINK]: Dangerous function: memcpy at line marked // [TARGET_SINK]. [DESTINATION]: Buffer size calculation: Size_B = bufsize for destination newbuf (allocated via malloc(bufsize + 0)). [SOURCE]: Input size tracing: Size_A is derived from the function parameter bufsize; memcpy copies exactly bufsize bytes from buf. [CON...
[SINK]: Dangerous function: memcpy at line marked // [TARGET_SINK]. [DESTINATION]: Buffer size calculation: Size_B = bufsize for destination newbuf (allocated via malloc(bufsize + 0)). [SOURCE]: Input size tracing: Size_A is derived from the function parameter bufsize; memcpy copies exactly bufsize bytes from buf. [CON...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 2", "cwe_id": "CWE-119", "domain": "Network Router", "paradigm": "tree_of_thoughts", "ground_truth_label": 1, "fallacy_type": "byte vs element confusion", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation", ...
Perform 7-step defect analysis on this code fragment. Domain: Embedded RTOS <slice> void vuln_func_01() { char * data; char * *dataPtr1 = &data; char * *dataPtr2 = &data; data = NULL; /* Initialize data */ { char * data = *dataPtr1; { /* FLAW: data is allocated...
[SINK]: Dangerous function: free at line free(data). [DESTINATION]: Buffer size calculation: Size_B = 100 for destination dataBuffer. [SOURCE]: Input size tracing: Size_A is derived from static char array dataBuffer. Source operand traced as stack allocation. [CONSTRAINTS]: Guards found before sink: none. [SCRATCHPAD]:...
[SINK]: Dangerous function: free at line free(data). [DESTINATION]: Buffer size calculation: Size_B = 100 for destination dataBuffer. [SOURCE]: Input size tracing: Size_A is derived from static char array dataBuffer. Source operand traced as stack allocation. [CONSTRAINTS]: Guards found before sink: none. [SCRATCHPAD]:...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 2", "cwe_id": "CWE-590", "domain": "Embedded RTOS", "paradigm": "reflexion", "ground_truth_label": 1, "fallacy_type": "byte vs element confusion", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation", "snipp...
Perform 7-step defect analysis on this code fragment. Domain: Filesystem Driver <slice> static void test_bug28386() { int rc; MYSQL_STMT *stmt; MYSQL_RES *result; MYSQL_ROW row; MYSQL_BIND bind; const char hello[] = "data"; DBUG_ENTER("data"); myheader("data"); rc = mysql_query(mysql, "data"); myquery(rc); r...
[SINK]: Dangerous function: strstr at line accessing row[256]. [DESTINATION]: Buffer size calculation: Size_B = unknown for row (depends on query result). [SOURCE]: Input size tracing: Size_A is index 256, fixed value. [CONSTRAINTS]: Guards found before sink: none. [SCRATCHPAD]: | Iteration | Pointer/Index Value | Rema...
[SINK]: Dangerous function: strstr at line accessing row[256]. [DESTINATION]: Buffer size calculation: Size_B = unknown for row (depends on query result). [SOURCE]: Input size tracing: Size_A is index 256, fixed value. [CONSTRAINTS]: Guards found before sink: none. [SCRATCHPAD]: | Iteration | Pointer/Index Value | Rema...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 2", "cwe_id": "CWE-119", "domain": "Filesystem Driver", "paradigm": "execution_trace", "ground_truth_label": 1, "fallacy_type": "loop bound off-by-one", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation", ...
Perform 7-step defect analysis on this code fragment. Domain: Web Server <slice> piv_put_data(sc_card_t*card, int tag, const u8*buf, size_t buf_len) { int r; u8*sbuf; size_t sbuflen; u8*p; size_t tag_len; SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE); // [TARGET_SINK] tag_len = piv_objects[tag].tag_len; sb...
[SINK]: Dangerous function: memcpy at line of second memcpy (copying buf). [DESTINATION]: Buffer size calculation: Size_B = sbuflen = put_tag_and_len(0, tag_len, NULL) + buf_len. [SOURCE]: Input size tracing: Size_A is derived from buf_len and tag_len. Source operand traced as function parameters. [CONSTRAINTS]: Guards...
[SINK]: Dangerous function: memcpy at line of second memcpy (copying buf). [DESTINATION]: Buffer size calculation: Size_B = sbuflen = put_tag_and_len(0, tag_len, NULL) + buf_len. [SOURCE]: Input size tracing: Size_A is the length provided by buf_len, as the second memcpy copies exactly buf_len bytes from buf. [CONSTRAI...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 2", "cwe_id": "CWE-119", "domain": "Web Server", "paradigm": "tree_of_thoughts", "ground_truth_label": 1, "fallacy_type": "conflating element-count and byte-count", "fallacy_location": "[SCRATCHPAD]", "snippet_id": "dvul-b8da46303ec9d8e...
Perform 7-step defect analysis on this code fragment. Domain: Network Router <slice> static void goodG2B() { int h; char * data; char * dataBuffer = (char *)ALLOCA(100*sizeof(char)); data = dataBuffer; for(h = 0; h < 1; h++) { /* FIX: Initialize data as a small buffer that as ...
[SINK]: Dangerous function: strncpy at line of strncpy(dest, data, strlen(data)). [DESTINATION]: Buffer size calculation: Size_B = 50 bytes for destination dest (declared as char dest[50]). [SOURCE]: Input size tracing: Size_A is derived from strlen(data). Source operand traced as data, a pointer to a 100-byte buffer b...
[SINK]: Dangerous function: strncpy at line of strncpy(dest, data, strlen(data)). [DESTINATION]: Buffer size calculation: Size_B = 50 bytes for destination dest (declared as char dest[50]). [SOURCE]: Input size tracing: Size_A is derived from strlen(data). Source operand traced as data, a pointer to a 100-byte buffer b...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 2", "cwe_id": "CWE-121", "domain": "Network Router", "paradigm": "tree_of_thoughts", "ground_truth_label": 0, "fallacy_type": "guard sufficient", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation", "snippe...
Perform 7-step defect analysis on this code fragment. Domain: Browser Renderer <slice> #include <cstdint> #include <memory> struct RenderConfig { int32_t buffer_size; /* 32-bit unsigned */ char* data; // [STRUCT_METADATA]: Size=16 bytes }; struct RenderNode { std::unique_ptr<RenderConfig> confi...
[SINK]: Dangerous function: delete[] at line 28 and 30. [DESTINATION]: Buffer size calculation: Size_B = size bytes for raw_config->data. [SOURCE]: Input size tracing: Size_A is derived from node->config->buffer_size. Source operand traced as user-controlled integer. [CONSTRAINTS]: Guards found before sink: if (size > ...
[SINK]: Dangerous function: delete[] at line 28 and 30. [DESTINATION]: Buffer size calculation: Size_B = size bytes for raw_config->data. [SOURCE]: Input size tracing: Size_A is derived from node->config->buffer_size. Source operand traced as user-controlled integer. [CONSTRAINTS]: Guards found before sink: if (size > ...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 3", "cwe_id": "CWE-415", "domain": "Browser Renderer", "paradigm": "reflexion", "ground_truth_label": 1, "fallacy_type": "sizeof pointer assumed 1", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation", "sni...
Perform 7-step defect analysis on this code fragment. Domain: Cryptographic Parser <slice> #include <stdlib.h> #include <string.h> #include <wchar.h> typedef struct { int encoding; /* 32-bit unsigned */ wchar_t *data; size_t length; /* 32-bit unsigned */ } UTF16Buffer; typedef struct { UTF1...
[SINK]: Dangerous function: wmemcpy at line 30. [DESTINATION]: Buffer size calculation: Size_B = alloc_elements * sizeof(wchar_t) for destination temp. [SOURCE]: Input size tracing: Size_A is derived from input_len. Source operand traced as input_len * sizeof(wchar_t). [CONSTRAINTS]: Guards found before sink: if (!p ||...
[SINK]: Dangerous function: wmemcpy at line 30. [DESTINATION]: Buffer size calculation: Size_B = alloc_elements * sizeof(wchar_t) for destination temp. [SOURCE]: Input size tracing: Size_A is derived from input_len. Source operand traced as input_len * sizeof(wchar_t). [CONSTRAINTS]: Guards found before sink: if (!p ||...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 3", "cwe_id": "CWE-131", "domain": "Cryptographic Parser", "paradigm": "tree_of_thoughts", "ground_truth_label": 1, "fallacy_type": "sizeof pointer assumed 1", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbati...
Perform 7-step defect analysis on this code fragment. Domain: Cryptographic Parser <slice> void vuln_func_01() { char data; /* define a function pointer */ void (*funcPtr) (char) = vuln_func_02; data = ' '; /* POTENTIAL FLAW: Use the minimum size of the data type */ // [TARGET_SINK] ...
[SINK]: Dangerous function: assignment of CHAR_MIN at line data = CHAR_MIN; [DESTINATION]: Buffer size calculation: Size_B = 1 byte for variable data (char) [SOURCE]: Input size tracing: Size_A = CHAR_MIN value (-128) from <climits> macro [CONSTRAINTS]: Guards found before sink: none [SCRATCHPAD]: | Iteration | Variabl...
[SINK]: Dangerous function: assignment of CHAR_MIN at line data = CHAR_MIN; [DESTINATION]: Buffer size calculation: Size_B = 1 byte for variable data (char) [SOURCE]: Input size tracing: Size_A = CHAR_MIN value (-128) from <climits> macro [CONSTRAINTS]: Guards found before sink: none [SCRATCHPAD]: | Iteration | Variabl...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 2", "cwe_id": "CWE-680", "domain": "Cryptographic Parser", "paradigm": "execution_trace", "ground_truth_label": 1, "fallacy_type": "byte vs element confusion", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbati...
Perform 7-step defect analysis on this code fragment. Domain: Network Router <slice> static void goodG2B() { char * data; char * dataBuffer = (char *)ALLOCA(100*sizeof(char)); data = dataBuffer; /* FIX: Initialize data as a small buffer that as small or smaller than the small buffer used in t...
[SINK]: Dangerous function: safe_func_01 at line with [TARGET_SINK]. [DESTINATION]: Buffer size calculation: Size_B = 100 for destination data (dataBuffer). [SOURCE]: Input size tracing: Size_A is derived from memset data with size 50 (49 'A's + null). Source operand traced as 50. [CONSTRAINTS]: Guards found before sin...
[SINK]: Dangerous function: safe_func_01 at line with [TARGET_SINK]. [DESTINATION]: Buffer size calculation: Size_B = 100 for destination data (dataBuffer). [SOURCE]: Input size tracing: Size_A is derived from memset data with size 50 (49 'A's + null). Source operand traced as 50. [CONSTRAINTS]: Guards found before sin...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 2", "cwe_id": "CWE-121", "domain": "Network Router", "paradigm": "tree_of_thoughts", "ground_truth_label": 0, "fallacy_type": "loop bound off-by-one", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation", "s...
Perform 7-step defect analysis on this code fragment. Domain: Network Router <slice> static void goodG2BSink() { char * data = safe_func_01; { char source[100]; // [STRUCT_METADATA]: Size=100 bytes memset(source, 'C', 100-1); /* fill with 'C's */ source[100-1] = '\0'; /* null...
[SINK]: Dangerous function: memcpy at line with [TARGET_SINK]. [DESTINATION]: Buffer size calculation: Size_B = 100 for destination data. [SOURCE]: Input size tracing: Size_A is derived from source array. Source operand traced as source[100]. [CONSTRAINTS]: Guards found before sink: none [SCRATCHPAD]: Step 1) Define Si...
[SINK]: Dangerous function: memcpy at line with [TARGET_SINK]. [DESTINATION]: Buffer size calculation: Size_B = 100 for destination data. [SOURCE]: Input size tracing: Size_A derived from source array. Source operand traced as source[100]. [CONSTRAINTS]: Guards found before sink: none [SCRATCHPAD]: Step 1) Define Size_...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 2", "cwe_id": "CWE-121", "domain": "Network Router", "paradigm": "reflexion", "ground_truth_label": 0, "fallacy_type": "unverified external buffer size", "fallacy_location": "[SCRATCHPAD]", "snippet_id": "real-32610be0acfd7f93", "from...
Perform 7-step defect analysis on this code fragment. Domain: Network Router <slice> void vuln_func_01() { wchar_t * data; wchar_t dataBuffer[100]; // [STRUCT_METADATA]: Size=400 bytes data = dataBuffer; if(STATIC_CONST_FIVE==5) { /* FLAW: Initialize data as a large buffer that i...
[SINK]: Dangerous function: memcpy at line <implicit>. [DESTINATION]: Buffer size calculation: Size_B = 200 bytes for destination dest. [SOURCE]: Input size tracing: Size_A is derived from wcslen(data)*sizeof(wchar_t). Source operand traced as data, buffer of size 400 bytes, but used length 396 bytes. [CONSTRAINTS]: Gu...
[SINK]: Dangerous function: memcpy at line <implicit>. [DESTINATION]: Buffer size calculation: Size_B = 200 bytes for destination dest. [SOURCE]: Input size tracing: Size_A is derived from wcslen(data)*sizeof(wchar_t). Source operand traced as data, buffer of size 400 bytes, but used length 396 bytes. [CONSTRAINTS]: Gu...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 2", "cwe_id": "CWE-121", "domain": "Network Router", "paradigm": "tree_of_thoughts", "ground_truth_label": 1, "fallacy_type": "byte vs element confusion", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation", ...
Perform 7-step defect analysis on this code fragment. Domain: Compression Library <slice> #include <cstdint> #include <cstring> #include <vector> #include <variant> template<typename T> struct CompressionBuffer { std::vector<uint8_t> data; size_t capacity; // [STRUCT_METADATA]: Size=24 bytes ...
[SINK]: Dangerous function: memcpy at line 34. [DESTINATION]: Buffer size calculation: Size_B = 1024 for destination buf.data.data(). [SOURCE]: Input size tracing: Size_A is derived from block_size * sizeof(T). Source operand traced as block_size (uint32_t) from config. [CONSTRAINTS]: Guards found before sink: if (need...
[SINK]: Dangerous function: memcpy at line 34. [DESTINATION]: Buffer size calculation: Size_B = 1024 for destination buf.data.data(). [SOURCE]: Input size tracing: Size_A is derived from block_size * sizeof(T). Source operand traced as block_size (uint32_t) from config. [CONSTRAINTS]: Guards found before sink: if (need...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 3", "cwe_id": "CWE-680", "domain": "Compression Library", "paradigm": "counterfactual", "ground_truth_label": 0, "fallacy_type": "sizeof pointer assumed 1", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation"...
Perform 7-step defect analysis on this code fragment. Domain: Game Engine <slice> #include <stdint.h> #include <stdlib.h> #include <string.h> // [STRUCT_METADATA]: Size=24 bytes (8+4+4+8 padding) typedef struct { uint64_t id; uint32_t type; uint32_t flags; uint8_t data[]; // flexible array ...
[SINK]: Dangerous function: array index at line 73. [DESTINATION]: Buffer size calculation: Size_B = 16 bytes for ent->data. [SOURCE]: Input size tracing: Size_A is derived from constant 20. Source operand traced as literal 20. [CONSTRAINTS]: Guards found before sink: none [SCRATCHPAD]: Step 1) Define Size_A = 20 (inde...
[SINK]: Dangerous function: array index at line 73. [DESTINATION]: Buffer size calculation: Size_B = 16 bytes for ent->data. [SOURCE]: Input size tracing: Size_A is derived from constant 20. Source operand traced as literal 20. [CONSTRAINTS]: Guards found before sink: none [SCRATCHPAD]: Step 1) Define Size_A = 20 (inde...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 4", "cwe_id": "CWE-125", "domain": "Game Engine", "paradigm": "linear", "ground_truth_label": 1, "fallacy_type": "opaque pointer aliasing", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbation", "snippet_id":...
Perform 7-step defect analysis on this code fragment. Domain: Database Storage Engine <slice> static inline void expire_data_free(struct expire_data*data) { if(! data) return; safe_close(data->dev_autofs_fd); safe_close(data->ioctl_fd); // [TARGET_SINK] free(data); } </slice> Instructions: - Locate the line...
[SINK]: Dangerous function: free at line 6. [DESTINATION]: Buffer size calculation: Not applicable. [SOURCE]: Input size tracing: Not applicable. [CONSTRAINTS]: Guards found before sink: if(! data) return; [SCRATCHPAD]: Step 1) Define Size_A = not applicable. Step 2) Define Size_B = not applicable. Step 3 & 4) Path 1: ...
[SINK]: Dangerous function: free at line 6. [DESTINATION]: Buffer size calculation: Not applicable. [SOURCE]: Input size tracing: Not applicable. [CONSTRAINTS]: Guards found before sink: if(! data) return; [SCRATCHPAD]: Step 1) Define Size_A = not applicable. Step 2) Define Size_B = not applicable. Step 3 & 4) Path 1: ...
{ "source_dataset": "synthetic_ds_v4", "complexity_level": "Level 2", "cwe_id": "CWE-416", "domain": "Database Storage Engine", "paradigm": "tree_of_thoughts", "ground_truth_label": 0, "fallacy_type": "loop bound off-by-one", "fallacy_location": "[SCRATCHPAD]", "fallacy_method": "mechanical_perturbati...
End of preview.

YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

C/C++ Memory-Safety Dataset

A high-quality dataset for fine-tuning Large Language Models on C/C++ memory-safety analysis. Every record produces a structured 7-tag analysis under one of five Chain-of-Thought reasoning paradigms.

  • 2,393 SFT training records Β· 1,754 DPO training records
  • 14 CWE classes (buffer overflows + pointer lifecycle)
  • 5 reasoning paradigms (linear, tree-of-thoughts, counterfactual, reflexion, execution-trace)
  • Stratified train / validation / test split + held-out OOD gold benchmark
  • Qwen-safe (no special-token collisions), label-verified, no CWE-class leakage

Quick start

from datasets import load_dataset

ds = load_dataset("json", data_files={
    "train":      "data/train/sft_train.jsonl",
    "validation": "data/validation/sft_val.jsonl",
    "test":       "data/test/sft_test.jsonl",
    "gold":       "data/benchmark/sft_val_gold.jsonl",
})

The records use ShareGPT format and load directly into HuggingFace Trainer / SFTTrainer / DPOTrainer without preprocessing.


Repository layout

.
β”œβ”€β”€ data/                       Final dataset (ShareGPT JSONL)
β”‚   β”œβ”€β”€ DATASET_CARD.md
β”‚   β”œβ”€β”€ train/{sft_train,dpo_train}.jsonl
β”‚   β”œβ”€β”€ validation/{sft_val,dpo_val}.jsonl
β”‚   β”œβ”€β”€ test/{sft_test,dpo_test}.jsonl
β”‚   └── benchmark/sft_val_gold.jsonl     (held-out, fresh seed)
β”‚
β”œβ”€β”€ source/                     Original filtered corpora used during synthesis
β”‚   β”œβ”€β”€ juliet/                 NIST Juliet test cases by CWE
β”‚   β”œβ”€β”€ juliet_corpus.txt       de-tokenized + perplexity-filtered Juliet (175 MB)
β”‚   └── diversevul_corpus.txt   de-tokenized + filtered DiverseVul (472 MB)
β”‚
β”œβ”€β”€ generate.py                 Synthesize new records via any DeepSeek-V4 API
β”œβ”€β”€ convert.py                  Format conversion + HuggingFace push
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ LICENSE
└── README.md

The source/ corpora are large; if cloning via Git clean, fetch them with Git LFS or download separately. They are not required to use the final dataset β€” only to regenerate / extend it.


Format

Every SFT record is a ShareGPT chat:

{
  "messages": [
    {"role": "system",    "content": "<paradigm-specific system prompt + 7-tag schema>"},
    {"role": "user",      "content": "Domain: ...\n<slice>{C/C++ code}</slice>"},
    {"role": "assistant", "content": "[SINK]: ...\n[CONCLUSION]: VULNERABLE CWE-XXX"}
  ],
  "metadata": {
    "snippet_id": "...", "cwe_id": "CWE-XXX",
    "complexity_level": "Level 2|3|4",
    "paradigm": "linear|tree_of_thoughts|counterfactual|reflexion|execution_trace",
    "ground_truth_label": 0|1,
    "domain": "..."
  }
}

Every DPO record is a preference triple:

{
  "instruction": "Domain: ...\n<slice>...</slice>",
  "chosen":      "[SINK]: ...\n[CONCLUSION]: VULNERABLE CWE-XXX",
  "rejected":    "[SINK]: (subtle reasoning fallacy)\n[CONCLUSION]: NOT_VULNERABLE CWE-XXX",
  "metadata": {
    "fallacy_type": "...", "fallacy_method": "mechanical_perturbation",
    "snippet_id": "...", "ground_truth_label": 0|1
  }
}

The 7-tag schema is fixed:

[SINK]:        Dangerous function: <name> at line <X>.
[DESTINATION]: Buffer size calculation: Size_B = <bytes>.
[SOURCE]:      Input size tracing: Size_A is derived from <var>.
[CONSTRAINTS]: Guards found before sink: <code or 'none'>.
[SCRATCHPAD]:  <paradigm-specific multi-step reasoning>
[MATH]:        Required safety: Size_A <= Size_B; <HOLDS or VIOLATED>.
[CONCLUSION]:  <VULNERABLE or NOT_VULNERABLE> CWE-<ID>

See data/DATASET_CARD.md for full distribution stats and a recommended LoRA training config.


Convert / inspect

# Distribution stats
python convert.py --stats --in data/train/sft_train.jsonl

# Peek at a record
python convert.py --peek 1 --in data/train/sft_train.jsonl

# Convert to other formats
python convert.py --to alpaca     --in data/train/sft_train.jsonl --out alpaca.jsonl
python convert.py --to chatml     --in data/train/sft_train.jsonl --out chatml.txt
python convert.py --to openai     --in data/train/sft_train.jsonl --out openai.jsonl
python convert.py --to preference --in data/train/dpo_train.jsonl --out pref.jsonl

# Push to HuggingFace Hub
python convert.py --to hf-push --in data/ --hf-repo your-name/cwe-memory-safety

Generate (regenerate / extend)

generate.py is self-contained and works against any DeepSeek-V4-compatible chat-completions endpoint (DeepSeek API, self-hosted vLLM, OpenRouter, etc.).

# Set credentials in .env or export them
echo "DEEPSEEK_API_KEY=sk-..." > .env
# Optional overrides:
# DEEPSEEK_API_BASE=https://api.deepseek.com
# DEEPSEEK_MODEL_FLASH=deepseek-chat
# DEEPSEEK_MODEL_PRO=deepseek-reasoner

# Cheapest run: 200 SFT records, Flash only, $1 cap
python generate.py --sft 200 --budget 1.00 --out data_new

# Larger run with Pro thinking on hard paradigms + DPO
python generate.py --sft 3000 --dpo --pro --budget 5.00 --out data_new

Pipeline (per spec):

  1. Synthesize a labeled C/C++ snippet with a [TARGET_SINK] marker.
  2. Generate a 7-tag analysis under one of 5 reasoning paradigms.
  3. Validate format + label agreement; auto-repair the conclusion if the model disagreed with the ground-truth label.
  4. (Optional) Mechanically perturb the analysis to create a DPO pair (one of 9 reasoning fallacies inserted, conclusion flipped).

The CoT paradigm assignment is round-robin so all five paradigms appear roughly equally β€” linear and execution_trace use the Flash tier; tree_of_thoughts, counterfactual, reflexion use Pro when --pro is set.


Quality guarantees

  • 100 % records contain all 7 required tags
  • 0 cross-split snippet-code overlap (train ↔ val/test/gold)
  • 0 special-token collisions (<|im_start|>, <|im_end|>, <|endoftext|>, <|fim_*|>)
  • 100 % [CONCLUSION] agreement with ground_truth_label
  • DPO chosen β‰  rejected conclusion (label flip verified)
  • No CWE-class hint in user prompts (model must derive CWE from code)
  • CWE-prefixed function names (e.g. CWE121_Stack_*) renamed generically

License

MIT. See LICENSE.

The source/juliet/ directory contains files derived from the NIST Juliet Test Suite (public domain). The source/diversevul_corpus.txt is derived from DiverseVul (MIT). The synthetic and generated portions are released under MIT.

Downloads last month
679