# Security controls in the coding stage of the SDLC

The coding stage needs seven kinds of control: a secure coding standard, developer tooling that applies it, peer review with a security checklist, automated code analysis, protected branches with least-privilege repository access, hardened developer endpoints and accounts, and a rule for choosing dependencies. In NIST SP 800-218 v1.1 they are tasks PW.5.1, PW.7.1, PW.7.2, PS.1.1, PO.5.2, PW.4.1 and PW.4.4. Each leaves a record: the standard, the pull request history, scan results with triage entries, and repository rule settings. A table below gives owner and evidence for each, and a worked pull request follows. Read 19 Nov 2026.

## The controls, who owns them and what they leave behind

| Control | SSDF v1.1 task | What it means in practice | Owner | Evidence |
|---|---|---|---|---|
| Secure coding standard | PW.5.1 | Follow secure coding practices suited to your languages and environment: validate inputs and encode outputs, avoid unsafe functions, handle errors, provide logging | Engineering lead with security | The standard, versioned, with the date of the last review |
| Developer tooling that applies it | PW.5.1 (examples 5 and 7) | Editor and build features that encourage or require secure practices; linters and formatters to standardize code | Platform or developer experience | Tool configuration stored as code in the repository |
| Developer self-review | PW.5.1 (example 9) | The author reads their own change first; this complements, not replaces, review by others | Author | Pull request description or checklist ticked |
| Decide where review and analysis apply | PW.7.1 | Policy that says when code review and when code analysis are used, including third-party and reusable code | Security lead | Review policy, reviewed on schedule |
| Peer review against the standard | PW.7.2 | Review the change against the coding standard, with checklists, and record the discussion | Reviewer and code owner | Pull request approvals and comments |
| Automated code analysis | PW.7.2 (example 4) | Static analysis checks code for vulnerabilities and standard violations, with a human reviewing what it reports | Security champion triages, developer fixes | Scan result per change; findings in the tracker |
| Record and triage findings | PW.7.2 | Every issue from review or analysis, and each recommended fix, goes into the team's workflow or issue tracker | Team lead | Tracker entries with status and owner |
| Check-in checks for unsafe practices | PW.7.2 (example 6) | Automated tools find and remediate documented unsafe practices as code is checked in (a secrets check is one such category) | Platform with security | Check result per push or pull request |
| Repository access and change control | PS.1.1 | Store all code, including configuration as code, with least-privilege access; track every change to an individual account; code owner approves changes by others; sign commits | Repository administrator, code owners | Repository rules, audit log, signed commit history |
| Designated code owners | PO.2.1 (example 7) | A group or team is the code owner for each project | Engineering manager | Code owner file, current membership |
| Developer endpoints and accounts | PO.5.2 | Harden endpoints with a risk-based approach; multi-factor authentication for access to development endpoints and resources | IT and platform | Endpoint baseline, authentication settings |
| Choosing and checking dependencies | PW.4.1, PW.4.4 | Take components from sanctioned, vetted sources, get provenance data, and check that components keep meeting your requirements through their life | Developers, with security | Approved component list, component inventory, vulnerability check results |

OWASP ASVS says it can be the basis for a secure coding reference, and that an organization should write its own specific guidance, ideally with approved security mechanisms and libraries that developers can reference. A standard of that kind is the document to cite for PW.5.1.

Two build-time items are named elsewhere in the framework (PW.6.1 and PW.6.2 on compiler and build tool settings) and belong to the build stage, not here.

## Code review rules that hold up

SP 800-218 asks you to decide when review applies (PW.7.1) and to review against your own standard, record the discussion and track the results (PW.7.2). Its examples include peer review with the existing analysis results in hand, review checklists, and expert reviewers for code that needs particular care.

OWASP's Secure Code Review Cheat Sheet separates two kinds of review, which suits a policy:

- **Diff-based review** looks at changes only: pull requests, commits, completed features. It is the daily workflow, and its steps include assessing the impact on existing controls, checking modified trust boundaries and new integrations, and ensuring no regression.
- **Baseline review** examines the whole codebase: new applications, major releases, legacy onboarding, compliance needs and post-incident analysis.

The same sheet says manual review is the way to find what automated tools often miss, such as business logic and complex security implementations, and lists the high-risk code patterns to focus on: input handling, query construction, file operations, authentication and session logic, authorization checks, cryptographic operations, error handling and logging, configuration loading.

Example rules a team might adopt (values are examples to adjust):

| Rule | Why |
|---|---|
| Every change to the main branch needs at least one approving review from someone other than the author | PS.1.1 and PW.7.2: change accountability and a second reader |
| Changes under the authentication, authorization and cryptography directories also need approval from the code owner for that path | PO.2.1 code owners; PW.1.1 treats authentication and credential management as high-risk |
| The reviewer uses the security checklist for the kinds of code the change touches | PW.7.2 example 5 |
| Findings from review and analysis go to the tracker, not into chat | PW.7.2: record and triage in the workflow system |
| A change that adds a dependency names it in the pull request and links the approval | PW.4.1 |

How strict the rules are, and which findings block a merge, is a gate decision; see [security gates](/security-gates/).

## Automated checks in the coding stage and what each misses

PW.7.2 lists static analysis as one method: use a tool to check code for vulnerabilities and compliance with the coding standard, with a person reviewing what it reports and fixing as needed. Treat each category by what it can and cannot see:

| Check (category) | Finds | Does not replace | Where the result goes |
|---|---|---|---|
| Linters and formatters | Style and some unsafe constructs | Review of logic | Editor and pull request |
| Static analysis | Known classes of flaws in source, standard violations | Business logic review, design review | Pull request status, tracker |
| Secrets check | Credentials committed in code or configuration | Managing and rotating the credentials themselves | Check on push or pull request |
| Dependency check | Known vulnerabilities and unapproved components in what you pull in | Judging whether a component is a good fit | Pull request status, inventory |

