Buckthorn
See what a package runs before you install it.
Static checks for Python and npm packages, MCP configs and Hugging Face remote code.
Nothing is installed, imported or run.
$ buckthorn scan colourful_logs-1.4.2-py3-none-any.whl
colourful_logs-1.4.2-py3-none-any.whl: flagged
high BKT-HIDE-001 colourful_logs/__init__.py:2 exec of data decoded by base64.b64decode
medium BKT-PTH-001 colourful_logs-1.4.2.pth:1 .pth line runs code at every Python start
1 scanned: 1 flagged
A package can run code the moment you install it, every time Python starts, or as soon as you import it. Buckthorn reads that code first, straight from the wheel, sdist or npm tarball, and tells you what it does.
What it is for
A quiet CI gate. buckthorn check uv.lock reads every pinned file before
anything is installed. On packages it had never seen, it raised about a
quarter of GuardDog's false alarms (numbers below).
Upgrades. buckthorn diff requests==2.32.3 requests==2.32.4 shows only
what the new version adds. If a maintainer account is taken over, the new
code is in that diff.
Your agent's MCP config (preview). An agent starts every server in
.mcp.json with your credentials, and uvx some-server pulls whatever was
released that day, dependencies included. buckthorn check .mcp.json reads
that install set.
Install
Needs Python 3.11 or newer.
pipx install buckthorn # or: pip install buckthorn
uvx buckthorn --help # or run it without installing
buckthorn scan pkg-1.2.0-py3-none-any.whl # one wheel or sdist
buckthorn scan ./dist # a folder of them
buckthorn scan left-pad-1.3.0.tgz # an npm tarball (preview)
buckthorn check uv.lock # every pinned dependency
buckthorn check .mcp.json # an agent's MCP servers (preview)
buckthorn diff requests==2.32.3 requests==2.32.4 # only what an upgrade adds
buckthorn scan --format json ./dist # machine-readable
checkreadsrequirements.txtwith hashes,uv.lockandpoetry.lock.checkanddifffetch from PyPI over https only (pypi.org and files.pythonhosted.org), and check each file's sha256 before reading it.- By default
checkreads the file this machine would install for each package.--all-filesreads every platform's.
What the verdict means
| Verdict | Meaning |
|---|---|
clean |
Nothing flagged in what runs at install, at start-up or at import. Code that only runs when you call it is not read, so clean is not "safe". |
flagged |
At least one finding above info. Read it, then fix or accept it. |
not_verified |
Something could not be read. Never reported as clean. |
Exit codes: 0 clean, 1 flagged or not_verified (--allow-not-verified lets
not_verified pass), 2 a usage or input error.
In CI
The GitHub Action checks a lockfile before anything is installed. It fails the build on a finding and writes SARIF for code scanning:
permissions:
contents: read
security-events: write # for the SARIF upload
steps:
- uses: actions/checkout@v4
- uses: hedgerow-dev/buckthorn@v0.1.1
with:
lockfile: uv.lock
- uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: buckthorn.sarif
- Python version. The check reads the files pip would pick for your
project's Python: the repository's
.python-version, or 3.12 when there is none. Setpython-versionif your project installs with another one. - Pin by SHA. Tags are shown here for reading. For a security check, pin
each action to a commit SHA instead, as
action.ymldoes for its own steps. - All inputs, including
allowlistand signed receipts, are in action.yml.
The first run. A real lockfile often has a package or two that does one
of these things on purpose, like setuptools' .pth file. Accept what is
there today once, then only new behaviour fails the build:
buckthorn check uv.lock --write-allowlist buckthorn-allow.json
Read the file before you commit it, and pass it as the action's allowlist.
Each entry is pinned to the version it was found in, so an upgrade that keeps
the same behaviour shows up again for review.
Pre-commit. The hook runs whenever uv.lock, poetry.lock or a
requirements*.txt changes:
repos:
- repo: https://github.com/hedgerow-dev/buckthorn
rev: v0.1.1
hooks:
- id: buckthorn-check
How well it works
We tested it on packages it had never seen, with the plan committed before
the first scan
(PROTOCOL.md).
That run used commit c80b090, from before the last fixes in 0.1.0.
| On unseen packages | Buckthorn | GuardDog 3.2.0 |
|---|---|---|
| Malicious archives flagged (430) | 52.3% | 68.6% |
| Benign files flagged (5,723) | 5.4% | 23.7% |
- Quiet on real projects. Per project, Buckthorn flagged 8.8% of PyPI's
ranks 1,001 to 3,000 and 5.4% of recently updated projects. So expect a
flag or two on a real lockfile the first time;
--write-allowlistis for that. - It misses more malware than GuardDog. Most of what it misses runs only
when you call a function, like a downloader behind
fetch(url). Of 50 misses we looked at, only one was install, start-up or import code a rule should have caught. In our view it works best next to a feed of known malware, such as OSV's malicious-packages data, and a broader scanner. - Tuning data is not the headline. On the corpora we tuned on, it flags about 90% of pypi_malregistry and 85% of DataDog's malicious PyPI samples. The rules were written against that data, so those numbers say less.
The full write-up is in eval/heldout/RESULTS.md.
BUCKTHORN_CALL_TIME=1 also reads code that only runs when called, and flags
five combinations, such as fetching code and running it. It is off by
default, because it has not been tested on unseen data yet.
Also in preview
An agent's MCP config
An agent starts every MCP server in its config as soon as it loads it, with
your credentials, and nobody looks at what uvx some-server pulls in that
day. Point check at the config:
buckthorn check .mcp.json # Claude Code
buckthorn check .vscode/mcp.json # VS Code
buckthorn check ~/.cursor/mcp.json # Cursor (Windsurf and Claude Desktop too)
- For each server launched with
uvx,uv run --withorpipx run, it fetches the PyPI release that would run and scans it, then every package thatuvxorpipxwould install with it. - Dependencies come from the release's static metadata (
Requires-Dist), never from installing or building the package. - A dependency with no exact version pin is counted in the summary: the newest match was checked, and a later release is what the next start installs. Servers with no version pinned are counted too.
- npm and Docker servers are reported as not checked yet.
- Values from
env, arguments and URLs are never printed.
npm packages
scan reads npm tarballs too: the .tgz the registry serves, or what
npm pack writes.
npm pack left-pad@1.3.0 && buckthorn scan left-pad-1.3.0.tgz
It reads the scripts in package.json, the JavaScript that preinstall,
install and postinstall run, and the code that runs when the package is
loaded. package-lock.json is not read yet. npm support is newer than the
Python side: it was tuned on the top 1,000 npm packages and 200 malicious
ones, and has not been tested on unseen packages. The rules are the
BKT-NPM-* ones in
docs/rules.md.
Model repos with remote code
trust_remote_code=True runs the model repo's own Python when you load it.
Buckthorn reads that code first: the files auto_map names, what they import,
and the methods transformers calls while loading (__init__, post_init,
_init_weights and the rest). This part is new, and we have not published
an evaluation on real repos yet.
buckthorn hf org/name@<commit> # fetch config and code only, never weights
buckthorn hf org/name # reads main today, tells you its commit
buckthorn scan ./my-model # a downloaded repo or a Hub cache snapshot
hf talks to huggingface.co only, fetches by commit and checks each file
against the Hub's blob id. Pin that commit in from_pretrained(revision=...),
since a verdict for one commit says nothing about the next. forward and
generate run only when you call them, so they are not read. Rules are in
docs/rules.md; how this could plug
into Hayward is in docs/hf-remote-code.md.
Reference
Accepting a finding
Some real packages do what Buckthorn looks for on purpose: setuptools and
coverage.py install .pth files that run at start-up. Once you have looked
at one, record it in an allowlist and pass --allowlist allow.json:
{
"allow": [
{
"rule": "BKT-PTH-001",
"package": "setuptools",
"file": "distutils-precedence.pth",
"reason": "setuptools' distutils shim; reviewed 2026-11-03"
}
]
}
rule, package and reason are required. file is a glob, matched with
the version folder taken out (*/setup.py matches pkg-2.0/setup.py), and
version pins the entry to one release. Allowed findings leave the verdict
but stay in the JSON report with their reason. Coverage gaps (BKT-SKIP-*,
BKT-LOCK-002) cannot be allowed: they mean something was not read.
For an npm tarball, package is the name in the file name. The registry
names @scope/pkg as pkg-1.0.0.tgz, so an entry for pkg also covers
another scope's pkg. Pin version to keep it narrow.
Output formats
--format text (default), json, or sarif for GitHub code scanning.
The JSON report carries a schema_version. It goes up when a key changes
meaning or is removed. New keys can appear in any release.
Scan receipts
--receipt FILE also writes an unsigned in-toto statement: each artifact's
sha256 and what Buckthorn found in it, taken before --allowlist. It has the
same shape as Hayward's receipts. It is analysis evidence, not a safety
certificate. In GitHub Actions, set the action's receipt and attest: "true" inputs to have GitHub sign it with Sigstore.
For coding agents (MCP server)
pip install "buckthorn[mcp]"
buckthorn mcp
A stdio MCP server with three read-only tools, all returning the same JSON as
--format json:
scan_path: a wheel, sdist or folder of them, no network.check_release: a PyPInameandversion. The file this machine would install, fetched and hash-checked ascheckdoes.check_mcp_config: the text of an MCP config, checked ascheckdoes.
Every rule is listed in docs/rules.md, and the design is in SPEC.md.
Buckthorn is MIT licensed and part of Hedgerow, next to Hayward for model files.
Metadata
Release files for buckthorn 0.1.1
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 |
|---|---|---|---|---|
| buckthorn-0.1.1.tar.gz | 226.8 kB | With provenance | Details for buckthorn-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| buckthorn-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for buckthorn-0.1.1-py3-none-any.whl |
Total release size: 354.7 kB
Release files / buckthorn-0.1.1.tar.gz
| Download URL | buckthorn-0.1.1.tar.gz |
|---|---|
| Size | 226.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a29ce8c17ce6ec8f6413b214a77fe29479449eb0fadc7ebba2c60521df0da885
|
|
BLAKE2b-256 checksum How to use checksums |
8e3b40a67b8133c3e9da323125190f558529245a6b8607d1104b03ca0ca889c8
|
| 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 23, 2026.
Transparency logRelease files / buckthorn-0.1.1-py3-none-any.whl
| Download URL | buckthorn-0.1.1-py3-none-any.whl |
|---|---|
| Size | 127.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e3d42916a9ccbe597ce14afd5cd4fde0457b451b1159787396b8cee0b9d675c5
|
|
BLAKE2b-256 checksum How to use checksums |
fa18375380c31f1e5a184259f4a9e9f3175bb4b88f6869eacffcd02d53889854
|
| 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 23, 2026.
Transparency logSecurity for buckthorn 0.1.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.
Attestation for buckthorn-0.1.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 23, 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.