Code Review in the SDLC Process


  • 4 basic techniques for analyzing the security of a software application:
    • automated scanning
    • manual penetration testing
    • static analysis
    • manual code review

4 Step Code Review Cycle

1. Identify Security Code Review Objectives

  • During this step, goals and constraints are established for the review as the bases for an overall plan
  • review the code with specific goals, time limits, and knowledge of the issues you want to uncover
  • Ideal flow of activities for code review:
    1. threat modeling
      • Understand code and data flows
      • identify high-risk areas and pain points
    2. code reviews
      • document all findings and the process
    3. resolve problems
      • cooperate with owners of code on applying fixes and further efforts
    4. learn the lesson
      • update tools, educate development teams, improve processes, plan future iterations
  • For effected security code review, set goals and constraints for the following:
    • time
      • Set a time limit
      • helps avoid spending too much time on a single issue
      • Performing multiple, smaller reviews is more effective than doing one long review
    • types of issues
      • determine what types of issues you are looking for
      • e.g.,
        • general issues that affect confidentiality, integrity, and availability
        • issues related to application’s security quality-of-service requirements
        • issues related to application’s compliance requirements
        • issues related to the technologies your application uses
        • issues related to the functionality the application exposes
        • issues found during threat modeling
    • out of scope items
      • identify what you will not be looking for
      • explain why these are out of scope

2. Perform a Preliminary Scan

  • Static analysis is used to:
    • find an initial set of security issues
    • improve your understanding of where you will be most likely to find security issues when you review the code more fully
    • discover hot spots where additional security issues are likely to be discovered in later steps
  • typically done with:
    • automatic scans
    • manual scans
    • combination of both
  • Automatic scans
    • typically used to
      • identify low hanging fruit to create a prioritized list for further investigation
    • can supplement manual testing
    • should never replace manual testing
    • typically have false positives and false negatives
  • Manual scan
    • should be conducted after automatic scanning
    • focus on answering the following questions:
      • input data validation
        • does the app have input validation?
        • is validation performed on the client, server, or both?
        • is there a centralized validation mechanism or are validation routines spread throughout the code base?
      • code that authenticates and authorizes users
        • does the app authenticate user?
        • what roles are allowed, how do they interact?
        • is there custom authentication or authorization code?
      • error-handling code
        • is there a consistent error-handling architecture?
        • does the application catch and throw structured exceptions?
        • are there areas of the code with especially dense or sparse error handling?
      • complex code
        • Are there areas of the code that appear especially complex?
      • cryptography
        • does the application use cryptography?
      • interop
        • does the application use interop to call into native code?

3. Review Code for Security Issues

  • The results from step 2 are typically used to focus the analysis of the reviewer during step 3

4. Review for Security Issues Unique to the Architecture

  • Software security architect reviews code
  • Application flaws and business logic vulnerabilities require the context and understanding of a human analyst
  • ultimate goal of security code reviews is to find code vulnerabilities that are accessible by an attacker and that may allow the attacker to bypass a security boundary