Skip to main content

GrantTrace

CI PyPI Python License

English | 简体中文

Evidence-driven, read-only authorization testing for OpenAPI APIs.

GrantTrace reads your OpenAPI specification, requests the same resources as an Owner, a Visitor and an Anonymous identity, and compares what each of them gets back. It reports BOLA / IDOR and related authorization flaws only when the responses prove them and plans every request offline first. Against your API it sends GET requests, plus query-style POSTs only where you declare them read-only; it never sends PATCH, PUT or DELETE.

GrantTrace HTML report: summary, coverage and per-endpoint results
python -m pip install granttrace
granttrace demo     # a disposable local API; no configuration or credentials needed

The demo starts a throwaway API on 127.0.0.1 with fictional data, finds the BOLA and the mass assignment flaw planted in it, restores its data, stops, and writes an HTML and a JSON report. These are the demo's own test flaws, not results from a real API. A sample report from the demo is in the repository; GitHub shows its HTML source, so download the raw file and open it in a browser.

Why GrantTrace

  • Evidence, not status codes. A BOLA finding is CONFIRMED only when the Owner's own request returns a valid response, the Anonymous request is explicitly denied, and the Visitor's response contains concrete values or identifiers from the Owner's resource. Weaker signals are reported as SUSPICIOUS or INCONCLUSIVE, never as vulnerabilities.
  • Safe by default. Scans are read-only. GET operations whose paths, identifiers or descriptions suggest side effects are skipped before any request, and writes against external targets are refused.
  • Read-only POST, only when you vouch for it. A query-style POST (search, lookup, query...) is compared across identities only after you declare read_only: true and give the request body. Its path, operationId or summary must name a read action and must not name a mutation; otherwise nothing is sent. These checks reduce risk but cannot prove a POST has no side effects.
  • Sensitive-field leads. With detect_sensitive_exposure, unmasked sensitive-looking Owner fields (phone, salary, credentials...) that reach the Visitor are reported as leads. They are confirmed only on top of a confirmed object-level finding and never from a field name alone.
  • Role matrix. Optional identities.roles are probed on operations with a required_role. A lower role is a violation only when it receives the privileged baseline's configured protected data, not merely an HTTP 200.
  • Plan before you send. --init-config drafts a configuration and a review checklist from the specification, --validate-config checks it offline, and --dry-run shows what would be requested while sending nothing.
  • Reports people can act on. Each result explains what was compared; each confirmed finding comes with remediation, retest steps, a cURL template and minimized evidence. Credentials are redacted unless you opt in with --include-sensitive-evidence. JSON serves automation and SARIF serves code scanning.
  • Honest coverage. Reports show attempted and conclusive coverage separately. No confirmed findings does not mean an API is secure.

What it checks

Check CWE How it runs What you configure
BOLA / IDOR CWE-639 Read-only, as Owner, Visitor and Anonymous Two test accounts and a resource each of them owns
Broken Authentication CWE-306 Read-only, on operations the specification protects private_data_paths: Owner values Anonymous must not see
Broken Function Level Authorization CWE-285 Read-only The required role and each identity's role
Role matrix (RBAC) CWE-285 Read-only, one request per configured role identities.roles, required_role and private_data_paths
BOLA on query-style POST CWE-639 Declared read_only: true POST with a read action in its name The request body (or identity_bodies)
Private data in collections CWE-639 Read-only, on list endpoints private_data_paths
Property-level authorization (BOPLA) CWE-200 Read-only Per-field rules in bopla; detect_sensitive_exposure adds heuristic leads
Mass Assignment CWE-915 Built-in demo only –

Mass assignment testing writes to a resource, so GrantTrace only does it when it can verify the resource's actual state and restore it. It cannot observe that state for an external API, so PATCH and PUT checks against your target stop before any write; the built-in demo, which owns its data, shows the complete flow with independent readback and verified rollback.

Not supported yet: GraphQL and gRPC; OAuth, OIDC or mTLS login flows (configure tokens or headers yourself); API keys in the query string; POST other than declared read-only queries; DELETE tests; writes against external APIs.

