Audit Context Building: Build the Audit Context Before Vulnerability Hunting

Preface

When taking over an unfamiliar codebase for a security audit, a common approach is to scan for patterns and chase suspicious calls. If no one documented what each function assumes, what it guarantees, and what it depends on in the previous round, it often becomes difficult to determine whether later findings are real or false. Trail of Bits splits “understand first, then assign blame” into a dedicated phase and hardens the process through an Agent Skill. This article introduces the purpose, outputs, and usage of audit-context-building.

What This Is

audit-context-building is a Skill in the Code Auditing category of Trail of Bits’ skills marketplace. The official description is: understand the code before looking for bugs—what each function assumes, what it guarantees, and what it depends on elsewhere. It’s suitable as a starting point for audits, threat modeling, or architecture reviews, and before any vulnerability hunting pass.

The Skill metadata’s allowed-tools are: Workflow, Task, Read, Grep, Glob.

The core philosophy can be summarized in one sentence: Build understanding, not verdicts. This phase provides context for subsequent hunting and does not replace hunting itself.

Core Functions

Scope of the Phase

What it’s for:

  • At the start of an audit, threat modeling, or architecture review when the code is still unfamiliar;
  • When prior findings exist, but no one has yet mapped how the system is pieced together.

What it explicitly does not do:

  • It does not name vulnerabilities, suggest fixes, write PoCs, or assess severity (those belong to the next phase: hunting);
  • When the code is already well understood, it’s not worth spending tokens redoing it.

When code “expects a condition to hold” yet there is “no check anywhere,” this Skill requires recording that fact as-is and moving on; whether it constitutes an issue is left to later phases.

Workflow and Dispatch

Because the analysis can be extensive and the main context needs to be preserved for later use, long analyses are written to disk via sub-workflows, and the main session only receives compact records back.

  1. Whole codebase or multiple functions — run /audit-context-building:audit-context <path>. This workflow performs targeted analysis, dispatches a subagent for each function, writes audit-context/DOSSIER.md, and generates one file per function under audit-context/functions/. The main context only receives a compact record.
  2. Single function — dispatch the audit-context-building:function-analyzer agent. The analysis body is written to disk, and a single record is returned.

Afterwards, start from the index, unenforced assumptions, and open questions; read the corresponding function file only when details are needed. The workflow constrains behavior by binding subagents that return schemas (they cannot return long prose); the Skill text mainly serves as routing.

Outputs and How to Read Them

Each function record includes:

  • Conditions that must always hold (with corresponding line numbers);
  • Assumptions the function “takes as given by default” (and the basis; if none exists, this is marked);
  • Which functions it calls, and what each callee must provide;
  • Things that remain unclear.

DOSSIER.md supplements cross-function rules, reachability, and clusters of complex regions.

When reading, prioritize two things:

  • nothing found assumptions: the code depends on a condition being true, but there is no evidence anywhere in the codebase that makes it true—this is the most valuable input to hand to the hunting phase.
  • Open questions: honestly listing what has not been understood is more important than forcefully closing it; these should carry forward rather than be forced into a conclusion.

If two records contradict each other, they should be cited side by side and not silently merged—this reflects facts about the code or the analysis, not a flaw in the analysis.

Format and Cross-Domain Notes

  • resources/ANALYSIS_FORMAT.md defines the record format;
  • resources/FUNCTION_MICRO_ANALYSIS_EXAMPLE.md provides C and Solidity examples;
  • resources/DOMAIN_NOTES.md explains how to fill each slot for targets such as smart contracts, C/C++, decompiled firmware, and web services, and which calls have “invisible internals.”

The most important rule: follow the calls. Whether a function is correct often depends on the behavior of its callees; looking only at the caller can lead to misjudgment. Read the callee, traverse the full path (not just the success path), and state what guarantees each assumption; if nothing does, use nothing found. Every claim should reference line numbers; otherwise, list it as an open question.

Installation and Enablement

The Skill is distributed via the Trail of Bits plugin marketplace. You need to add the marketplace first, then install the corresponding plugin.

Claude Code

/plugin marketplace add trailofbits/skills

Browse and install:

/plugin menu

Choose the audit-context-building plugin under the Code Auditing category (description: Understand a codebase before looking for bugs in it, one function at a time).

Codex

Codex supports compatibility with Claude plugin marketplaces, so it does not require separate Codex sidecar metadata in this repository:

codex plugin marketplace add trailofbits/skills
codex plugin list
codex plugin add <plugin-name>@trailofbits

Replace <plugin-name> with the plugin name that contains audit-context-building (consistent with the marketplace listing).

Local development

Add a local marketplace path under the parent directory of the repository. For example, if the repository is at ~/projects/skills:

cd /path/to/parent
/plugins marketplace add ./skills

Official Skill directory:

https://github.com/trailofbits/skills/tree/main/plugins/audit-context-building/skills/audit-context-building

Typical Usage

  1. Load the trailofbits/skills marketplace in Claude Code (or a compatible environment) and enable the audit-context-building plugin.
  2. Start full-codebase context building for an unfamiliar repository:
/audit-context-building:audit-context <path>

Replace <path> with the target code path. After it completes, review audit-context/DOSSIER.md and the per-function files under audit-context/functions/.
3. If you only need to deepen a single function, dispatch audit-context-building:function-analyzer, and read its on-disk prose and the returned compact record.
4. From the dossier and records, collect nothing found assumptions and open questions, then proceed to vulnerability hunting or other Trail of Bits audit Skills.

Use Cases and Cautions

Who it’s for

  • Security engineers and auditors doing audits, threat modeling, or architecture reviews on unfamiliar projects;
  • Teams that want to embed Trail of Bits’ “build context first, then hunt” methodology into an Agent workflow.

Limitations and cautions

  • This Skill does not perform vulnerability naming or severity evaluation; it should be used in separate phases from hunting/review plugins such as c-review and differential-review.
  • Large codebase analysis relies on subagents and on-disk outputs; the main session should rely on the returned index and records, avoiding stuffing full prose back into context.
  • When extending the format or evaluating the credibility of records, read ANALYSIS_FORMAT.md and the example documentation in the repository.

Closing

audit-context-building systematically writes “function assumptions, guarantees, and dependencies” to disk, so later vulnerability hunting can start from the same system map. Official location:

https://github.com/trailofbits/skills/tree/main/plugins/audit-context-building/skills/audit-context-building

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye