Security Checklist on Code reviews
2 min readAug 17, 2021
Everyone should do/are doing code reviews, but how many are actively thinking about security? Because of this, I’ve tried to make a checklist with things that should be checked on a new feature, from (my perspective) security point of view:
Checklist
Input Validations
- All inputs from users are validated ( length, format, range, and are enforced by appropriate limits)?
- Are flaws in regular expressions that may cause problems with the validation of the inputs?
- Is “exact match” used (and if it’s not possible was the content checked to accept only expected values)?
- Are the inputs that contain harmful information (such as js scripts or SQL queries) rejecting the values?
- Are the XML documents validated by their schemas?
- Are SQL queries dynamically created using the user input?
- Is data validated both on the server-side and client-side?
- Are HTTP headers validated for each request?
- On file upload, is the validation of the content of the file also (not only the extension)?
Authentification
- Are the sessions handled as they should?
- Does the error messages leak information ( for example “Password is wrong” )
- Are the brute force attacks or invalid logins logged correctly and without leaking information?
- Do you have a lockout mechanism implemented and a rate limit?
- Are the password saved using some encryption, hashing and salts?
Authorization
- Is the authorization checked on each request?
- Is the endpoint/page/resource denied by default?
- Are correct roles set for accessing each resource?
- Can the authorization or authentication be manipulated using scripts, cookies, SQL or other kinds of manipulation?
Session management
- If there are parameters passed using query strings, are they validated?
- Do the cookies and the session expire?
- Are the cookies encrypted?
- Is the session storage secure?
- Does the app handle as it should the invalid session ids?
- Is the logout invalidating the session?
- After a session is made invalid, all the access to resources is denied?
- Is the app using SSL and do not pass sensitive information from or to non-SSL pages?
Exception Handling
- Do all the methods throw correct exceptions?
- Does the error shown to the user include stack trace, ids or other sensitive information?
- Is the app still secure after an exception is thrown?
- Are exceptions never shown to the users?
- Is in place a rollback and trace mechanism after a crash occurs?
- Are all the actions of the user logged?
- Sensitive actions like changing a password are logged?
Also, a good check would be https://owasp.org/www-project-top-ten/and do not forget to check the components not to have known vulnerabilities.