Skip to main content
Change of provenance

The repository or configuration that created this release differ from a previous release. View details.

Weir

Catch your AI agent leaking API keys. Agent frameworks can copy keys into traces and logs, and coding agents can read them into the model's context. Weir finds each key by its exact value, names where it went, and never prints it.

  • The agents you build: plant fake keys where your real ones live, run the agent's own flows, and get a verdict for every place they reached: spans, logs, console output, the model, other services. Leak, clean or incomplete. It found CVE-2026-116691 (GHSA-j7qq-vr8c-xvw3) in MLflow.
  • The coding agent you use: in Claude Code, a status line shows which of your real keys entered the session or left in a tool call, and an optional hook strips known keys from tool results before the model reads them.

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"
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.

To check a credential swap or sandbox instead of your agent, weir-run verify --target iron-proxy runs a planted key through it and writes a record you can sign and check before a deployment: docs/verify.md.

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. If a run didn't exercise something, Weir says incomplete, not clean, and shows exactly what it checked. 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: CVE-2026-116691 (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.9.0

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

Change of provenance

The repository or configuration that created these release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Source distribution (sdist)

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

Built distribution (wheel)

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

Total release size: 644.3 kB

Release files / weir_scan-0.9.0.tar.gz

Change of provenance

This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Download URL weir_scan-0.9.0.tar.gz
Size 405.5 kB
Tags Source
SHA-256 checksum
How to use checksums
823d0c06235d5ee27f16fd52e39d718fce21da937fafec1fc0c1672ebae17665
BLAKE2b-256 checksum
How to use checksums
82fbb1ae79beb1136998f546ac5a398230ab9ff58e9b2d24098353ecabd05a82
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 Nov 8, 2026.

Transparency log

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

Change of provenance

This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Download URL weir_scan-0.9.0-py3-none-any.whl
Size 238.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6bed45efd543579d10a2c7872cc501a9af53ec60c55b744fc3bbbdc63587bd62
BLAKE2b-256 checksum
How to use checksums
77571b70bef112a65f2ea232a2dde05d8206bd96164012f643c583bd29811ddf
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 Nov 8, 2026.

Transparency log

Security for weir-scan 0.9.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.

Change of provenance

The repository and configuration that created this release differ from a previous release.

While this could reflect a routine change by the project maintainers, it may also indicate that the release files have been compromised.

Repository

Select from 2 files

Attestation for weir_scan-0.9.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 Nov 8, 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