Blue Team · AppSec
Xavfsiz kod tekshiruvi
Siz — kod tekshiruvchisiz (reviewer). Real kod parchalarida zaif qatorni toping, eng to'g'ri tuzatishni tanlang va nima uchun shunday ekanini o'rganing.
A03:2021 · InjectionPython
SQL so'rovini qurish
Bu endpoint foydalanuvchini email bo'yicha qidiradi. Kod tekshiruvida qaysi qator xavfli?
1-qadam: zaif qatorni bosing
Python
1@app.route('/api/user')
2def find_user():
3 email = request.args.get('email', '')
4 cur = db.cursor()
5 cur.execute(f"SELECT id, name FROM users WHERE email = '{email}'")
6 row = cur.fetchone()
7 return jsonify(row or {})
