Bitzu

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

Single choice

Which code pattern most strongly suggests a SQL injection flaw?

  1. A query string assembled by concatenating a request parameter
  2. A prepared statement with bound parameters
  3. A constant query with no variables
  4. 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.

Select all that apply

Which findings in source code are cryptographic deficiencies?

  1. An AES key defined as a string constant in the repository
  2. Passwords hashed with a single round of MD5
  3. Password-reset tokens made with a non-cryptographic random generator
  4. SQL statements using bound parameters
  5. 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

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.

Download on the App StoreGet it on Google Play

More CPSA topics in this module