Protego field desk
← BACK
CODE SECURITY AUDIT
1/10
Python

User lookup endpoint in a Flask REST API

This route is part of an internal admin dashboard. It fetches a user record by ID passed as a query parameter.

⚡

Click on lines containing security vulnerabilities to flag them. Submit when ready.

app.py
1from flask import Flask, request, jsonify
2import sqlite3
3
4app = Flask(__name__)
5
6@app.route('/api/user')
7def get_user():
8 user_id = request.args.get('id')
9 query = f"SELECT * FROM users WHERE id = {user_id}"
10 conn = sqlite3.connect('db.sqlite3')
11 result = conn.execute(query).fetchone()
12 return jsonify(result)
Click suspicious lines above, then submit

About Vuln Hunter

Read real-looking code snippets in Python, JavaScript, and TypeScript. Click on the exact lines containing security bugs. One file is a trap: clean code designed to trigger false positives.

Difficulty: AdvancedTime: ~10 min

How it works

  • You read ten real looking code snippets in Python, JavaScript, and TypeScript and click the exact lines you think contain a security bug.
  • Your score on each file depends on flagging the vulnerable lines while avoiding false positives, which cost you points.
  • One file is a trap: it is clean, secure code, and the right move is to flag nothing.
  • After each file the game reveals every bug, its severity, and the matching CWE or CVE.

What you'll learn

  • Spotting classic web bugs: SQL injection, cross-site scripting, command injection, and path traversal.
  • Recognizing hardcoded secrets, server-side request forgery, and open redirects in real code.
  • Why MD5 password hashing and non constant time comparison are weak, and how the JWT alg:none flaw works.
  • Resisting false positives by reading secure code, such as a correct bcrypt password check.

FAQ

Is it free and do I need to sign in?

Yes, it is free and needs no account. All of the code and scoring run in your browser.

Who is it for?

Developers, code reviewers, and application security learners who want hands-on practice finding bugs in source code.

What languages and bugs appear?

Python, JavaScript, and TypeScript snippets covering OWASP style issues like SQL injection, XSS, SSRF, path traversal, and weak cryptography.

Keep going