ContextLock is a CLI on PyPI that scans coding-agent configuration for hard-coded credentials, unpinned MCP server packages, and hooks that download and execute code.
Run agentbom scan to see what the repository configures and which files to review. The scanner runs offline and treats commands and scripts as text. In CI, agentbom check also flags changes to agent files since you committed agentbom.lock.
Install contextlock with uv. The package requires Python 3.11 or later and provides the agentbom command.
uv tool install contextlock
agentbom scan .To install with pip, run pip install contextlock.
In a Git checkout, the scanner reads the working copy of each supported file listed in the index. To include a new file, stage it with git add.
For example, a .mcp.json entry named docs with command npx and arguments ["-y", "docs-mcp"] produces this finding below the inventory.
MED ABOM-005 .mcp.json server "docs" runs npx package "docs-mcp" without an exact version
1 finding (0 high, 1 medium, 0 low).
The default threshold is high, so this finding alone exits with code 0. Use agentbom scan . --fail-on medium to fail on this finding.
Once you have reviewed the agent files, run these commands from the repository root.
agentbom lock
agentbom checkCommit agentbom.lock. The check runs the scan and compares the current files with the lockfile. It fails when a covered file or definition is added, removed, or changed.
If you lock the docs server at docs-mcp@1.2.0 and then edit .mcp.json to use docs-mcp@1.3.0, the report includes this diff.
HIGH ABOM-006 .mcp.json MCP server "docs" differs from agentbom.lock: launch.args
1 finding (1 high, 0 medium, 0 low).
CHANGED file:.mcp.json
text: changed (only a digest is locked; review the file's diff)
CHANGED mcp_server:.mcp.json:docs
launch.args:
- ["-y", "docs-mcp@1.2.0"]
+ ["-y", "docs-mcp@1.3.0"]
2 differences from agentbom.lock.
For an intended change, review the file diff, run agentbom lock again, and commit the updated lockfile with the change.
After committing agentbom.lock, add a workflow such as .github/workflows/agentbom.yml. Replace <commit> with the full commit SHA of the ContextLock Action.
name: ContextLock
on:
pull_request:
permissions:
contents: read
pull-requests: write
jobs:
agentbom:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
- uses: Psionic-labs/contextlock/action@<commit>The Action installs ContextLock from the pinned commit. It writes the report to the job summary, updates one pull request comment, and fails the job when agentbom check exits with an error or a finding at or above the configured threshold. A fork pull request gets a read-only token. The check still runs and the comment step emits a warning.
To upload to GitHub code scanning, add the security-events: write permission and set the Action's upload-sarif input to ${{ github.event.pull_request.head.repo.full_name == github.repository }}. This limits uploads to pull requests from the same repository.
In November 2026, the survey selected 500 public GitHub repositories through searches for agent configuration files. It scanned 495 of them, with 13 scans reporting at least one error. ContextLock flagged 177 repositories, including 43 with a high-severity finding. The most widespread rule match was for hooks that run commands from repository-controlled files, which appeared in 94 repositories.
These counts measure rule matches in the selected sample. Git ignores the raw results under .massscan/. The aggregate counts come from scripts/survey_stats.py.
agentbom scan [PATH] [--format terminal|json|sarif|markdown] [--fail-on high|medium|low] [--policy FILE]
agentbom lock [PATH]
agentbom check [PATH] [--format terminal|json|sarif|markdown] [--fail-on high|medium|low] [--policy FILE]PATH defaults to the current directory. Run lock and check at the repository root.
| Code | Meaning |
|---|---|
0 |
The scan completed and no unsuppressed finding met the threshold. |
1 |
At least one unsuppressed finding met the threshold. Drift always meets the threshold. |
2 |
The command could not complete, for example because an agent file could not be read or parsed, the policy was invalid, or check lacked a valid lockfile. |
For scan and check, --fail-on overrides fail_on in the policy. Both default to high. lock exits with code 0 after writing the lockfile, or code 2 if it cannot write a complete lock.
| Format | Contents |
|---|---|
terminal |
Inventory table, findings, and any errors. check also prints the lockfile diff. |
json |
Schema version 4 with artifacts, drift, errors, findings, suppressed, and policy_notes. |
sarif |
SARIF 2.1.0 for GitHub code scanning. High, medium, and low map to security-severity values of 8.0, 5.0, and 2.0. Suppressed findings are omitted. |
markdown |
A heading and a code block for the GitHub job summary and pull request comment. |
Each JSON finding has rule_id, severity, confidence, message, location, artifact_id, and fix. JSON artifacts include a content_hash. The report lists the keys of MCP server env and headers and settings env. It omits their values and the bodies of skills, rules files, and scripts.
ContextLock recognizes repository files for Claude Code, Codex, Cursor, GitHub Copilot, and VS Code, along with AGENTS.md. Find the exact patterns in the file registry.
| Kind | Paths |
|---|---|
| MCP servers | .mcp.json, .cursor/mcp.json, .vscode/mcp.json |
| Hooks | .claude/settings.json, .claude/settings.local.json, .codex/hooks.json, .cursor/hooks.json, .github/hooks/*.json |
| Settings | .claude/settings.json and .claude/settings.local.json for permissions, enableAllProjectMcpServers, and env |
| Scripts | Shell, PowerShell, Python, JavaScript, TypeScript, Ruby, Perl, and batch files under .claude/hooks/, .cursor/hooks/, .codex/hooks/, .github/hooks/, and the skill directories below |
| Skills | .claude/skills/*/SKILL.md at any depth, .agents/skills/*/SKILL.md, .cursor/skills/*/SKILL.md, .github/skills/*/SKILL.md |
| Rules files | AGENTS.md, CLAUDE.md, CLAUDE.local.md, .claude/rules/**/*.md, and .cursor/rules/**/*.mdc at any depth. At the root, also .claude/commands/**/*.md, .claude/agents/**/*.md, .cursorrules, .github/copilot-instructions.md, .github/instructions/**/*.instructions.md, .github/prompts/**/*.prompt.md, and .github/agents/**/*.md. |
In Git, the index determines which paths to consider. The scanner skips submodule contents and rejects split or sparse indexes. Outside Git, it looks for supported files under the supplied path and skips .git directories.
The scanner resolves symlinks through repository paths and reports matched files at their real paths. A dangling link, an absolute target, or a target outside the repository or inside a submodule causes an error at a supported agent file path. At other paths, the lockfile records a digest of each unresolved link's target, so adding or retargeting the link shows up in check. A working tree path that goes through a link Git does not record also causes an error.
An agent file larger than 2 MiB, encoded as something other than UTF-8, or invalid for its format causes a scan error.
The table lists each rule's default severity. Severity and confidence can vary by finding. The rules and their examples live in src/agentbom/rules/ and fixtures/.
| ID | What it checks | Default |
|---|---|---|
| ABOM-001 | Hidden Unicode, including tag, zero-width, and bidirectional characters | High |
| ABOM-002 | Commands that download and execute code | High |
| ABOM-003 | Reads of credential paths, such as SSH keys, cloud credentials, or .env files |
High |
| ABOM-004 | Commands that send file contents or environment variables to an external URL | High |
| ABOM-005 | MCP server launches from packages, images, or Git sources without an exact version | Medium |
| ABOM-006 | Files or definitions that differ from agentbom.lock during check |
High |
| ABOM-007 | Wildcard allowlists, permission-bypass modes, or auto-approve settings | Medium |
| ABOM-008 | Hooks that run commands from repository-controlled files | Medium |
| ABOM-009 | Instructions to ignore earlier instructions or hide actions from the user | Medium |
| ABOM-010 | Hard-coded tokens or secrets | High |
scan and check read agentbom.policy.yml from the repository root when it exists. Use --policy FILE to select another file.
version: 1
fail_on: high
allow:
mcp_servers:
- path: .mcp.json
name: docs
sha256: <content_hash>
skills:
- path: .claude/skills/release/SKILL.md
sha256: <content_hash>
ignore:
- rule: ABOM-005
path: .cursor/mcp.json
reason: Keep the shared test configuration during the package migration.
expires: 2027-03-01Use the content_hash from agentbom scan --format json to approve a specific MCP server or skill as reviewed. When that hash changes, the findings return.
An ignore applies to one rule at paths that match a Git ignore pattern. Each entry needs a reason and an expiry date. The entry applies through that date. A policy that ignores ABOM-006 is invalid.
JSON reports include suppressed findings under suppressed. Terminal reports show the count. Expired and unmatched exceptions appear as policy notes.
agentbom.lock records artifact definitions and a digest of each covered file. The definitions make changes to launch arguments, hook commands, and settings permissions readable in a diff. File digests also catch edits to comments and fields the scanner does not parse.
MCP server env and headers and settings env record their keys only. Skills, rules files, and scripts store a SHA-256 digest of the body. For a change to a body, review the source file diff.
Line ending changes between LF and CRLF and UTF-8 byte-order marks produce the same digest. With identical input, lock writes identical bytes. It writes a replacement file only after a complete scan. Hooks use their position in the configuration as part of their identity, so inserting one can show later hooks as changed. A scanner upgrade can also change how a definition is recorded.
| Input | Default | Meaning |
|---|---|---|
path |
. |
Repository root relative to the workspace |
command |
check |
Use scan to run the rules without a lockfile |
fail-on |
Empty | Overrides the policy threshold |
comment |
true |
Post or update the pull request comment |
sarif-file |
agentbom.sarif |
Path for the SARIF report relative to the workspace |
upload-sarif |
false |
Upload to code scanning. Requires security-events: write and a GitHub Code Security license on private repositories. |
github-token |
github.token |
Token for the pull request comment |
git clone https://github.com/Psionic-labs/contextlock.git
cd contextlock
uv sync
uv run agentbom scan .Report vulnerabilities in ContextLock through SECURITY.md. For findings in other repositories, follow the vulnerability disclosure policy.
Apache-2.0. LICENSE
