The repository or configuration that created this release differ from a previous release. View details.
weir-run
The canary runner checks whether a program exposes the credentials it
holds to a place outside your control: its telemetry, its console output,
the model provider (prompts and messages) or any other service or host. It
plants a unique fake credential (a canary) wherever a real one would live,
runs the program's own example flows against a local mock that records
every request and exports telemetry to a file, and asks weir canary judge one question: did any planted value reach the capture, or a request
to anything but its own provider? Because the runner knows every value it
planted, the answer is an exact match in seven encoded forms, not a
pattern guess.
Its contract, and the judge's, is weir's
docs/canary.md.
This page is for the maintainer who adds the check to a project's CI.
The pieces
weir-run run --config canary.toml
1. plant one fresh fake value per placement -> ledger (mode 0600, private temp dir)
2. mock 127.0.0.1 only: OpenAI-compatible and Anthropic Messages model API,
OAuth endpoints, OTLP/HTTP receiver, your project's own APIs;
refuses every proxied request to another host
3. flows each under an empty environment plus an allowlist, URLs pointed at the mock,
in a network namespace whose only network is loopback (Linux)
4. capture OTLP/JSON lines + other telemetry bodies + each flow's stdout and stderr
+ every request the mock received, refused ones included
5. judge weir canary judge (weir-scan: opens no socket, starts no process)
6. delete the ledger and the capture
exit 0 clean and complete | 1 a canary leaked | 2 usage, input or runner error | 3 incomplete
- The judge is weir-scan's, called only through its command line. The
runner never imports weir, and weir never imports the runner (both are
import-linter contracts in the repository's
pyproject.toml). The runner requires weir-scan 0.6.0 or later, the first release whoseweir canary judgereads the ledger'snetworkanddirectrecords and takes--requests(the request sink); without a judge it exits 2 before running anything. - Local and offline. The mock binds
127.0.0.1on a port the OS picks; there is no option to bind anything else. Every flow gets the mock as its HTTP and HTTPS proxy, and the mock refuses every proxied request: aCONNECTor an absolute-URL request for any other host gets a 403, and nothing is forwarded, opened or resolved. On Linux every flow also runs in a network namespace with no route out, so a client that ignores proxy settings reaches nothing either (see Network isolation). - Test-time only. The runner is a dependency of your CI job, never of your program. The mock and the receiver exist only for one run.
Checking a credential swap
weir-run verify --target iron-proxy checks a proxy or
sandbox that holds a key on an agent's behalf, instead of your own flows,
and writes an evidence record that can be signed and checked before a
deployment. See
docs/verify.md.
Fake data only
- Every value in a run is generated by the runner: the canaries it plants
and the tokens its OAuth endpoints issue. Never put a real credential in
a config, a flow's
envor anywhere a flow reads it. - Never point a flow at a real provider. Every API a flow calls must be the
mock: the model API through
OPENAI_BASE_URLorANTHROPIC_BASE_URL, your project's own APIs through[[mock.endpoint]], OAuth through the mock's endpoints. - The ledger and the capture are deleted when the run ends. Do not copy them anywhere, and never commit one: a provider-shaped canary in a public repository is reported to the provider as a leaked key. Only the value-free report may be kept, for example as a CI artifact.
- In a CI job, check out with
persist-credentials: falseso the job token is not in the checkout a flow can read.
Try the demo
The demo is one synthetic agent flow, standard library only: it gets an
OAuth token, asks the model (which calls its web_search tool), calls the
search API, sends the result back, and exports its spans over OTLP/HTTP.
weir-run run --config demo/canary.toml # exits 0
weir-run run --config demo/canary-leak.toml # exits 1
canary-leak.toml differs only in DEMO_LEAK = "1", which makes the flow
record its search key and its HTTP Basic client credentials as span
attributes, put its request headers (with the access token) in a JSON
string attribute, and print the search key in a debug line. The run
reports each as a LEAK line by placement, file, line and form, and the
relayed debug line reads debug: search key <canary:env.SEARCH_API_KEY>.
The config
[mock]
oauth = true # serve the OAuth endpoints (default false)
model_reply = "Done." # the model's final answer
tool_calls = "each-offered-tool-once" # or "none"
[mock.credential_fields] # extra credential fields of built-in endpoints
model = ["header:api-key"] # endpoints: model, oauth, otlp (otlp: header and query only)
# model always has header:x-api-key, the Anthropic key header
[[mock.endpoint]] # one of your project's own APIs
id = "search" # served at {mock}/ep/search/...
credential_fields = ["header:x-api-key", "query:api_key", "body:api_key"]
status = 200
reply = '{"results": []}'
content_type = "application/json"
capture = false # true: keep request bodies as capture files
[[placement]]
id = "env.SEARCH_API_KEY" # the variable is the id after "env."
kind = "env" # env | code
shape = "generic" # see Shapes
provider = "search" # the mocked endpoint it belongs to: model, oauth, otlp or an endpoint id
provider_host = "api.search.example" # its real host: a refused attempt to reach it is evidence
[[placement]]
id = "code.client.api_key"
kind = "code"
variable = "MY_VARIABLE" # the flow reads this; omit it for CANARY_CODE_CLIENT_API_KEY
provider = "model" # passed to the model client, so it belongs to the model API
[[placement]]
id = "env.BACKUP_API_KEY"
kind = "env"
provider = "search"
required = false # a fallback only some flows read: not exercised does not make the run incomplete
[[flow]]
id = "quickstart"
command = ["{python}", "examples/quickstart.py"] # {python}: the runner's interpreter
cwd = "." # relative to this file
timeout_seconds = 300
env = { SEARCH_BASE_URL = "{mock}/ep/search" } # non-secret settings; {mock} is the mock
skip = "needs a GPU" # optional: recorded as skipped, which is incomplete
Unknown tables and keys are errors (exit 2), so a typo cannot silently
drop a placement. Ids follow the contract's id rule (1 to 128 characters
from [A-Za-z0-9._:#/-]) and are unique.
Placements
This release plants two kinds and mints a third (docs/canary.md, "Placements and kinds"):
| kind | where the canary lives |
|---|---|
env |
the flow's environment, under the variable your software reads |
code |
a variable the runner names; the flow reads it and passes it explicitly to a constructor or call |
mock-oauth |
every authorization code, device code, access, refresh and ID token the mock's OAuth endpoints issue, as runtime.oauth.<token>#<n>; nothing to configure |
Shapes
A canary is a provider's prefix followed by random [A-Za-z0-9], so
software that checks a key's prefix or length accepts it. Each provider
shape matches the key pattern weir's catalog judges that provider's keys
by. No value ever contains FAKE, TEST, EXAMPLE, DEMO,
PLACEHOLDER or REDACTED, in any letter case.
| shape | prefix and body |
|---|---|
generic |
40 characters, no prefix |
openai |
sk-proj- + 48 |
anthropic |
sk-ant-api03- + 93 |
github |
ghp_ + 36 |
google |
AIza + 35 |
aws-access-key-id |
AKIA + 16 of [A-Z0-9] |
Values come from the CSPRNG, fresh each run. --seed N swaps in a
deterministic stream for reproducing a run locally; never use it in CI.
What a flow receives
A flow starts from an empty environment, not the job's, and gets exactly:
| variables | value |
|---|---|
PATH |
the runner's PATH |
HOME, TMPDIR, TEMP, TMP |
a fresh private directory per flow (USERPROFILE too on Windows) |
LANG, PYTHONUTF8 |
C.UTF-8, 1 |
SYSTEMROOT, PATHEXT |
Windows only, from the runner |
CANARY_MOCK_URL |
the mock's base URL, http://127.0.0.1:<port> |
OPENAI_BASE_URL, OPENAI_API_BASE |
<mock>/v1 |
ANTHROPIC_BASE_URL |
<mock>: the Anthropic SDKs add /v1/messages themselves |
OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_{TRACES,LOGS,METRICS}_ENDPOINT |
the mock's receiver |
OTEL_EXPORTER_OTLP_PROTOCOL and the per-signal ones |
http/protobuf |
HTTP_PROXY, HTTPS_PROXY, ALL_PROXY (both cases) |
the mock, which refuses |
NO_PROXY, no_proxy |
127.0.0.1,localhost |
| each placement's variable | its canary |
the flow's env |
as written, {mock} replaced |
A real provider key in your CI secrets never reaches a flow. A flow's leftover child processes are stopped when the flow ends.
The mock
| path | what it is |
|---|---|
POST /v1/chat/completions |
Chat Completions, plain and streaming. With tools offered, turn one calls every tool once with a minimal schema-valid argument, so each tool's credentials are exercised; once tool results are in the conversation it answers model_reply |
POST /v1/responses |
Responses, plain and streaming, same script |
POST /v1/messages |
the Anthropic Messages API, plain and streaming (message_start, ping, content_block_start, content_block_delta, content_block_stop, message_delta, message_stop), same script: turn one answers with a tool_use block for every offered tool, and once the last user message carries tool_result blocks it answers model_reply. A query such as ?beta=true, body fields it does not know and system entries between turns are accepted. The key goes in x-api-key |
HEAD, GET /api/hello |
a connectivity check on the model API's base URL: 200 |
POST /v1/embeddings, GET /v1/models |
fixed answers |
POST /v1/traces, /v1/logs, /v1/metrics |
the OTLP/HTTP receiver: protobuf or JSON, gzip or deflate |
GET /oauth/authorize |
redirects with a fresh code |
POST /oauth/token |
authorization code, refresh token, password, device code, client credentials, token exchange and JWT bearer grants; a refresh token where the grant usually has one, an ID token when the scope holds openid |
POST /oauth/device_authorization |
a fresh device code; the user code is not a credential |
GET /.well-known/openid-configuration |
discovery metadata pointing at the mock |
/ep/<id>/... |
a configured endpoint: its fixed reply |
Every supported grant succeeds, whatever it presents. The OAuth paths exist only with oauth = true.
Anything else is answered 404 and listed after the run.
Requests are a sink. The mock records every request it receives, a
refused one included, in capture/requests.jsonl: destination, method,
path, query, headers and body. The judge searches each request for every
canary and decides by the placement's own provider (provider and
provider_host above):
- in a credential field of a request to its own provider (its auth headers and the fields the endpoint declares), a canary is evidence that it was exercised, as a key in its own API's auth header should be;
- anywhere else it is a
LEAKnaming the sink and the field, for examplesink="model" at=body.messages[0].contentfor a key pasted into a prompt,sink="search"for a key sent to the wrong one of your APIs, orsink="collector.example (blocked)"for a key in a plain-HTTP request to another host; - a refused HTTPS
CONNECTcarries no visible content: it is listed asblocked connection: <host>:<port>and counted in the coverage, never a leak by itself.
A placement with neither a provider nor a provider_host belongs in no
request, so any request that holds it is a leak, and the runner says so
before any flow runs:
placement <id> has no provider: any request holding it counts as a leak.
A token the mock's OAuth endpoints issue belongs to those endpoints and to
every [[mock.endpoint]].
Credential fields. Before any of these handles a request, the mock
inspects its credential fields: the whole Authorization and
Proxy-Authorization headers on every mocked endpoint, each endpoint's
declared fields, the model API's x-api-key header (the Anthropic
Messages API's key),
and on the OAuth endpoints the form fields client_secret,
client_assertion, assertion, code, device_code, refresh_token,
subject_token, actor_token and password. A field holding a canary in
any encoded form (a Basic credential included) is accounted for, and the
judge attributes it from the request capture. Any other non-empty value is
recorded as unexpected.<endpoint>.<field>#<n>, never in the ledger, and
makes the run incomplete: a flow that sends a credential no canary
accounts for has left the check's premise.
The capture. The receiver writes each export request decompressed, as
one OTLP/JSON line (trace and span ids in lowercase hex), under
capture/otlp/; its headers go to the request capture only. A body it
cannot decode is kept as its own capture file and a marker line makes the
run incomplete. Request bodies of an endpoint with capture = true and
each flow's stdout and stderr are swept capture files.
Network isolation
On Linux, the runner runs the mock and every flow in an unprivileged user
and network namespace (what unshare --user --net makes) whose only
interface is loopback. The mock listens on 127.0.0.1 inside it, so flows
reach it as before, and nothing has a route to any other host. A flow
holds no capability in the namespace, so it cannot add one.
Every other address is routed to the namespace's own loopback, so a client that ignores the proxy settings fails at once (connection refused, or a failed name lookup) instead of hanging, and the runner sees the attempt:
| observed | reported as |
|---|---|
| a TCP connection opened to any address but loopback | tcp, the address and port |
| a UDP datagram sent to any address but loopback | udp, the address and port |
| a DNS query sent to any address, loopback included | dns, the name asked for |
Each distinct attempt makes the run incomplete, as
incomplete: direct_connection <flow>=<protocol>:<target>: isolation
stopped it, but what it would have sent was never seen. The runner's
output lists them as network: blocked direct ... lines. A blocked
datagram's payload, a DNS query included, is a swept capture file, so a
canary in it is a LEAK like any other.
Not observed: traffic on loopback, which never leaves; a name lookup made through a host service over a Unix socket, such as systemd-resolved's NSS module or nscd, which happens outside the namespace (the connection that follows is still blocked and reported); an IPv6 attempt where the kernel has IPv6 disabled, which fails with no packet; Unix-socket traffic to a host service such as a Docker socket; anything a process the flow detached does after the run.
Where the namespace cannot be made (not Linux; unprivileged user
namespaces disabled or restricted, as Ubuntu's
kernel.apparmor_restrict_unprivileged_userns=1 does), the run goes ahead
as before, the runner's output says network: not isolated (<why>), and
the report carries:
network not isolated: direct connections were not observed
| option | weir-run run |
pytest |
|---|---|---|
an unisolated run is incomplete (exit 3, incomplete: network_not_isolated) |
--require-isolation |
--canary-require-isolation |
Use --require-isolation in CI on Linux. A found leak still exits 1. A
flow that needs the host's network (installing packages, a database on the
host's loopback) does not work isolated: install first, or mock the
service. On a GitHub-hosted Ubuntu runner, allow unprivileged user
namespaces first:
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
Output
- stderr: first, one line for each placement with neither a
providernor aprovider_host; then each flow's status and its own stdout and stderr, relayed after the run with every encoded form of every canary replaced by<canary:PLACEMENT-ID>; whether the network was isolated, and each blocked direct attempt; refused egress and unmocked requests by count. - stdout: the judge's text report: one
LEAKline per hit, the not-exercised placements, the blocked destinations, the incomplete reasons, the coverage line, the network line and the result. It names placements, locations and sinks, never a value or a fragment of one. --report FILEalso writes the judge'scanary-report/1JSON.- The exit code is the judge's, or 2 for the runner's own usage and
configuration errors and any other failure of the run (an unwritable
--report, a judge that times out). A runner fault never exits 1.
A clean result is evidence about the flows that ran and the placements
planted, not a statement that the program is safe. Read the coverage line:
a placement no flow exercised is printed as not exercised, and makes the
run incomplete unless it sets required = false.
The pytest plugin
Installing the runner registers a canary_check fixture (subprocess mode):
def test_quickstart_exports_no_credentials(canary_check):
canary_check.mock(oauth=True)
search = canary_check.endpoint("search", credential_fields=["header:x-api-key"])
canary_check.env("SEARCH_API_KEY", provider="search")
variable = canary_check.code("code.client.api_key", provider="oauth")
canary_check.run(["{python}", "examples/quickstart.py"], env={"SEARCH_BASE_URL": search})
# teardown judges; the test fails on a leak or an incomplete run
Declare the mock and the endpoints, then the placements that name them as
their provider, first; the first run
plants the canaries and starts the mock. At teardown the plugin judges,
prints the redacted flow output and the report, deletes the ledger and the
capture, and fails the test unless the result is clean. To assert on the
result yourself, call result = canary_check.judge() (result.code,
result.report). The judge is the weir beside the interpreter or on
PATH; override the canary_judge_command fixture to use another. Flows
run isolated as under weir-run run; --canary-require-isolation is the
pytest option (see Network isolation).
Limits of this release
- Placements:
env,codeandmock-oauthonly. The other kinds in the contract (tool-field,mcp,settings-fileand the rest) are reserved. - Model APIs: OpenAI-compatible or Anthropic Messages API. Of the
Messages API,
POST /v1/messagesonly (no token counting, batches or files). - Network isolation is Linux only. Elsewhere, a client that ignores proxy
settings and has a hard-coded host is not stopped by the runner: on a
machine with network access it connects to that host directly. Run such
flows in a container with no route out, and use
--require-isolationwhere a run must not pass unisolated. - No in-process pytest mode yet. In GitHub Actions, the Weir action runs a config and posts the verdict on the pull request.
Metadata
Release files for weir-run 0.3.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)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| weir_run-0.3.0.tar.gz | 112.4 kB | With provenance | Details for weir_run-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| weir_run-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for weir_run-0.3.0-py3-none-any.whl |
Total release size: 180.5 kB
Release files / weir_run-0.3.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_run-0.3.0.tar.gz |
|---|---|
| Size | 112.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8c64e656fdfd7fd572423e4a7f0b3a99c02d4fba26cf986a80ba18e1df18e4f9
|
|
BLAKE2b-256 checksum How to use checksums |
8d15199e786b0d860c642d205bbdb11fbc421c6b8a44943d24574aeb5fc93e82
|
| 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 logRelease files / weir_run-0.3.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_run-0.3.0-py3-none-any.whl |
|---|---|
| Size | 68.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
99b678fd1da821e5f557e162363bcfc317f15db8b66805ebe0394014cc10e396
|
|
BLAKE2b-256 checksum How to use checksums |
7367f02894ec31a0ce8625d4d415bda99a3214719f52cb74af319360f17eed9a
|
| 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 logSecurity for weir-run 0.3.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
- Removed 0.2.1 github.com/IdoGol24/weir
- Added 0.3.0 github.com/ralis-ai/weir
Attestation for weir_run-0.3.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 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.