Skip to content

feat(canary): local honeytoken decoys for credential reads (#293) - #491

Closed
im02-crypto wants to merge 2 commits into
blitzcrieg1:masterfrom
im02-crypto:canary-honeytokens
Closed

im02-crypto wants to merge 2 commits into
blitzcrieg1:masterfrom
im02-crypto:canary-honeytokens

Conversation

@im02-crypto

Copy link
Copy Markdown
Contributor

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 (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, --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

What and why

  • If this fixes an open issue, the PR body says Closes #N (or Refs #N if partial), so the issue closes on merge instead of going stale

Checks

  • python -m pytest -q and python -m ruff check agentmetry tests pass (from apps/orchestrator)
  • agentmetry benchmark still reports 0 missed and 0 false positives, if detection, hooks or ingest changed
  • No secrets, .env, or real trail data in the diff
  • Docs or CHANGELOG updated if behaviour changed

The detection ruleset is under a freeze: rules.py, traits.py, engine.py, mitre.py and
policies/detection/manifest.yaml are hashed into a published fingerprint. A change to any of
them is welcome as an issue first; CONTRIBUTING.md says why.

…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.
@im02-crypto im02-crypto changed the title feat(canary): local honeytoken decoys for credential reads (#293) feat(canary): local honeytoken decoys for credential reads (#293) Nov 26, 2026

@blitzcrieg1 blitzcrieg1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking on #293. The opt-in local approach fits the issue. I found three places that need revision before CI approval.

  1. 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.
  2. Please publish optional rules atomically and handle malformed or unreadable optional config without disrupting the built-in DLP rules.
  3. 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.

@blitzcrieg1

Copy link
Copy Markdown
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Local honeytokens: decoy credentials whose use is a near-certain finding

2 participants