boundarycheck
Check that an API enforces the authorization boundaries you declare: tenant isolation, roles, hidden objects and field exposure. You write down who is allowed to see what (the policy); the tool replays read-only requests as each test user and compares what the API actually did with what your policy says it should do. Every result is one of seven honest states, and a failed or partial run can never look clean.
Status: v0.3.0, alpha. Live targets are read-only (
GET/HEAD): your own machine, or one declared remote host over verified HTTPS (see below). Write checks exist only against the built-in in-process lab. Use it only against systems you own or are explicitly authorized to assess. See SECURITY.md and LIMITATIONS.md.
What it does, and what it does not
| It checks | It does not |
|---|---|
| Cross-tenant reads (BOLA): can user A read tenant B's object? | Test writes on a live target: it sends GET/HEAD only, so a write-path flaw there is not detected |
| Role limits on read routes (BFLA): can a viewer reach an admin route? | Decide whether your policy is right: it judges the API against the policy you give it |
| Hidden objects: does a forbidden object answer exactly like a missing one? | Prove an API is secure: no_issue_observed means one request matched the policy, nothing more |
| Field exposure: does a response carry a field that role should not see? | Test timing channels, concurrency, rate limits or anything it was not told about |
List routes: does a list name objects the user may not see, or count them in total? |
Reach a remote host freely: a remote target must be declared completely, https only, one host, public addresses unless you list a private range (design) |
| Refused writes (fixture only): does a request the policy says must be refused still change a row, whatever status it returns? | Send a write the policy allows: that would test functionality, and it would change state |
Install
pipx install boundarycheck # or: uv tool install boundarycheck
boundarycheck --version # 0.3.0
Published on PyPI as boundarycheck through a protected
release workflow with signed provenance (docs/releasing.md). A PyPI install validates
configs, plans, and runs --transport live against loopback or one declared remote host; the fixture transport and the examples need
a source checkout, as in the next section.
Try it in two minutes (no network, no credentials)
The demo target is the tenant-boundary-lab: a small multi-tenant API with a patched and a deliberately vulnerable variant, served in process.
git clone --recurse-submodules https://github.com/MDPorsch/boundarycheck
cd boundarycheck
uv sync # needs uv (https://docs.astral.sh/uv/) and Python 3.13
uv run boundarycheck test --config examples/lab.yaml --transport fixture
Real output on the patched lab (419 cases: 240 reads, 81 refused writes, 98 concealment comparisons):
boundarycheck 0.3.0 | scope lab-demo | transport fixture:tenant-boundary-lab:patched
cases: no_issue_observed: 419, finding_candidate: 0, policy_denied: 0, not_run: 0, incomplete: 0, error: 0, inconclusive: 0 (total 419)
note: 7 write combination(s) that the policy allows were not exercised by design: write checks send only requests the policy says must be refused.
exit code 0. Note: no_issue_observed does not mean the target is secure.
Now break one control on purpose and watch it get caught (flags: TENANT_PREDICATE_OMITTED,
ROLE_CHECK_MISSING, PRIVATE_PROPERTY_SERIALIZED, MARKET_BOUNDARY_OMITTED,
WRITE_BEFORE_AUTHORIZATION):
uv run boundarycheck test --config examples/lab-vulnerable.yaml --transport fixture --fixture-flaws ROLE_CHECK_MISSING
cases: no_issue_observed: 281, finding_candidate: 5, ... (total 286)
FINDING BC-0067 BC-ROLE-01 [high] bob:contact.private.read:PA1: expected deny_forbidden (role_denied), observed allow (HTTP 200): access was granted where the policy denies it
FINDING BC-0076 BC-ROLE-01 [high] bob:project.write:PA1: expected deny_forbidden (role_denied), observed allow (HTTP 200): access was granted where the policy denies it; state changed: projects:... (modified)
...
exit code 1.
The fifth flaw is the interesting one: the lab writes first and then refuses, so every response is
the correct 403/404. A status-only runner calls it clean (try --reads-only: 249 clean, exit 0).
The state diff finds it:
uv run boundarycheck test --config examples/lab-vulnerable.yaml --transport fixture --fixture-flaws WRITE_BEFORE_AUTHORIZATION
cases: no_issue_observed: 265, finding_candidate: 21, ... (total 286)
FINDING BC-0076 BC-MUTATION-01 [high] bob:project.write:PA1: the request was not accepted (HTTP 403) but state changed: projects:... (modified)
...
exit code 1.
Use it on your own API
uv run boundarycheck init --output boundarycheck.yaml # an annotated starter, safe by default
$EDITOR boundarycheck.yaml # your tenants, test users, objects, routes and policy
uv run boundarycheck validate --config boundarycheck.yaml # schema + references + policy completeness. No network
uv run boundarycheck plan --config boundarycheck.yaml # prints every request. Sends nothing
export BC_TOKEN_ALICE=... BC_TOKEN_BOB=... # TEST users' tokens, read from the environment only
uv run boundarycheck test --config boundarycheck.yaml --transport live
uv run boundarycheck list-runs ; uv run boundarycheck report --run RUN_ID --format md
The config holds no secrets: a principal names where its credential comes from. The policy is the heart of
it, so write it from your requirements, not from the code under test.
examples/lab.yaml is a complete, commented example.
Start from an OpenAPI document
uv run boundarycheck import-openapi openapi.yaml --output boundarycheck.yaml
It writes a skeleton from the GET and HEAD operations: actions, resource kinds, response field names and a
credential scheme that follows the document's security scheme. It never writes your policy (that would be a
policy derived from the thing it judges), so every capability is [] and every field needs the top role: a run
before you edit it reports findings on purpose. It reads one local file, never fetches a URL, and never fills in a
remote address. The document is treated as untrusted input.
Credentials: bearer tokens, API keys, cookies, the OS keychain
principals:
alice: {credential: {env: BC_TOKEN_ALICE}} # Authorization: Bearer ...
bob: {credential: {env: BC_KEY_BOB, in: header, name: X-API-Key}} # an API key in a header
carol: {credential: {env: BC_SESSION_C, in: cookie, name: session}} # a session cookie
dave: {credential: {keychain: {username: dave@acme}}} # the macOS / Windows / Linux keychain
pipx install "boundarycheck[keychain]" # the optional extra
boundarycheck keychain set --username dave@acme # hidden prompt: the value never touches a file or the command line
Only real operating-system keychains are used (never a plaintext file). The tool never logs in for you: you supply the key or the session cookie of a test user. Keys in a query string are not supported (they end up in logs).
SARIF for your pipeline
Every run also writes report.sarif (SARIF 2.1.0) next to the JSON and Markdown reports;
boundarycheck report --run ID --format sarif prints it. Findings are results; anything that was not clean and is
not a finding is a notification, so a partial run never looks clean in a viewer. Use --sarif-uri path/in/repo.yaml
to point results at the config file as it appears in your repository. A SARIF file names your tenants, principals
and routes: do not upload it to a public repository's code scanning for client work.
A remote target (0.2.0)
uv run boundarycheck init --remote --output acme.yaml # one https host, an authorization block, safe defaults
$EDITOR acme.yaml # the host (twice), your engagement reference, when it ends
uv run boundarycheck preflight --config acme.yaml # resolves the name, judges every address, sends NO request
export BC_TOKEN_ALICE=... # TEST users' tokens, environment only
uv run boundarycheck test --config acme.yaml --transport live --ack-authorization
It talks to the one host you declared, over verified TLS, to public addresses only unless you list a private range, at 2 requests per second by default, and its report says the authorization is your declaration and was not verified. Read the design before using it.
Reading a result
| Status | Meaning |
|---|---|
no_issue_observed |
The response matched the declared policy. Not "secure". |
finding_candidate |
The response differed from the policy. A human reviews it (review_state: needs_review). |
inconclusive |
It ran but the answer cannot be mapped to a decision (for example HTTP 422, 429, 5xx, a non-JSON body). |
incomplete |
A timeout, connection failure or oversized response. |
policy_denied |
The tool refused to send it (budget exhausted, a redirect, a forbidden method or path). |
not_run |
Skipped for a stated reason, usually no credential for that user. |
error |
The tool itself failed (including a redaction failure). |
Exit code: 0 only if there is at least one case and every case is no_issue_observed; 1 if
any case is a finding_candidate; 2 for everything else (any other status, an unreadable config, a
usage error, a crash). Wire 0 into CI; treat 1 and 2 as red.
Two situations are worth knowing, and both are tested and documented rather than hidden:
- A wrong policy looks like a vulnerable API. The tool judges against the policy it was given.
Tell it that viewers may read private contacts and a correct API is reported as a (low-severity)
finding_candidate. That is why a finding is a candidate and, for a mismatch with the policy, confidence is neverhigh. The one exception isBC-MUTATION-01(a refused request that still changed state), which does not depend on the policy being right (D-B18). - An answer the tool cannot map is
inconclusive, never clean. The lab answers422for an id that is not a UUID; those cases areinconclusiveand the run exits2.
How it stays safe
- Loopback-only and read-only on a live target. Only
GET/HEAD, and never a request body: a write is sent only by the in-process fixture, only where the policy says it must be refused, and its effect is judged by a raw-SQL snapshot diff. The base URL must behttp://on127.0.0.0/8,::1orlocalhost. A name is resolved once, every address must be loopback, and the connection goes to the checked IP literal; the connected peer is verified again. Redirects are never followed, proxy variables are ignored, bodies are capped after decompression, and there is a timeout, a rate limit and a hard request budget. These are properties of the tool's own sockets. It cannot see where a loopback listener forwards: anssh -Ltunnel or a local proxy on127.0.0.1can still reach a remote host. Do not point it at one unless you are authorized for what is behind it. - A hostile config is parsed defensively. Size cap, no YAML tags, aliases, anchors, merge keys or duplicate keys, nesting cap, strict types, every identifier and path validated, only read methods.
- Credentials never touch disk or output. They are replaced in everything that is stored, and
before anything is written every credential used in the run is searched for in the report and the
evidence; if one is found nothing is written and the run exits
2. - Reports contain no response bodies: statuses, rule ids, the names of fields, and SHA-256
references to the redacted evidence. Run directories are
0700, files0600, a world-writable runs directory is refused, andpurge --older-thanbounds retention.
Documentation
- docs/contract.md: the behaviour the tests pin (oracle, comparator, transports, redaction).
- LIMITATIONS.md: what a clean run does not show. Read it before relying on a result.
- DECISIONS.md: choices and the reasons, including the ones awaiting the owner's confirmation.
- SECURITY.md, CONTRIBUTING.md, CHANGELOG.md.
Development
git clone --recurse-submodules https://github.com/MDPorsch/boundarycheck && cd boundarycheck
uv sync
uv run pytest -q # unit, negative, integration (against the lab) and packaging tests
uv run ruff check . && uv run ruff format --check . && uv run mypy
uv run python tools/mutation.py # optional, ~30 min: inject 145 security bugs, expect every one caught
uv run python tools/secret_scan.py # optional: gitleaks over all history + tree (brew install gitleaks)
The lab is a pinned git submodule at lab/, installed editable and for development only, so
installing boundarycheck never installs the lab and never installs the deliberately vulnerable variant.
A wheel install can validate configs, plan, and run --transport live; the fixture transport needs a
source checkout and says so clearly if it is missing.
Licence
Apache License 2.0 (NOTICE). The licence choice is recorded as D-B10 and was confirmed by the owner.
Metadata
Release files for boundarycheck 0.3.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 |
|---|---|---|---|---|
| boundarycheck-0.3.0.tar.gz | 71.2 kB | With provenance | Details for boundarycheck-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| boundarycheck-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for boundarycheck-0.3.0-py3-none-any.whl |
Total release size: 148.0 kB
Release files / boundarycheck-0.3.0.tar.gz
| Download URL | boundarycheck-0.3.0.tar.gz |
|---|---|
| Size | 71.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
25984b1cf53c6a2a4ab6a2aebd2379466cb0cb0bb9fecb8acd0350bd2de755c8
|
|
BLAKE2b-256 checksum How to use checksums |
bfe20d30455b3eceb2ba68e75b442c9d5dc8110d3bf04ac8c0dce43634b0458e
|
| 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 20, 2026.
Transparency logRelease files / boundarycheck-0.3.0-py3-none-any.whl
| Download URL | boundarycheck-0.3.0-py3-none-any.whl |
|---|---|
| Size | 76.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b031e5505d4a27e392a2f15b288b8cb9bffe66919bdad8ea6fbaf9288369d98d
|
|
BLAKE2b-256 checksum How to use checksums |
bcb12a3df47b85c914b5479841f3e2d375bff19b26d8b1885e634a26c52c59c1
|
| 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 20, 2026.
Transparency logSecurity for boundarycheck 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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for boundarycheck-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 20, 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.