Weir
Leak tests for AI agents.
Plant fake credentials where your real ones live, run your agent, and find out exactly where they ended up, before a real key does.
pip install weir-scan
weir canary judge --sample
How it works
Weir is two packages that work together, in CI or on your laptop:
- weir-run is the test rig. It plants a unique fake credential wherever a real one would live, runs your agent's own flows against a fake model on 127.0.0.1, and captures everything the agent exports.
- weir-scan is the inspector. It reads that capture and gives the verdict: leak, clean or incomplete. It also works on its own, on traces you already have.
pip install weir-scan weir-run
Who it's for
- Teams building agents: run it in CI on every dependency update. A framework or tracing upgrade that starts writing keys into telemetry fails the build, like a regression test for leaks.
- Framework and tracing maintainers: run it before each release, so the next advisory isn't about you.
Why it's different
- It doesn't guess. It looks for the exact values it planted, so a hit is a real leak, and a key is found even when it doesn't look like a key, raw or encoded.
- Offline and deterministic. No AI model decides anything, and Weir sends nothing anywhere. The scanner opens no sockets and starts no processes, and CI enforces that.
- No false all-clear. If a run didn't exercise something you marked required, Weir says "incomplete", not "clean", and shows exactly what it checked. Exit codes: 0 clean, 1 leak, 2 unusable input, 3 incomplete.
Proof
Found with Weir: GHSA-j7qq-vr8c-xvw3, an MLflow advisory, fixed in MLflow 3.17.0.
Try it on your own agent
The sample is a bundled fake ledger and capture with one planted value in a span attribute, so the check exits 1 and prints its leak report. It names the placement and the span, never the value:
LEAK env.SAMPLE_SERVICE_KEY file=canary-sample/otlp.jsonl:1 signal=traces span="call_service" at=attributes.app.client.config form=raw
coverage: 2 placements (1 leaked, 1 exercised, 0 not exercised, 1 required), 1 flows (1 ok), 1 files, 3 spans, 0 log records, 0 metric data points, 29 strings, 1347 bytes swept
result: leak
On your own agent:
weir-run run --config canary.toml
The config names where your credentials live and which flows to run. The weir-run README covers the config, the fake model, a canary_check pytest fixture and a demo. The judge's contract, including every encoding it matches, is docs/canary.md.
Also included: the flow scan and weir inventory (experimental)
The flow scan
weir scan reads the OpenTelemetry traces your agent already emits and fails the build when sensitive data travels to a place it should never reach, for example a bank account number from untrusted tool output that ends up in an outgoing email. It rebuilds the session step by step from the trace, follows the data, and prints the source, the destination and every step in between.
weir gauge your-export.jsonl # or: weir gauge --sample
weir scan your-export.jsonl
Most exports cannot support this yet, because content capture ships off by default almost everywhere. weir gauge measures how much of your trace the scan can actually see, and names the exact setting to switch on, read from the instrumentation in your own trace. The scan also reports any provider key pattern it finds sitting in a span, with no flow needed.
Each check is a rule, and a rule is a short JSON file naming a source, a destination and a match mode (bundled rules). Rewording prompts or adding a step does not change the result. When the trace evidence is too weak to prove a flow, the finding stays in the report, marked as not proven and saying why, instead of quietly disappearing.
weir scan exits 0 when nothing fails, 1 on a finding and 2 on unusable input.
weir inventory (experimental)
weir inventory --home DIR lists the credentials an agent could reach: standard credential files, project files (with imported gitleaks or trufflehog results), the launch environment and shell startup files, and the approved map .weir/reach.yml. It reports them by name, source and location only. It never prints, logs or stores a value; what it can store is a keyed fingerprint plus offsets (contract). Its output and JSON schema may change without notice.
Why you can trust it
- It searches for what it planted. A hit is a planted value found in the capture, never a pattern guess, and the judge's output depends only on where values appear, never on what they are.
- Nothing phoning home: a test, not a promise. The analysis path opens no sockets. The whole test suite runs with socket creation blocked (tests/_harness/g3.py), and packages/weir/tests/test_canary_judge.py fails if the judge opens a socket or starts a process.
- Nothing Weir prints is a credential. The judge names placements and locations, never a value or a fragment of one. No rendered weir output (text, gauge, HTML, ledger) contains a credential-shaped value; that is a test over every fixture in the corpus.
- It reads real traces, not only ones we wrote. The suite pins a frozen capture that no weir code ever touched (provenance). Malformed input is reported under one of a fixed list of named cases; it never guesses (contract).
- Attacker text cannot fake a flow. The flow scan fails the build only on links between steps that the instrumentation itself records. A flow that rests on a link inferred from matching text is reported, but never fails the build. Getting past that is a security bug (SECURITY.md).
- Claims about other people's software are sourced and dated (REMEDIATION_SOURCES.md).
FAQ
Why not just use SecretStr or redact in the collector? Redaction is worth doing. Weir checks whether it worked: it searches the exported output for the exact planted values, whatever path they took to get there.
How is this different from gitleaks or trufflehog? They find strings that look like secrets in code and files. Weir proves whether a value you planted reached your telemetry, in any of the encodings docs/canary.md lists. It does not replace them.
Does it need my real keys? No. It uses fake values by design, and a real key should never be in a run.
Does it send anything anywhere?
No. The analysis opens no sockets, and a test enforces it. The rig's fake model listens on 127.0.0.1 only and refuses every proxied request to another host.
Which frameworks? Any that can export OpenTelemetry spans to a file.
Honest limits
A clean result is evidence about the flows that ran and the credentials planted, not a statement that the program is safe.
- It finds whole values only. A truncated, split or partly masked value, a hashed, encrypted or compressed one, and encodings beyond those docs/canary.md lists (URL-encoded base64, UTF-16, line-wrapped base64) are not matched.
- It sees only telemetry that reached the capture.
- This release plants environment variables, values passed in code, and OAuth tokens. Model APIs must be OpenAI-compatible.
- The rig does not sandbox the network. A client that ignores the proxy settings and has a hard-coded host can reach that host directly; run such flows in a container or network namespace with no route out.
- The flow scan needs content capture switched on in your instrumentation;
weir gaugetells you whether it is.
License
Apache-2.0, all of it, permanently. Nothing held back, nothing gated, nothing phoning home.
Install weir-scan; the import and the command are both weir.
Why "weir"
A weir is a low dam built across a river to regulate and measure its
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.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| weir_scan-0.5.0.tar.gz | 239.6 kB | With provenance | Details for weir_scan-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| weir_scan-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for weir_scan-0.5.0-py3-none-any.whl |
Total release size: 403.2 kB
Release files / weir_scan-0.5.0.tar.gz
| Download URL | weir_scan-0.5.0.tar.gz |
|---|---|
| Size | 239.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3166efb2a904c4be203e8caaeb876a1e841c804415e7382fccb34285518b7d85
|
|
BLAKE2b-256 checksum How to use checksums |
48ab7ef384e1c5bf448cef3e7379fdfd25ea3285cd9eaec1b863794c2776c48a
|
| 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 21, 2026.
Transparency logRelease files / weir_scan-0.5.0-py3-none-any.whl
| Download URL | weir_scan-0.5.0-py3-none-any.whl |
|---|---|
| Size | 163.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
67e5adb4daebf309b8ac88e5ee08a9d094a011de358e4b6a4170cca63d51fe84
|
|
BLAKE2b-256 checksum How to use checksums |
e66b52d1505f80e8d843c10be0c1ab52d2222e2273560f9a9167d81d80156e5a
|
| 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 21, 2026.
Transparency logSecurity for weir-scan 0.5.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.
Attestation for weir_scan-0.5.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 21, 2026.
Transparency logA 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.