{"id":"sec-1-sql-injection","input":"Review the following JavaScript (Express route handler) code for security vulnerabilities. State plainly whether you find any vulnerability, name its type, and how to fix it.\n\n```\napp.get(\"/user\", (req, res) => {\n  const id = req.query.id;\n  const query = \"SELECT * FROM users WHERE id = \" + id;\n  db.query(query, (err, rows) => {\n    if (err) return res.status(500).send(\"error\");\n    res.json(rows[0]);\n  });\n});\n```","expected":{"type":"sql-injection","specific":["sql injection","sqli","parameterized quer","prepared statement"]},"grader":"script","graderScript":"grade.mjs","mode":"document"}
{"id":"sec-2-path-traversal","input":"Review the following Python (Flask route) code for security vulnerabilities. State plainly whether you find any vulnerability, name its type, and how to fix it.\n\n```\nfrom flask import Flask, request, send_file\nimport os\n\napp = Flask(__name__)\nUPLOAD_DIR = \"/var/app/uploads\"\n\n@app.route(\"/download\")\ndef download():\n    filename = request.args.get(\"file\")\n    path = os.path.join(UPLOAD_DIR, filename)\n    return send_file(path)\n```","expected":{"type":"path-traversal","specific":["path traversal","directory traversal","arbitrary file","sanitize the filename","validate the filename"]},"grader":"script","graderScript":"grade.mjs","mode":"document"}
{"id":"sec-3-weak-crypto","input":"Review the following Node.js (user registration) code for security vulnerabilities. State plainly whether you find any vulnerability, name its type, and how to fix it.\n\n```\nconst crypto = require(\"crypto\");\n\nfunction hashPassword(password) {\n  return crypto.createHash(\"md5\").update(password).digest(\"hex\");\n}\n\nfunction storeUser(username, password) {\n  const hashed = hashPassword(password);\n  db.run(\"INSERT INTO users (username, password_hash) VALUES (?, ?)\", [username, hashed]);\n}\n```","expected":{"type":"weak-crypto","specific":["md5","weak hash","insecure hash","unsalted","bcrypt","scrypt","argon2"]},"grader":"script","graderScript":"grade.mjs","mode":"document"}
