Repository navigation
feat(canary): local honeytoken decoys for credential reads (#293) - #491
Closed
im02-crypto wants to merge 2 commits into
Closed
im02-crypto wants to merge 2 commits into
im02-crypto wants to merge 2 commits into
Conversation
…eg1#293) An opt-in `agentmetry canary` command plants decoy credentials whose use is a finding at the tool boundary, with nothing leaving the machine. - `core/canary.py`: plant / list / remove / forget. State and the generated DLP rules live under `~/.agentmetry/canary/`, so the packaged manifest stays unchanged and an opt-in feature never ships in the default ruleset. - `core/audit/dlp/loader.py`: merge `~/.agentmetry/canary/*.yaml` after the built-in manifest, and only when the directory exists. The hook reads this on every tool call (blitzcrieg1#171), so that path stays cheap. - `cli`: `agentmetry canary {plant,list,remove,forget}` with `--kind aws|env`, `--scope home|project`, `--project` and `--name`. - README: CLI Reference entry and the collected-test count. How the issue's constraints are held: - Local only: detection is a DLP regex over what the agent already submitted, so there is no callback and no network. - The trail records the rule id, never the value: the rule is anchored on the planted value and the scanner redacts matches like any other token. - Never overwrites a real credential: planting refuses when the profile or key already exists. - Reversible: `remove` deletes exactly what was appended and refuses when the file changed underneath it; `forget` drops bookkeeping for that case. - Off by default: nothing exists until the command runs. No frozen detection file is touched (rules.py, traits.py, engine.py, mitre.py, policies/detection/manifest.yaml). 9 new tests in tests/test_canary.py; full suite 2984 passed, 7 skipped. Closes blitzcrieg1#293
Adds docs/canary.md: why a planted value beats a guessed one, how to plant and remove, the five guarantees (local only, rule id not value, never overwrites, reversible, off by default), and the limits worth knowing (only while the recorder runs, not a filesystem tripwire, the values are recognisably fake on purpose). Links it from the README CLI Reference entry.
blitzcrieg1
reviewed
Nov 26, 2026
blitzcrieg1
left a comment
Owner
There was a problem hiding this comment.
Thanks for taking on #293. The opt-in local approach fits the issue. I found three places that need revision before CI approval.
- Please make plant and remove recover safely from partial writes. Plant currently appends to the target before saving state and the DLP rule. A failed save can leave a decoy that the CLI cannot track or remove. Removal also rewrites the entire credential file. Preserve unrelated bytes, detect intervening changes, and test that an interrupted write can be retried or reversed.
- Please publish optional rules atomically and handle malformed or unreadable optional config without disrupting the built-in DLP rules.
- Please add synthetic hook-level tests showing what a recorded file read can detect and what happens when a decoy value reaches captured tool arguments. An exact-value DLP rule sees the value only when it reaches scanned input. The hook and orchestrator scrubbers are separate paths, so test that the full value is absent from saved output.
Please keep the tests on isolated synthetic files and credentials.
Owner
|
Landed as rebased PR #496. The CI failure was two lint errors (S506 on the safe YAML loader, fixed with the same noqa loader.py uses; one unused import); design reviewed: local-only, never overwrites real credentials, values redacted from the trail, fully reversible. Thanks @im02-crypto, this addresses #293. |
blitzcrieg1
added a commit
that referenced
this pull request
Nov 26, 2026
* docs(canary): document the opt-in honeytoken command (#293) Adds docs/canary.md: why a planted value beats a guessed one, how to plant and remove, the five guarantees (local only, rule id not value, never overwrites, reversible, off by default), and the limits worth knowing (only while the recorder runs, not a filesystem tripwire, the values are recognisably fake on purpose). Links it from the README CLI Reference entry. * feat(canary): local honeytoken decoys for credential reads (#293) An opt-in `agentmetry canary` command plants decoy credentials whose use is a finding at the tool boundary, with nothing leaving the machine. - `core/canary.py`: plant / list / remove / forget. State and the generated DLP rules live under `~/.agentmetry/canary/`, so the packaged manifest stays unchanged and an opt-in feature never ships in the default ruleset. - `core/audit/dlp/loader.py`: merge `~/.agentmetry/canary/*.yaml` after the built-in manifest, and only when the directory exists. The hook reads this on every tool call (#171), so that path stays cheap. - `cli`: `agentmetry canary {plant,list,remove,forget}` with `--kind aws|env`, `--scope home|project`, `--project` and `--name`. - README: CLI Reference entry and the collected-test count. How the issue's constraints are held: - Local only: detection is a DLP regex over what the agent already submitted, so there is no callback and no network. - The trail records the rule id, never the value: the rule is anchored on the planted value and the scanner redacts matches like any other token. - Never overwrites a real credential: planting refuses when the profile or key already exists. - Reversible: `remove` deletes exactly what was appended and refuses when the file changed underneath it; `forget` drops bookkeeping for that case. - Off by default: nothing exists until the command runs. No frozen detection file is touched (rules.py, traits.py, engine.py, mitre.py, policies/detection/manifest.yaml). 9 new tests in tests/test_canary.py; full suite 2984 passed, 7 skipped. Closes #293 * docs: changelog entry for the canary honeytoken command (#293, #491) Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <[email protected]> --------- Co-authored-by: im02-crypto <[email protected]> Co-authored-by: Mistral Vibe <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An opt-in
agentmetry canarycommand plants decoy credentials whose use is a finding at the tool boundary, with nothing leaving the machine.core/canary.py: plant / list / remove / forget. State and the generated DLP rules live under~/.agentmetry/canary/, so the packaged manifest stays unchanged and an opt-in feature never ships in the default ruleset.core/audit/dlp/loader.py: merge~/.agentmetry/canary/*.yamlafter the built-in manifest, and only when the directory exists. The hook reads this on every tool call (hooks: the hook costs 730ms, and 210ms of it is importing pydantic to read env vars #171), so that path stays cheap.cli:agentmetry canary {plant,list,remove,forget}with--kind aws|env,--scope home|project,--projectand--name.How the issue's constraints are held:
removedeletes exactly what was appended and refuses when the file changed underneath it;forgetdrops bookkeeping for that case.No frozen detection file is touched (rules.py, traits.py, engine.py, mitre.py, policies/detection/manifest.yaml).
9 new tests in tests/test_canary.py; full suite 2984 passed, 7 skipped.
Closes #293
What and why
Closes #N(orRefs #Nif partial), so the issue closes on merge instead of going staleChecks
python -m pytest -qandpython -m ruff check agentmetry testspass (fromapps/orchestrator)agentmetry benchmarkstill reports 0 missed and 0 false positives, if detection, hooks or ingest changed.env, or real trail data in the diffThe detection ruleset is under a freeze:
rules.py,traits.py,engine.py,mitre.pyandpolicies/detection/manifest.yamlare hashed into a published fingerprint. A change to any ofthem is welcome as an issue first; CONTRIBUTING.md says why.