Download data/research/benchmark/train.jsonl from Helinity/python-security-benchmark: direct link, hf CLI and curl.
- Browser
- Download file 81.3 kB
-
https://huggingface.co/datasets/Helinity/python-security-benchmark/resolve/main/data/research/benchmark/train.jsonl
- Command line
-
hf download hf://datasets/Helinity/python-security-benchmark/data/research/benchmark/train.jsonl
-
curl -L -o train.jsonl https://huggingface.co/datasets/Helinity/python-security-benchmark/resolve/main/data/research/benchmark/train.jsonl
81.3 kB
| {"code": "import os\nfrom hmac import compare_digest\n\ndef accepts_hook_token(provided_token):\n expected = os.environ.get(\"INBOUND_HOOK_TOKEN\")\n if not expected:\n return False\n return compare_digest(provided_token.encode(\"utf-8\"), expected.encode(\"utf-8\"))\n", "code_files": [{"code": "import os\nfrom hmac import compare_digest\n\ndef accepts_hook_token(provided_token):\n expected = os.environ.get(\"INBOUND_HOOK_TOKEN\")\n if not expected:\n return False\n return compare_digest(provided_token.encode(\"utf-8\"), expected.encode(\"utf-8\"))\n", "path": "snippet.py"}], "cwe_id": "CWE-798", "difficulty": "intermediate", "evidence_reference": "data/research/evidence.json::cases/inbound-hook-shared-secret-source", "expected_finding": false, "explanation": "The expected credential is deployment-managed, and absent configuration rejects the request. The timing-resistant comparison remains in use.", "fix_explanation": "Provision a separate random inbound credential for each deployment and reject requests if the expected token is unavailable.", "framework": null, "hard_negative": false, "id": "psp-034d6cf6377a", "label": "secure", "language": "python", "leakage_group_id": "credential-provisioning", "pair_id": "inbound-hook-shared-secret-source", "pattern": "inbound-hook-shared-secret-source", "provenance": {"authoring": "ai_assisted", "collection": "preserved_baseline", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "The fake fixture exercises normal authentication and observes configuration dependence in memory.", "sample_id": "psp-034d6cf6377a", "sanitization": "Require the deployment's expected secret and deny missing configuration.", "scenario_family_id": "credential-provisioning", "secure_fix": "Provision a separate random inbound credential for each deployment and reject requests if the expected token is unavailable.", "sink_location": {"end_line": 8, "path": "snippet.py", "start_line": 8}, "source_location": {"end_line": 5, "path": "snippet.py", "start_line": 5}, "source_type": "synthetic", "split": "train", "taint_path": null, "verification_method": "local_fixture_behavior", "verification_status": "behavior_verified", "vulnerability_type": "hardcoded_credentials", "vulnerable_lines": []} | |
| {"code": "import ssl\nfrom contextlib import closing\nfrom http.client import HTTPSConnection\n\ndef fetch_invoice_status():\n context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)\n context.check_hostname = False\n context.verify_mode = ssl.CERT_NONE\n with closing(HTTPSConnection(\"billing.example.invalid\", context=context, timeout=5)) as client:\n client.request(\"GET\", \"/status\")\n with client.getresponse() as response:\n if response.status != 200:\n raise OSError(\"Invoice status unavailable\")\n return response.read()\n", "code_files": [{"code": "import ssl\nfrom contextlib import closing\nfrom http.client import HTTPSConnection\n\ndef fetch_invoice_status():\n context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)\n context.check_hostname = False\n context.verify_mode = ssl.CERT_NONE\n with closing(HTTPSConnection(\"billing.example.invalid\", context=context, timeout=5)) as client:\n client.request(\"GET\", \"/status\")\n with client.getresponse() as response:\n if response.status != 200:\n raise OSError(\"Invoice status unavailable\")\n return response.read()\n", "path": "snippet.py"}], "cwe_id": "CWE-295", "difficulty": "intermediate", "evidence_reference": "data/research/evidence.json::cases/billing-https-context-verification", "expected_finding": true, "explanation": "The client disables certificate and hostname verification. HTTPS can encrypt a connection without authenticating the billing service.", "fix_explanation": "Use a verifying client context and configure an appropriate CA trust store when the deployment uses a private CA.", "framework": null, "hard_negative": false, "id": "psp-045b7df846e1", "label": "insecure", "language": "python", "leakage_group_id": "tls-peer-authentication", "pair_id": "billing-https-context-verification", "pattern": "billing-https-context-verification", "provenance": {"authoring": "ai_assisted", "collection": "preserved_baseline", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "The fixture inspects the TLS context at a fake transport boundary. It does not establish handshake behavior.", "sample_id": "psp-045b7df846e1", "sanitization": null, "scenario_family_id": "tls-peer-authentication", "secure_fix": "Use a verifying client context and configure an appropriate CA trust store when the deployment uses a private CA.", "sink_location": {"end_line": 8, "path": "snippet.py", "start_line": 8}, "source_location": null, "source_type": "synthetic", "split": "train", "taint_path": null, "verification_method": "tls_context_at_mock_transport", "verification_status": "behavior_verified", "vulnerability_type": "improper_certificate_validation", "vulnerable_lines": [{"end_line": 8, "path": "snippet.py", "start_line": 8}]} | |
| {"code": "import ssl\n\n\ndef connect_partner(config, socket):\n context = config.server_context\n if context.verify_mode != ssl.CERT_REQUIRED or not context.check_hostname:\n raise ValueError(\"Server authentication is required\")\n return context.wrap_socket(socket, server_hostname=config.partner_hostname)\n", "code_files": [{"code": "import ssl\n\n\ndef connect_partner(config, socket):\n context = config.server_context\n if context.verify_mode != ssl.CERT_REQUIRED or not context.check_hostname:\n raise ValueError(\"Server authentication is required\")\n return context.wrap_socket(socket, server_hostname=config.partner_hostname)\n", "path": "subject.py"}], "cwe_id": "CWE-295", "difficulty": "advanced", "evidence_reference": "data/research/evidence.json::cases/tls-guard-at-connector", "expected_finding": false, "explanation": "The injected context may be misconfigured, but the connector refuses to wrap it unless server authentication is enabled and the expected name is supplied.", "fix_explanation": "Require certificate and hostname checks immediately before socket wrapping.", "framework": null, "hard_negative": true, "id": "psp-19500b8a5b0a", "label": "secure", "language": "python", "leakage_group_id": "tls-peer-authentication", "pair_id": null, "pattern": "tls-guard-at-connector", "provenance": {"authoring": "ai_assisted", "collection": "hard_negative", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "Assumes trusted, request-local configuration. The fixture observes guards with a fake socket wrapper.", "sample_id": "psp-19500b8a5b0a", "sanitization": "Require certificate and hostname checks immediately before socket wrapping.", "scenario_family_id": "tls-peer-authentication", "secure_fix": "Require certificate and hostname checks immediately before socket wrapping.", "sink_location": {"end_line": 8, "path": "subject.py", "start_line": 8}, "source_location": {"end_line": 5, "path": "subject.py", "start_line": 5}, "source_type": "synthetic", "split": "train", "taint_path": null, "verification_method": "mock_tls_configuration_gate", "verification_status": "behavior_verified", "vulnerability_type": "improper_certificate_validation", "vulnerable_lines": []} | |
| {"code": "# file: fragments.py\nfrom html import escape\n\n\ndef render_transcript(receipt_id, text):\n return f\"<article><h2>{receipt_id:d}</h2><aside>{escape(text, quote=False)}</aside></article>\"\n\n# file: subject.py\nfrom .fragments import render_transcript\n\n\nclass TranscriptPreview:\n def __init__(self, transcripts):\n self.transcripts = transcripts\n\n def get(self, receipt_id):\n transcript = self.transcripts.get(receipt_id)\n if transcript is None:\n return 404, \"\"\n return 200, render_transcript(receipt_id, transcript.text)\n", "code_files": [{"code": "from html import escape\n\n\ndef render_transcript(receipt_id, text):\n return f\"<article><h2>{receipt_id:d}</h2><aside>{escape(text, quote=False)}</aside></article>\"\n", "path": "fragments.py"}, {"code": "from .fragments import render_transcript\n\n\nclass TranscriptPreview:\n def __init__(self, transcripts):\n self.transcripts = transcripts\n\n def get(self, receipt_id):\n transcript = self.transcripts.get(receipt_id)\n if transcript is None:\n return 404, \"\"\n return 200, render_transcript(receipt_id, transcript.text)\n", "path": "subject.py"}], "cwe_id": "CWE-79", "difficulty": "advanced", "evidence_reference": "data/research/evidence.json::cases/helpdesk-transcript-renderer", "expected_finding": false, "explanation": "The renderer escapes the text while retaining the receipt identifier and markup around it.", "fix_explanation": "Escape stored transcript text in its HTML text-node context.", "framework": null, "hard_negative": false, "id": "psp-1d7b5d2c9e67", "label": "secure", "language": "python", "leakage_group_id": "html-output-encoding", "pair_id": "helpdesk-transcript-renderer", "pattern": "helpdesk-transcript-renderer", "provenance": {"authoring": "ai_assisted", "collection": "research_pair", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "The source and sink span files. The fixture measures parsing of harmless transcript text and the missing-record path.", "sample_id": "psp-1d7b5d2c9e67", "sanitization": "Escape stored transcript text in its HTML text-node context.", "scenario_family_id": "html-output-encoding", "secure_fix": "Escape stored transcript text in its HTML text-node context.", "sink_location": {"end_line": 5, "path": "fragments.py", "start_line": 5}, "source_location": {"end_line": 9, "path": "subject.py", "start_line": 9}, "source_type": "synthetic", "split": "train", "taint_path": ["stored transcript", "preview service", "renderer HTML text escaping", "text node"], "verification_method": "html_parser_shape", "verification_status": "behavior_verified", "vulnerability_type": "cross_site_scripting", "vulnerable_lines": []} | |
| {"code": "class HelpAssetIndex:\n def __init__(self, public_assets):\n self._public = public_assets.copy()\n\n def read(self, opaque_key):\n asset = self._public.get(opaque_key)\n if asset is None:\n return 404, b\"\"\n return 200, asset.read_bytes()\n", "code_files": [{"code": "class HelpAssetIndex:\n def __init__(self, public_assets):\n self._public = public_assets.copy()\n\n def read(self, opaque_key):\n asset = self._public.get(opaque_key)\n if asset is None:\n return 404, b\"\"\n return 200, asset.read_bytes()\n", "path": "subject.py"}], "cwe_id": "CWE-22", "difficulty": "intermediate", "evidence_reference": "data/research/evidence.json::cases/opaque-help-asset", "expected_finding": false, "explanation": "The input selects a preloaded public asset and never becomes a filesystem path.", "fix_explanation": "Look up an opaque key in a trusted catalog of public file handles.", "framework": null, "hard_negative": true, "id": "psp-223115b99599", "label": "secure", "language": "python", "leakage_group_id": "restricted-path-selection", "pair_id": null, "pattern": "opaque-help-asset", "provenance": {"authoring": "ai_assisted", "collection": "hard_negative", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "The catalog must be populated by trusted code. Verification reads a temporary fixture through one known key.", "sample_id": "psp-223115b99599", "sanitization": "Look up an opaque key in a trusted catalog of public file handles.", "scenario_family_id": "restricted-path-selection", "secure_fix": "Look up an opaque key in a trusted catalog of public file handles.", "sink_location": {"end_line": 9, "path": "subject.py", "start_line": 9}, "source_location": {"end_line": 5, "path": "subject.py", "start_line": 5}, "source_type": "synthetic", "split": "train", "taint_path": null, "verification_method": "local_fixture_behavior", "verification_status": "behavior_verified", "vulnerability_type": "path_traversal", "vulnerable_lines": []} | |
| {"code": "import os\n\ndef metrics_headers():\n token = os.environ.get(\"METRICS_API_TOKEN\")\n if not token:\n raise RuntimeError(\"Metrics service credential unavailable\")\n return {\"Authorization\": \"Bearer \" + token}\n", "code_files": [{"code": "import os\n\ndef metrics_headers():\n token = os.environ.get(\"METRICS_API_TOKEN\")\n if not token:\n raise RuntimeError(\"Metrics service credential unavailable\")\n return {\"Authorization\": \"Bearer \" + token}\n", "path": "snippet.py"}], "cwe_id": "CWE-798", "difficulty": "introductory", "evidence_reference": "data/research/evidence.json::cases/outbound-metrics-credential-source", "expected_finding": false, "explanation": "The deployment injects the credential at runtime and missing configuration prevents the service from constructing the request header.", "fix_explanation": "Inject the outbound token from deployment-managed secrets and fail closed when it is missing.", "framework": null, "hard_negative": false, "id": "psp-284303fed7c6", "label": "secure", "language": "python", "leakage_group_id": "credential-provisioning", "pair_id": "outbound-metrics-credential-source", "pattern": "outbound-metrics-credential-source", "provenance": {"authoring": "ai_assisted", "collection": "preserved_baseline", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "Obvious literal serves as an introductory scenario; verification observes distinct behavior under missing and present configuration.", "sample_id": "psp-284303fed7c6", "sanitization": "Require a runtime credential instead of using a source-code fallback.", "scenario_family_id": "credential-provisioning", "secure_fix": "Inject the outbound token from deployment-managed secrets and fail closed when it is missing.", "sink_location": {"end_line": 7, "path": "snippet.py", "start_line": 7}, "source_location": {"end_line": 4, "path": "snippet.py", "start_line": 4}, "source_type": "synthetic", "split": "train", "taint_path": null, "verification_method": "local_fixture_behavior", "verification_status": "behavior_verified", "vulnerability_type": "hardcoded_credentials", "vulnerable_lines": []} | |
| {"code": "def read_billing_rollup(conn, actor):\n if not actor.is_billing_auditor:\n raise PermissionError(\"Billing rollup is unavailable\")\n return conn.execute(\n \"SELECT region, gross_revenue FROM billing_rollup\",\n ).fetchall()\n", "code_files": [{"code": "def read_billing_rollup(conn, actor):\n if not actor.is_billing_auditor:\n raise PermissionError(\"Billing rollup is unavailable\")\n return conn.execute(\n \"SELECT region, gross_revenue FROM billing_rollup\",\n ).fetchall()\n", "path": "snippet.py"}], "cwe_id": "CWE-862", "difficulty": "introductory", "evidence_reference": "data/research/evidence.json::cases/billing-rollup-capability", "expected_finding": false, "explanation": "The server-side actor has its billing auditor entitlement checked before the database read.", "fix_explanation": "Authorize access using the authenticated actor's billing entitlement from trusted server-side state.", "framework": null, "hard_negative": false, "id": "psp-2b0d8aab0496", "label": "secure", "language": "python", "leakage_group_id": "resource-authorization", "pair_id": "billing-rollup-capability", "pattern": "billing-rollup-capability", "provenance": {"authoring": "ai_assisted", "collection": "preserved_baseline", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "An in-memory database and fabricated roles exercise denied and allowed access. The location marks the operation with the missing guard.", "sample_id": "psp-2b0d8aab0496", "sanitization": "Require a trusted billing-auditor capability before reading.", "scenario_family_id": "resource-authorization", "secure_fix": "Authorize access using the authenticated actor's billing entitlement from trusted server-side state.", "sink_location": {"end_line": 4, "path": "snippet.py", "start_line": 4}, "source_location": {"end_line": 1, "path": "snippet.py", "start_line": 1}, "source_type": "synthetic", "split": "train", "taint_path": null, "verification_method": "in_memory_sqlite", "verification_status": "behavior_verified", "vulnerability_type": "missing_authorization", "vulnerable_lines": []} | |
| {"code": "import random\n\n\ndef preview_positions(layout_seed, count):\n generator = random.Random(layout_seed)\n return [(generator.randrange(80), generator.randrange(20)) for _ in range(count)]\n", "code_files": [{"code": "import random\n\n\ndef preview_positions(layout_seed, count):\n generator = random.Random(layout_seed)\n return [(generator.randrange(80), generator.randrange(20)) for _ in range(count)]\n", "path": "subject.py"}], "cwe_id": "CWE-338", "difficulty": "introductory", "evidence_reference": "data/research/evidence.json::cases/reproducible-layout-jitter", "expected_finding": false, "explanation": "Layout coordinates confer no authority and contain no credential, so a seeded PRNG is appropriate.", "fix_explanation": "Use the PRNG exclusively for deterministic non-security presentation.", "framework": null, "hard_negative": true, "id": "psp-316e6bb9b764", "label": "secure", "language": "python", "leakage_group_id": "prng-security-context", "pair_id": null, "pattern": "reproducible-layout-jitter", "provenance": {"authoring": "ai_assisted", "collection": "hard_negative", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "A sink-context counterexample. The test observes repeatability, length and coordinate bounds.", "sample_id": "psp-316e6bb9b764", "sanitization": "Use the PRNG exclusively for deterministic non-security presentation.", "scenario_family_id": "prng-security-context", "secure_fix": "Use the PRNG exclusively for deterministic non-security presentation.", "sink_location": {"end_line": 5, "path": "subject.py", "start_line": 5}, "source_location": {"end_line": 4, "path": "subject.py", "start_line": 4}, "source_type": "synthetic", "split": "train", "taint_path": null, "verification_method": "local_fixture_behavior", "verification_status": "behavior_verified", "vulnerability_type": "cryptographically_weak_prng", "vulnerable_lines": []} | |
| {"code": "import secrets\n\ndef new_pairing_code():\n return f\"{secrets.randbelow(100_000_000):08d}\"\n", "code_files": [{"code": "import secrets\n\ndef new_pairing_code():\n return f\"{secrets.randbelow(100_000_000):08d}\"\n", "path": "snippet.py"}], "cwe_id": "CWE-338", "difficulty": "introductory", "evidence_reference": "data/research/evidence.json::cases/device-pairing-random-code", "expected_finding": false, "explanation": "The code is drawn uniformly from the same range with a cryptographic random source. The small code space still requires expiration and strict online attempt limits.", "fix_explanation": "Use a cryptographic random source for pairing codes and enforce short expiry, single use and attempt limits in the pairing flow.", "framework": null, "hard_negative": false, "id": "psp-4b9457286a85", "label": "secure", "language": "python", "leakage_group_id": "prng-security-context", "pair_id": "device-pairing-random-code", "pattern": "device-pairing-random-code", "provenance": {"authoring": "ai_assisted", "collection": "preserved_baseline", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "The evidence covers generator selection and formatting. Rate limits, replay protection and code lifetime are outside the snippet.", "sample_id": "psp-4b9457286a85", "sanitization": "Use a cryptographic generator; external flow must control attempts and expiry.", "scenario_family_id": "prng-security-context", "secure_fix": "Use a cryptographic random source for pairing codes and enforce short expiry, single use and attempt limits in the pairing flow.", "sink_location": {"end_line": 4, "path": "snippet.py", "start_line": 4}, "source_location": null, "source_type": "synthetic", "split": "train", "taint_path": null, "verification_method": "mock_rng_source_selection", "verification_status": "behavior_verified", "vulnerability_type": "cryptographically_weak_prng", "vulnerable_lines": []} | |
| {"code": "import pickle\n\n\ndef copy_display_preference(theme):\n if type(theme) is not str or theme not in {\"light\", \"dark\"}:\n raise ValueError(\"Unknown theme\")\n encoded = pickle.dumps({\"theme\": theme}, protocol=4)\n return pickle.loads(encoded)\n", "code_files": [{"code": "import pickle\n\n\ndef copy_display_preference(theme):\n if type(theme) is not str or theme not in {\"light\", \"dark\"}:\n raise ValueError(\"Unknown theme\")\n encoded = pickle.dumps({\"theme\": theme}, protocol=4)\n return pickle.loads(encoded)\n", "path": "subject.py"}], "cwe_id": "CWE-502", "difficulty": "advanced", "evidence_reference": "data/research/evidence.json::cases/local-value-roundtrip", "expected_finding": false, "explanation": "The caller controls a bounded enum-like string. The object decoder receives bytes created in the same call from an exact, validated primitive value.", "fix_explanation": "Serialize a new primitive-only value inside the same function and deserialize only those locally generated bytes.", "framework": null, "hard_negative": true, "id": "psp-59a7821d0785", "label": "secure", "language": "python", "leakage_group_id": "deserialization-provenance", "pair_id": null, "pattern": "local-value-roundtrip", "provenance": {"authoring": "ai_assisted", "collection": "hard_negative", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "A same-process provenance counterexample. The decoder is replaced by a spy that checks canonical local bytes; no pickle input is decoded.", "sample_id": "psp-59a7821d0785", "sanitization": "Serialize a new primitive-only value inside the same function and deserialize only those locally generated bytes.", "scenario_family_id": "deserialization-provenance", "secure_fix": "Serialize a new primitive-only value inside the same function and deserialize only those locally generated bytes.", "sink_location": {"end_line": 8, "path": "subject.py", "start_line": 8}, "source_location": {"end_line": 4, "path": "subject.py", "start_line": 4}, "source_type": "synthetic", "split": "train", "taint_path": null, "verification_method": "mock_decoder_input_provenance", "verification_status": "behavior_verified", "vulnerability_type": "untrusted_deserialization", "vulnerable_lines": []} | |
| {"code": "import random\n\ndef issue_download_grant():\n return random.randbytes(32).hex()\n", "code_files": [{"code": "import random\n\ndef issue_download_grant():\n return random.randbytes(32).hex()\n", "path": "snippet.py"}], "cwe_id": "CWE-338", "difficulty": "introductory", "evidence_reference": "data/research/evidence.json::cases/download-grant-random-token", "expected_finding": true, "explanation": "The ordinary random module generates a bearer credential using a PRNG intended for simulation. Encoding the bytes as hex does not make them unpredictable.", "fix_explanation": "Generate bearer credentials from secrets and manage storage, expiry and revocation separately.", "framework": null, "hard_negative": false, "id": "psp-64d8e79325ab", "label": "insecure", "language": "python", "leakage_group_id": "prng-security-context", "pair_id": "download-grant-random-token", "pattern": "download-grant-random-token", "provenance": {"authoring": "ai_assisted", "collection": "preserved_baseline", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "Trivial source-selection case. The check observes generator selection and output format, not unpredictability.", "sample_id": "psp-64d8e79325ab", "sanitization": null, "scenario_family_id": "prng-security-context", "secure_fix": "Generate bearer credentials from secrets and manage storage, expiry and revocation separately.", "sink_location": {"end_line": 4, "path": "snippet.py", "start_line": 4}, "source_location": null, "source_type": "synthetic", "split": "train", "taint_path": null, "verification_method": "mock_rng_source_selection", "verification_status": "behavior_verified", "vulnerability_type": "cryptographically_weak_prng", "vulnerable_lines": [{"end_line": 4, "path": "snippet.py", "start_line": 4}]} | |
| {"code": "def record_reset_request(logger, event_id):\n logger.info(\"Reset requested event=%s\", event_id)\n", "code_files": [{"code": "def record_reset_request(logger, event_id):\n logger.info(\"Reset requested event=%s\", event_id)\n", "path": "snippet.py"}], "cwe_id": "CWE-532", "difficulty": "introductory", "evidence_reference": "data/research/evidence.json::cases/reset-token-log-minimization", "expected_finding": false, "explanation": "Only a server-generated, non-secret event identifier is recorded. The logging function does not receive the reset token.", "fix_explanation": "Correlate reset events with a non-secret identifier and exclude reset credentials from the logger's inputs.", "framework": null, "hard_negative": false, "id": "psp-67b22f1d5b40", "label": "secure", "language": "python", "leakage_group_id": "private-operational-logs", "pair_id": "reset-token-log-minimization", "pattern": "reset-token-log-minimization", "provenance": {"authoring": "ai_assisted", "collection": "preserved_baseline", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "A direct disclosure contrast with a fake credential and no recovery service.", "sample_id": "psp-67b22f1d5b40", "sanitization": "Keep the reset credential out of the logging function.", "scenario_family_id": "private-operational-logs", "secure_fix": "Correlate reset events with a non-secret identifier and exclude reset credentials from the logger's inputs.", "sink_location": {"end_line": 2, "path": "snippet.py", "start_line": 2}, "source_location": null, "source_type": "synthetic", "split": "train", "taint_path": null, "verification_method": "local_fixture_behavior", "verification_status": "behavior_verified", "vulnerability_type": "sensitive_information_in_logs", "vulnerable_lines": []} | |
| {"code": "def record_gateway_result(logger, route_name, status_code, request_headers):\n has_content_type = any(name.lower() == \"content-type\" for name in request_headers)\n logger.info(\n \"route=%s status=%d has_content_type=%s\",\n route_name, status_code, has_content_type,\n )\n", "code_files": [{"code": "def record_gateway_result(logger, route_name, status_code, request_headers):\n has_content_type = any(name.lower() == \"content-type\" for name in request_headers)\n logger.info(\n \"route=%s status=%d has_content_type=%s\",\n route_name, status_code, has_content_type,\n )\n", "path": "snippet.py"}], "cwe_id": "CWE-532", "difficulty": "intermediate", "evidence_reference": "data/research/evidence.json::cases/gateway-header-log-allowlist", "expected_finding": false, "explanation": "The log records service-owned route and status metadata plus the presence of one header. It contains no request header values.", "fix_explanation": "Select specific non-sensitive diagnostics for the log instead of serializing a request header collection.", "framework": null, "hard_negative": false, "id": "psp-8290ac386b10", "label": "secure", "language": "python", "leakage_group_id": "private-operational-logs", "pair_id": "gateway-header-log-allowlist", "pattern": "gateway-header-log-allowlist", "provenance": {"authoring": "ai_assisted", "collection": "preserved_baseline", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "Realistic diagnostic metadata contrast; checks case-insensitive header presence and omission of a fake credential.", "sample_id": "psp-8290ac386b10", "sanitization": "Allowlist header presence and omit all header values.", "scenario_family_id": "private-operational-logs", "secure_fix": "Select specific non-sensitive diagnostics for the log instead of serializing a request header collection.", "sink_location": {"end_line": 3, "path": "snippet.py", "start_line": 3}, "source_location": {"end_line": 1, "path": "snippet.py", "start_line": 1}, "source_type": "synthetic", "split": "train", "taint_path": null, "verification_method": "local_fixture_behavior", "verification_status": "behavior_verified", "vulnerability_type": "sensitive_information_in_logs", "vulnerable_lines": []} | |
| {"code": "from html import escape\n\n\ndef language_option(locale_id, catalog):\n label = catalog[locale_id][\"display_name\"]\n return '<option value=\"{}\">{}</option>'.format(escape(locale_id), escape(label))\n", "code_files": [{"code": "from html import escape\n\n\ndef language_option(locale_id, catalog):\n label = catalog[locale_id][\"display_name\"]\n return '<option value=\"{}\">{}</option>'.format(escape(locale_id), escape(label))\n", "path": "subject.py"}], "cwe_id": "CWE-79", "difficulty": "intermediate", "evidence_reference": "data/research/evidence.json::cases/fixed-options-fragment", "expected_finding": false, "explanation": "Both dynamic fields are escaped before insertion into their respective HTML contexts.", "fix_explanation": "Quote and escape the value attribute and escape visible option text.", "framework": null, "hard_negative": true, "id": "psp-850f7b8eb633", "label": "secure", "language": "python", "leakage_group_id": "html-output-encoding", "pair_id": null, "pattern": "fixed-options-fragment", "provenance": {"authoring": "ai_assisted", "collection": "hard_negative", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "Tests harmless strings containing quotes and angle brackets, checking parsed fields and element shape.", "sample_id": "psp-850f7b8eb633", "sanitization": "Quote and escape the value attribute and escape visible option text.", "scenario_family_id": "html-output-encoding", "secure_fix": "Quote and escape the value attribute and escape visible option text.", "sink_location": {"end_line": 6, "path": "subject.py", "start_line": 6}, "source_location": {"end_line": 4, "path": "subject.py", "start_line": 4}, "source_type": "synthetic", "split": "train", "taint_path": null, "verification_method": "html_parser_shape", "verification_status": "behavior_verified", "vulnerability_type": "cross_site_scripting", "vulnerable_lines": []} | |
| {"code": "# file: policy.py\ndef can_archive(members, principal_id, project_id):\n return members.role_for(principal_id, project_id) == \"maintainer\"\n\n# file: subject.py\nfrom .policy import can_archive\n\n\nclass ProjectArchiveEndpoint:\n def __init__(self, members, projects):\n self.members = members\n self.projects = projects\n\n def post(self, request):\n if request.principal is None:\n return 401\n project_id = request.json[\"project_id\"]\n if not can_archive(self.members, request.principal.id, project_id):\n return 403\n self.projects.mark_archived(project_id)\n return 204\n", "code_files": [{"code": "def can_archive(members, principal_id, project_id):\n return members.role_for(principal_id, project_id) == \"maintainer\"\n", "path": "policy.py"}, {"code": "from .policy import can_archive\n\n\nclass ProjectArchiveEndpoint:\n def __init__(self, members, projects):\n self.members = members\n self.projects = projects\n\n def post(self, request):\n if request.principal is None:\n return 401\n project_id = request.json[\"project_id\"]\n if not can_archive(self.members, request.principal.id, project_id):\n return 403\n self.projects.mark_archived(project_id)\n return 204\n", "path": "subject.py"}], "cwe_id": "CWE-862", "difficulty": "advanced", "evidence_reference": "data/research/evidence.json::cases/project-archive-permission", "expected_finding": false, "explanation": "The endpoint checks a trusted membership role before creating the archive side effect.", "fix_explanation": "Enforce the trusted membership policy before any write and retain unauthenticated rejection.", "framework": null, "hard_negative": false, "id": "psp-851f629c71f2", "label": "secure", "language": "python", "leakage_group_id": "resource-authorization", "pair_id": "project-archive-permission", "pattern": "project-archive-permission", "provenance": {"authoring": "ai_assisted", "collection": "research_pair", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "A two-module endpoint and policy fixture covers anonymous, viewer and maintainer outcomes.", "sample_id": "psp-851f629c71f2", "sanitization": "Enforce the trusted membership policy before any write and retain unauthenticated rejection.", "scenario_family_id": "resource-authorization", "secure_fix": "Enforce the trusted membership policy before any write and retain unauthenticated rejection.", "sink_location": {"end_line": 15, "path": "subject.py", "start_line": 15}, "source_location": {"end_line": 12, "path": "subject.py", "start_line": 12}, "source_type": "synthetic", "split": "train", "taint_path": null, "verification_method": "mock_repository_authorization", "verification_status": "behavior_verified", "vulnerability_type": "missing_authorization", "vulnerable_lines": []} | |
| {"code": "def record_gateway_result(logger, route_name, status_code, request_headers):\n logger.info(\"route=%s status=%d headers=%r\", route_name, status_code, request_headers)\n", "code_files": [{"code": "def record_gateway_result(logger, route_name, status_code, request_headers):\n logger.info(\"route=%s status=%d headers=%r\", route_name, status_code, request_headers)\n", "path": "snippet.py"}], "cwe_id": "CWE-532", "difficulty": "intermediate", "evidence_reference": "data/research/evidence.json::cases/gateway-header-log-allowlist", "expected_finding": true, "explanation": "Dumping the complete headers can store Authorization or Cookie values in log files.", "fix_explanation": "Select specific non-sensitive diagnostics for the log instead of serializing a request header collection.", "framework": null, "hard_negative": false, "id": "psp-8e0f2269de12", "label": "insecure", "language": "python", "leakage_group_id": "private-operational-logs", "pair_id": "gateway-header-log-allowlist", "pattern": "gateway-header-log-allowlist", "provenance": {"authoring": "ai_assisted", "collection": "preserved_baseline", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "Realistic diagnostic metadata contrast; checks case-insensitive header presence and omission of a fake credential.", "sample_id": "psp-8e0f2269de12", "sanitization": null, "scenario_family_id": "private-operational-logs", "secure_fix": "Select specific non-sensitive diagnostics for the log instead of serializing a request header collection.", "sink_location": {"end_line": 2, "path": "snippet.py", "start_line": 2}, "source_location": {"end_line": 1, "path": "snippet.py", "start_line": 1}, "source_type": "synthetic", "split": "train", "taint_path": ["request headers", "gateway metadata", "log message"], "verification_method": "local_fixture_behavior", "verification_status": "behavior_verified", "vulnerability_type": "sensitive_information_in_logs", "vulnerable_lines": [{"end_line": 2, "path": "snippet.py", "start_line": 2}]} | |
| {"code": "from html import escape\n\ndef search_field(query):\n value = escape(query, quote=True)\n return f'<input type=\"search\" name=\"q\" value=\"{value}\">'\n", "code_files": [{"code": "from html import escape\n\ndef search_field(query):\n value = escape(query, quote=True)\n return f'<input type=\"search\" name=\"q\" value=\"{value}\">'\n", "path": "snippet.py"}], "cwe_id": "CWE-79", "difficulty": "intermediate", "evidence_reference": "data/research/evidence.json::cases/search-input-html-attribute", "expected_finding": false, "explanation": "The attribute is quoted and the escaping covers quotes. The fixed attribute is plain text, so no URL or JavaScript encoding is required here.", "fix_explanation": "Quote the plain-text attribute and escape quote characters along with the other HTML metacharacters.", "framework": null, "hard_negative": false, "id": "psp-a1d632eb1f0e", "label": "secure", "language": "python", "leakage_group_id": "html-output-encoding", "pair_id": "search-input-html-attribute", "pattern": "search-input-html-attribute", "provenance": {"authoring": "ai_assisted", "collection": "preserved_baseline", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "Tests ordinary text containing a quote in an attribute; no active browser content is used.", "sample_id": "psp-a1d632eb1f0e", "sanitization": "Escape quotes in a quoted, plain-text HTML attribute.", "scenario_family_id": "html-output-encoding", "secure_fix": "Quote the plain-text attribute and escape quote characters along with the other HTML metacharacters.", "sink_location": {"end_line": 5, "path": "snippet.py", "start_line": 5}, "source_location": {"end_line": 3, "path": "snippet.py", "start_line": 3}, "source_type": "synthetic", "split": "train", "taint_path": ["search query", "quote-aware escaping", "double-quoted value attribute"], "verification_method": "html_parser_shape", "verification_status": "behavior_verified", "vulnerability_type": "cross_site_scripting", "vulnerable_lines": []} | |
| {"code": "# file: fragments.py\ndef render_transcript(receipt_id, text):\n return f\"<article><h2>{receipt_id:d}</h2><aside>{text}</aside></article>\"\n\n# file: subject.py\nfrom .fragments import render_transcript\n\n\nclass TranscriptPreview:\n def __init__(self, transcripts):\n self.transcripts = transcripts\n\n def get(self, receipt_id):\n transcript = self.transcripts.get(receipt_id)\n if transcript is None:\n return 404, \"\"\n return 200, render_transcript(receipt_id, transcript.text)\n", "code_files": [{"code": "def render_transcript(receipt_id, text):\n return f\"<article><h2>{receipt_id:d}</h2><aside>{text}</aside></article>\"\n", "path": "fragments.py"}, {"code": "from .fragments import render_transcript\n\n\nclass TranscriptPreview:\n def __init__(self, transcripts):\n self.transcripts = transcripts\n\n def get(self, receipt_id):\n transcript = self.transcripts.get(receipt_id)\n if transcript is None:\n return 404, \"\"\n return 200, render_transcript(receipt_id, transcript.text)\n", "path": "subject.py"}], "cwe_id": "CWE-79", "difficulty": "advanced", "evidence_reference": "data/research/evidence.json::cases/helpdesk-transcript-renderer", "expected_finding": true, "explanation": "The renderer passes stored transcript text through as HTML markup.", "fix_explanation": "Escape stored transcript text in its HTML text-node context.", "framework": null, "hard_negative": false, "id": "psp-a38135b4714f", "label": "insecure", "language": "python", "leakage_group_id": "html-output-encoding", "pair_id": "helpdesk-transcript-renderer", "pattern": "helpdesk-transcript-renderer", "provenance": {"authoring": "ai_assisted", "collection": "research_pair", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "The source and sink span files. The fixture measures parsing of harmless transcript text and the missing-record path.", "sample_id": "psp-a38135b4714f", "sanitization": null, "scenario_family_id": "html-output-encoding", "secure_fix": "Escape stored transcript text in its HTML text-node context.", "sink_location": {"end_line": 2, "path": "fragments.py", "start_line": 2}, "source_location": {"end_line": 9, "path": "subject.py", "start_line": 9}, "source_type": "synthetic", "split": "train", "taint_path": ["stored transcript", "preview service", "renderer text-node interpolation"], "verification_method": "html_parser_shape", "verification_status": "behavior_verified", "vulnerability_type": "cross_site_scripting", "vulnerable_lines": [{"end_line": 2, "path": "fragments.py", "start_line": 2}]} | |
| {"code": "def announcement_html(message):\n return f\"<p class='announcement'>{message}</p>\"\n", "code_files": [{"code": "def announcement_html(message):\n return f\"<p class='announcement'>{message}</p>\"\n", "path": "snippet.py"}], "cwe_id": "CWE-79", "difficulty": "introductory", "evidence_reference": "data/research/evidence.json::cases/announcement-html-text", "expected_finding": true, "explanation": "The message comes from a user and is inserted into an HTML text node that a browser can interpret as markup.", "fix_explanation": "Use HTML text escaping or an autoescaping HTML template for the message.", "framework": null, "hard_negative": false, "id": "psp-a7cb69a8b8f6", "label": "insecure", "language": "python", "leakage_group_id": "html-output-encoding", "pair_id": "announcement-html-text", "pattern": "announcement-html-text", "provenance": {"authoring": "ai_assisted", "collection": "preserved_baseline", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "Introductory browser-output contrast; the test measures HTML parse shape for ordinary text containing markup delimiters.", "sample_id": "psp-a7cb69a8b8f6", "sanitization": null, "scenario_family_id": "html-output-encoding", "secure_fix": "Use HTML text escaping or an autoescaping HTML template for the message.", "sink_location": {"end_line": 2, "path": "snippet.py", "start_line": 2}, "source_location": {"end_line": 1, "path": "snippet.py", "start_line": 1}, "source_type": "synthetic", "split": "train", "taint_path": ["user message", "interpolated HTML text node"], "verification_method": "html_parser_shape", "verification_status": "behavior_verified", "vulnerability_type": "cross_site_scripting", "vulnerable_lines": [{"end_line": 2, "path": "snippet.py", "start_line": 2}]} | |
| {"code": "from html import escape\n\ndef search_field(query):\n value = escape(query, quote=False)\n return f'<input type=\"search\" name=\"q\" value=\"{value}\">'\n", "code_files": [{"code": "from html import escape\n\ndef search_field(query):\n value = escape(query, quote=False)\n return f'<input type=\"search\" name=\"q\" value=\"{value}\">'\n", "path": "snippet.py"}], "cwe_id": "CWE-79", "difficulty": "intermediate", "evidence_reference": "data/research/evidence.json::cases/search-input-html-attribute", "expected_finding": true, "explanation": "Escaping ampersands and angle brackets leaves double quotes from the request able to end the value attribute.", "fix_explanation": "Quote the plain-text attribute and escape quote characters along with the other HTML metacharacters.", "framework": null, "hard_negative": false, "id": "psp-a9a16e96b918", "label": "insecure", "language": "python", "leakage_group_id": "html-output-encoding", "pair_id": "search-input-html-attribute", "pattern": "search-input-html-attribute", "provenance": {"authoring": "ai_assisted", "collection": "preserved_baseline", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "Tests ordinary text containing a quote in an attribute; no active browser content is used.", "sample_id": "psp-a9a16e96b918", "sanitization": "Escapes ampersands and angle brackets but leaves quotes literal.", "scenario_family_id": "html-output-encoding", "secure_fix": "Quote the plain-text attribute and escape quote characters along with the other HTML metacharacters.", "sink_location": {"end_line": 5, "path": "snippet.py", "start_line": 5}, "source_location": {"end_line": 3, "path": "snippet.py", "start_line": 3}, "source_type": "synthetic", "split": "train", "taint_path": ["search query", "HTML escaping", "double-quoted value attribute"], "verification_method": "html_parser_shape", "verification_status": "behavior_verified", "vulnerability_type": "cross_site_scripting", "vulnerable_lines": [{"end_line": 5, "path": "snippet.py", "start_line": 5}]} | |
| {"code": "def queue_workspace_export(queue, actor, workspace_id):\n if not actor.can_export_workspace(workspace_id):\n raise PermissionError(\"Workspace export is unavailable\")\n return queue.enqueue(\"workspace_export\", workspace_id=workspace_id, requested_by=actor.id)\n", "code_files": [{"code": "def queue_workspace_export(queue, actor, workspace_id):\n if not actor.can_export_workspace(workspace_id):\n raise PermissionError(\"Workspace export is unavailable\")\n return queue.enqueue(\"workspace_export\", workspace_id=workspace_id, requested_by=actor.id)\n", "path": "snippet.py"}], "cwe_id": "CWE-862", "difficulty": "intermediate", "evidence_reference": "data/research/evidence.json::cases/workspace-export-capability", "expected_finding": false, "explanation": "The trusted actor capability check applies the export policy to this workspace before the privileged job is created.", "fix_explanation": "Check the authenticated actor's workspace-scoped export permission before queuing work. Apply the worker's authorization policy if permissions can change before execution.", "framework": null, "hard_negative": false, "id": "psp-b191e72d0b2d", "label": "secure", "language": "python", "leakage_group_id": "resource-authorization", "pair_id": "workspace-export-capability", "pattern": "workspace-export-capability", "provenance": {"authoring": "ai_assisted", "collection": "preserved_baseline", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "A fake queue observes policy ordering and side-effect suppression; separate worker-time policy is outside scope.", "sample_id": "psp-b191e72d0b2d", "sanitization": "Apply the workspace-specific export entitlement before queuing.", "scenario_family_id": "resource-authorization", "secure_fix": "Check the authenticated actor's workspace-scoped export permission before queuing work. Apply the worker's authorization policy if permissions can change before execution.", "sink_location": {"end_line": 4, "path": "snippet.py", "start_line": 4}, "source_location": {"end_line": 1, "path": "snippet.py", "start_line": 1}, "source_type": "synthetic", "split": "train", "taint_path": null, "verification_method": "mock_queue_authorization", "verification_status": "behavior_verified", "vulnerability_type": "missing_authorization", "vulnerable_lines": []} | |
| {"code": "import random\n\ndef new_pairing_code():\n return f\"{random.randrange(100_000_000):08d}\"\n", "code_files": [{"code": "import random\n\ndef new_pairing_code():\n return f\"{random.randrange(100_000_000):08d}\"\n", "path": "snippet.py"}], "cwe_id": "CWE-338", "difficulty": "introductory", "evidence_reference": "data/research/evidence.json::cases/device-pairing-random-code", "expected_finding": true, "explanation": "The eight-digit device pairing code comes from a general-purpose PRNG without a cryptographic unpredictability guarantee.", "fix_explanation": "Use a cryptographic random source for pairing codes and enforce short expiry, single use and attempt limits in the pairing flow.", "framework": null, "hard_negative": false, "id": "psp-b453545fc451", "label": "insecure", "language": "python", "leakage_group_id": "prng-security-context", "pair_id": "device-pairing-random-code", "pattern": "device-pairing-random-code", "provenance": {"authoring": "ai_assisted", "collection": "preserved_baseline", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "The evidence covers generator selection and formatting. Rate limits, replay protection and code lifetime are outside the snippet.", "sample_id": "psp-b453545fc451", "sanitization": null, "scenario_family_id": "prng-security-context", "secure_fix": "Use a cryptographic random source for pairing codes and enforce short expiry, single use and attempt limits in the pairing flow.", "sink_location": {"end_line": 4, "path": "snippet.py", "start_line": 4}, "source_location": null, "source_type": "synthetic", "split": "train", "taint_path": null, "verification_method": "mock_rng_source_selection", "verification_status": "behavior_verified", "vulnerability_type": "cryptographically_weak_prng", "vulnerable_lines": [{"end_line": 4, "path": "snippet.py", "start_line": 4}]} | |
| {"code": "from html import escape\n\ndef announcement_html(message):\n return f\"<p class='announcement'>{escape(message, quote=False)}</p>\"\n", "code_files": [{"code": "from html import escape\n\ndef announcement_html(message):\n return f\"<p class='announcement'>{escape(message, quote=False)}</p>\"\n", "path": "snippet.py"}], "cwe_id": "CWE-79", "difficulty": "introductory", "evidence_reference": "data/research/evidence.json::cases/announcement-html-text", "expected_finding": false, "explanation": "HTML escaping applies to the untrusted string in this text-node context. The constant markup stays intact while the message renders as text.", "fix_explanation": "Use HTML text escaping or an autoescaping HTML template for the message.", "framework": null, "hard_negative": false, "id": "psp-b5aab3dadaad", "label": "secure", "language": "python", "leakage_group_id": "html-output-encoding", "pair_id": "announcement-html-text", "pattern": "announcement-html-text", "provenance": {"authoring": "ai_assisted", "collection": "preserved_baseline", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "Introductory browser-output contrast; the test measures HTML parse shape for ordinary text containing markup delimiters.", "sample_id": "psp-b5aab3dadaad", "sanitization": "Escape for a plain HTML text node.", "scenario_family_id": "html-output-encoding", "secure_fix": "Use HTML text escaping or an autoescaping HTML template for the message.", "sink_location": {"end_line": 4, "path": "snippet.py", "start_line": 4}, "source_location": {"end_line": 3, "path": "snippet.py", "start_line": 3}, "source_type": "synthetic", "split": "train", "taint_path": ["user message", "HTML text escaping", "interpolated text node"], "verification_method": "html_parser_shape", "verification_status": "behavior_verified", "vulnerability_type": "cross_site_scripting", "vulnerable_lines": []} | |
| {"code": "def metrics_headers():\n token = \"synthetic-example-metrics-credential\"\n return {\"Authorization\": \"Bearer \" + token}\n", "code_files": [{"code": "def metrics_headers():\n token = \"synthetic-example-metrics-credential\"\n return {\"Authorization\": \"Bearer \" + token}\n", "path": "snippet.py"}], "cwe_id": "CWE-798", "difficulty": "introductory", "evidence_reference": "data/research/evidence.json::cases/outbound-metrics-credential-source", "expected_finding": true, "explanation": "The synthetic literal represents a static outbound service credential embedded in source code, making it available to anyone who obtains that source.", "fix_explanation": "Inject the outbound token from deployment-managed secrets and fail closed when it is missing.", "framework": null, "hard_negative": false, "id": "psp-b7bc7cd6291d", "label": "insecure", "language": "python", "leakage_group_id": "credential-provisioning", "pair_id": "outbound-metrics-credential-source", "pattern": "outbound-metrics-credential-source", "provenance": {"authoring": "ai_assisted", "collection": "preserved_baseline", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "Obvious literal serves as an introductory scenario; verification observes distinct behavior under missing and present configuration.", "sample_id": "psp-b7bc7cd6291d", "sanitization": null, "scenario_family_id": "credential-provisioning", "secure_fix": "Inject the outbound token from deployment-managed secrets and fail closed when it is missing.", "sink_location": {"end_line": 3, "path": "snippet.py", "start_line": 3}, "source_location": {"end_line": 2, "path": "snippet.py", "start_line": 2}, "source_type": "synthetic", "split": "train", "taint_path": null, "verification_method": "local_fixture_behavior", "verification_status": "behavior_verified", "vulnerability_type": "hardcoded_credentials", "vulnerable_lines": [{"end_line": 2, "path": "snippet.py", "start_line": 2}]} | |
| {"code": "def read_billing_rollup(conn, actor):\n return conn.execute(\n \"SELECT region, gross_revenue FROM billing_rollup\",\n ).fetchall()\n", "code_files": [{"code": "def read_billing_rollup(conn, actor):\n return conn.execute(\n \"SELECT region, gross_revenue FROM billing_rollup\",\n ).fetchall()\n", "path": "snippet.py"}], "cwe_id": "CWE-862", "difficulty": "introductory", "evidence_reference": "data/research/evidence.json::cases/billing-rollup-capability", "expected_finding": true, "explanation": "Any authenticated account reaching this function can retrieve internal billing data because the endpoint skips the auditor authorization check.", "fix_explanation": "Authorize access using the authenticated actor's billing entitlement from trusted server-side state.", "framework": null, "hard_negative": false, "id": "psp-c05787605d93", "label": "insecure", "language": "python", "leakage_group_id": "resource-authorization", "pair_id": "billing-rollup-capability", "pattern": "billing-rollup-capability", "provenance": {"authoring": "ai_assisted", "collection": "preserved_baseline", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "An in-memory database and fabricated roles exercise denied and allowed access. The location marks the operation with the missing guard.", "sample_id": "psp-c05787605d93", "sanitization": null, "scenario_family_id": "resource-authorization", "secure_fix": "Authorize access using the authenticated actor's billing entitlement from trusted server-side state.", "sink_location": {"end_line": 2, "path": "snippet.py", "start_line": 2}, "source_location": {"end_line": 1, "path": "snippet.py", "start_line": 1}, "source_type": "synthetic", "split": "train", "taint_path": null, "verification_method": "in_memory_sqlite", "verification_status": "behavior_verified", "vulnerability_type": "missing_authorization", "vulnerable_lines": [{"end_line": 2, "path": "snippet.py", "start_line": 2}]} | |
| {"code": "def record_reset_request(logger, event_id, reset_token):\n logger.info(\"Reset requested event=%s token=%s\", event_id, reset_token)\n", "code_files": [{"code": "def record_reset_request(logger, event_id, reset_token):\n logger.info(\"Reset requested event=%s token=%s\", event_id, reset_token)\n", "path": "snippet.py"}], "cwe_id": "CWE-532", "difficulty": "introductory", "evidence_reference": "data/research/evidence.json::cases/reset-token-log-minimization", "expected_finding": true, "explanation": "The log contains a password-reset token while the token may still authorize a reset.", "fix_explanation": "Correlate reset events with a non-secret identifier and exclude reset credentials from the logger's inputs.", "framework": null, "hard_negative": false, "id": "psp-c7506ea17056", "label": "insecure", "language": "python", "leakage_group_id": "private-operational-logs", "pair_id": "reset-token-log-minimization", "pattern": "reset-token-log-minimization", "provenance": {"authoring": "ai_assisted", "collection": "preserved_baseline", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "A direct disclosure contrast with a fake credential and no recovery service.", "sample_id": "psp-c7506ea17056", "sanitization": null, "scenario_family_id": "private-operational-logs", "secure_fix": "Correlate reset events with a non-secret identifier and exclude reset credentials from the logger's inputs.", "sink_location": {"end_line": 2, "path": "snippet.py", "start_line": 2}, "source_location": {"end_line": 1, "path": "snippet.py", "start_line": 1}, "source_type": "synthetic", "split": "train", "taint_path": ["reset credential", "formatted log entry"], "verification_method": "local_fixture_behavior", "verification_status": "behavior_verified", "vulnerability_type": "sensitive_information_in_logs", "vulnerable_lines": [{"end_line": 2, "path": "snippet.py", "start_line": 2}]} | |
| {"code": "import ssl\nfrom contextlib import closing\nfrom http.client import HTTPSConnection\n\ndef fetch_invoice_status():\n context = ssl.create_default_context()\n with closing(HTTPSConnection(\"billing.example.invalid\", context=context, timeout=5)) as client:\n client.request(\"GET\", \"/status\")\n with client.getresponse() as response:\n if response.status != 200:\n raise OSError(\"Invoice status unavailable\")\n return response.read()\n", "code_files": [{"code": "import ssl\nfrom contextlib import closing\nfrom http.client import HTTPSConnection\n\ndef fetch_invoice_status():\n context = ssl.create_default_context()\n with closing(HTTPSConnection(\"billing.example.invalid\", context=context, timeout=5)) as client:\n client.request(\"GET\", \"/status\")\n with client.getresponse() as response:\n if response.status != 200:\n raise OSError(\"Invoice status unavailable\")\n return response.read()\n", "path": "snippet.py"}], "cwe_id": "CWE-295", "difficulty": "intermediate", "evidence_reference": "data/research/evidence.json::cases/billing-https-context-verification", "expected_finding": false, "explanation": "The default client context validates the chain against trusted roots and checks the configured hostname. The client makes one HTTPS request and rejects redirect responses.", "fix_explanation": "Use a verifying client context and configure an appropriate CA trust store when the deployment uses a private CA.", "framework": null, "hard_negative": false, "id": "psp-caacc027f50d", "label": "secure", "language": "python", "leakage_group_id": "tls-peer-authentication", "pair_id": "billing-https-context-verification", "pattern": "billing-https-context-verification", "provenance": {"authoring": "ai_assisted", "collection": "preserved_baseline", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "The fixture inspects the TLS context at a fake transport boundary. It does not establish handshake behavior.", "sample_id": "psp-caacc027f50d", "sanitization": "Use default certificate and hostname verification for the fixed HTTPS endpoint.", "scenario_family_id": "tls-peer-authentication", "secure_fix": "Use a verifying client context and configure an appropriate CA trust store when the deployment uses a private CA.", "sink_location": {"end_line": 6, "path": "snippet.py", "start_line": 6}, "source_location": null, "source_type": "synthetic", "split": "train", "taint_path": null, "verification_method": "tls_context_at_mock_transport", "verification_status": "behavior_verified", "vulnerability_type": "improper_certificate_validation", "vulnerable_lines": []} | |
| {"code": "import ssl\n\ndef open_relay_tls(connected_socket, relay_dns_name):\n context = ssl.create_default_context(cafile=\"/etc/example-mail/relay-ca.pem\")\n return context.wrap_socket(connected_socket, server_hostname=relay_dns_name)\n", "code_files": [{"code": "import ssl\n\ndef open_relay_tls(connected_socket, relay_dns_name):\n context = ssl.create_default_context(cafile=\"/etc/example-mail/relay-ca.pem\")\n return context.wrap_socket(connected_socket, server_hostname=relay_dns_name)\n", "path": "snippet.py"}], "cwe_id": "CWE-295", "difficulty": "intermediate", "evidence_reference": "data/research/evidence.json::cases/mail-relay-tls-trust-source", "expected_finding": false, "explanation": "The context validates the chain against deployment-managed trust anchors and checks the expected relay name from trusted configuration.", "fix_explanation": "Source both relay identity and CA trust from administrator-controlled configuration.", "framework": null, "hard_negative": false, "id": "psp-cb247be4e59b", "label": "secure", "language": "python", "leakage_group_id": "tls-peer-authentication", "pair_id": "mail-relay-tls-trust-source", "pattern": "mail-relay-tls-trust-source", "provenance": {"authoring": "ai_assisted", "collection": "preserved_baseline", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "Realistic trust-root provenance distinction. The trust-loading call and server hostname are observed through a fake context.", "sample_id": "psp-cb247be4e59b", "sanitization": "Load only deployment-managed CA trust alongside the configured relay name.", "scenario_family_id": "tls-peer-authentication", "secure_fix": "Source both relay identity and CA trust from administrator-controlled configuration.", "sink_location": {"end_line": 4, "path": "snippet.py", "start_line": 4}, "source_location": null, "source_type": "synthetic", "split": "train", "taint_path": null, "verification_method": "mock_tls_trust_loading", "verification_status": "behavior_verified", "vulnerability_type": "improper_certificate_validation", "vulnerable_lines": []} | |
| {"code": "import secrets\n\ndef issue_download_grant():\n return secrets.token_hex(32)\n", "code_files": [{"code": "import secrets\n\ndef issue_download_grant():\n return secrets.token_hex(32)\n", "path": "snippet.py"}], "cwe_id": "CWE-338", "difficulty": "introductory", "evidence_reference": "data/research/evidence.json::cases/download-grant-random-token", "expected_finding": false, "explanation": "The secrets module obtains 32 bytes from the operating system's cryptographic randomness source and hex-encodes them.", "fix_explanation": "Generate bearer credentials from secrets and manage storage, expiry and revocation separately.", "framework": null, "hard_negative": false, "id": "psp-ce924de4c758", "label": "secure", "language": "python", "leakage_group_id": "prng-security-context", "pair_id": "download-grant-random-token", "pattern": "download-grant-random-token", "provenance": {"authoring": "ai_assisted", "collection": "preserved_baseline", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "Trivial source-selection case. The check observes generator selection and output format, not unpredictability.", "sample_id": "psp-ce924de4c758", "sanitization": "Use the OS-backed secrets API for the bearer token.", "scenario_family_id": "prng-security-context", "secure_fix": "Generate bearer credentials from secrets and manage storage, expiry and revocation separately.", "sink_location": {"end_line": 4, "path": "snippet.py", "start_line": 4}, "source_location": null, "source_type": "synthetic", "split": "train", "taint_path": null, "verification_method": "mock_rng_source_selection", "verification_status": "behavior_verified", "vulnerability_type": "cryptographically_weak_prng", "vulnerable_lines": []} | |
| {"code": "import ssl\n\ndef open_relay_tls(connected_socket, relay_dns_name, uploaded_ca_path):\n context = ssl.create_default_context(cafile=uploaded_ca_path)\n return context.wrap_socket(connected_socket, server_hostname=relay_dns_name)\n", "code_files": [{"code": "import ssl\n\ndef open_relay_tls(connected_socket, relay_dns_name, uploaded_ca_path):\n context = ssl.create_default_context(cafile=uploaded_ca_path)\n return context.wrap_socket(connected_socket, server_hostname=relay_dns_name)\n", "path": "snippet.py"}], "cwe_id": "CWE-295", "difficulty": "intermediate", "evidence_reference": "data/research/evidence.json::cases/mail-relay-tls-trust-source", "expected_finding": true, "explanation": "An untrusted upload supplies the CA bundle for a managed relay. Verification can succeed against trust anchors chosen by the upload author.", "fix_explanation": "Source both relay identity and CA trust from administrator-controlled configuration.", "framework": null, "hard_negative": false, "id": "psp-d1608de39fc7", "label": "insecure", "language": "python", "leakage_group_id": "tls-peer-authentication", "pair_id": "mail-relay-tls-trust-source", "pattern": "mail-relay-tls-trust-source", "provenance": {"authoring": "ai_assisted", "collection": "preserved_baseline", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "Realistic trust-root provenance distinction. The trust-loading call and server hostname are observed through a fake context.", "sample_id": "psp-d1608de39fc7", "sanitization": null, "scenario_family_id": "tls-peer-authentication", "secure_fix": "Source both relay identity and CA trust from administrator-controlled configuration.", "sink_location": {"end_line": 4, "path": "snippet.py", "start_line": 4}, "source_location": {"end_line": 3, "path": "snippet.py", "start_line": 3}, "source_type": "synthetic", "split": "train", "taint_path": ["CA bundle selection", "TLS context trust store", "relay connection"], "verification_method": "mock_tls_trust_loading", "verification_status": "behavior_verified", "vulnerability_type": "improper_certificate_validation", "vulnerable_lines": [{"end_line": 4, "path": "snippet.py", "start_line": 4}]} | |
| {"code": "def queue_workspace_export(queue, actor, workspace_id):\n return queue.enqueue(\"workspace_export\", workspace_id=workspace_id, requested_by=actor.id)\n", "code_files": [{"code": "def queue_workspace_export(queue, actor, workspace_id):\n return queue.enqueue(\"workspace_export\", workspace_id=workspace_id, requested_by=actor.id)\n", "path": "snippet.py"}], "cwe_id": "CWE-862", "difficulty": "intermediate", "evidence_reference": "data/research/evidence.json::cases/workspace-export-capability", "expected_finding": true, "explanation": "The function records the authenticated user's identity but never checks their permission to export the requested workspace.", "fix_explanation": "Check the authenticated actor's workspace-scoped export permission before queuing work. Apply the worker's authorization policy if permissions can change before execution.", "framework": null, "hard_negative": false, "id": "psp-d70ca65300fd", "label": "insecure", "language": "python", "leakage_group_id": "resource-authorization", "pair_id": "workspace-export-capability", "pattern": "workspace-export-capability", "provenance": {"authoring": "ai_assisted", "collection": "preserved_baseline", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "A fake queue observes policy ordering and side-effect suppression; separate worker-time policy is outside scope.", "sample_id": "psp-d70ca65300fd", "sanitization": null, "scenario_family_id": "resource-authorization", "secure_fix": "Check the authenticated actor's workspace-scoped export permission before queuing work. Apply the worker's authorization policy if permissions can change before execution.", "sink_location": {"end_line": 2, "path": "snippet.py", "start_line": 2}, "source_location": {"end_line": 1, "path": "snippet.py", "start_line": 1}, "source_type": "synthetic", "split": "train", "taint_path": null, "verification_method": "mock_queue_authorization", "verification_status": "behavior_verified", "vulnerability_type": "missing_authorization", "vulnerable_lines": [{"end_line": 2, "path": "snippet.py", "start_line": 2}]} | |
| {"code": "# file: policy.py\ndef can_archive(members, principal_id, project_id):\n return members.role_for(principal_id, project_id) == \"maintainer\"\n\n# file: subject.py\nclass ProjectArchiveEndpoint:\n def __init__(self, members, projects):\n self.members = members\n self.projects = projects\n\n def post(self, request):\n if request.principal is None:\n return 401\n project_id = request.json[\"project_id\"]\n self.projects.mark_archived(project_id)\n return 204\n", "code_files": [{"code": "def can_archive(members, principal_id, project_id):\n return members.role_for(principal_id, project_id) == \"maintainer\"\n", "path": "policy.py"}, {"code": "class ProjectArchiveEndpoint:\n def __init__(self, members, projects):\n self.members = members\n self.projects = projects\n\n def post(self, request):\n if request.principal is None:\n return 401\n project_id = request.json[\"project_id\"]\n self.projects.mark_archived(project_id)\n return 204\n", "path": "subject.py"}], "cwe_id": "CWE-862", "difficulty": "advanced", "evidence_reference": "data/research/evidence.json::cases/project-archive-permission", "expected_finding": true, "explanation": "The endpoint checks authentication but omits its available per-project authorization policy.", "fix_explanation": "Enforce the trusted membership policy before any write and retain unauthenticated rejection.", "framework": null, "hard_negative": false, "id": "psp-dc0709469a91", "label": "insecure", "language": "python", "leakage_group_id": "resource-authorization", "pair_id": "project-archive-permission", "pattern": "project-archive-permission", "provenance": {"authoring": "ai_assisted", "collection": "research_pair", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "A two-module endpoint and policy fixture covers anonymous, viewer and maintainer outcomes.", "sample_id": "psp-dc0709469a91", "sanitization": null, "scenario_family_id": "resource-authorization", "secure_fix": "Enforce the trusted membership policy before any write and retain unauthenticated rejection.", "sink_location": {"end_line": 10, "path": "subject.py", "start_line": 10}, "source_location": {"end_line": 9, "path": "subject.py", "start_line": 9}, "source_type": "synthetic", "split": "train", "taint_path": null, "verification_method": "mock_repository_authorization", "verification_status": "behavior_verified", "vulnerability_type": "missing_authorization", "vulnerable_lines": [{"end_line": 10, "path": "subject.py", "start_line": 10}]} | |
| {"code": "# file: subject.py\nfrom .ticket import to_receipt\n\n\nclass TicketReceiptService:\n def __init__(self, audit):\n self.audit = audit\n\n def acknowledge(self, ticket):\n receipt = to_receipt(ticket)\n self.audit.info(\"Acknowledged %s: %s\", receipt[\"ticket_id\"], ticket[\"body\"])\n return receipt\n\n# file: ticket.py\ndef to_receipt(ticket):\n return {\"ticket_id\": ticket[\"id\"], \"status\": \"received\"}\n", "code_files": [{"code": "from .ticket import to_receipt\n\n\nclass TicketReceiptService:\n def __init__(self, audit):\n self.audit = audit\n\n def acknowledge(self, ticket):\n receipt = to_receipt(ticket)\n self.audit.info(\"Acknowledged %s: %s\", receipt[\"ticket_id\"], ticket[\"body\"])\n return receipt\n", "path": "subject.py"}, {"code": "def to_receipt(ticket):\n return {\"ticket_id\": ticket[\"id\"], \"status\": \"received\"}\n", "path": "ticket.py"}], "cwe_id": "CWE-532", "difficulty": "intermediate", "evidence_reference": "data/research/evidence.json::cases/support-ticket-audit", "expected_finding": true, "explanation": "The acknowledgement logs the complete support-ticket body, which may contain private information.", "fix_explanation": "Use the receipt identifier as the audit field and keep the body out of logs.", "framework": null, "hard_negative": false, "id": "psp-dc2a0ed8e7cb", "label": "insecure", "language": "python", "leakage_group_id": "private-operational-logs", "pair_id": "support-ticket-audit", "pattern": "support-ticket-audit", "provenance": {"authoring": "ai_assisted", "collection": "research_pair", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "Separate receipt construction and logging across two modules; verification observes output and a fictional private field.", "sample_id": "psp-dc2a0ed8e7cb", "sanitization": null, "scenario_family_id": "private-operational-logs", "secure_fix": "Use the receipt identifier as the audit field and keep the body out of logs.", "sink_location": {"end_line": 10, "path": "subject.py", "start_line": 10}, "source_location": {"end_line": 8, "path": "subject.py", "start_line": 8}, "source_type": "synthetic", "split": "train", "taint_path": ["support ticket payload", "receipt construction", "operational log"], "verification_method": "local_fixture_behavior", "verification_status": "behavior_verified", "vulnerability_type": "sensitive_information_in_logs", "vulnerable_lines": [{"end_line": 10, "path": "subject.py", "start_line": 10}]} | |
| {"code": "import json\n\n\ndef log_checkout(logger, checkout):\n public_event = {\"event\": \"checkout\", \"cart_items\": len(checkout[\"items\"])}\n logger.info(json.dumps(public_event))\n", "code_files": [{"code": "import json\n\n\ndef log_checkout(logger, checkout):\n public_event = {\"event\": \"checkout\", \"cart_items\": len(checkout[\"items\"])}\n logger.info(json.dumps(public_event))\n", "path": "subject.py"}], "cwe_id": "CWE-532", "difficulty": "intermediate", "evidence_reference": "data/research/evidence.json::cases/audit-selection-before-serialize", "expected_finding": false, "explanation": "Passing the checkout into the function does not mean the whole object reaches the log. The emitted event contains only type and item count.", "fix_explanation": "Construct a new event from the permitted count before serialization.", "framework": null, "hard_negative": true, "id": "psp-dcde61252dfc", "label": "secure", "language": "python", "leakage_group_id": "private-operational-logs", "pair_id": null, "pattern": "audit-selection-before-serialize", "provenance": {"authoring": "ai_assisted", "collection": "hard_negative", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "Fake private fields in cart items and checkout metadata are absent from the emitted event.", "sample_id": "psp-dcde61252dfc", "sanitization": "Construct a new event from the permitted count before serialization.", "scenario_family_id": "private-operational-logs", "secure_fix": "Construct a new event from the permitted count before serialization.", "sink_location": {"end_line": 6, "path": "subject.py", "start_line": 6}, "source_location": {"end_line": 4, "path": "subject.py", "start_line": 4}, "source_type": "synthetic", "split": "train", "taint_path": null, "verification_method": "local_fixture_behavior", "verification_status": "behavior_verified", "vulnerability_type": "sensitive_information_in_logs", "vulnerable_lines": []} | |
| {"code": "# file: subject.py\nfrom .ticket import to_receipt\n\n\nclass TicketReceiptService:\n def __init__(self, audit):\n self.audit = audit\n\n def acknowledge(self, ticket):\n receipt = to_receipt(ticket)\n self.audit.info(\"Acknowledged %s\", receipt[\"ticket_id\"])\n return receipt\n\n# file: ticket.py\ndef to_receipt(ticket):\n return {\"ticket_id\": ticket[\"id\"], \"status\": \"received\"}\n", "code_files": [{"code": "from .ticket import to_receipt\n\n\nclass TicketReceiptService:\n def __init__(self, audit):\n self.audit = audit\n\n def acknowledge(self, ticket):\n receipt = to_receipt(ticket)\n self.audit.info(\"Acknowledged %s\", receipt[\"ticket_id\"])\n return receipt\n", "path": "subject.py"}, {"code": "def to_receipt(ticket):\n return {\"ticket_id\": ticket[\"id\"], \"status\": \"received\"}\n", "path": "ticket.py"}], "cwe_id": "CWE-532", "difficulty": "intermediate", "evidence_reference": "data/research/evidence.json::cases/support-ticket-audit", "expected_finding": false, "explanation": "The acknowledgement logs only the receipt ID and preserves the receipt response.", "fix_explanation": "Use the receipt identifier as the audit field and keep the body out of logs.", "framework": null, "hard_negative": false, "id": "psp-e905585aa378", "label": "secure", "language": "python", "leakage_group_id": "private-operational-logs", "pair_id": "support-ticket-audit", "pattern": "support-ticket-audit", "provenance": {"authoring": "ai_assisted", "collection": "research_pair", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "Separate receipt construction and logging across two modules; verification observes output and a fictional private field.", "sample_id": "psp-e905585aa378", "sanitization": "Use the receipt identifier as the audit field and keep the body out of logs.", "scenario_family_id": "private-operational-logs", "secure_fix": "Use the receipt identifier as the audit field and keep the body out of logs.", "sink_location": {"end_line": 10, "path": "subject.py", "start_line": 10}, "source_location": {"end_line": 8, "path": "subject.py", "start_line": 8}, "source_type": "synthetic", "split": "train", "taint_path": null, "verification_method": "local_fixture_behavior", "verification_status": "behavior_verified", "vulnerability_type": "sensitive_information_in_logs", "vulnerable_lines": []} | |
| {"code": "from hmac import compare_digest\n\ndef accepts_hook_token(provided_token):\n expected = b\"synthetic-example-hook-credential\"\n return compare_digest(provided_token.encode(\"utf-8\"), expected)\n", "code_files": [{"code": "from hmac import compare_digest\n\ndef accepts_hook_token(provided_token):\n expected = b\"synthetic-example-hook-credential\"\n return compare_digest(provided_token.encode(\"utf-8\"), expected)\n", "path": "snippet.py"}], "cwe_id": "CWE-798", "difficulty": "intermediate", "evidence_reference": "data/research/evidence.json::cases/inbound-hook-shared-secret-source", "expected_finding": true, "explanation": "A timing-resistant comparison still permits access using a credential obtainable from the source. The value shown is a fictional placeholder.", "fix_explanation": "Provision a separate random inbound credential for each deployment and reject requests if the expected token is unavailable.", "framework": null, "hard_negative": false, "id": "psp-f28d3bb328e4", "label": "insecure", "language": "python", "leakage_group_id": "credential-provisioning", "pair_id": "inbound-hook-shared-secret-source", "pattern": "inbound-hook-shared-secret-source", "provenance": {"authoring": "ai_assisted", "collection": "preserved_baseline", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "The fake fixture exercises normal authentication and observes configuration dependence in memory.", "sample_id": "psp-f28d3bb328e4", "sanitization": "Timing-resistant comparison does not protect a hardcoded expected secret.", "scenario_family_id": "credential-provisioning", "secure_fix": "Provision a separate random inbound credential for each deployment and reject requests if the expected token is unavailable.", "sink_location": {"end_line": 5, "path": "snippet.py", "start_line": 5}, "source_location": {"end_line": 4, "path": "snippet.py", "start_line": 4}, "source_type": "synthetic", "split": "train", "taint_path": null, "verification_method": "local_fixture_behavior", "verification_status": "behavior_verified", "vulnerability_type": "hardcoded_credentials", "vulnerable_lines": [{"end_line": 4, "path": "snippet.py", "start_line": 4}]} | |
| {"code": "def read_invoice(connection, principal, invoice_number):\n return connection.execute(\n \"SELECT invoice_number, status FROM invoices WHERE account_id = ? AND invoice_number = ?\",\n (principal.account_id, invoice_number),\n ).fetchone()\n", "code_files": [{"code": "def read_invoice(connection, principal, invoice_number):\n return connection.execute(\n \"SELECT invoice_number, status FROM invoices WHERE account_id = ? AND invoice_number = ?\",\n (principal.account_id, invoice_number),\n ).fetchone()\n", "path": "subject.py"}], "cwe_id": "CWE-862", "difficulty": "advanced", "evidence_reference": "data/research/evidence.json::cases/account-scoped-invoice-query", "expected_finding": false, "explanation": "The chosen invoice number is checked against the principal's account inside the query, so no standalone authorization branch is required.", "fix_explanation": "Bind the authenticated principal's server-side account scope in the database predicate.", "framework": null, "hard_negative": true, "id": "psp-fec537bf528f", "label": "secure", "language": "python", "leakage_group_id": "resource-authorization", "pair_id": null, "pattern": "account-scoped-invoice-query", "provenance": {"authoring": "ai_assisted", "collection": "hard_negative", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "A real in-memory SQLite query verifies own-account lookup and no row outside that account under the server-side principal assumption.", "sample_id": "psp-fec537bf528f", "sanitization": "Bind the authenticated principal's server-side account scope in the database predicate.", "scenario_family_id": "resource-authorization", "secure_fix": "Bind the authenticated principal's server-side account scope in the database predicate.", "sink_location": {"end_line": 2, "path": "subject.py", "start_line": 2}, "source_location": {"end_line": 1, "path": "subject.py", "start_line": 1}, "source_type": "synthetic", "split": "train", "taint_path": null, "verification_method": "in_memory_sqlite", "verification_status": "behavior_verified", "vulnerability_type": "missing_authorization", "vulnerable_lines": []} | |