Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions bake/tests/audit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,15 @@ fn audit_examples_follow_the_record_format() {
let (_, outcome) = rest.split_once("; ").expect("finding has an outcome");
assert!(!outcome.contains("; "), "description contains `; `: {line}");
assert!(
["advisory ", "fixed in #", "accepted, ", "tracked in #"]
.iter()
.any(|form| outcome.starts_with(form)),
[
"advisory ",
"fixed in #",
"accepted, ",
"tracked in #",
"rejected, "
]
.iter()
.any(|form| outcome.starts_with(form)),
"{line}"
);
assert!(outcome.ends_with('.'), "{line}");
Expand Down
16 changes: 12 additions & 4 deletions context/audit.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Confirm a finding with a local failing test or reproduction where practical. Whe

## Classify findings

A security finding is a weakness that lets an attacker affect confidentiality, integrity, or availability, given the project's trust boundaries. A defect without attacker leverage is an ordinary issue, not an audit finding. Record a hardening opportunity as a `low` finding only when it needs a decision; otherwise leave it out.
A security finding is a weakness that lets an attacker affect confidentiality, integrity, or availability, given the project's trust boundaries. A defect without attacker leverage is an ordinary issue, not an audit finding. Record a hardening opportunity as a `low` finding only when it needs a decision; otherwise leave it out. When a plausible finding is ruled out only after investigation, record it as rejected rather than leaving it out, so the next reviewer does not repeat the investigation.

Assign each finding a severity by its impact and how readily an attacker can trigger it, not by the effort to fix it:

Expand All @@ -78,7 +78,7 @@ Assign each finding a severity by its impact and how readily an attacker can tri

Establish whether each finding affects a released version: reproduce it on the latest release of each supported version, or confirm that the vulnerable code is present in those release tags.

Before reporting a finding, check whether it is already known: accepted in a `// SECURITY:` comment or design requirement, recorded in an earlier audit with an open issue, or the subject of an unpublished advisory, including draft advisories you can access. Do not report a known finding again unless its stated assumption no longer holds or its impact has changed; in that case, report it as a new finding that names the earlier one.
Before reporting a finding, check whether it is already known: accepted or rejected in a `// SECURITY:` comment or design requirement, recorded in an earlier audit with an open issue, or the subject of an unpublished advisory, including draft advisories you can access. Do not report a known finding again unless its stated assumption or reasoning no longer holds or its impact has changed; in that case, report it as a new finding that names the earlier one.

## Decide each outcome

Expand All @@ -88,6 +88,7 @@ Each finding has one outcome:
- **Fixed:** the weakness is fixed in a pull request. This suits code that has not been released, and released weaknesses below the advisory threshold.
- **Accepted:** the maintainers decide not to fix it. Add a `// SECURITY:` comment where the risk lives, stating the assumption that makes it acceptable, so a later reviewer can tell whether it still holds. When the same assumption applies across the project, such as "configuration files are trusted", capture it once in `design/*.md` with `base-design-author`, and refer to it from the comments.
- **Tracked:** the weakness remains open in a public issue. This suits only findings that the maintainers judge are not exploitable in released versions and are safe to discuss publicly.
- **Rejected:** on investigation the finding is not a weakness: the attacker gains nothing they could not already do, or the behavior is correct given the project's semantics. Add a `// SECURITY:` comment where a reviewer would look, stating the reasoning that rules it out, so the next review does not report it again. An accepted finding is a weakness whose risk is tolerated under an assumption; a rejected finding is not a weakness, and the comment records why.

Use the language's comment syntax, keeping the `SECURITY:` marker:

Expand All @@ -96,7 +97,12 @@ Use the language's comment syntax, keeping the `SECURITY:` marker:
fn load_includes(path: &Path) -> Result<Configuration, Error> {
```

Accepting a risk, choosing the advisory process, and opening a public issue are maintainer decisions. Propose an outcome with its evidence; do not choose one on the maintainers' behalf.
```rust
// SECURITY: Trailer fields are merged into the header map. This is not a smuggling vector: a field is only accepted as a trailer when its definition permits it, so it carries no meaning that depends on arriving before the body.
fn read_trailers(&mut self, headers: &mut Headers) -> Result<(), Error> {
```

Accepting a risk, rejecting a finding, choosing the advisory process, and opening a public issue are maintainer decisions. Propose an outcome with its evidence; do not choose one on the maintainers' behalf.

## Record the audit

Expand All @@ -113,14 +119,16 @@ Revision: `fc81a68c1e2b5d0c9a7e4f3b2a1d0c9b8a7f6e5d` on `main`.
- high: unbounded header count allows memory exhaustion; advisory GHSA-xxxx-xxxx-xxxx.
- low: header count limit not applied to trailers; fixed in #61.
- low: unbounded include depth; accepted, configuration is trusted (`// SECURITY:` at `load_includes`).
- medium: trailer fields merged into the header map; rejected, only fields whose definition permits trailers are accepted (`// SECURITY:` at `read_trailers`).
- `src/request.rs` reviewed with no findings.
```

Follow this format exactly so the records remain searchable and machine-readable:

- List one entry per file, by path relative to the repository root, in byte order as `git ls-tree` lists them.
- End each entry with either `reviewed with no findings.` or `reviewed with findings:` followed by a nested list.
- Write each finding as `{severity}: {description}; {outcome}.`, where the outcome is `advisory {identifier}`, `fixed in #{number}`, `accepted, {reason}`, or `tracked in #{number}`. Do not use `; ` within the description.
- Write each finding as `{severity}: {description}; {outcome}.`, where the outcome is `advisory {identifier}`, `fixed in #{number}`, `accepted, {reason}`, `tracked in #{number}`, or `rejected, {reason}`. Do not use `; ` within the description.
- Give a rejected finding the severity it would have had if it were real, so the record shows what was ruled out.
- Record a finding that spans files under the file where it is best fixed or explained, and name the other files in its description.
- Keep the identifier an advisory had when the record merged; the advisory record lists its later aliases.

Expand Down
2 changes: 1 addition & 1 deletion design/record-format.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Requirement

The `security/audit-{date}-{sha}.md` and `security/advisory-{date}-{slug}.md` formats must remain readable by simple line-oriented tools. An audit entry names one file and its outcome on a single line, with findings in a nested list using the fixed outcome forms. An advisory record carries its identifiers, package, severity, and version requirements in front matter.
The `security/audit-{date}-{sha}.md` and `security/advisory-{date}-{slug}.md` formats must remain readable by simple line-oriented tools. An audit entry names one file and its outcome on a single line, with findings in a nested list using the fixed outcome forms. Adding an outcome form is additive: existing records remain valid, and tools that recognize the forms must be updated before records use the new one. An advisory record carries its identifiers, package, severity, and version requirements in front matter.

Changing the filename pattern, entry wording, outcome forms, or front matter fields is a breaking change for projects that keep records. Such a change requires a migration path for existing records and a corresponding release note.

Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Security audit and advisory records for projects, captured in `security/` and ma

## Motivation

"Review this file for security issues" is easy to ask and hard to track. Without a record, the same unchanged code is reviewed repeatedly, other code is never reviewed, and accepted risks are reported again by each new reviewer. Vulnerabilities need a careful path from private report to public advisory, without disclosing them before users can update.
"Review this file for security issues" is easy to ask and hard to track. Without a record, the same unchanged code is reviewed repeatedly, other code is never reviewed, and accepted risks and rejected findings are reported again by each new reviewer. Vulnerabilities need a careful path from private report to public advisory, without disclosing them before users can update.

`base-security` defines two kinds of tracked record. An audit records which files were reviewed at which revision, with an outcome for each finding, so the next audit can review only what changed. An advisory records a published vulnerability, with its identifiers and affected versions in front matter.

Expand All @@ -21,7 +21,7 @@ The install command is provided by `bake-agent-context`, which `base-project` in

The package provides two self-contained skills:

- [Security Audit](context/audit.md), installed as `base-security-audit`: find files that are due for review, review them against trust boundaries and common weaknesses, decide an outcome for each finding, and record the audit in `security/audit-{date}-{sha}.md`. Accepted risks are explained in `// SECURITY:` comments where they live, so later reviews do not report them again.
- [Security Audit](context/audit.md), installed as `base-security-audit`: find files that are due for review, review them against trust boundaries and common weaknesses, decide an outcome for each finding, and record the audit in `security/audit-{date}-{sha}.md`. Accepted risks and rejected findings are explained in `// SECURITY:` comments where they live, so later reviews do not report them again.
- [Security Advisory](context/advisory.md), installed as `base-security-advisory`: triage a report, prepare a fix privately, release it, publish the GitHub Security Advisory, and record it in `security/advisory-{date}-{slug}.md`.

An audit record looks like this:
Expand Down
1 change: 1 addition & 0 deletions releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased

- Add the `rejected, {reason}` outcome to `base-security-audit` for findings that investigation rules out, recorded with a `// SECURITY:` comment so they are not reported again. Tools that validate outcome forms must accept the new form.
- Derive the `base-security-audit` and `base-security-advisory` skill names from the package and filename, instead of repeating them in front matter. Installed names are unchanged.

## v0.1.1
Expand Down
Loading