Install

  • Python 3.9+ on macOS, Linux or Windows: python -m pip install granttrace
  • Windows without Python: download GrantTrace-v<version>-Windows-x64.zip from the latest release, unzip the whole archive and double-click Start-Demo.bat. The program is not code-signed yet, so SmartScreen may warn about it; check the download against the release's SHA256SUMS.txt. See Windows portable.

This README describes the main branch; the changelog lists what each release contains.

Audit your own API

Use a test environment you are authorized to test, two test accounts, and resources each of them owns. Steps 1 to 4 only touch local files. Step 5 needs the configuration's identities: without them GrantTrace refuses to scan any target other than a loopback address (localhost, 127.0.0.1, ::1) and sends nothing.

# 1. Draft a configuration and a review checklist from the specification
granttrace --spec openapi.yaml --init-config config.local.json

# 2. Edit config.local.json: test accounts, their resources and expected access;
#    replace every __GRANTTRACE_INPUT__: placeholder, then remove _granttrace_draft

# 3. Validate offline
granttrace --spec openapi.yaml --config config.local.json --validate-config

# 4. Review the plan; a dry run sends no requests
granttrace --spec openapi.yaml --config config.local.json --dry-run --export-json plan.local.json

# 5. Run a read-only scan against an authorized test target
granttrace --spec openapi.yaml --config config.local.json \
  --target https://authorized-test.example --export-json result.local.json

A specification cannot say who owns a resource or who may read it: that comes from you. Shared resources and administrator access can be legitimate; declare them in the configuration rather than treating them as findings. The configuration guide covers identities, API keys and cookies, policies and the evidence each check needs.

Outputs

  • HTML (-o report.html; granttrace_report.html by default): summary, coverage, one row per check and one card per confirmed finding.
  • JSON (--export-json): every result with its evidence, for automation.
  • SARIF 2.1.0 (--export-sarif): confirmed findings only, for GitHub code scanning. See SARIF export.
A confirmed BOLA finding with remediation, retest steps, a cURL template and redacted evidence

The HTML report's interface text is in Chinese for now; check reasons and evidence are in English.

Safety

Only test systems you are explicitly authorized to test. GrantTrace sends no PATCH, PUT or DELETE to your API and refuses writes to external targets, but static rules cannot prove that a GET, or a POST you declare read-only, has no side effects, so review the dry-run plan before a scan. Report vulnerabilities in GrantTrace itself privately, as described in SECURITY.md.

Documentation

Development

git clone https://github.com/ysc070528/granttrace.git
cd granttrace
python -m pip install -e ".[dev]" "setuptools>=77" wheel
python -m pytest

To scan the bundled mock target, run python mock_server/server.py and, in a second terminal, granttrace --spec openapi.json --config config.example.json --target http://127.0.0.1:8080. CONTRIBUTING.md lists the checks CI runs. Contributors follow the Code of Conduct.

License

Apache License 2.0

Metadata

Release files for granttrace 2.7.1

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

Source distribution (sdist)

Source distribution for granttrace 2.7.1
File Size Uploaded Provenance Actions
granttrace-2.7.1.tar.gz 1.6 MB With provenance Details for granttrace-2.7.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for granttrace 2.7.1
File Interpreter ABI Platform Actions
granttrace-2.7.1-py3-none-any.whl Python 3 none any Details for granttrace-2.7.1-py3-none-any.whl

Total release size: 1.8 MB

Release files / granttrace-2.7.1.tar.gz

Download URL granttrace-2.7.1.tar.gz
Size 1.6 MB
Tags Source
SHA-256 checksum
How to use checksums
aeb55cd642f3645af477c514d11ee21a33608ccab6ff7b6e1030323b1033b846
BLAKE2b-256 checksum
How to use checksums
443699ba72e18fb677ac10ae2862f1087a19edb0732f4bb67d7d8afe52cf1cfb
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 12, 2026.

Transparency log

Release files / granttrace-2.7.1-py3-none-any.whl

Download URL granttrace-2.7.1-py3-none-any.whl
Size 199.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
85d0fa730beaf232ff9e9f9ead35f5044e929179e8fca440f30ca50982a253d5
BLAKE2b-256 checksum
How to use checksums
0c34d986fed32d377fb9ad4d51a9ebae6c94d8a2f4f318552a7060d040768ffa
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 12, 2026.

Transparency log

Security for granttrace 2.7.1

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 granttrace-2.7.1.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 12, 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