File size: 78,584 Bytes
2ef05ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
{"id": "SCP-000389", "language": "Kotlin", "framework": "Android", "title": "Hardcoded API key in BuildConfig", "description": "An Android app embeds a key in BuildConfig.", "owasp": "A02:2021 - Cryptographic Failures", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-798", "mitre_attack": "T1552.001 - Unsecured Credentials: Credentials In Files", "severity": "High", "difficulty": "Beginner", "vulnerable_code": "val key = BuildConfig.API_KEY  // Vulnerable: extracted from APK\\", "secure_code": "val key = getString(R.string.api_key)  // still in APK; use backend proxy / NDK  // Better: fetch at runtime\\", "patch": "--- a/Api.kt\\n+++ b/Api.kt\\n@@ -1,2 +1,3 @@\\n-val key = BuildConfig.API_KEY\\n+// Fetch from backend at runtime or use NDK obfuscation\\n+val key = fetchKeyFromBackend()\\", "root_cause": "Secret in APK.", "attack": "Reverse APK for key.", "impact": "Key compromise.", "fix": "Proxy via backend.", "guideline": "Don't embed secrets in APK.", "tags": ["secrets", "kotlin", "android", "config"], "metadata": {"domain": "Mobile", "input_source": "source_code", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000304", "language": "Scala", "framework": "Play", "title": "Weak password hashing (MD5)", "description": "A Play auth stores MD5 password hashes.", "owasp": "A02:2021 - Cryptographic Failures", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-916", "mitre_attack": "T1600 - Weaken Encryption", "severity": "High", "difficulty": "Beginner", "vulnerable_code": "def hashPw(pw: String) = MessageDigest.getInstance(\"MD5\").digest(pw.getBytes)  // Vulnerable", "secure_code": "import java.security.SecureRandom\nimport org.mindrot.jbcrypt.BCrypt\ndef hashPw(pw: String) = BCrypt.hashpw(pw, BCrypt.gensalt(12))  // Secure", "patch": "--- a/Auth.scala\n+++ b/Auth.scala\n@@ -1,2 +1,3 @@\n-def hashPw(pw: String) = MessageDigest.getInstance(\"MD5\").digest(pw.getBytes)\n+import org.mindrot.jbcrypt.BCrypt\n+def hashPw(pw: String) = BCrypt.hashpw(pw, BCrypt.gensalt(12))", "root_cause": "MD5 unsalted/fast.", "attack": "Crack passwords.", "impact": "Credential compromise.", "fix": "Use bcrypt/argon2.", "guideline": "Slow salted KDFs.", "tags": ["crypto", "scala", "play", "passwords"], "metadata": {"domain": "Authentication systems", "input_source": "request_body", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000311", "language": "Go", "framework": "Gin", "title": "XSS via template unescaped", "description": "A Gin template renders user input with template.HTML.", "owasp": "A03:2021 - Injection", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-79", "mitre_attack": "T1059.007 - Command and Scripting Interpreter: JavaScript", "severity": "Medium", "difficulty": "Beginner", "vulnerable_code": "c.HTML(200, \"post.tmpl\", gin.H{\"comment\": template.HTML(comment)})  // Vulnerable: unescaped", "secure_code": "c.HTML(200, \"post.tmpl\", gin.H{\"comment\": comment})  // Secure: auto-escaped", "patch": "--- a/post.go\n+++ b/post.go\n@@ -1,2 +1,2 @@\n-c.HTML(200, \"post.tmpl\", gin.H{\"comment\": template.HTML(comment)})\n+c.HTML(200, \"post.tmpl\", gin.H{\"comment\": comment})", "root_cause": "template.HTML disables escaping.", "attack": "comment=<script>steal()</script> runs.", "impact": "XSS.", "fix": "Use default escaping.", "guideline": "Avoid template.HTML on user input.", "tags": ["xss", "go", "gin", "template"], "metadata": {"domain": "E-commerce", "input_source": "db", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:L/A:N"}
{"id": "SCP-000212", "language": "Python", "framework": "FastAPI", "title": "YAML full load of untrusted config", "description": "A FastAPI service parses uploaded YAML with yaml.load (full), enabling RCE.", "owasp": "A08:2021 - Software and Data Integrity Failures", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-502", "mitre_attack": "T1190 - Exploit Public-Facing Application", "severity": "Critical", "difficulty": "Intermediate", "vulnerable_code": "import yaml\ndef parse(body: bytes):\n    return yaml.load(body)  # Vulnerable: arbitrary object construction", "secure_code": "import yaml\ndef parse(body: bytes):\n    return yaml.safe_load(body)  # Secure: no arbitrary objects", "patch": "--- a/parse.py\n+++ b/parse.py\n@@ -1,3 +1,3 @@\n-    return yaml.load(body)\n+    return yaml.safe_load(body)", "root_cause": "yaml.load allows arbitrary Python object construction.", "attack": "Upload YAML with !!python/object/apply to run code.", "impact": "Remote code execution.", "fix": "Use yaml.safe_load.", "guideline": "Use safe_load for untrusted YAML.", "tags": ["deserialization", "fastapi", "python", "rce"], "metadata": {"domain": "Microservices", "input_source": "request_body", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000211", "language": "Python", "framework": "Flask", "title": "Unsafe pickle load of user upload", "description": "A Flask endpoint unpickles a client-supplied blob, enabling RCE.", "owasp": "A08:2021 - Software and Data Integrity Failures", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-502", "mitre_attack": "T1190 - Exploit Public-Facing Application", "severity": "Critical", "difficulty": "Intermediate", "vulnerable_code": "@app.route(\"/load\", methods=[\"POST\"])\ndef load():\n    data = request.files[\"f\"].read()\n    obj = pickle.loads(data)  # Vulnerable: RCE\n    return jsonify(obj)", "secure_code": "@app.route(\"/load\", methods=[\"POST\"])\ndef load():\n    data = request.files[\"f\"].read()\n    obj = json.loads(data)  # Secure: no code execution\n    return jsonify(obj)", "patch": "--- a/app.py\n+++ b/app.py\n@@ -1,4 +1,4 @@\n-    obj = pickle.loads(data)  # Vulnerable: RCE\n+    obj = json.loads(data)  # Secure: no code execution", "root_cause": "pickle.loads executes arbitrary code during deserialization.", "attack": "Attacker uploads a pickle that runs os.system('...').", "impact": "Remote code execution.", "fix": "Use JSON or signed, schema-validated formats.", "guideline": "Never unpickle untrusted data.", "tags": ["deserialization", "flask", "python", "rce"], "metadata": {"domain": "E-commerce", "input_source": "form_field", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000328", "language": "C#", "framework": "ASP.NET Core", "title": "Path traversal in file result", "description": "A controller returns a file from a user path.", "owasp": "A01:2021 - Broken Access Control", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-22", "mitre_attack": "T1190 - Exploit Public-Facing Application", "severity": "High", "difficulty": "Intermediate", "vulnerable_code": "return PhysicalFile(\"/data/\" + name, \"application/octet-stream\");  // Vulnerable: traversal\\", "secure_code": "var safe = Path.GetFullPath(Path.Combine(\"/data\", name));\\nif (!safe.StartsWith(\"/data\")) return Forbid();  // Secure\\nreturn PhysicalFile(safe, \"application/octet-stream\");\\", "patch": "--- a/FilesController.cs\\n+++ b/FilesController.cs\\n@@ -1,3 +1,5 @@\\n-return PhysicalFile(\"/data/\" + name, \"application/octet-stream\");\\n+var safe = Path.GetFullPath(Path.Combine(\"/data\", name));\\n+if (!safe.StartsWith(\"/data\")) return Forbid();\\n+return PhysicalFile(safe, \"application/octet-stream\");\\", "root_cause": "Unsanitized filename.", "attack": "name=../../etc/passwd reads file.", "impact": "File disclosure.", "fix": "Confine to base dir.", "guideline": "Confine file paths.", "tags": ["path-traversal", "csharp", "aspnet", "file-read"], "metadata": {"domain": "Backend", "input_source": "query_param", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000329", "language": "C#", "framework": "ASP.NET Core", "title": "Missing authorization on admin endpoint", "description": "An admin endpoint lacks [Authorize(Roles=...)]", "owasp": "A01:2021 - Broken Access Control", "owasp_api": "API1:2023 - Broken Object Level Authorization", "owasp_llm": "", "cwe": "CWE-862", "mitre_attack": "T1190 - Exploit Public-Facing Application", "severity": "Critical", "difficulty": "Intermediate", "vulnerable_code": "[HttpDelete(\"admin/user/{id}\")]\\npublic IActionResult Delete(int id) { repo.Remove(id); return Ok(); }  // Vulnerable: no role\\", "secure_code": "[Authorize(Roles = \"Admin\")]  // Secure\\n[HttpDelete(\"admin/user/{id}\")]\\npublic IActionResult Delete(int id) { repo.Remove(id); return Ok(); }\\", "patch": "--- a/AdminController.cs\\n+++ b/AdminController.cs\\n@@ -1,4 +1,5 @@\\n+[Authorize(Roles = \"Admin\")]\\n [HttpDelete(\"admin/user/{id}\")]\\n public IActionResult Delete(int id) { repo.Remove(id); return Ok(); }\\", "root_cause": "No role check.", "attack": "Any user deletes accounts.", "impact": "Privilege escalation.", "fix": "Add [Authorize(Roles)].", "guideline": "Enforce role checks.", "tags": ["authorization", "csharp", "aspnet", "broken-access-control"], "metadata": {"domain": "Authentication systems", "input_source": "path_param", "auth_required": true}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000171", "language": "JavaScript", "framework": "GraphQL", "title": "GraphQL field-level authorization missing", "description": "A GraphQL type exposes a salary field to any authenticated user.", "owasp": "A01:2021 - Broken Access Control", "owasp_api": "API1:2023 - Broken Object Level Authorization", "owasp_llm": "", "cwe": "CWE-862", "mitre_attack": "T1190 - Exploit Public-Facing Application", "severity": "High", "difficulty": "Intermediate", "vulnerable_code": "const typeDefs = `\n  type Employee { id: ID! name: String! salary: Float! }  // Vulnerable: salary public\n`;", "secure_code": "const resolvers = {\n  Employee: {\n    salary: (e, _, ctx) => ctx.user.isManager ? e.salary : null  // Secure\n  }\n};", "patch": "--- a/graphql/schema.js\n+++ b/graphql/schema.js\n@@ -1,4 +1,6 @@\n-  type Employee { id: ID! name: String! salary: Float! }\n+  type Employee { id: ID! name: String! salary: Float! }\n+const resolvers = { Employee: { salary: (e,_,ctx) => ctx.user.isManager ? e.salary : null } };", "root_cause": "Sensitive field resolvable by any user.", "attack": "Any employee queries their own salary of others.", "impact": "Sensitive data disclosure.", "fix": "Field-level authorization in resolvers.", "guideline": "Authorize sensitive GraphQL fields.", "tags": ["graphql", "authorization", "javascript", "access-control"], "metadata": {"domain": "E-commerce", "input_source": "args", "auth_required": true}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000216", "language": "Python", "framework": "Flask", "title": "Reflected XSS via flash message", "description": "A Flask route renders a flash message containing user input without escaping.", "owasp": "A03:2021 - Injection", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-79", "mitre_attack": "T1059.007 - Command and Scripting Interpreter: JavaScript", "severity": "Medium", "difficulty": "Beginner", "vulnerable_code": "flash(\"Hello \" + request.args.get(\"name\"))  # Vulnerable: reflected\nreturn render_template(\"hi.html\")", "secure_code": "name = escape(request.args.get(\"name\", \"\"))  # Secure: escape\nflash(\"Hello \" + name)\nreturn render_template(\"hi.html\")", "patch": "--- a/views.py\n+++ b/views.py\n@@ -1,4 +1,5 @@\n-flash(\"Hello \" + request.args.get(\"name\"))\n+name = escape(request.args.get(\"name\", \"\"))\n+flash(\"Hello \" + name)\n return render_template(\"hi.html\")", "root_cause": "User input echoed into flash without escaping.", "attack": "name=<script>steal()</script> executes.", "impact": "XSS.", "fix": "Escape on output; rely on autoescaping.", "guideline": "Escape user input in messages.", "tags": ["xss", "flask", "python", "injection"], "metadata": {"domain": "E-commerce", "input_source": "query_param", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:L/A:N"}
{"id": "SCP-000265", "language": "C", "framework": "POSIX", "title": "Hardcoded credentials in binary", "description": "A C client embeds a password string in source.", "owasp": "A02:2021 - Cryptographic Failures", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-798", "mitre_attack": "T1552.001 - Unsecured Credentials: Credentials In Files", "severity": "High", "difficulty": "Beginner", "vulnerable_code": "const char *PW = \"admin123\";  // Vulnerable: hardcoded", "secure_code": "char *get_pw() { return getenv(\"APP_PW\"); }  // Secure: from env", "patch": "--- a/client.c\n+++ b/client.c\n@@ -1,2 +1,2 @@\n-const char *PW = \"admin123\";\n+char *get_pw() { return getenv(\"APP_PW\"); }", "root_cause": "Credential in binary.", "attack": "Extract string from binary.", "impact": "Credential leak.", "fix": "Load from env/secret.", "guideline": "Externalize credentials.", "tags": ["secrets", "c", "config"], "metadata": {"domain": "IoT", "input_source": "source_code", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000418", "language": "YAML", "framework": "Kubernetes", "title": "Secret in plaintext ConfigMap/Env", "description": "A manifest stores a secret as a plaintext env var.", "owasp": "A02:2021 - Cryptographic Failures", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-798", "mitre_attack": "T1552.001 - Unsecured Credentials: Credentials In Files", "severity": "High", "difficulty": "Beginner", "vulnerable_code": "env:\\n- name: DB_PASSWORD\\n  value: \"P@ssw0rd!\"  # Vulnerable: plaintext secret\\", "secure_code": "env:\\n- name: DB_PASSWORD\\n  valueFrom:\\n    secretKeyRef:\\n      name: db-secret\\n      key: password  # Secure: from Secret\\", "patch": "--- a/deploy.yaml\\n+++ b/deploy.yaml\\n@@ -1,4 +1,6 @@\\n-env:\\n-- name: DB_PASSWORD\\n  value: \"P@ssw0rd!\"\\n+env:\\n+- name: DB_PASSWORD\\n+  valueFrom:\\n+    secretKeyRef:\\n+      name: db-secret\\n+      key: password\\", "root_cause": "Secret in manifest.", "attack": "Read manifest for creds.", "impact": "Credential leak.", "fix": "Use Secret/secretKeyRef.", "guideline": "Externalize secrets.", "tags": ["secrets", "yaml", "kubernetes", "config"], "metadata": {"domain": "Kubernetes", "input_source": "manifest", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000358", "language": "PHP", "framework": "Laravel", "title": "CSRF protection disabled", "description": "A form POST skips CSRF verification.", "owasp": "A01:2021 - Broken Access Control", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-352", "mitre_attack": "T1190 - Exploit Public-Facing Application", "severity": "Medium", "difficulty": "Beginner", "vulnerable_code": "<form method=\"POST\"> ... </form>  <!-- Vulnerable: no @csrf -->\\", "secure_code": "<form method=\"POST\"> @csrf ... </form>  <!-- Secure: token -->\\", "patch": "--- a/edit.blade.php\\n+++ b/edit.blade.php\\n@@ -1,2 +1,2 @@\\n-<form method=\"POST\"> ... </form>\\n+<form method=\"POST\"> @csrf ... </form>\\", "root_cause": "Missing CSRF token.", "attack": "Cross-site POST forges change.", "impact": "Unauthorized action.", "fix": "Add @csrf.", "guideline": "Protect state changes.", "tags": ["csrf", "php", "laravel", "config"], "metadata": {"domain": "E-commerce", "input_source": "form_field", "auth_required": true}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:L/A:N"}
{"id": "SCP-000012", "language": "Java", "framework": "Spring Boot", "title": "Path traversal in file download", "description": "A Spring controller builds a file path from a request parameter without canonicalization.", "owasp": "A01:2021 - Broken Access Control", "owasp_api": "API3:2023 - Broken Object Property Level Authorization", "owasp_llm": "", "cwe": "CWE-22", "mitre_attack": "T1190 - Exploit Public-Facing Application", "severity": "High", "difficulty": "Intermediate", "vulnerable_code": "@GetMapping(\"/files/{name}\")\npublic Resource download(@PathVariable String name) {\n    // Vulnerable: path from input\n    return new FileInputStreamResource(\n        new FileInputStream(\"/var/data/\" + name));\n}\n", "secure_code": "@GetMapping(\"/files/{name}\")\npublic Resource download(@PathVariable String name) throws IOException {\n    Path base = Paths.get(\"/var/data\").toRealPath();\n    Path resolved = base.resolve(name).normalize();\n    if (!resolved.startsWith(base)) {\n        throw new ResponseStatusException(HttpStatus.BAD_REQUEST);\n    }\n    return new InputStreamResource(Files.newInputStream(resolved));\n}\n", "patch": "--- a/FileController.java\n+++ b/FileController.java\n@@ -2,5 +2,10 @@\n-    return new FileInputStreamResource(new FileInputStream(\"/var/data/\" + name));\n+    Path base = Paths.get(\"/var/data\").toRealPath();\n+    Path resolved = base.resolve(name).normalize();\n+    if (!resolved.startsWith(base)) throw new ResponseStatusException(HttpStatus.BAD_REQUEST);\n", "root_cause": "User input is used directly to construct filesystem paths without canonicalization or containment checks.", "attack": "name=../../etc/passwd reads arbitrary files outside the intended directory.", "impact": "Disclosure of sensitive system or application files.", "fix": "Resolve and canonicalize the path, then verify it stays within the allowed base directory.", "guideline": "Canonicalize and contain: ensure resolved paths stay under the trusted root.", "tags": ["path-traversal", "spring", "java", "file"], "metadata": {"domain": "REST API", "input_source": "path_param", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000007", "language": "Python", "framework": "Django", "title": "IDOR on invoice download", "description": "A Django view returns an object purely by its numeric id without checking ownership.", "owasp": "A01:2021 - Broken Access Control", "owasp_api": "API1:2023 - Broken Object Level Authorization", "owasp_llm": "", "cwe": "CWE-639", "mitre_attack": "T1190 - Exploit Public-Facing Application", "severity": "High", "difficulty": "Beginner", "vulnerable_code": "from django.http import HttpResponse\nfrom .models import Invoice\n\ndef download_invoice(request, invoice_id):\n    # Vulnerable: no ownership check\n    inv = Invoice.objects.get(pk=invoice_id)\n    return HttpResponse(inv.pdf, content_type='application/pdf')\n", "secure_code": "from django.http import HttpResponse, Http404\nfrom .models import Invoice\n\ndef download_invoice(request, invoice_id):\n    # Secure: scope to the authenticated user\n    try:\n        inv = Invoice.objects.get(pk=invoice_id, user=request.user)\n    except Invoice.DoesNotExist:\n        raise Http404\n    return HttpResponse(inv.pdf, content_type='application/pdf')\n", "patch": "--- a/views.py\n+++ b/views.py\n@@ -3,6 +3,10 @@\n-    inv = Invoice.objects.get(pk=invoice_id)\n+    try:\n+        inv = Invoice.objects.get(pk=invoice_id, user=request.user)\n+    except Invoice.DoesNotExist:\n+        raise Http404\n", "root_cause": "Object access is keyed only by an attacker-controllable identifier, not by caller ownership.", "attack": "User changes invoice_id from 1001 to 1002 and downloads another customer's invoice.", "impact": "Disclosure of other users' financial documents (PII, billing data).", "fix": "Always scope database queries by the authenticated principal (user/tenant).", "guideline": "Enforce object-level authorization on every record lookup.", "tags": ["idor", "django", "python", "access-control"], "metadata": {"domain": "E-commerce", "input_source": "path_param", "auth_required": true}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000347", "language": "PHP", "framework": "Laravel", "title": "Command injection via shell_exec", "description": "A Laravel controller passes user input to shell_exec.", "owasp": "A03:2021 - Injection", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-78", "mitre_attack": "T1059 - Command and Scripting Interpreter", "severity": "High", "difficulty": "Intermediate", "vulnerable_code": "$out = shell_exec(\"ping -c1 \" . $host);  // Vulnerable: shell\\", "secure_code": "if (!preg_match(\"/^[\\w.-]+$/\", $host)) abort(400);\\n$out = shell_exec(escapeshellarg(\"ping -c1 \") . escapeshellarg($host));  // Secure\\", "patch": "--- a/PingController.php\\n+++ b/PingController.php\\n@@ -1,3 +1,4 @@\\n-$out = shell_exec(\"ping -c1 \" . $host);\\n+if (!preg_match(\"/^[\\w.-]+$/\", $host)) abort(400);\\n+$out = shell_exec(escapeshellarg(\"ping -c1 \") . escapeshellarg($host));\\", "root_cause": "Shell with user input.", "attack": "host=;cat /etc/passwd executes.", "impact": "Command injection.", "fix": "Validate + escapeshellarg.", "guideline": "Avoid shell; escape args.", "tags": ["command-injection", "php", "laravel", "rce"], "metadata": {"domain": "IoT", "input_source": "query_param", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000234", "language": "Java", "framework": "Spring Boot", "title": "Path traversal in file servlet", "description": "A Spring controller reads a file using a raw request path.", "owasp": "A01:2021 - Broken Access Control", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-22", "mitre_attack": "T1190 - Exploit Public-Facing Application", "severity": "High", "difficulty": "Intermediate", "vulnerable_code": "@GetMapping(\"/file\")\npublic Resource file(@RequestParam String p) {\n  return new FileSystemResource(\"/data/\" + p);  // Vulnerable: traversal\n}", "secure_code": "@GetMapping(\"/file\")\npublic Resource file(@RequestParam String p) {\n  Path base = Paths.get(\"/data\").toRealPath();\n  Path full = base.resolve(p).normalize();\n  if (!full.startsWith(base)) throw new ResponseStatusException(FORBIDDEN);  // Secure\n  return new FileSystemResource(full);\n}", "patch": "--- a/FileCtrl.java\n+++ b/FileCtrl.java\n@@ -1,4 +1,7 @@\n-  return new FileSystemResource(\"/data/\" + p);\n+  Path base = Paths.get(\"/data\").toRealPath();\n+  Path full = base.resolve(p).normalize();\n+  if (!full.startsWith(base)) throw new ResponseStatusException(FORBIDDEN);\n+  return new FileSystemResource(full);", "root_cause": "Unsanitized path joined to base dir.", "attack": "p=../../etc/passwd reads arbitrary file.", "impact": "File disclosure.", "fix": "Resolve and confine to base dir.", "guideline": "Confine file paths to a base directory.", "tags": ["path-traversal", "spring", "java", "file-read"], "metadata": {"domain": "Backend", "input_source": "query_param", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000133", "language": "Ruby", "framework": "Rails", "title": "Cross-site scripting in JSON response", "description": "A Rails API returns user input inside a JSON string rendered unsanitized in a page.", "owasp": "A03:2021 - Injection", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-79", "mitre_attack": "T1059.007 - Command and Scripting Interpreter: JavaScript", "severity": "Medium", "difficulty": "Beginner", "vulnerable_code": "def comment\n  render json: { text: params[:text] }  # Vulnerable if embedded in HTML later\nend", "secure_code": "def comment\n  text = ERB::Util.html_escape(params[:text])  # Secure\n  render json: { text: text }\nend", "patch": "--- a/comments_controller.rb\n+++ b/comments_controller.rb\n@@ -1,3 +1,4 @@\n-def comment\n-  render json: { text: params[:text] }\n+  text = ERB::Util.html_escape(params[:text])\n+  render json: { text: text }", "root_cause": "User input returned unescaped, later injected into DOM.", "attack": "text=<img onerror=steal()> executes when rendered.", "impact": "Stored XSS.", "fix": "Escape/encode on output; use safe DOM APIs.", "guideline": "Encode on output even in JSON consumed by pages.", "tags": ["xss", "rails", "ruby", "json"], "metadata": {"domain": "E-commerce", "input_source": "request_body", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:L/A:N"}
{"id": "SCP-000383", "language": "Rust", "framework": "Actix", "title": "Business logic: negative amount", "description": "A transfer handler accepts a negative amount.", "owasp": "A04:2021 - Insecure Design", "owasp_api": "API3:2023 - Broken Object Property Level Authorization", "owasp_llm": "", "cwe": "CWE-840", "mitre_attack": "T1190 - Exploit Public-Facing Application", "severity": "Medium", "difficulty": "Intermediate", "vulnerable_code": "acc.balance += req.amount;  // Vulnerable: negative allowed\\", "secure_code": "if req.amount <= 0.0 || req.amount > 1_000_000.0 { return Err(...); }  // Secure\\nacc.balance += req.amount;\\", "patch": "--- a/account.rs\\n+++ b/account.rs\\n@@ -1,3 +1,4 @@\\n-acc.balance += req.amount;\\n+if req.amount <= 0.0 || req.amount > 1_000_000.0 { return Err(...); }\\n+acc.balance += req.amount;\\", "root_cause": "Client amount not validated.", "attack": "amount=-100 increases balance.", "impact": "Financial abuse.", "fix": "Validate amount.", "guideline": "Validate business values.", "tags": ["business-logic", "rust", "actix", "banking"], "metadata": {"domain": "Banking", "input_source": "request_body", "auth_required": true}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:L/A:N"}
{"id": "SCP-000077", "language": "Scala", "framework": "Play", "title": "Reflected XSS in Play template", "description": "A Play Twirl template renders a request param with @ (unescaped) instead of @(...).", "owasp": "A03:2021 - Injection", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-79", "mitre_attack": "T1059.007 - Command and Scripting Interpreter: JavaScript", "severity": "Medium", "difficulty": "Beginner", "vulnerable_code": "@(name: String)\n<div class=\"hi\">Hello @name</div>\n", "secure_code": "@(name: String)\n<div class=\"hi\">Hello @Html(name)</div>\n", "patch": "--- a/views/greet.scala.html\n+++ b/views/greet.scala.html\n@@ -1,2 +1,2 @@\n-<div class=\"hi\">Hello @name</div>\n+<div class=\"hi\">Hello @Html(name)</div>\n", "root_cause": "Twirl @name auto-escapes, but @Html(...) marks content as trusted raw HTML.", "attack": "name=<script>steal()</script> executes if ever passed through Html().", "impact": "XSS if misused; here the fix shows the correct escaped usage.", "fix": "Use default @ escaping; reserve @Html for vetted, sanitized markup only.", "guideline": "Default to escaped output in templates; avoid Html() on user input.", "tags": ["xss", "scala", "play", "template"], "metadata": {"domain": "E-commerce", "input_source": "query_param", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:L/A:N"}
{"id": "SCP-000300", "language": "Scala", "framework": "Play", "title": "IDOR on resource read", "description": "A Play action returns a resource by id without ownership.", "owasp": "A01:2021 - Broken Access Control", "owasp_api": "API1:2023 - Broken Object Level Authorization", "owasp_llm": "", "cwe": "CWE-639", "mitre_attack": "T1190 - Exploit Public-Facing Application", "severity": "High", "difficulty": "Beginner", "vulnerable_code": "def show(id: Long) = Action { repo.find(id).map(Ok(_)).getOrElse(NotFound) }  // Vulnerable: no owner", "secure_code": "def show(id: Long) = Action { req =>\n  repo.findOwned(id, req.user.id).map(Ok(_)).getOrElse(NotFound)  // Secure\n}", "patch": "--- a/Resource.scala\n+++ b/Resource.scala\n@@ -1,2 +1,3 @@\n-def show(id: Long) = Action { repo.find(id).map(Ok(_)).getOrElse(NotFound) }\n+def show(id: Long) = Action { req =>\n+  repo.findOwned(id, req.user.id).map(Ok(_)).getOrElse(NotFound) }", "root_cause": "No ownership scoping.", "attack": "Enumerate others resources.", "impact": "PII disclosure.", "fix": "Scope by owner.", "guideline": "Authorize reads by owner.", "tags": ["idor", "scala", "play", "access-control"], "metadata": {"domain": "E-commerce", "input_source": "path_param", "auth_required": true}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000027", "language": "PHP", "framework": "Laravel", "title": "Cryptographically weak random token", "description": "A Laravel app generates password-reset tokens with rand()/mt_rand(), which is predictable.", "owasp": "A02:2021 - Cryptographic Failures", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-338", "mitre_attack": "T1600 - Weaken Encryption", "severity": "High", "difficulty": "Intermediate", "vulnerable_code": "public function issueToken($userId)\n{\n    // Vulnerable: predictable PRNG\n    $token = mt_rand(100000, 999999);\n    DB::insert('reset_tokens', ['user_id'=>$userId, 'token'=>$token]);\n    return $token;\n}\n", "secure_code": "public function issueToken($userId)\n{\n    // Secure: CSPRNG, 32 bytes hex\n    $token = bin2hex(random_bytes(32));\n    DB::insert('reset_tokens', ['user_id'=>$userId, 'token'=>hash('sha256', $token)]);\n    return $token;\n}\n", "patch": "--- a/TokenService.php\n+++ b/TokenService.php\n@@ -2,6 +2,7 @@\n-    $token = mt_rand(100000, 999999);\n+    $token = bin2hex(random_bytes(32));\n+    DB::insert('reset_tokens', ['user_id'=>$userId, 'token'=>hash('sha256', $token)]);\n", "root_cause": "A non-cryptographic PRNG is used for security-sensitive tokens, making them guessable.", "attack": "Attacker predicts the next mt_rand() value and resets another user's password.", "impact": "Account takeover via predictable reset tokens.", "fix": "Use a CSPRNG (random_bytes / Str::random) and store only a hash of the token.", "guideline": "Generate secrets with CSPRNGs; never use rand()/mt_rand() for tokens.", "tags": ["crypto", "laravel", "php", "tokens"], "metadata": {"domain": "Authentication systems", "input_source": "server", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000078", "language": "Scala", "framework": "Akka HTTP", "title": "SSRF in Akka HTTP client call", "description": "An Akka HTTP service fetches an arbitrary user-supplied URL without allowlisting.", "owasp": "A10:2021 - Server-Side Request Forgery", "owasp_api": "API7:2023 - Server Side Request Forgery", "owasp_llm": "", "cwe": "CWE-918", "mitre_attack": "T1190 - Exploit Public-Facing Application", "severity": "High", "difficulty": "Intermediate", "vulnerable_code": "def proxy(url: String) = Action.async {\n  // Vulnerable: arbitrary URL\n  Http().singleRequest(HttpRequest(uri = url))\n}\n", "secure_code": "def proxy(url: String) = Action.async {\n  // Secure: allowlist host + https only\n  val allowed = Set(\"api.trusted.example\")\n  val u = Uri(url)\n  if (u.scheme != \"https\" || !allowed.contains(u.authority.host.toString)) {\n    Future.successful(Forbidden)\n  } else Http().singleRequest(HttpRequest(uri = u))\n}\n", "patch": "--- a/ProxyController.scala\n+++ b/ProxyController.scala\n@@ -2,4 +2,8 @@\n-  Http().singleRequest(HttpRequest(uri = url))\n+  val allowed = Set(\"api.trusted.example\")\n+  val u = Uri(url)\n+  if (u.scheme != \"https\" || !allowed.contains(u.authority.host.toString))\n+    Future.successful(Forbidden)\n+  else Http().singleRequest(HttpRequest(uri = u))\n", "root_cause": "Outbound requests follow attacker-controlled URLs with no host allowlist/egress control.", "attack": "url=http://169.254.169.254/ reads cloud metadata credentials.", "impact": "Internal network access, credential theft.", "fix": "Allowlist destinations, enforce HTTPS, block internal ranges.", "guideline": "Validate outbound URLs; block internal/metadata endpoints.", "tags": ["ssrf", "scala", "akka", "cloud"], "metadata": {"domain": "Microservices", "input_source": "query_param", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000101", "language": "Python", "framework": "Kubernetes Operator", "title": "Secret exposed in operator log", "description": "An operator logs the full resource spec including a Secret reference's literal value.", "owasp": "A09:2021 - Security Logging and Monitoring Failures", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-532", "mitre_attack": "T1562.001 - Impair Defenses", "severity": "Medium", "difficulty": "Beginner", "vulnerable_code": "def reconcile(req):\n    # Vulnerable: logs secret contents\n    logging.info('spec=%s', req.obj['spec'])\n", "secure_code": "SENSITIVE = {'password', 'token', 'secret'}\ndef _redact(spec):\n    return {k: '***' if k.lower() in SENSITIVE else v for k, v in spec.items()}\ndef reconcile(req):\n    logging.info('spec=%s', _redact(req.obj['spec']))\n", "patch": "--- a/operator.py\n+++ b/operator.py\n@@ -1,3 +1,6 @@\n-    logging.info('spec=%s', req.obj['spec'])\n+    def _redact(spec):\n+        return {k: '***' if k.lower() in SENSITIVE else v for k, v in spec.items()}\n+    logging.info('spec=%s', _redact(req.obj['spec']))\n", "root_cause": "Full resource specs containing secrets are written to logs.", "attack": "Anyone with log access reads secret values.", "impact": "Secret disclosure.", "fix": "Redact sensitive fields before logging; never log secrets.", "guideline": "Redact secrets in all logs; scrub sensitive keys.", "tags": ["kubernetes", "logging", "python", "secrets"], "metadata": {"domain": "Microservices", "input_source": "request_body", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:L/A:N"}
{"id": "SCP-000035", "language": "Rust", "framework": "Actix", "title": "Path traversal in static file handler", "description": "A Rust/Actix handler concatenates a request path to a base dir without canonicalization.", "owasp": "A01:2021 - Broken Access Control", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-22", "mitre_attack": "T1190 - Exploit Public-Facing Application", "severity": "High", "difficulty": "Intermediate", "vulnerable_code": "async fn files(req: HttpRequest) -> impl Responder {\n    let name = req.match_info().get(\"name\").unwrap();\n    // Vulnerable: raw concatenation\n    let path = format!(\"/srv/static/{}\", name);\n    actix_files::NamedFile::open(path)\n}\n", "secure_code": "use std::path::{Path, PathBuf};\nasync fn files(req: HttpRequest) -> impl Responder {\n    let name = req.match_info().get(\"name\").unwrap_or(\"\");\n    let base = Path::new(\"/srv/static\").canonicalize().unwrap();\n    let target: PathBuf = base.join(name);\n    // Secure: ensure the resolved path stays under base\n    if !target.starts_with(&base) { return HttpResponse::BadRequest().finish(); }\n    actix_files::NamedFile::open(target)\n}\n", "patch": "--- a/files.rs\n+++ b/files.rs\n@@ -2,5 +2,9 @@\n-    let path = format!(\"/srv/static/{}\", name);\n+    let base = Path::new(\"/srv/static\").canonicalize().unwrap();\n+    let target: PathBuf = base.join(name);\n+    if !target.starts_with(&base) { return HttpResponse::BadRequest().finish(); }\n+    actix_files::NamedFile::open(target)\n", "root_cause": "Unvalidated path segments let ../ escape the intended directory.", "attack": "name=../../etc/passwd reads arbitrary files from the host.", "impact": "Sensitive file disclosure.", "fix": "Canonicalize and verify the resolved path is contained within the base directory.", "guideline": "Join then contain: verify canonical path under the trusted root.", "tags": ["path-traversal", "rust", "actix", "file"], "metadata": {"domain": "REST API", "input_source": "path_param", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000188", "language": "Java", "framework": "Spring Boot", "title": "Hardcoded API key in Spring component", "description": "A Spring service hardcodes a payment gateway key.", "owasp": "A02:2021 - Cryptographic Failures", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-798", "mitre_attack": "T1552.001 - Unsecured Credentials: Credentials In Files", "severity": "High", "difficulty": "Beginner", "vulnerable_code": "@Value(\"sk_live_abc123\")  // Vulnerable: hardcoded\nprivate String gatewayKey;", "secure_code": "@Value(\"${GATEWAY_KEY}\")  // Secure: from env/secret\nprivate String gatewayKey;", "patch": "--- a/GatewayService.java\n+++ b/GatewayService.java\n@@ -1,2 +1,2 @@\n-@Value(\"sk_live_abc123\")\n+@Value(\"${GATEWAY_KEY}\")\n private String gatewayKey;", "root_cause": "Secret in source.", "attack": "Repo access reveals the key.", "impact": "Payment fraud.", "fix": "Use env/secret manager.", "guideline": "Externalize secrets.", "tags": ["secrets", "spring", "java", "config"], "metadata": {"domain": "Banking", "input_source": "source_code", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000090", "language": "TypeScript", "framework": "NestJS", "title": "Client-side amount manipulation in checkout", "description": "A NestJS checkout trusts the price sent from the client instead of the server catalog.", "owasp": "A04:2021 - Insecure Design", "owasp_api": "API3:2023 - Broken Object Property Level Authorization", "owasp_llm": "", "cwe": "CWE-602", "mitre_attack": "T1190 - Exploit Public-Facing Application", "severity": "High", "difficulty": "Intermediate", "vulnerable_code": "@Post('checkout')\ncheckout(@Body() b: { itemId: string; price: number }) {\n    // Vulnerable: trusts client price\n    return this.billing.charge(b.price);\n}\n", "secure_code": "@Post('checkout')\nasync checkout(@Body() b: { itemId: string }) {\n    // Secure: look up authoritative price server-side\n    const item = await this.catalog.get(b.itemId);\n    return this.billing.charge(item.price);\n}\n", "patch": "--- a/checkout.controller.ts\n+++ b/checkout.controller.ts\n@@ -1,5 +1,6 @@\n-checkout(@Body() b: { itemId: string; price: number }) {\n-    return this.billing.charge(b.price);\n+async checkout(@Body() b: { itemId: string }) {\n+    const item = await this.catalog.get(b.itemId);\n+    return this.billing.charge(item.price);\n", "root_cause": "Price is taken from the client, so an attacker can set it to 0.01.", "attack": "Intercept the request and change price to 0.01 to buy at a discount.", "impact": "Revenue loss, fraud.", "fix": "Never trust client-supplied prices; derive totals server-side from the catalog.", "guideline": "Compute prices server-side from authoritative sources.", "tags": ["fintech", "nestjs", "typescript", "price-tampering"], "metadata": {"domain": "E-commerce", "input_source": "request_body", "auth_required": true}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000315", "language": "Go", "framework": "Gin", "title": "Open redirect via ReturnURL", "description": "A Gin login redirects to ReturnURL without validation.", "owasp": "A01:2021 - Broken Access Control", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-601", "mitre_attack": "T1566 - Phishing", "severity": "Medium", "difficulty": "Beginner", "vulnerable_code": "c.Redirect(302, c.Query(\"ReturnURL\"))  // Vulnerable", "secure_code": "u := c.Query(\"ReturnURL\")\nif !strings.HasPrefix(u, \"/\") || strings.HasPrefix(u, \"//\") { u = \"/\" }  // Secure\nc.Redirect(302, u)", "patch": "--- a/login.go\n+++ b/login.go\n@@ -1,2 +1,4 @@\n-c.Redirect(302, c.Query(\"ReturnURL\"))\n+u := c.Query(\"ReturnURL\")\n+if !strings.HasPrefix(u, \"/\") || strings.HasPrefix(u, \"//\") { u = \"/\" }\n+c.Redirect(302, u)", "root_cause": "Unvalidated redirect.", "attack": "ReturnURL=//evil.com phishing.", "impact": "Phishing.", "fix": "Allowlist relative.", "guideline": "Validate redirects.", "tags": ["open-redirect", "go", "gin", "phishing"], "metadata": {"domain": "Authentication systems", "input_source": "query_param", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:L/A:N"}
{"id": "SCP-000145", "language": "Ruby", "framework": "Rails", "title": "Insecure redirect after OAuth with no state", "description": "A Rails OAuth callback does not verify the state parameter.", "owasp": "A01:2021 - Broken Access Control", "owasp_api": "API2:2023 - Broken Authentication", "owasp_llm": "", "cwe": "CWE-352", "mitre_attack": "T1190 - Exploit Public-Facing Application", "severity": "Medium", "difficulty": "Intermediate", "vulnerable_code": "def oauth_callback\n  # Vulnerable: no state check\n  user = User.from_omniauth(request.env['omniauth.auth'])\n  session[:user_id] = user.id\nend", "secure_code": "def oauth_callback\n  if session[:oauth_state] != params[:state]  # Secure\n    return head :bad_request\n  end\n  user = User.from_omniauth(request.env['omniauth.auth'])\n  session[:user_id] = user.id\nend", "patch": "--- a/callbacks_controller.rb\n+++ b/callbacks_controller.rb\n@@ -1,5 +1,7 @@\n-def oauth_callback\n-  user = User.from_omniauth(request.env['omniauth.auth'])\n+def oauth_callback\n+  if session[:oauth_state] != params[:state]\n+    return head :bad_request\n+  end\n+  user = User.from_omniauth(request.env['omniauth.auth'])", "root_cause": "Missing state verification enables OAuth CSRF login.", "attack": "Attacker initiates login linking victim to attacker's account.", "impact": "Account confusion, takeover.", "fix": "Generate and verify a state parameter per round trip.", "guideline": "Verify OAuth state; use PKCE for public clients.", "tags": ["oauth", "csrf", "rails", "ruby"], "metadata": {"domain": "Authentication systems", "input_source": "query_param", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:L/A:N"}
{"id": "SCP-000107", "language": "C", "framework": "Embedded", "title": "Stack-based buffer overflow in HTTP header parse", "description": "An embedded web server copies a header value into a fixed stack buffer without bounds.", "owasp": "A03:2021 - Injection", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-120", "mitre_attack": "T1203 - Exploitation for Client Execution", "severity": "Critical", "difficulty": "Advanced", "vulnerable_code": "void parse_header(char *line) {\n    char val[64];\n    // Vulnerable: strcpy from attacker input\n    strcpy(val, strchr(line, ':') + 1);\n}\n", "secure_code": "void parse_header(char *line) {\n    char val[64];\n    char *v = strchr(line, ':') + 1;\n    // Secure: bounded copy\n    strncpy(val, v, sizeof(val) - 1);\n    val[sizeof(val) - 1] = '\\0';\n}\n", "patch": "--- a/httpd.c\n+++ b/httpd.c\n@@ -3,4 +3,6 @@\n-    strcpy(val, strchr(line, ':') + 1);\n+    char *v = strchr(line, ':') + 1;\n+    strncpy(val, v, sizeof(val) - 1);\n+    val[sizeof(val) - 1] = '\\0';\n", "root_cause": "strcpy into a fixed buffer allows overflow with a long header value.", "attack": "Send a huge header to overflow the stack and hijack execution.", "impact": "Remote code execution on the device.", "fix": "Use bounded copies (strncpy + NUL) or length-checked parsers.", "guideline": "Avoid strcpy; bound all copies; compile with stack protectors.", "tags": ["iot", "c", "buffer-overflow", "http"], "metadata": {"domain": "IoT", "input_source": "network", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000140", "language": "Java", "framework": "Spring Boot", "title": "Reflected XSS in Thymeleaf", "description": "A Thymeleaf template uses th:utext with user input, disabling escaping.", "owasp": "A03:2021 - Injection", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-79", "mitre_attack": "T1059.007 - Command and Scripting Interpreter: JavaScript", "severity": "Medium", "difficulty": "Beginner", "vulnerable_code": "<!-- greeting.html -->\n<div th:utext=\"${name}\"></div>  <!-- Vulnerable: unescaped -->", "secure_code": "<!-- greeting.html -->\n<div th:text=\"${name}\"></div>  <!-- Secure: escaped -->", "patch": "--- a/greeting.html\n+++ b/greeting.html\n@@ -1,2 +1,2 @@\n-<div th:utext=\"${name}\"></div>\n+<div th:text=\"${name}\"></div>", "root_cause": "th:utext marks content as safe, disabling escaping.", "attack": "name=<script>steal()</script> executes.", "impact": "XSS.", "fix": "Use th:text (escaped) for user data.", "guideline": "Prefer th:text; avoid th:utext on user input.", "tags": ["xss", "spring", "java", "thymeleaf"], "metadata": {"domain": "E-commerce", "input_source": "query_param", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:L/A:N"}
{"id": "SCP-000209", "language": "PHP", "framework": "Laravel", "title": "Cryptographic weakness: base64 used as 'encryption'", "description": "A Laravel app 'encrypts' data with base64 only.", "owasp": "A02:2021 - Cryptographic Failures", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-327", "mitre_attack": "T1600 - Weaken Encryption", "severity": "High", "difficulty": "Beginner", "vulnerable_code": "$enc = base64_encode($data);  // Vulnerable: not encryption", "secure_code": "use Illuminate\\Support\\Facades\\Crypt;\n$enc = Crypt::encryptString($data);  // Secure: AES-256-CBC + MAC", "patch": "--- a/Crypto.php\n+++ b/Crypto.php\n@@ -1,2 +1,3 @@\n-$enc = base64_encode($data);\n+use Illuminate\\Support\\Facades\\Crypt;\n+$enc = Crypt::encryptString($data);", "root_cause": "Base64 is encoding, not encryption.", "attack": "Attacker base64-decodes to read data.", "impact": "Data disclosure.", "fix": "Use Laravel Crypt (AES-256).", "guideline": "Use real encryption, not encoding.", "tags": ["crypto", "laravel", "php", "weak-encryption"], "metadata": {"domain": "Healthcare", "input_source": "server", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000249", "language": "Ruby", "framework": "Rails", "title": "IDOR on message read", "description": "A Rails action returns a message by id without owner check.", "owasp": "A01:2021 - Broken Access Control", "owasp_api": "API1:2023 - Broken Object Level Authorization", "owasp_llm": "", "cwe": "CWE-639", "mitre_attack": "T1190 - Exploit Public-Facing Application", "severity": "High", "difficulty": "Beginner", "vulnerable_code": "def show\n  @msg = Message.find(params[:id])  # Vulnerable: no owner\nend", "secure_code": "def show\n  @msg = current_user.messages.find(params[:id])  # Secure: scoped\nend", "patch": "--- a/messages_controller.rb\n+++ b/messages_controller.rb\n@@ -1,3 +1,3 @@\n-def show\n  @msg = Message.find(params[:id])\n+  @msg = current_user.messages.find(params[:id])", "root_cause": "No ownership scoping on read.", "attack": "Enumerator reads others messages.", "impact": "PII disclosure.", "fix": "Scope by owner.", "guideline": "Scope reads by owner.", "tags": ["idor", "rails", "ruby", "access-control"], "metadata": {"domain": "E-commerce", "input_source": "path_param", "auth_required": true}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000096", "language": "JavaScript", "framework": "Express", "title": "HL7v2 injection in message builder", "description": "An Express service builds HL7v2 messages by concatenating patient fields without escaping separators.", "owasp": "A03:2021 - Injection", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-93", "mitre_attack": "T1190 - Exploit Public-Facing Application", "severity": "Medium", "difficulty": "Advanced", "vulnerable_code": "function hl7(patient) {\n  // Vulnerable: unescaped field with pipe/newline\n  return `PID|1|${patient.name}|${patient.dob}`;\n}\n", "secure_code": "function esc(s) { return String(s).replace(/[\\r\\n|]/g, ''); }\nfunction hl7(patient) {\n  // Secure: strip HL7 field/segment separators\n  return `PID|1|${esc(patient.name)}|${esc(patient.dob)}`;\n}\n", "patch": "--- a/hl7.js\n+++ b/hl7.js\n@@ -1,4 +1,6 @@\n+function esc(s) { return String(s).replace(/[\\r\\n|]/g, ''); }\n function hl7(patient) {\n-  return `PID|1|${patient.name}|${patient.dob}`;\n+  return `PID|1|${esc(patient.name)}|${esc(patient.dob)}`;\n", "root_cause": "Patient fields containing HL7 separators corrupt the message or inject segments.", "attack": "name=EVN|1|admin sets a fake segment altering downstream routing.", "impact": "Message corruption, false data, misrouting.", "fix": "Escape HL7 separators and validate field contents.", "guideline": "Escape/encode structured-message separators before concatenation.", "tags": ["healthcare", "hl7", "express", "injection"], "metadata": {"domain": "Healthcare", "input_source": "request_body", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:L/A:N"}
{"id": "SCP-000341", "language": "C#", "framework": "ASP.NET Core", "title": "Insecure random for token (System.Random)", "description": "A token generator uses System.Random.", "owasp": "A02:2021 - Cryptographic Failures", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-338", "mitre_attack": "T1600 - Weaken Encryption", "severity": "High", "difficulty": "Intermediate", "vulnerable_code": "var r = new Random(); var tok = r.Next().ToString();  // Vulnerable: predictable\\", "secure_code": "var bytes = RandomNumberGenerator.GetBytes(32); var tok = Convert.ToBase64String(bytes);  // Secure: CSPRNG\\", "patch": "--- a/Token.cs\\n+++ b/Token.cs\\n@@ -1,3 +1,3 @@\\n-var r = new Random(); var tok = r.Next().ToString();\\n+var bytes = RandomNumberGenerator.GetBytes(32); var tok = Convert.ToBase64String(bytes);\\", "root_cause": "Non-CSPRNG token.", "attack": "Predict token.", "impact": "Token forgery.", "fix": "Use RandomNumberGenerator.", "guideline": "Use CSPRNG for tokens.", "tags": ["crypto", "csharp", "aspnet", "tokens"], "metadata": {"domain": "Authentication systems", "input_source": "server", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000318", "language": "Go", "framework": "Gin", "title": "CORS allow-all with credentials", "description": "A Gin CORS config permits any origin with credentials.", "owasp": "A05:2021 - Security Misconfiguration", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-942", "mitre_attack": "T1190 - Exploit Public-Facing Application", "severity": "Medium", "difficulty": "Beginner", "vulnerable_code": "c.Writer.Header().Set(\"Access-Control-Allow-Origin\", \"*\")  // Vulnerable\nc.Writer.Header().Set(\"Access-Control-Allow-Credentials\", \"true\")", "secure_code": "c.Writer.Header().Set(\"Access-Control-Allow-Origin\", \"https://app.example.com\")  // Secure\nc.Writer.Header().Set(\"Access-Control-Allow-Credentials\", \"true\")", "patch": "--- a/cors.go\n+++ b/cors.go\n@@ -1,3 +1,3 @@\n-c.Writer.Header().Set(\"Access-Control-Allow-Origin\", \"*\")\n-c.Writer.Header().Set(\"Access-Control-Allow-Credentials\", \"true\")\n+c.Writer.Header().Set(\"Access-Control-Allow-Origin\", \"https://app.example.com\")\n+c.Writer.Header().Set(\"Access-Control-Allow-Credentials\", \"true\")", "root_cause": "Wildcard origin + credentials.", "attack": "Cross-origin read with cookies.", "impact": "Data theft.", "fix": "Pin origins.", "guideline": "Restrict CORS.", "tags": ["cors", "go", "gin", "config"], "metadata": {"domain": "E-commerce", "input_source": "header", "auth_required": true}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:L/A:N"}
{"id": "SCP-000268", "language": "C", "framework": "POSIX", "title": "Unchecked return of malloc", "description": "A C program uses malloc result without NULL check.", "owasp": "A03:2021 - Injection", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-252", "mitre_attack": "T1203 - Exploitation for Client Execution", "severity": "Medium", "difficulty": "Beginner", "vulnerable_code": "void *p = malloc(n);\nmemcpy(p, src, n);  // Vulnerable: p may be NULL", "secure_code": "void *p = malloc(n);\nif (!p) return -1;  // Secure: check\nmemcpy(p, src, n);", "patch": "--- a/alloc.c\n+++ b/alloc.c\n@@ -1,3 +1,4 @@\n-void *p = malloc(n);\n-memcpy(p, src, n);\n+void *p = malloc(n);\n+if (!p) return -1;\n+memcpy(p, src, n);", "root_cause": "Unchecked allocation.", "attack": "Force OOM to get NULL then crash.", "impact": "DoS / corruption.", "fix": "Check malloc return.", "guideline": "Always check alloc returns.", "tags": ["memory-safety", "c", "error-handling"], "metadata": {"domain": "IoT", "input_source": "internal", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:L/A:N"}
{"id": "SCP-000183", "language": "Python", "framework": "Django", "title": "Allowlist not enforced on file type", "description": "A Django upload accepts any extension, enabling webshell.", "owasp": "A04:2021 - Insecure Design", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-434", "mitre_attack": "T1190 - Exploit Public-Facing Application", "severity": "High", "difficulty": "Intermediate", "vulnerable_code": "def up(req):\n  f = req.FILES['f']\n  with open('/media/'+f.name, 'wb') as o: o.write(f.read())  # Vulnerable", "secure_code": "ALLOWED = {'.png', '.jpg', '.pdf'}\ndef up(req):\n  f = req.FILES['f']\n  ext = os.path.splitext(f.name)[1].lower()\n  if ext not in ALLOWED: return HttpResponse('bad type', 415)  # Secure\n  name = secrets.token_hex(16) + ext\n  with open('/media/'+name, 'wb') as o: o.write(f.read())", "patch": "--- a/views.py\n+++ b/views.py\n@@ -1,4 +1,8 @@\n-  with open('/media/'+f.name, 'wb') as o: o.write(f.read())\n+  ext = os.path.splitext(f.name)[1].lower()\n+  if ext not in ALLOWED: return HttpResponse('bad type', 415)\n+  name = secrets.token_hex(16) + ext\n+  with open('/media/'+name, 'wb') as o: o.write(f.read())", "root_cause": "Any extension stored in webroot.", "attack": "Upload .php webshell and request it.", "impact": "RCE.", "fix": "Allowlist extensions; randomize name; store outside exec context.", "guideline": "Validate upload types; randomize names.", "tags": ["file-upload", "django", "python", "rce"], "metadata": {"domain": "E-commerce", "input_source": "form_field", "auth_required": true}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000380", "language": "Rust", "framework": "Actix", "title": "Insecure TLS (danger_accept_invalid_certs)", "description": "A reqwest client accepts invalid certificates.", "owasp": "A02:2021 - Cryptographic Failures", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-295", "mitre_attack": "T1557 - Adversary-in-the-Middle", "severity": "Critical", "difficulty": "Advanced", "vulnerable_code": "let client = reqwest::Client::builder().danger_accept_invalid_certs(true).build()?;  // Vulnerable\\", "secure_code": "let client = reqwest::Client::builder().build()?;  // Secure: verifies certs\\", "patch": "--- a/client.rs\\n+++ b/client.rs\\n@@ -1,3 +1,3 @@\\n-let client = reqwest::Client::builder().danger_accept_invalid_certs(true).build()?;\\n+let client = reqwest::Client::builder().build()?;\\", "root_cause": "Cert verification disabled.", "attack": "MITM intercepts TLS.", "impact": "Credential/data theft.", "fix": "Keep verification on.", "guideline": "Always verify TLS peers.", "tags": ["tls", "rust", "actix", "mitm"], "metadata": {"domain": "Banking", "input_source": "network", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000303", "language": "Scala", "framework": "Play", "title": "Mass assignment via case class binding", "description": "A Play form binds all fields including role.", "owasp": "A04:2021 - Insecure Design", "owasp_api": "API3:2023 - Broken Object Property Level Authorization", "owasp_llm": "", "cwe": "CWE-915", "mitre_attack": "T1190 - Exploit Public-Facing Application", "severity": "High", "difficulty": "Beginner", "vulnerable_code": "def update = Action { implicit req =>\n  userForm.bindFromRequest.fold(_ => BadRequest, u => repo.update(u))  // Vulnerable: role bound\n}", "secure_code": "def update = Action { implicit req =>\n  val f = userForm.bindFromRequest.filterNot(_._1 == \"role\")\n  f.fold(_ => BadRequest, u => repo.update(u.copy(role = currentUser.role)))  // Secure\n}", "patch": "--- a/UserCtrl.scala\n+++ b/UserCtrl.scala\n@@ -1,3 +1,4 @@\n-def update = Action { implicit req =>\n  userForm.bindFromRequest.fold(_ => BadRequest, u => repo.update(u))\n+  val f = userForm.bindFromRequest.filterNot(_._1 == \"role\")\n+  f.fold(_ => BadRequest, u => repo.update(u.copy(role = currentUser.role)))", "root_cause": "All fields bound from request.", "attack": "POST role=admin escalates.", "impact": "Privilege escalation.", "fix": "Whitelist fields.", "guideline": "Use form whitelists.", "tags": ["mass-assignment", "scala", "play", "auth"], "metadata": {"domain": "E-commerce", "input_source": "request_body", "auth_required": true}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000232", "language": "Java", "framework": "Spring Boot", "title": "Insecure Java deserialization (ObjectInputStream)", "description": "A Spring endpoint reads a serialized Java object from the request.", "owasp": "A08:2021 - Software and Data Integrity Failures", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-502", "mitre_attack": "T1190 - Exploit Public-Facing Application", "severity": "Critical", "difficulty": "Advanced", "vulnerable_code": "ObjectInputStream ois = new ObjectInputStream(req.getInputStream());\nObject o = ois.readObject();  // Vulnerable: gadget chains -> RCE", "secure_code": "MyDto o = objectMapper.readValue(req.getInputStream(), MyDto.class);  // Secure: JSON DTO", "patch": "--- a/Ctrl.java\n+++ b/Ctrl.java\n@@ -1,3 +1,3 @@\n-ObjectInputStream ois = new ObjectInputStream(req.getInputStream());\n-Object o = ois.readObject();\n+MyDto o = objectMapper.readValue(req.getInputStream(), MyDto.class);", "root_cause": "Native Java deserialization of untrusted bytes.", "attack": "Send a gadget-chain payload for RCE.", "impact": "Remote code execution.", "fix": "Avoid native deserialization; use JSON DTOs.", "guideline": "Never deserialize untrusted Java objects.", "tags": ["deserialization", "spring", "java", "rce"], "metadata": {"domain": "Microservices", "input_source": "request_body", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000214", "language": "Python", "framework": "Django", "title": "Django DEBUG=True in production", "description": "A Django settings file enables DEBUG in production, leaking stack traces.", "owasp": "A05:2021 - Security Misconfiguration", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-209", "mitre_attack": "T1190 - Exploit Public-Facing Application", "severity": "Medium", "difficulty": "Beginner", "vulnerable_code": "DEBUG = True  # Vulnerable: leaks tracebacks in prod", "secure_code": "DEBUG = os.environ.get(\"DJANGO_DEBUG\", \"False\") == \"True\"  # Secure: off by default", "patch": "--- a/settings.py\n+++ b/settings.py\n@@ -1,2 +1,2 @@\n-DEBUG = True\n+DEBUG = os.environ.get(\"DJANGO_DEBUG\", \"False\") == \"True\"", "root_cause": "DEBUG on in production exposes internals.", "attack": "Trigger error to read settings and source.", "impact": "Info disclosure.", "fix": "Default DEBUG off; enable per env.", "guideline": "Never run DEBUG=True in production.", "tags": ["config", "django", "python", "info-leak"], "metadata": {"domain": "Backend", "input_source": "source_code", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:L/A:N"}
{"id": "SCP-000070", "language": "C++", "framework": "STL", "title": "Weak RNG for session token", "description": "A C++ service generates session tokens with rand(), which is predictable.", "owasp": "A02:2021 - Cryptographic Failures", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-338", "mitre_attack": "T1600 - Weaken Encryption", "severity": "High", "difficulty": "Intermediate", "vulnerable_code": "#include <cstdlib>\nstd::string token() {\n    // Vulnerable: rand()\n    return std::to_string(rand());\n}\n", "secure_code": "#include <random>\nstd::string token() {\n    // Secure: CSPRNG\n    std::random_device rd;\n    std::mt19937_64 gen(rd());\n    return std::to_string(gen());\n}\n", "patch": "--- a/token.cpp\n+++ b/token.cpp\n@@ -2,4 +2,7 @@\n-    return std::to_string(rand());\n+    std::random_device rd;\n+    std::mt19937_64 gen(rd());\n+    return std::to_string(gen());\n", "root_cause": "rand() is not cryptographically secure; tokens are guessable.", "attack": "Attacker predicts session tokens and hijacks sessions.", "impact": "Session hijacking.", "fix": "Use std::random_device / OS CSPRNG for tokens.", "guideline": "Use CSPRNG (random_device) for secrets, not rand().", "tags": ["crypto", "cpp", "tokens"], "metadata": {"domain": "Authentication systems", "input_source": "server", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000260", "language": "C", "framework": "POSIX", "title": "Double free", "description": "A C program frees the same pointer twice.", "owasp": "A03:2021 - Injection", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-415", "mitre_attack": "T1203 - Exploitation for Client Execution", "severity": "High", "difficulty": "Advanced", "vulnerable_code": "void run() {\n  char *p = malloc(16);\n  free(p); free(p);  // Vulnerable: double free\n}", "secure_code": "void run() {\n  char *p = malloc(16);\n  free(p); p = NULL;  // Secure: null after free\n}", "patch": "--- a/run.c\n+++ b/run.c\n@@ -1,4 +1,4 @@\n-  free(p); free(p);\n+  free(p); p = NULL;", "root_cause": "Freeing same pointer twice.", "attack": "Heap corruption / RCE.", "impact": "Memory corruption.", "fix": "Null after free.", "guideline": "Avoid double free.", "tags": ["double-free", "c", "memory-safety"], "metadata": {"domain": "IoT", "input_source": "internal", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000134", "language": "C++", "framework": "STL", "title": "Command injection via popen", "description": "A C++ service builds a report command with popen and user input.", "owasp": "A03:2021 - Injection", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-78", "mitre_attack": "T1059.004 - Command and Scripting Interpreter: Unix Shell", "severity": "Critical", "difficulty": "Intermediate", "vulnerable_code": "#include <stdio.h>\nvoid report(const char* t) {\n  char c[256]; snprintf(c,sizeof c,\"gen %s\", t);\n  popen(c, \"r\");  // Vulnerable\n}", "secure_code": "#include <array>\nvoid report(const char* t) {\n  if (strpbrk(t, \";&|$\\\"'\") != nullptr) return;  // Secure: validate\n  std::array<char,256> cmd{}; snprintf(cmd.data(), cmd.size(), \"gen %s\", t);\n  popen(cmd.data(), \"r\");\n}", "patch": "--- a/report.cpp\n+++ b/report.cpp\n@@ -2,4 +2,5 @@\n-  char c[256]; snprintf(c,sizeof c,\"gen %s\", t);\n-  popen(c, \"r\");\n+  if (strpbrk(t, \";&|$\\\"'\") != nullptr) return;\n+  std::array<char,256> cmd{}; snprintf(cmd.data(), cmd.size(), \"gen %s\", t);\n+  popen(cmd.data(), \"r\");", "root_cause": "Input passed to a shell via popen.", "attack": "t=x; rm -rf / runs commands.", "impact": "Remote code execution.", "fix": "Validate input; avoid shell; use argument arrays.", "guideline": "Validate before popen; avoid shell metachars.", "tags": ["command-injection", "cpp", "popen", "rce"], "metadata": {"domain": "Background workers", "input_source": "argv", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000386", "language": "Kotlin", "framework": "Android", "title": "SQL injection in Android Room raw query", "description": "An Android DAO runs a raw query with string concatenation.", "owasp": "A03:2021 - Injection", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-89", "mitre_attack": "T1190 - Exploit Public-Facing Application", "severity": "High", "difficulty": "Intermediate", "vulnerable_code": "@Query(\"SELECT * FROM users WHERE name = :name\")  // ok but\\nfun search(name: String): List<User>  // misuse below\\nfun raw(n: String) = db.query(\"SELECT * FROM users WHERE name='$n'\")  // Vulnerable\\", "secure_code": "@Query(\"SELECT * FROM users WHERE name = :name\")\\nfun search(@Param(\"name\") name: String): List<User>  // Secure: bound param\\", "patch": "--- a/UserDao.kt\\n+++ b/UserDao.kt\\n@@ -1,4 +1,3 @@\\n-fun raw(n: String) = db.query(\"SELECT * FROM users WHERE name='$n'\")\\n+@Query(\"SELECT * FROM users WHERE name = :name\")\\n+fun search(@Param(\"name\") name: String): List<User>\\", "root_cause": "Raw query with concatenation.", "attack": "n=' OR 1=1 dumps rows.", "impact": "Data disclosure.", "fix": "Use @Query with params.", "guideline": "Bind all SQL params.", "tags": ["sqli", "kotlin", "android", "injection"], "metadata": {"domain": "Mobile", "input_source": "query_param", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000339", "language": "C#", "framework": "ASP.NET Core", "title": "CORS allow-all with credentials", "description": "CORS policy allows any origin with credentials.", "owasp": "A05:2021 - Security Misconfiguration", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-942", "mitre_attack": "T1190 - Exploit Public-Facing Application", "severity": "Medium", "difficulty": "Beginner", "vulnerable_code": "policy.AllowAnyOrigin().AllowCredentials();  // Vulnerable\\", "secure_code": "policy.WithOrigins(\"https://app.example.com\").AllowCredentials();  // Secure\\", "patch": "--- a/Program.cs\\n+++ b/Program.cs\\n@@ -1,2 +1,2 @@\\n-policy.AllowAnyOrigin().AllowCredentials();\\n+policy.WithOrigins(\"https://app.example.com\").AllowCredentials();\\", "root_cause": "Wildcard origin + credentials.", "attack": "Cross-origin read with cookies.", "impact": "Data theft.", "fix": "Pin origins.", "guideline": "Restrict CORS.", "tags": ["cors", "csharp", "aspnet", "config"], "metadata": {"domain": "E-commerce", "input_source": "header", "auth_required": true}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:L/A:N"}
{"id": "SCP-000032", "language": "Kotlin", "framework": "Android", "title": "Hardcoded API key in Android source", "description": "An Android app embeds a backend API key as a string literal in Kotlin source.", "owasp": "A02:2021 - Cryptographic Failures", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-798", "mitre_attack": "T1552.001 - Unsecured Credentials: Credentials In Files", "severity": "High", "difficulty": "Beginner", "vulnerable_code": "object Config {\n    // Vulnerable: key shipped in APK\n    const val API_KEY = \"AKIA1234567890ABCDEF\"\n}\n", "secure_code": "object Config {\n    // Secure: read from BuildConfig / gradle properties, not source\n    val API_KEY: String\n        get() = BuildConfig.API_KEY  // injected at build from local.properties\n}\n", "patch": "--- a/Config.kt\n+++ b/Config.kt\n@@ -1,4 +1,5 @@\n-    const val API_KEY = \"AKIA1234567890ABCDEF\"\n+    val API_KEY: String get() = BuildConfig.API_KEY\n", "root_cause": "Secrets compiled into the APK are trivially recovered via reverse engineering.", "attack": "Attacker decompiles the APK and extracts the API key for backend abuse.", "impact": "Backend quota theft, data access, or cost abuse.", "fix": "Keep keys out of source; use build-time injection, NDK obfuscation, or backend-mediated tokens.", "guideline": "Never ship secrets in mobile binaries; use short-lived tokens via a backend.", "tags": ["secrets", "android", "kotlin", "mobile"], "metadata": {"domain": "IoT", "input_source": "source_code", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000251", "language": "Ruby", "framework": "Rails", "title": "CSRF protection disabled", "description": "A Rails controller skips CSRF for a state-changing action.", "owasp": "A01:2021 - Broken Access Control", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-352", "mitre_attack": "T1190 - Exploit Public-Facing Application", "severity": "Medium", "difficulty": "Beginner", "vulnerable_code": "class ApiController < ApplicationController\n  skip_before_action :verify_authenticity_token  # Vulnerable\nend", "secure_code": "class ApiController < ApplicationController\n  protect_from_forgery with: :exception  # Secure\nend", "patch": "--- a/api_controller.rb\n+++ b/api_controller.rb\n@@ -1,3 +1,3 @@\n-class ApiController < ApplicationController\n  skip_before_action :verify_authenticity_token\n+  protect_from_forgery with: :exception", "root_cause": "CSRF skipping on mutating action.", "attack": "Cross-site POST forges change.", "impact": "Unauthorized action.", "fix": "Keep CSRF protection.", "guideline": "Don't skip CSRF on state changes.", "tags": ["csrf", "rails", "ruby", "config"], "metadata": {"domain": "E-commerce", "input_source": "form_field", "auth_required": true}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:L/A:N"}
{"id": "SCP-000466", "language": "Java", "framework": "Spring Boot", "title": "Session fixation in Spring", "description": "Spring login does not configure session fixation protection.", "owasp": "A07:2021 - Auth Failures", "owasp_api": "API2:2023", "owasp_llm": "", "cwe": "CWE-384", "mitre_attack": "T1539", "severity": "Medium", "difficulty": "Beginner", "vulnerable_code": "http.formLogin();", "secure_code": "http.sessionManagement()\n    .sessionFixation().migrateSession();", "patch": "--- a/SecurityConfig.java\n+++ b/SecurityConfig.java\n@@ -1,2 +1,3 @@\n-http.formLogin();\n+http.sessionManagement()\n+    .sessionFixation().migrateSession();", "root_cause": "No session fixation policy.", "attack": "Fixation attack.", "impact": "Account takeover.", "fix": "Migrate session on auth.", "guideline": "Rotate session on login.", "tags": ["session", "spring", "java", "auth"], "metadata": {"auth_required": true, "domain": "Authentication systems", "input_source": "form_field"}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:L/A:N"}
{"id": "SCP-000256", "language": "C", "framework": "POSIX", "title": "Buffer overflow in strcpy", "description": "A C function copies input with strcpy into a fixed buffer.", "owasp": "A03:2021 - Injection", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-120", "mitre_attack": "T1203 - Exploitation for Client Execution", "severity": "High", "difficulty": "Intermediate", "vulnerable_code": "void copy(char *in) {\n  char buf[32];\n  strcpy(buf, in);  // Vulnerable: no bounds\n}", "secure_code": "void copy(char *in) {\n  char buf[32];\n  strncpy(buf, in, sizeof(buf) - 1);  // Secure: bounded\n  buf[sizeof(buf)-1] = '00';\n}", "patch": "--- a/copy.c\n+++ b/copy.c\n@@ -1,4 +1,6 @@\n-  strcpy(buf, in);\n+  strncpy(buf, in, sizeof(buf) - 1);\n+  buf[sizeof(buf)-1] = '00';", "root_cause": "Unbounded copy into stack buffer.", "attack": "Long input overwrites return address.", "impact": "RCE.", "fix": "Use bounded copies.", "guideline": "Avoid strcpy; use strncpy/snprintf.", "tags": ["buffer-overflow", "c", "memory-safety"], "metadata": {"domain": "IoT", "input_source": "argv", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000458", "language": "Python", "framework": "FastAPI", "title": "Excessive data exposure", "description": "Endpoint returns full ORM object including secrets.", "owasp": "A01:2021 - Broken Access Control", "owasp_api": "API3:2023", "owasp_llm": "", "cwe": "CWE-200", "mitre_attack": "T1190", "severity": "Medium", "difficulty": "Beginner", "vulnerable_code": "@app.get(\"/me\")\nasync def me(u: User = Depends(current)):\n    return u  # leaks internal fields", "secure_code": "@app.get(\"/me\")\nasync def me(u: User = Depends(current)):\n    return UserPublic.from_orm(u)  # whitelisted", "patch": "--- a/me.py\n+++ b/me.py\n@@ -1,3 +1,4 @@\n-async def me(u: User = Depends(current)):\n-    return u\n+async def me(u: User = Depends(current)):\n+    return UserPublic.from_orm(u)", "root_cause": "Full object serialization.", "attack": "Read internal/private fields.", "impact": "Info disclosure.", "fix": "Use response schemas.", "guideline": "Whitelist response fields.", "tags": ["exposure", "fastapi", "python", "api"], "metadata": {"auth_required": true, "domain": "E-commerce", "input_source": "cookie"}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:L/A:N"}
{"id": "SCP-000382", "language": "Rust", "framework": "Actix", "title": "CORS allow-all with credentials", "description": "CORS permits any origin with credentials.", "owasp": "A05:2021 - Security Misconfiguration", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-942", "mitre_attack": "T1190 - Exploit Public-Facing Application", "severity": "Medium", "difficulty": "Beginner", "vulnerable_code": ".allowed_origin(Origin::star())  // Vulnerable + credentials\\", "secure_code": ".allowed_origin(Origin::exact(\"https://app.example.com\".parse().unwrap()))  // Secure\\", "patch": "--- a/cors.rs\\n+++ b/cors.rs\\n@@ -1,2 +1,2 @@\\n-.allowed_origin(Origin::star())\\n+.allowed_origin(Origin::exact(\"https://app.example.com\".parse().unwrap()))\\", "root_cause": "Wildcard origin + credentials.", "attack": "Cross-origin read with cookies.", "impact": "Data theft.", "fix": "Pin origins.", "guideline": "Restrict CORS.", "tags": ["cors", "rust", "actix", "config"], "metadata": {"domain": "E-commerce", "input_source": "header", "auth_required": true}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:L/A:N"}
{"id": "SCP-000200", "language": "Python", "framework": "Django", "title": "No rate limit on password reset", "description": "A Django password reset has no rate limit, enabling account enumeration/abuse.", "owasp": "A07:2021 - Identification and Authentication Failures", "owasp_api": "API4:2023 - Unrestricted Resource Consumption", "owasp_llm": "", "cwe": "CWE-307", "mitre_attack": "T1110 - Brute Force", "severity": "Medium", "difficulty": "Beginner", "vulnerable_code": "def reset(req):\n  send_reset(req.POST['email'])  # Vulnerable: no throttle\n  return ok()", "secure_code": "from django_ratelimit.core import is_ratelimited\ndef reset(req):\n  if is_ratelimited(req, group='reset', key='ip', rate='3/m', method=ALL):  # Secure\n    return HttpResponse('slow down', 429)\n  send_reset(req.POST['email'])\n  return ok()", "patch": "--- a/views.py\n+++ b/views.py\n@@ -1,3 +1,6 @@\n-  send_reset(req.POST['email'])\n+  if is_ratelimited(req, group='reset', key='ip', rate='3/m', method=ALL):\n+    return HttpResponse('slow down', 429)\n+  send_reset(req.POST['email'])", "root_cause": "No throttle on reset.", "attack": "Mass reset emails; enumerate valid accounts.", "impact": "Abuse, enumeration.", "fix": "Rate limit reset endpoint.", "guideline": "Throttle password reset.", "tags": ["rate-limiting", "django", "python", "auth"], "metadata": {"domain": "Authentication systems", "input_source": "request_body", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:L/A:N"}
{"id": "SCP-000069", "language": "C++", "framework": "STL", "title": "Path traversal in file open", "description": "A C++ service opens a file whose path is built from a request parameter.", "owasp": "A01:2021 - Broken Access Control", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-22", "mitre_attack": "T1190 - Exploit Public-Facing Application", "severity": "High", "difficulty": "Intermediate", "vulnerable_code": "#include <fstream>\nstd::string read(const std::string& name) {\n    // Vulnerable: raw path from input\n    std::ifstream f(\"/var/data/\" + name);\n    return std::string(std::istreambuf_iterator<char>(f), {});\n}\n", "secure_code": "#include <filesystem>\nstd::string read(const std::string& name) {\n    // Secure: canonicalize and contain\n    auto base = std::filesystem::canonical(\"/var/data\");\n    auto p = std::filesystem::weakly_canonical(base / name);\n    if (p.parent_path() != base) return {};\n    std::ifstream f(p);\n    return std::string(std::istreambuf_iterator<char>(f), {});\n}\n", "patch": "--- a/io.cpp\n+++ b/io.cpp\n@@ -2,5 +2,9 @@\n-    std::ifstream f(\"/var/data/\" + name);\n+    auto base = std::filesystem::canonical(\"/var/data\");\n+    auto p = std::filesystem::weakly_canonical(base / name);\n+    if (p.parent_path() != base) return {};\n+    std::ifstream f(p);\n", "root_cause": "User input builds filesystem paths without canonicalization/containment.", "attack": "name=../../etc/passwd discloses system files.", "impact": "Sensitive file disclosure.", "fix": "Canonicalize and verify the path stays under the base directory.", "guideline": "Resolve and contain; verify under trusted root.", "tags": ["path-traversal", "cpp", "file"], "metadata": {"domain": "Desktop application", "input_source": "request_body", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000366", "language": "Rust", "framework": "Actix", "title": "SQL injection via string format", "description": "An Actix handler builds a query by formatting.", "owasp": "A03:2021 - Injection", "owasp_api": "", "owasp_llm": "", "cwe": "CWE-89", "mitre_attack": "T1190 - Exploit Public-Facing Application", "severity": "High", "difficulty": "Intermediate", "vulnerable_code": "let q = format!(\"SELECT * FROM users WHERE name = '{}''\", name);\\nsqlx::query(&q).fetch_all(&pool).await  // Vulnerable\\", "secure_code": "sqlx::query(\"SELECT * FROM users WHERE name = $1\").bind(&name).fetch_all(&pool).await  // Secure: bound\\", "patch": "--- a/handler.rs\\n+++ b/handler.rs\\n@@ -1,3 +1,2 @@\\n-let q = format!(\"SELECT * FROM users WHERE name = '{}''\", name);\\n-sqlx::query(&q).fetch_all(&pool).await\\n+sqlx::query(\"SELECT * FROM users WHERE name = $1\").bind(&name).fetch_all(&pool).await\\", "root_cause": "Format into SQL.", "attack": "name=' OR 1=1 dumps rows.", "impact": "Data disclosure.", "fix": "Use bound parameters.", "guideline": "Bind all SQL params.", "tags": ["sqli", "rust", "actix", "injection"], "metadata": {"domain": "E-commerce", "input_source": "query_param", "auth_required": false}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"}
{"id": "SCP-000374", "language": "Rust", "framework": "Actix", "title": "IDOR on resource read", "description": "A handler returns a resource by id without owner check.", "owasp": "A01:2021 - Broken Access Control", "owasp_api": "API1:2023 - Broken Object Level Authorization", "owasp_llm": "", "cwe": "CWE-639", "mitre_attack": "T1190 - Exploit Public-Facing Application", "severity": "High", "difficulty": "Beginner", "vulnerable_code": "let inv = repo.find_invoice(id).await?;  // Vulnerable: no owner\nOk(HttpResponse::Ok().json(inv))", "secure_code": "let inv = repo.find_invoice_for(id, user_id).await?;  // Secure: scoped\nOk(HttpResponse::Ok().json(inv))", "patch": "--- a/invoice.rs\n+++ b/invoice.rs\n@@ -1,2 +1,3 @@\n-let inv = repo.find_invoice(id).await?;\n+let inv = repo.find_invoice_for(id, user_id).await?;", "root_cause": "No ownership scoping.", "attack": "Enumerate others invoices.", "impact": "PII disclosure.", "fix": "Scope by owner.", "guideline": "Authorize reads by owner.", "tags": ["idor", "rust", "actix", "access-control"], "metadata": {"domain": "E-commerce", "input_source": "path_param", "auth_required": true}, "cvss_vector": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"}