File size: 24,254 Bytes
1340dfb | 1 2 3 4 5 6 7 8 9 10 11 12 | {"code": "def log_moderation_note(logger, note):\n logger.info(\"Moderation note: %s\", note)\n", "code_files": [{"code": "def log_moderation_note(logger, note):\n logger.info(\"Moderation note: %s\", note)\n", "path": "snippet.py"}], "cwe_id": "CWE-117", "difficulty": "introductory", "evidence_reference": "data/research/evidence.json::cases/moderation-note-log-framing", "expected_finding": true, "explanation": "In a line-oriented text log, parameterized logging still renders embedded newlines from the user note as line breaks.", "fix_explanation": "Use a structured serializer that escapes control characters and preserve the resulting one-record-per-line framing in the log sink.", "framework": null, "hard_negative": false, "id": "psp-0ac5df35bdec", "label": "insecure", "language": "python", "leakage_group_id": "line-log-framing", "pair_id": "moderation-note-log-framing", "pattern": "moderation-note-log-framing", "provenance": {"authoring": "ai_assisted", "collection": "preserved_baseline", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "The finding depends on a line-oriented log. The fixture exercises a normal multiline note.", "sample_id": "psp-0ac5df35bdec", "sanitization": null, "scenario_family_id": "line-log-framing", "secure_fix": "Use a structured serializer that escapes control characters and preserve the resulting one-record-per-line framing in the log sink.", "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": "test", "taint_path": ["multiline moderation note", "rendered log message", "line-oriented logger"], "verification_method": "local_fixture_behavior", "verification_status": "behavior_verified", "vulnerability_type": "log_output_neutralization", "vulnerable_lines": [{"end_line": 2, "path": "snippet.py", "start_line": 2}]}
{"code": "import json\n\ndef log_moderation_note(logger, note):\n record = {\"event\": \"moderation_note\", \"note\": note}\n logger.info(\"%s\", json.dumps(record, ensure_ascii=True))\n", "code_files": [{"code": "import json\n\ndef log_moderation_note(logger, note):\n record = {\"event\": \"moderation_note\", \"note\": note}\n logger.info(\"%s\", json.dumps(record, ensure_ascii=True))\n", "path": "snippet.py"}], "cwe_id": "CWE-117", "difficulty": "introductory", "evidence_reference": "data/research/evidence.json::cases/moderation-note-log-framing", "expected_finding": false, "explanation": "The JSON serializer escapes line breaks and control characters from the note, keeping the payload on one physical line with a message-only formatter.", "fix_explanation": "Use a structured serializer that escapes control characters and preserve the resulting one-record-per-line framing in the log sink.", "framework": null, "hard_negative": false, "id": "psp-268a2b1a5877", "label": "secure", "language": "python", "leakage_group_id": "line-log-framing", "pair_id": "moderation-note-log-framing", "pattern": "moderation-note-log-framing", "provenance": {"authoring": "ai_assisted", "collection": "preserved_baseline", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "The finding depends on a line-oriented log. The fixture exercises a normal multiline note.", "sample_id": "psp-268a2b1a5877", "sanitization": "Serialize the message payload as a single JSON record.", "scenario_family_id": "line-log-framing", "secure_fix": "Use a structured serializer that escapes control characters and preserve the resulting one-record-per-line framing in the log sink.", "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": "test", "taint_path": ["multiline note", "JSON string escaping", "single physical log line"], "verification_method": "local_fixture_behavior", "verification_status": "behavior_verified", "vulnerability_type": "log_output_neutralization", "vulnerable_lines": []}
{"code": "def attach_handoff_cookie(response, handoff_token):\n response.set_cookie(\n \"account_handoff\", handoff_token, max_age=60, path=\"/handoff/\",\n secure=True, httponly=True, samesite=\"Lax\",\n )\n return response\n", "code_files": [{"code": "def attach_handoff_cookie(response, handoff_token):\n response.set_cookie(\n \"account_handoff\", handoff_token, max_age=60, path=\"/handoff/\",\n secure=True, httponly=True, samesite=\"Lax\",\n )\n return response\n", "path": "snippet.py"}], "cwe_id": "CWE-614", "difficulty": "intermediate", "evidence_reference": "data/research/evidence.json::cases/handoff-cookie-transport-policy", "expected_finding": false, "explanation": "The account handoff credential always gets Secure under the public HTTPS policy, independently of the transport on the proxy-to-application hop.", "fix_explanation": "Set Secure for the sensitive browser-facing cookie in the HTTPS-only deployment, independently of how the internal hop is configured.", "framework": "django", "hard_negative": false, "id": "psp-2baf18b59c8b", "label": "secure", "language": "python", "leakage_group_id": "https-cookie-policy", "pair_id": "handoff-cookie-transport-policy", "pattern": "handoff-cookie-transport-policy", "provenance": {"authoring": "ai_assisted", "collection": "preserved_baseline", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "The fixture observes Django-compatible response arguments. It does not test Django middleware or an actual proxy.", "sample_id": "psp-2baf18b59c8b", "sanitization": "Set Secure from the public HTTPS policy, independent of proxy-to-app transport.", "scenario_family_id": "https-cookie-policy", "secure_fix": "Set Secure for the sensitive browser-facing cookie in the HTTPS-only deployment, independently of how the internal hop is configured.", "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": "test", "taint_path": null, "verification_method": "mock_cookie_response", "verification_status": "behavior_verified", "vulnerability_type": "missing_secure_cookie_attribute", "vulnerable_lines": []}
{"code": "def attach_handoff_cookie(response, handoff_token, backend_uses_tls):\n response.set_cookie(\n \"account_handoff\", handoff_token, max_age=60, path=\"/handoff/\",\n secure=backend_uses_tls, httponly=True, samesite=\"Lax\",\n )\n return response\n", "code_files": [{"code": "def attach_handoff_cookie(response, handoff_token, backend_uses_tls):\n response.set_cookie(\n \"account_handoff\", handoff_token, max_age=60, path=\"/handoff/\",\n secure=backend_uses_tls, httponly=True, samesite=\"Lax\",\n )\n return response\n", "path": "snippet.py"}], "cwe_id": "CWE-614", "difficulty": "intermediate", "evidence_reference": "data/research/evidence.json::cases/handoff-cookie-transport-policy", "expected_finding": true, "explanation": "In a Django app behind a TLS-terminating proxy, the internal HTTP hop makes backend_uses_tls false. The browser-facing cookie then omits Secure and may be sent on a matching HTTP request if the browser permits one.", "fix_explanation": "Set Secure for the sensitive browser-facing cookie in the HTTPS-only deployment, independently of how the internal hop is configured.", "framework": "django", "hard_negative": false, "id": "psp-32928d79534c", "label": "insecure", "language": "python", "leakage_group_id": "https-cookie-policy", "pair_id": "handoff-cookie-transport-policy", "pattern": "handoff-cookie-transport-policy", "provenance": {"authoring": "ai_assisted", "collection": "preserved_baseline", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "The fixture observes Django-compatible response arguments. It does not test Django middleware or an actual proxy.", "sample_id": "psp-32928d79534c", "sanitization": null, "scenario_family_id": "https-cookie-policy", "secure_fix": "Set Secure for the sensitive browser-facing cookie in the HTTPS-only deployment, independently of how the internal hop is configured.", "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": "test", "taint_path": null, "verification_method": "mock_cookie_response", "verification_status": "behavior_verified", "vulnerability_type": "missing_secure_cookie_attribute", "vulnerable_lines": [{"end_line": 2, "path": "snippet.py", "start_line": 2}]}
{"code": "from dataclasses import dataclass\n\n\n@dataclass(frozen=True)\nclass BrowserCookiePolicy:\n secure: bool\n\n def __post_init__(self):\n if self.secure is not True:\n raise ValueError(\"Browser credential requires HTTPS\")\n\n def attach(self, response, session_id):\n response.set_cookie(\"account_sid\", session_id, secure=self.secure, httponly=True)\n", "code_files": [{"code": "from dataclasses import dataclass\n\n\n@dataclass(frozen=True)\nclass BrowserCookiePolicy:\n secure: bool\n\n def __post_init__(self):\n if self.secure is not True:\n raise ValueError(\"Browser credential requires HTTPS\")\n\n def attach(self, response, session_id):\n response.set_cookie(\"account_sid\", session_id, secure=self.secure, httponly=True)\n", "path": "subject.py"}], "cwe_id": "CWE-614", "difficulty": "advanced", "evidence_reference": "data/research/evidence.json::cases/secure-browser-policy-cookie", "expected_finding": false, "explanation": "The cookie call receives a variable flag whose policy object requires True at construction and is not mutated by untrusted code.", "fix_explanation": "Validate the secure flag at construction and store it in a frozen policy.", "framework": "django-compatible", "hard_negative": true, "id": "psp-434ba5e39499", "label": "secure", "language": "python", "leakage_group_id": "https-cookie-policy", "pair_id": null, "pattern": "secure-browser-policy-cookie", "provenance": {"authoring": "ai_assisted", "collection": "hard_negative", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "The variable-looking Secure argument is invariant over supported application use.", "sample_id": "psp-434ba5e39499", "sanitization": "Validate the secure flag at construction and store it in a frozen policy.", "scenario_family_id": "https-cookie-policy", "secure_fix": "Validate the secure flag at construction and store it in a frozen policy.", "sink_location": {"end_line": 13, "path": "subject.py", "start_line": 13}, "source_location": {"end_line": 6, "path": "subject.py", "start_line": 6}, "source_type": "synthetic", "split": "test", "taint_path": null, "verification_method": "mock_cookie_response", "verification_status": "behavior_verified", "vulnerability_type": "missing_secure_cookie_attribute", "vulnerable_lines": []}
{"code": "from http.cookies import SimpleCookie\n\ndef dashboard_cookie(session_id):\n cookie = SimpleCookie()\n cookie[\"dashboard_sid\"] = session_id\n cookie[\"dashboard_sid\"][\"path\"] = \"/\"\n cookie[\"dashboard_sid\"][\"httponly\"] = True\n cookie[\"dashboard_sid\"][\"samesite\"] = \"Lax\"\n cookie[\"dashboard_sid\"][\"secure\"] = True\n return cookie[\"dashboard_sid\"].OutputString()\n", "code_files": [{"code": "from http.cookies import SimpleCookie\n\ndef dashboard_cookie(session_id):\n cookie = SimpleCookie()\n cookie[\"dashboard_sid\"] = session_id\n cookie[\"dashboard_sid\"][\"path\"] = \"/\"\n cookie[\"dashboard_sid\"][\"httponly\"] = True\n cookie[\"dashboard_sid\"][\"samesite\"] = \"Lax\"\n cookie[\"dashboard_sid\"][\"secure\"] = True\n return cookie[\"dashboard_sid\"].OutputString()\n", "path": "snippet.py"}], "cwe_id": "CWE-614", "difficulty": "introductory", "evidence_reference": "data/research/evidence.json::cases/dashboard-session-cookie-transport", "expected_finding": false, "explanation": "The Set-Cookie value emitted by the HTTPS application includes Secure, which tells the browser to restrict transmission to secure channels.", "fix_explanation": "Set the Secure attribute on the session cookie when serving the dashboard over HTTPS.", "framework": null, "hard_negative": false, "id": "psp-4d12701661fa", "label": "secure", "language": "python", "leakage_group_id": "https-cookie-policy", "pair_id": "dashboard-session-cookie-transport", "pattern": "dashboard-session-cookie-transport", "provenance": {"authoring": "ai_assisted", "collection": "preserved_baseline", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "The test parses the actual serialized header; transport and browser behavior are out of scope.", "sample_id": "psp-4d12701661fa", "sanitization": "Set the Secure cookie attribute.", "scenario_family_id": "https-cookie-policy", "secure_fix": "Set the Secure attribute on the session cookie when serving the dashboard over HTTPS.", "sink_location": {"end_line": 10, "path": "snippet.py", "start_line": 10}, "source_location": {"end_line": 3, "path": "snippet.py", "start_line": 3}, "source_type": "synthetic", "split": "test", "taint_path": null, "verification_method": "local_fixture_behavior", "verification_status": "behavior_verified", "vulnerability_type": "missing_secure_cookie_attribute", "vulnerable_lines": []}
{"code": "import subprocess\n\n\ndef emit_worker_version(tool):\n command = {\n \"compiler\": (\"/usr/bin/cc\", \"--version\"),\n \"archiver\": (\"/usr/bin/tar\", \"--version\"),\n }[tool]\n return subprocess.run(command, check=True, capture_output=True, text=True, timeout=3)\n", "code_files": [{"code": "import subprocess\n\n\ndef emit_worker_version(tool):\n command = {\n \"compiler\": (\"/usr/bin/cc\", \"--version\"),\n \"archiver\": (\"/usr/bin/tar\", \"--version\"),\n }[tool]\n return subprocess.run(command, check=True, capture_output=True, text=True, timeout=3)\n", "path": "subject.py"}], "cwe_id": "CWE-78", "difficulty": "intermediate", "evidence_reference": "data/research/evidence.json::cases/worker-tool-registry", "expected_finding": false, "explanation": "The request chooses a registry entry for a fixed version command. The selected binary locations are deployment-controlled.", "fix_explanation": "Resolve a public label to a fixed argument tuple and launch without a shell.", "framework": null, "hard_negative": true, "id": "psp-a59d1748d047", "label": "secure", "language": "python", "leakage_group_id": "os-process-arguments", "pair_id": null, "pattern": "worker-tool-registry", "provenance": {"authoring": "ai_assisted", "collection": "hard_negative", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "Uses a mocked process interface. Neither executable is started.", "sample_id": "psp-a59d1748d047", "sanitization": "Resolve a public label to a fixed argument tuple and launch without a shell.", "scenario_family_id": "os-process-arguments", "secure_fix": "Resolve a public label to a fixed argument tuple and launch without a shell.", "sink_location": {"end_line": 9, "path": "subject.py", "start_line": 9}, "source_location": {"end_line": 4, "path": "subject.py", "start_line": 4}, "source_type": "synthetic", "split": "test", "taint_path": null, "verification_method": "mock_process_argument_contract", "verification_status": "behavior_verified", "vulnerability_type": "command_injection", "vulnerable_lines": []}
{"code": "from http.cookies import SimpleCookie\n\ndef dashboard_cookie(session_id):\n cookie = SimpleCookie()\n cookie[\"dashboard_sid\"] = session_id\n cookie[\"dashboard_sid\"][\"path\"] = \"/\"\n cookie[\"dashboard_sid\"][\"httponly\"] = True\n cookie[\"dashboard_sid\"][\"samesite\"] = \"Lax\"\n return cookie[\"dashboard_sid\"].OutputString()\n", "code_files": [{"code": "from http.cookies import SimpleCookie\n\ndef dashboard_cookie(session_id):\n cookie = SimpleCookie()\n cookie[\"dashboard_sid\"] = session_id\n cookie[\"dashboard_sid\"][\"path\"] = \"/\"\n cookie[\"dashboard_sid\"][\"httponly\"] = True\n cookie[\"dashboard_sid\"][\"samesite\"] = \"Lax\"\n return cookie[\"dashboard_sid\"].OutputString()\n", "path": "snippet.py"}], "cwe_id": "CWE-614", "difficulty": "introductory", "evidence_reference": "data/research/evidence.json::cases/dashboard-session-cookie-transport", "expected_finding": true, "explanation": "The returned Set-Cookie value has HttpOnly and SameSite but lacks Secure. A matching HTTP request can expose the session credential.", "fix_explanation": "Set the Secure attribute on the session cookie when serving the dashboard over HTTPS.", "framework": null, "hard_negative": false, "id": "psp-abb10311fdd7", "label": "insecure", "language": "python", "leakage_group_id": "https-cookie-policy", "pair_id": "dashboard-session-cookie-transport", "pattern": "dashboard-session-cookie-transport", "provenance": {"authoring": "ai_assisted", "collection": "preserved_baseline", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "The test parses the actual serialized header; transport and browser behavior are out of scope.", "sample_id": "psp-abb10311fdd7", "sanitization": null, "scenario_family_id": "https-cookie-policy", "secure_fix": "Set the Secure attribute on the session cookie when serving the dashboard over HTTPS.", "sink_location": {"end_line": 9, "path": "snippet.py", "start_line": 9}, "source_location": {"end_line": 3, "path": "snippet.py", "start_line": 3}, "source_type": "synthetic", "split": "test", "taint_path": null, "verification_method": "local_fixture_behavior", "verification_status": "behavior_verified", "vulnerability_type": "missing_secure_cookie_attribute", "vulnerable_lines": [{"end_line": 9, "path": "snippet.py", "start_line": 9}]}
{"code": "def log_sync_result(logger, peer_status):\n messages = {\"retry\": \"retry requested\", \"error\": \"peer reported an error\"}\n message = messages.get(peer_status, \"unknown status\")\n logger.warning(\"Sync result: %s\", message)\n", "code_files": [{"code": "def log_sync_result(logger, peer_status):\n messages = {\"retry\": \"retry requested\", \"error\": \"peer reported an error\"}\n message = messages.get(peer_status, \"unknown status\")\n logger.warning(\"Sync result: %s\", message)\n", "path": "snippet.py"}], "cwe_id": "CWE-117", "difficulty": "introductory", "evidence_reference": "data/research/evidence.json::cases/sync-result-log-event-catalog", "expected_finding": false, "explanation": "A peer can select among predefined messages or the fixed fallback. The peer's raw string is absent from the log.", "fix_explanation": "Translate peer statuses through a closed catalog of log messages and use a constant fallback.", "framework": null, "hard_negative": false, "id": "psp-bb30712a268d", "label": "secure", "language": "python", "leakage_group_id": "line-log-framing", "pair_id": "sync-result-log-event-catalog", "pattern": "sync-result-log-event-catalog", "provenance": {"authoring": "ai_assisted", "collection": "preserved_baseline", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "The peer status domain is deliberately small. The test confirms both a known status and unexpected multiline input.", "sample_id": "psp-bb30712a268d", "sanitization": "Select a trusted message or a constant fallback.", "scenario_family_id": "line-log-framing", "secure_fix": "Translate peer statuses through a closed catalog of log messages and use a constant fallback.", "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": "test", "taint_path": null, "verification_method": "local_fixture_behavior", "verification_status": "behavior_verified", "vulnerability_type": "log_output_neutralization", "vulnerable_lines": []}
{"code": "def log_sync_result(logger, peer_status):\n logger.warning(\"Sync result: %s\", peer_status)\n", "code_files": [{"code": "def log_sync_result(logger, peer_status):\n logger.warning(\"Sync result: %s\", peer_status)\n", "path": "snippet.py"}], "cwe_id": "CWE-117", "difficulty": "introductory", "evidence_reference": "data/research/evidence.json::cases/sync-result-log-event-catalog", "expected_finding": true, "explanation": "A status string from a remote peer reaches a line-oriented log. Embedded control characters can alter the apparent log records.", "fix_explanation": "Translate peer statuses through a closed catalog of log messages and use a constant fallback.", "framework": null, "hard_negative": false, "id": "psp-c386cd238de6", "label": "insecure", "language": "python", "leakage_group_id": "line-log-framing", "pair_id": "sync-result-log-event-catalog", "pattern": "sync-result-log-event-catalog", "provenance": {"authoring": "ai_assisted", "collection": "preserved_baseline", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "The peer status domain is deliberately small. The test confirms both a known status and unexpected multiline input.", "sample_id": "psp-c386cd238de6", "sanitization": null, "scenario_family_id": "line-log-framing", "secure_fix": "Translate peer statuses through a closed catalog of log messages and use a constant fallback.", "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": "test", "taint_path": ["peer status", "message formatting", "line-oriented logger"], "verification_method": "local_fixture_behavior", "verification_status": "behavior_verified", "vulnerability_type": "log_output_neutralization", "vulnerable_lines": [{"end_line": 2, "path": "snippet.py", "start_line": 2}]}
{"code": "import subprocess\n\n\ndef service_shell_status():\n return subprocess.run(\n \"printf '%s\\\\n' ready\", shell=True, check=True, capture_output=True, text=True,\n executable=\"/bin/sh\", cwd=\"/\", env={\"PATH\": \"/usr/bin:/bin\"}, timeout=2,\n ).stdout.strip()\n", "code_files": [{"code": "import subprocess\n\n\ndef service_shell_status():\n return subprocess.run(\n \"printf '%s\\\\n' ready\", shell=True, check=True, capture_output=True, text=True,\n executable=\"/bin/sh\", cwd=\"/\", env={\"PATH\": \"/usr/bin:/bin\"}, timeout=2,\n ).stdout.strip()\n", "path": "subject.py"}], "cwe_id": "CWE-78", "difficulty": "intermediate", "evidence_reference": "data/research/evidence.json::cases/internal-shell-status", "expected_finding": false, "explanation": "Shell use is visible but the executed expression and environment contain no user input. Assumes an administrator-controlled POSIX installation.", "fix_explanation": "Use a constant command, fixed shell path and working directory, and explicit environment.", "framework": null, "hard_negative": true, "id": "psp-e9a92f174f5b", "label": "secure", "language": "python", "leakage_group_id": "os-process-arguments", "pair_id": null, "pattern": "internal-shell-status", "provenance": {"authoring": "ai_assisted", "collection": "hard_negative", "independent_human_review": false, "origin": "original_synthetic"}, "review_note": "Deliberate shell keyword false-positive case. A process spy checks the constant call; no shell is launched.", "sample_id": "psp-e9a92f174f5b", "sanitization": "Use a constant command, fixed shell path and working directory, and explicit environment.", "scenario_family_id": "os-process-arguments", "secure_fix": "Use a constant command, fixed shell path and working directory, and explicit environment.", "sink_location": {"end_line": 5, "path": "subject.py", "start_line": 5}, "source_location": null, "source_type": "synthetic", "split": "test", "taint_path": null, "verification_method": "mock_process_argument_contract", "verification_status": "behavior_verified", "vulnerability_type": "command_injection", "vulnerable_lines": []}
|