Skip to content

Lesson 1 of 1

Review checklist

Listen to an AI summary of Review checklist

0:00 / 0:35

How to use the checklist

A change is shown as a diff. In each of the five areas, find the items that match the changed lines. A line that stores a password matches the item Passwords.

A diff fails an item when the code does not do what the item says. Each item has a link to the lesson that teaches the item. The checklist does not cover every weakness.

Input

Validation on the server
The server checks that every input is the kind of data expected (Checks made only in the browser).
SQL injection
No input is joined into the text of a SQL query.
Command injection
No input is joined into a command.
Output encoding
Input shown on a web page has characters such as < replaced, so the browser shows text (Cross-site scripting).
File uploads
The server checks an uploaded file's content and size and chooses the stored name.
Path traversal
A file name from input cannot lead out of the intended folder (Paths and file names).
Server-side request forgery
The server checks an address from input before contacting the address, and refuses a private address (Requests the server makes).
Insecure deserialisation
No input is read with a format that can run code, such as Python's pickle.
Reading XML
Code that reads XML loads no outside files (Other interpreters).
Open redirects
A redirect, which sends the browser to another page, goes only to an address on a fixed list.
Language models
Code keeps instructions to a model apart from data, and treats the model's reply as input (Prompt injection).

Authentication and sessions

Authentication is checking who a person is. After sign-in, the browser sends a session id with each request, in a value called a cookie. The session id tells the server who is signed in.

Passwords
Each password is stored as a slow hash with a salt (Hashing and salts).
Failed sign-ins
A rate limit caps the wrong passwords one account or computer can try (Signing in).
Second factor
Sign-in offers everyone a second proof, such as a code from a phone (Signing in).
Session ids
Ready-made code makes each session id and changes the session id at sign-in (Sessions).
Session cookies
The session cookie has the settings HttpOnly, Secure and SameSite (Sessions).
Session end
The server removes a session at sign-out and after a set time (Sessions).
JSON Web Tokens
Each token says who is signed in. The server checks the signature, the algorithm and the expiry time of a token (Signed tokens).
Sign-in with another account
The callback checks state, checks the ID token and finds the account by sub (OAuth and OpenID Connect sign-in).
Password reset
A reset link holds a random value that works once and soon expires.
Cross-site request forgery
A request that changes data has a secret value from the application's own page (CSRF defences).

Authorisation

Authorisation is checking what a signed-in person may see and do.

Object references
Every read or change of a record checks that the person asking owns the record.
Mass assignment
The code copies only chosen values from a request onto a record (Object references).
Function level checks
Every action checks on the server that the signed-in person may use the action.
Default deny
A route refuses every request that no rule allows (Function level checks).
Roles
A role, such as administrator, comes from the server's records, not from the request (Function level checks).

Business logic

Misuse cases
The review asks who can use a new feature, how many times, in what order and with what values.
Values
The server decides prices, totals and roles, not the request (Rules the code must enforce).
Steps
Each step, such as paying, checks that the earlier steps finished (Rules the code must enforce).
Race conditions
Two requests at the same moment cannot both pass one check, such as for the last ticket.
Limits
Sizes, counts and the number of requests in a set time have limits (Limits on what a request can use).

Configuration and data

Configuration is the settings the software runs with.

Debug settings
Debug mode is off on the real website (Framework configuration).
Security headers
Every page is sent with security headers (Framework configuration).
Errors
A person sees a fixed error message, and the details go to the log (Error handling).
Logging
The log records events such as failed sign-ins, with no passwords, session ids or keys.
Secrets
No secret, such as a password or a key, is written in the code (Secrets in code).
Cryptography
Encryption uses a current method from a maintained library, with the keys outside the code.
TLS
Every connection uses TLS and checks who the other computer is (Protection in transit).
Dependencies
Each dependency is a version with no known vulnerability (Reading a dependency change).
Browser code
Code in the browser checks which website sent a message, and the server lets only named websites read its responses (Same origin policy).

The checklist on one merge request

One merge request adds a page to a sports shop website that shows one order. The picture shows the diff of the Python file orders.py.

orders.py+2-1

  1. def show_order(number):
  2. - return "Coming soon"
  3. + order = find_order(number)# looks up one order
  4. + return show_page("order.html", order)# builds the page from the order
The diff of orders.py.

The parameter number is an order number from a request, so the Input area applies. The diff does not show the code of find_order. A reviewer opens the file that holds find_order before passing the item SQL injection.

The page shows one customer's order, so the Authorisation area applies. The added lines fetch an order by number and never check who owns the order. The diff fails the item Object references, which is also the lesson to read again.

No changed line stores a password, sets a price or changes a setting, so the other three areas do not apply.

Check your understanding

  1. Name the lesson that teaches the item Session cookies.

    Show the answer

    Sessions.

  2. Which item on the checklist does the merge request for one order fail?

    Show the answer

    Object references. The added lines never check who owns the order.

  3. Give one reason why a reviewer opens the file that holds find_order.

    Show the answer

    The diff does not show the code of find_order, so the item SQL injection cannot be passed yet.