{"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= 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= 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": "
\\", "secure_code": " \\", "patch": "--- a/edit.blade.php\\n+++ b/edit.blade.php\\n@@ -1,2 +1,2 @@\\n-\\n+\\", "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=