Skip to main content

Weir

Leak tests for AI agents. Plant fake credentials where your real ones live, run your agent, and find every place it exposed them: its telemetry, the model it calls, or any other service.

CI PyPI License: Apache-2.0

Weir plants fake keys in your agent, lets its telemetry flow, and checks every span, log and metric for those exact values: leak, clean or incomplete.

Try it in 10 seconds

pip install weir-scan
weir canary judge --sample

Terminal recording: weir canary judge --sample prints a LEAK line naming the planted fake key and the span it reached, then "result: leak", and exits 1.

Two ways to use it

1. Test your agent, in CI or on your laptop

weir-run plants a unique fake key wherever a real one would live, runs your agent's own flows against a local fake model, and captures everything the agent sends out. weir canary judge then searches all of it for those exact values.

pip install weir-scan weir-run
weir-run run --config canary.toml
[[placement]]
id = "env.OPENAI_API_KEY"
kind = "env"
shape = "openai"
required = true
provider = "model"     # where this key is allowed to go

[[flow]]
id = "quickstart"
command = ["{python}", "examples/quickstart.py"]

In a pull request, one step runs it and posts the verdict as a comment:

- uses: IdoGol24/weir@<ref>

Config, pytest fixture and the full workflow: weir-run README · action README.

2. Watch your own Claude Code sessions

A status-line segment counts how many of your real credentials entered the session's context, and how many were sent out in a tool call. /weir explains each one: where it came from, the turn that moved it, where it sits now, and what to do. It never shows a value.

Setup can also add a redaction hook. When a Read, Bash, Grep, Glob or WebFetch result holds one of your inventoried keys as a whole value, in the forms weir audit matches, the hook replaces it with [weir: NAME removed] before the model sees it, and the status line counts it as kept out. Claude Code's hooks reference says this replacement "only changes what Claude sees". For a large output, such as a Bash output past about 30,000 characters, Claude Code also saves the whole output to a file in the session's folder and gives Claude its path (tools reference). That saved copy holds the original output, written before the hook runs, so the hook also rewrites it the same way, owner-only. If the hook fails, the status line says "possibly not redacted".

The weir segment beside an existing status line: a green check and "no known key seen", then a warning sign with "2 entered" in amber and "1 sent" in red.

uv tool install weir-scan     # or: pipx install weir-scan
weir statusline setup         # shows the change, applies it only when you type yes

weir statusline undo removes it. Linux and macOS. Details: docs/statusline.md.

Why it's different

  • It doesn't guess. It looks for the exact values it planted, raw or encoded, so a hit is a real leak.
  • It checks every way out: spans, logs, metrics, console output, prompts sent to the model, and requests to any other service. On Linux, where unprivileged user namespaces are allowed, the agent runs with no outside network, so a direct connection is caught too.
  • No false all-clear in the test rig. In a weir-run test, if something you marked required wasn't exercised, the result is "incomplete", never "clean". Exit codes: 0 clean, 1 leak, 2 unusable input, 3 incomplete.
  • Offline and deterministic. No AI model decides anything, and Weir itself sends nothing anywhere. Tests enforce both.

Found with Weir: GHSA-j7qq-vr8c-xvw3, an MLflow advisory, fixed in 3.17.0.

Limits

  • It finds whole values only, not hashed, split or truncated ones.
  • It sees only what the agent sends while the test runs.
  • Network isolation is Linux-only and needs unprivileged user namespaces. Elsewhere the report says the network wasn't isolated.
  • The fake model speaks the OpenAI-compatible and Anthropic Messages APIs.
  • The status line knows only the keys in your inventory, as whole values. A key that leaves inside a file or by its variable name isn't seen.
  • The inventory covers one project at a time.

The full lists are in docs/canary.md and docs/statusline.md.

The redaction hook:

  • It only changes what the model reads after a tool call. It can't undo a command that already ran, or catch a key pasted into the chat.
  • It matches your inventoried keys as whole values only. A key glued to other text, or inside a PDF, isn't removed.
  • When the hook can't finish, or a tool call fails, Claude Code passes the original output on. The status line then shows "possibly not redacted" or "entered", never green.

Full list: docs/statusline.md#the-redaction-hook

Also in the box

  • weir scan: follows sensitive data through traces you already have, for example from untrusted tool output to an outgoing email.
  • weir inventory: lists the credentials an agent could reach, by name only.
  • weir audit: checks your real credentials against saved agent sessions, offline.

FAQ

Does it need my real keys? No. Tests use fake values only. For the status line, Weir stores only keyed fingerprints of your real keys, never the keys themselves.

How is it different from gitleaks or trufflehog? They find strings that look like secrets in your code. Weir proves whether a specific value actually left through your agent. Use both.

Does it send anything anywhere? No. The fake model listens on 127.0.0.1 only and forwards nothing, and the scanner opens no network connections. Tests enforce both.

License

Apache-2.0, all of it, permanently. Nothing held back, nothing gated, nothing phoning home.

Why "weir"

A weir: a low dam across a river, with water flowing evenly over its crest
A weir is a low dam that measures a river's flow. The water keeps moving; the measurement happens anyway.
Damhead Weir, Water of Leith. Photo by 501ghost, Wikimedia Commons, CC0.

Metadata

Release files for weir-scan 0.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for weir-scan 0.8.0
File Size Uploaded Provenance Actions
weir_scan-0.8.0.tar.gz 397.2 kB With provenance Details for weir_scan-0.8.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for weir-scan 0.8.0
File Interpreter ABI Platform Actions
weir_scan-0.8.0-py3-none-any.whl Python 3 none any Details for weir_scan-0.8.0-py3-none-any.whl

Total release size: 632.5 kB

Release files / weir_scan-0.8.0.tar.gz

Download URL weir_scan-0.8.0.tar.gz
Size 397.2 kB
Tags Source
SHA-256 checksum
How to use checksums
263b141ac75fd55a96916aa977ad1e64f88b6e67212c1d2c101d475cce1549e0
BLAKE2b-256 checksum
How to use checksums
fe4b99199d9e4e8c7c90e671a265d3e5dd0354729932c412e59e8f08b785a22d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Release files / weir_scan-0.8.0-py3-none-any.whl

Download URL weir_scan-0.8.0-py3-none-any.whl
Size 235.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
de1280f7811ba51a5ead76c520fadea3818788ae0153bab067f933468930e6b9
BLAKE2b-256 checksum
How to use checksums
83d12e11e6403a100b7fa3413c4f610589c9c1a9d2e070fd25cce6253415f3b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Security for weir-scan 0.8.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for weir_scan-0.8.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page