Spaces:
Sleeping
Sleeping
File size: 8,418 Bytes
d25ab77 | 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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | [
{
"snippet_id": "hard_001",
"filename": "db.py",
"code": "def load_user(cursor, user_id):\n query = f\"SELECT * FROM users WHERE id = {user_id}\"\n return cursor.execute(query).fetchone()",
"context": "Used by an internal admin dashboard.",
"gold_issues": [
{
"issue_id": "hard_001_sqli",
"line": 2,
"issue_type": "SECURITY",
"severity": "CRITICAL",
"description": "SQL query interpolates user input directly and is vulnerable to SQL injection.",
"required": true,
"explanation_keywords": ["sql injection", "parameterized", "query", "interpolate", "user input"],
"fix_keywords": ["parameterized", "placeholder", "bind", "params"],
"owasp_category": "A03:2021-Injection",
"owasp_keywords": ["owasp", "injection", "a03"]
}
],
"must_approve": false,
"must_reject": true
},
{
"snippet_id": "hard_002",
"filename": "settings.py",
"code": "API_KEY = \"sk-live-hardcoded-secret\"\n\ndef get_auth_header():\n return {\"Authorization\": f\"Bearer {API_KEY}\"}",
"gold_issues": [
{
"issue_id": "hard_002_secret",
"line": 1,
"issue_type": "SECURITY",
"severity": "HIGH",
"description": "Hardcoded API secret in source code.",
"required": true,
"explanation_keywords": ["hardcoded", "secret", "api key", "credential"],
"fix_keywords": ["environment", "vault", "secret manager", "config"],
"owasp_category": "A07:2021-Identification and Authentication Failures",
"owasp_keywords": ["secret", "credential", "authentication", "owasp"]
}
],
"must_approve": false,
"must_reject": true
},
{
"snippet_id": "hard_003",
"filename": "storage.py",
"code": "from pathlib import Path\n\ndef read_report(base_dir, user_filename):\n path = Path(base_dir) / user_filename\n return path.read_text()",
"gold_issues": [
{
"issue_id": "hard_003_path_traversal",
"line": 4,
"issue_type": "SECURITY",
"severity": "HIGH",
"description": "User-controlled file path can escape the intended directory.",
"required": true,
"explanation_keywords": ["path traversal", "directory", "user filename", "path"],
"fix_keywords": ["resolve", "validate", "allowlist", "basename"],
"owasp_category": "A01:2021-Broken Access Control",
"owasp_keywords": ["broken access control", "path traversal", "owasp", "a01"]
}
],
"must_approve": false,
"must_reject": true
},
{
"snippet_id": "hard_004",
"filename": "net.py",
"code": "import os\n\ndef ping(hostname):\n return os.system(f\"ping -c 1 {hostname}\")",
"gold_issues": [
{
"issue_id": "hard_004_command_injection",
"line": 4,
"issue_type": "SECURITY",
"severity": "CRITICAL",
"description": "Shell command is built from user input, allowing command injection.",
"required": true,
"explanation_keywords": ["command injection", "shell", "os.system", "user input"],
"fix_keywords": ["subprocess", "argument list", "shell false", "validate"],
"owasp_category": "A03:2021-Injection",
"owasp_keywords": ["owasp", "injection", "a03", "command injection"]
}
],
"must_approve": false,
"must_reject": true
},
{
"snippet_id": "hard_005",
"filename": "serializer.py",
"code": "import pickle\n\ndef load_session(user_data):\n return pickle.loads(user_data)",
"gold_issues": [
{
"issue_id": "hard_005_pickle",
"line": 4,
"issue_type": "SECURITY",
"severity": "CRITICAL",
"description": "Untrusted pickle deserialization can lead to arbitrary code execution.",
"required": true,
"explanation_keywords": ["pickle", "deserialization", "arbitrary code", "untrusted"],
"fix_keywords": ["json", "safe format", "validate", "trusted"],
"owasp_category": "A08:2021-Software and Data Integrity Failures",
"owasp_keywords": ["integrity", "deserialization", "owasp", "a08"]
}
],
"must_approve": false,
"must_reject": true
},
{
"snippet_id": "hard_006",
"filename": "crypto.py",
"code": "import hashlib\n\ndef hash_password(password):\n return hashlib.md5(password.encode()).hexdigest()",
"gold_issues": [
{
"issue_id": "hard_006_weak_crypto",
"line": 4,
"issue_type": "SECURITY",
"severity": "HIGH",
"description": "Uses MD5 for password hashing, which is cryptographically weak.",
"required": true,
"explanation_keywords": ["md5", "weak", "hash", "password", "crypto"],
"fix_keywords": ["bcrypt", "argon2", "scrypt", "salt"],
"owasp_category": "A02:2021-Cryptographic Failures",
"owasp_keywords": ["cryptographic", "owasp", "a02", "weak crypto"]
}
],
"must_approve": false,
"must_reject": true
},
{
"snippet_id": "hard_007",
"filename": "shell.py",
"code": "import subprocess\n\ndef run(cmd):\n return subprocess.run(cmd, shell=True, check=True)",
"gold_issues": [
{
"issue_id": "hard_007_shell_true",
"line": 4,
"issue_type": "SECURITY",
"severity": "CRITICAL",
"description": "Runs shell commands with shell=True on untrusted input.",
"required": true,
"explanation_keywords": ["shell=true", "subprocess", "command injection", "shell"],
"fix_keywords": ["shell false", "argument list", "validate", "subprocess"],
"owasp_category": "A03:2021-Injection",
"owasp_keywords": ["owasp", "injection", "a03", "shell"]
}
],
"must_approve": false,
"must_reject": true
},
{
"snippet_id": "hard_008",
"filename": "redirects.py",
"code": "def login_redirect(next_url):\n return {\"location\": next_url, \"status\": 302}",
"gold_issues": [
{
"issue_id": "hard_008_open_redirect",
"line": 2,
"issue_type": "SECURITY",
"severity": "HIGH",
"description": "Redirect target is fully user-controlled, creating an open redirect.",
"required": true,
"explanation_keywords": ["open redirect", "redirect", "next_url", "user controlled"],
"fix_keywords": ["allowlist", "relative path", "validate", "trusted host"],
"owasp_category": "A01:2021-Broken Access Control",
"owasp_keywords": ["owasp", "broken access control", "open redirect", "a01"]
}
],
"must_approve": false,
"must_reject": true
},
{
"snippet_id": "hard_009",
"filename": "orders.py",
"code": "def view_order(request, db):\n order_id = request.query_params[\"order_id\"]\n return db.get_order(order_id)",
"context": "Customer dashboard handler.",
"gold_issues": [
{
"issue_id": "hard_009_idor",
"line": 3,
"issue_type": "SECURITY",
"severity": "HIGH",
"description": "Looks up an order by user-supplied id without an ownership check, enabling IDOR.",
"required": true,
"explanation_keywords": ["idor", "ownership", "authorization", "access control", "order id"],
"fix_keywords": ["authorize", "ownership", "current user", "scoped query"],
"owasp_category": "A01:2021-Broken Access Control",
"owasp_keywords": ["owasp", "broken access control", "idor", "a01"]
}
],
"must_approve": false,
"must_reject": true
},
{
"snippet_id": "hard_010",
"filename": "yaml_loader.py",
"code": "import yaml\n\ndef parse_config(data):\n return yaml.load(data, Loader=yaml.Loader)",
"gold_issues": [
{
"issue_id": "hard_010_yaml_load",
"line": 4,
"issue_type": "SECURITY",
"severity": "HIGH",
"description": "Unsafe YAML loader can construct arbitrary Python objects from untrusted input.",
"required": true,
"explanation_keywords": ["yaml.load", "unsafe", "loader", "object", "untrusted"],
"fix_keywords": ["safe_load", "safe loader", "validate", "trusted"],
"owasp_category": "A08:2021-Software and Data Integrity Failures",
"owasp_keywords": ["owasp", "integrity", "yaml", "a08"]
}
],
"must_approve": false,
"must_reject": true
}
]
|