Triage is where these checks succeed or fail. Findings that nobody owns turn into noise. Give each class a rule: which severity blocks a merge, which warns, who triages and within what time, and how a false positive is closed with a reason. Tests that run the code are covered in the [test stage](/stages/test/).

## Repository settings that enforce the controls

SP 800-218 is not tied to one platform. PS.1.1 says to store all code under least privilege and gives examples: track changes to individual accounts, use commit signing, have the code owner review and approve changes by others. Source hosts expose these as branch or ruleset settings. GitHub's documentation on protected branches is one concrete reference; other hosts offer equivalents. As documented there:

| Setting | What it enforces | SSDF link |
|---|---|---|
| Force pushes disabled and branch deletion blocked | On by default for a protected branch; history cannot be rewritten or the branch removed | PS.1.1 (tracked changes) |
| Require pull request reviews, with a set number of approvals | Changes reach the branch only through an approved pull request | PS.1.1, PW.7.2 |
| Require review from code owners | A pull request touching owned code needs that owner's approval | PS.1.1 example 4, PO.2.1 |
| Require approval of the most recent push by someone other than the pusher | A second person has looked at the final state of the change | PW.7.2 |
| Require status checks to pass | Required checks (tests, analysis) must succeed before merging; "strict" also requires the branch to be up to date | PW.7.2, PO.4.1 |
| Require conversation resolution | All review comments are resolved or acknowledged | PW.7.2 |
| Require signed commits | Only signed and verified commits are accepted on the branch | PS.1.1 example 3 |
| Do not allow bypassing the above settings | By default admins and custom roles with the "bypass branch protections" permission are exempt; this setting applies the rules to them too | PO.4.1 (record exceptions) |

Export the rule settings or keep them as configuration so an assessor can see them, and keep the host's audit log; those are your evidence for PS.1.1. Review who holds admin or bypass permissions on the same schedule as other exceptions.

## Worked example: reviewing the password reset pull request

The feature is the password reset by email link from the [design page](/stages/design/), with the requirements R1 to R11 from the [requirements page](/stages/requirements/). The pull request adds the reset service. The reviewer turns the model's threats into things to check in the diff. All threat and requirement IDs are from those pages; the example is illustrative.

| Threat | What the reviewer looks for in the change | Automated help | Evidence |
|---|---|---|---|
| T1 | The code path for unknown addresses does the same work and returns the same message as for known ones, rather than leaving early | Test comparing both responses | Test result linked to R6 |
| T2, T3 | Tokens come from the secure random generator the standard names; only a hash is stored; the record is marked used on consumption; expiry is checked on the server | Static analysis rule for weak random sources; unit tests for single use and expiry | Review comment, tests passed |
| T4 | The link is built from configured settings, not request values; the reset page sets a no-referrer policy; log statements do not print tokens or passwords | Secrets and log checks; header test | Checklist ticked in the pull request |
| T5 | The final step checks for a second factor when the account has one | Test with a multi-factor account | Test result linked to R1 |
| T6 | Rate limits are applied on request and on token attempts, and a request never changes the account | Test that the limit applies | Limit documented in the decision record |
| T7 | The server tracks the step and refuses to skip | Test calling the last step directly | Test result linked to R4 |
| T8 | Security events are logged with who, what, when in UTC | Log review in test | Log samples attached |
| T9 | The password update ends the account's other sessions | Test: old session fails | Test result linked to R9 |
| T10 | Support tooling cannot set a password | Review of the admin interface diff | Review comment |

What the pull request leaves behind: the approving review from someone other than the author, code owner approval for the authentication path, passing required checks, resolved conversations, tracker entries for any findings with owner and status, and the link from each test to the requirement it covers. That is the PW.7.2 record and most of the PS.1.1 record for this change.

When the reviewer finds a gap, such as a log statement that prints a token, the finding is a tracker entry linked to T4 and R10, not a chat message. When the team decides to merge with a known gap, that is an exception with an owner and an expiry; see [security gates](/security-gates/).

## Questions people ask

### What are the security controls in the coding stage of the SDLC?

A secure coding standard, tooling that applies it, peer review with a security checklist, automated code analysis with triage, protected branches with least-privilege access and signed commits, hardened developer endpoints and accounts, and rules for choosing dependencies. SP 800-218 covers them in tasks PW.5.1, PW.7.1, PW.7.2, PS.1.1, PO.5.2, PW.4.1 and PW.4.4.

### Is automated code analysis enough without code review?

No. SP 800-218 PW.7.2 describes static analysis with a human reviewing what it reports, and OWASP says manual review is how you find what automated tools often miss, such as business logic and complex security implementations.

## Sources

- [NIST SP 800-218, Secure Software Development Framework (SSDF) Version 1.1](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-218.pdf), read 2026-11-19
- [OWASP Secure Code Review Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Secure_Code_Review_Cheat_Sheet.html), read 2026-11-19
- [GitHub Docs, About protected branches](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches), read 2026-11-19
- [OWASP Application Security Verification Standard 5.0.0, What is the ASVS](https://github.com/OWASP/ASVS/blob/v5.0.0_release/5.0/en/0x03-What-is-the-ASVS.md), read 2026-11-19
- [OWASP Forgot Password Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Forgot_Password_Cheat_Sheet.html), read 2026-11-19

Last reviewed: 2026-11-19

Canonical: https://sdlcsecurity.com/stages/code/
