CPSA ยท Web application assessment: injection, sessions and code
Security source code review
Finding input handling, authentication, crypto and error handling deficiencies by reading code.
Key points
- Trace from sources (parameters, headers, cookies, files) to sinks (queries, commands, eval, HTML output).
- Input: string-built queries, no allow-list validation, unsafe output.
- Access: credentials in code, client-only checks, no server-side authorisation.
- Crypto: hard-coded keys, MD5 or SHA-1 for passwords, weak random tokens.
- Errors: stack traces to users, empty catch blocks failing open, secrets in logs.
Source: https://cheatsheetseries.owasp.org/cheatsheets/SQL_Injection_Prevention_Cheat_Sheet.html
Practice questions
Which code pattern most strongly suggests a SQL injection flaw?
- A query string assembled by concatenating a request parameter
- A prepared statement with bound parameters
- A constant query with no variables
- A lookup that maps input to a fixed list of columns
Show answer
Answer: A. A query string assembled by concatenating a request parameter
Building the query text by concatenating a request value lets that value become SQL. Parameterised calls, constant queries and allow-listed mappings keep data out of the SQL text.
Which findings in source code are cryptographic deficiencies?
- An AES key defined as a string constant in the repository
- Passwords hashed with a single round of MD5
- Password-reset tokens made with a non-cryptographic random generator
- SQL statements using bound parameters
- Output encoding applied before rendering HTML
Show answer
Answer: A. An AES key defined as a string constant in the repository, B. Passwords hashed with a single round of MD5, C. Password-reset tokens made with a non-cryptographic random generator
A hard-coded key, a fast hash for passwords and a non-cryptographic random generator for tokens all weaken cryptographic protection. Parameterised queries address injection, not crypto.
True or false: validating input in client-side JavaScript is enough to protect the server.
Show answer
Answer: False
False. Anyone can bypass browser code by sending requests directly, so validation and authorisation must be enforced on the server; client checks are only a convenience.
Practice 8 questions on this topic in Bitzu
Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.
