Skip to main content

Buckthorn

See what a package runs before you install it.

Static checks for Python, npm and NuGet packages, MCP configs and Hugging Face remote code.
Nothing is installed, imported or run.

License MIT Python 3.11+ Status 0.4.0 Code it runs: none

$ 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.

Before an install. buckthorn guard turns a verdict into allow, warn or block, and a Claude Code hook runs it before an agent's pip install or npm install. An optional known-malware snapshot checks OSV's malware reports first. Read the known limits too.

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 scan newtonsoft.json.13.0.4.nupkg        # a NuGet package (preview)
buckthorn check uv.lock                            # every pinned dependency
buckthorn check package-lock.json                  # the same for npm (preview)
buckthorn check packages.lock.json                 # the same for NuGet (preview)
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
  • check reads requirements.txt with hashes, uv.lock and poetry.lock, and package-lock.json, packages.lock.json and packages.config (preview).
  • For Python, check and diff fetch from PyPI over https only (pypi.org and files.pythonhosted.org), and check each file's sha256 before reading it. npm and NuGet are below.
  • By default check reads the file this machine would install for each package. --all-files reads every platform's.

New in 0.4.0:

buckthorn guard example-pkg==1.0                   # allow, warn or block
buckthorn init --claude-hook                       # CI workflow and the Claude Code hook
buckthorn hook install                             # only the Claude Code hook
buckthorn osv refresh                              # offline known-malware snapshot

check of NuGet (packages.lock.json, packages.config) is also in this release (preview).

See init, guard, the hook and the snapshot.

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. guard has its own, with 3 for warn (below).

A lockfile, MCP config or --allowlist over 64 MiB, or one that is a FIFO, a device or a folder, is not read: that is an input error (exit 2).

Set it up with buckthorn init

In 0.4.0, init still pins the Action and the pre-commit hook to the v0.3.0 commit SHA. A follow-up after the 0.4.0 tag moves those pins to v0.4.0 and can turn on cache: "true".

One command turns on the checks below for every lockfile in a repo:

buckthorn init            # or: buckthorn init path/to/repo

It finds the lockfiles the v0.3.0 Action reads (hash-pinned requirements*.txt, uv.lock, poetry.lock, package-lock.json, npm-shrinkwrap.json) and writes .github/workflows/buckthorn.yml. That workflow runs the Action once per lockfile: on pull requests and pushes to the default branch that change one, and weekly. Every action in it is pinned to a commit SHA. A finding fails the build, and so does anything that could not be fully read.

  • Pre-commit. If .pre-commit-config.yaml exists, init adds the hook, or updates its rev to the release in place. It never creates the file, and when the file is in a shape it cannot safely edit, it prints the lines to add by hand instead.
  • Safe to run again. A second run changes nothing. A workflow you edited by hand is not replaced: init shows the diff and exits 1. --force replaces it, --dry-run shows the changes and writes nothing.
  • Requirements without hashes are still added, but each such line is reported as not checked, which fails the build. pip-compile --generate-hashes writes a file the check can read.
  • Exit codes: 0 set up or already set up, 1 the workflow file differs (nothing written), 2 bad input or no supported lockfile.
  • Claude Code hook. buckthorn init --claude-hook also adds the Claude Code hook to the repo's .claude/settings.json, as buckthorn hook install does, with the same --dry-run and --force. A second run says "already set up". With --claude-hook, a repo with no lockfile only gets a note (the hook is still added), and the exit code is the worse of the two parts. Bad input (a bad --branch, a symlink in the way, a file that is not UTF-8) exits 2 and writes neither.

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.4.0
    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. Set python-version if 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.yml does for its own steps.
  • Download cache. cache: "true" keeps downloaded artifacts between runs with actions/cache. Only the download is saved: every cached file is checked against the lockfile's hash and scanned again on every run. The bytes that pass the hash check are the bytes scanned; the file is not opened again in between. Cache files are written whole (to a temp file, then renamed) and owner-only (0600). A cached file, or its hash folder, that is a symlink or a Windows junction is not used: that artifact is not_verified. The same goes for --cache-dir on the command line.
  • All inputs, including allowlist and 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.4.0
    hooks:
      - id: buckthorn-check

Guard: allow, warn or block

buckthorn guard turns the verdict into one decision, for scripts and hooks that have to say yes or no. It reads the same inputs as scan and check, plus name==version from PyPI and npm:name@version from the npm registry, and adds no new checks.

buckthorn guard example_pkg-1.0-py3-none-any.whl
buckthorn guard uv.lock
buckthorn guard example-pkg==1.0 --json
buckthorn guard npm:@demo/pkg@1.0.0
Verdict --mode block (default) --mode warn
clean allow allow
flagged block warn
not_verified block (warn with --allow-not-verified) warn
  • Exit codes: 0 allow, 1 block, 2 a usage or input error, 3 warn.
  • Files or specs: a target is a file only if it has a /, starts with ., ends like a wheel, sdist or requirements file, or is named like a lockfile or MCP config. Pass a folder as ./dir. Anything else is a package spec, even when a file of that name is in the folder. A file that is not there is an input error.
  • Never allowed: a spec without ==, a direct URL (name @ https://...), a fetch that fails, and a file with nothing in it to check are all not_verified. None is ever allowed.
  • Untrusted input: put -- before targets you did not write, so none can become an option: buckthorn guard -- "$spec".
  • Mode: --mode, or BUCKTHORN_GUARD_MODE, else block.
  • Allowlist: --allowlist works as it does for scan and check.
  • Output: one line per block or warn, nothing on allow (-v says how many were checked and names each download on stderr). --json (or --format json) has a schema_version, tool, version, the overall decision and its reason (null on allow), and per package the name, version, source (file, lockfile, pypi or npm), verdict, decision, reason, findings, and allowed (allowlisted findings, each with its reason). On an input error it prints {"schema_version": 1, "error": ...} and exits 2.
  • Every run reads again. Only downloads are kept, with --cache-dir, and they are hash-checked on every read (how, under download cache).
  • Unpinned specs: --resolve-unpinned checks name or name>=1 at the newest release on PyPI the spec allows (not yanked, no pre-release unless only those match). The JSON says which in version and resolved_from. A later release could differ. Without the flag they stay not_verified. The choice uses Buckthorn's own Python, which can differ from your project's.
  • Accepting a finding: --write-allowlist FILE works as it does for scan and check.
  • npm: npm:name@1.2.3, npm:name@tag, npm:name (the latest tag) and npm:@scope/name@.... The tarball is fetched from registry.npmjs.org only and checked against the registry's integrity (sha512), else its shasum, before it is read, then scanned as scan reads a .tgz. A semver range, a fetch that fails and a version that is not there are not_verified. In the JSON, source is npm, and resolved_from names the input when a tag picked the version.
  • Extras: name[extra] also checks each direct dependency the extras add on this Python, as an unpinned spec. In the JSON each one has required_by, the spec that added it (null otherwise). Their own dependencies are not followed. --max-extra-deps N makes more than N of them an input error, with "too_many": true in the JSON.

In Claude Code (best-effort hook)

A PreToolUse hook. When Claude Code is about to run a plain pip install, uv add, npm install, npx or claude mcp add (the full list is below), the hook runs guard on the named packages first and denies the call if guard blocks. A second entry stops Claude's file-editing tools from writing the allowlist or Claude Code's settings.

buckthorn hook install            # writes .claude/settings.json in this project
buckthorn hook install --dry-run  # shows the change, writes nothing
buckthorn hook uninstall          # removes only this entry

The file is .claude/settings.json in $CLAUDE_PROJECT_DIR if set, else in the nearest folder up that has a .git, else in the current folder. The command prints the path it used. --settings PATH picks another file.

It adds these two entries, and keeps everything else in the file:

{"matcher": "Bash", "hooks": [{"type": "command", "command": "buckthorn hook claude",
  "timeout": 120, "onFailure": "block"}]},
{"matcher": "Edit|Write|MultiEdit|NotebookEdit", "hooks": [{"type": "command",
  "command": "buckthorn hook claude", "timeout": 30, "onFailure": "block"}]}

An older install with only the Bash entry is upgraded by buckthorn hook install, no --force needed. buckthorn init --claude-hook installs it too.

This is a speed bump for one coding agent. It is not a sandbox and not install-time enforcement: anything Claude runs another way, and anything you run yourself, goes past it. The real check of the resolved tree is still buckthorn check on your lockfile in CI (the GitHub Action above).

What it checks. One command, no shell operators, in one of these forms, with or without a path (.venv/bin/pip, /usr/bin/python3):

Command Then
pip install, pip3 install, pip3.12 install PyPI specs, -r FILE, the pip flags below
python -m pip install, python3 -m pip install, python3.12 -m pip install the same
uv pip install, uv add, uv tool install the same (--requirements FILE too)
poetry add, pdm add, pipenv install PyPI specs, --dev/-D/-d, --group/-G NAME (poetry, pdm)
npm install, npm i, npm add npm specs, -D/--save-dev, -E/--save-exact, -O/--save-optional, -g/--global, --no-save, --silent/-s, --no-fund, --no-audit
pnpm add npm specs, -D, -g, -E
yarn add npm specs, -D/--dev, -E/--exact
bun add npm specs, -d/-D/--dev, -E/--exact
npx [-y] [-p SPEC]... CMD [args] the -p packages, else CMD as the package. With -p, CMD must be named exactly like one of the -p packages (npx -p @demo/cli cli) and must not be a program already on PATH; anything else (a path, a shell, node, perl, an installer) is not checked, and so is inline code (-e, -c, -Ic, --eval) or an installer or wrapper word in its arguments
bunx SPEC [args], pnpm dlx SPEC [args], yarn dlx SPEC [args] that package
claude mcp add [-s S] [-e K=V]... [-t stdio] NAME -- CMD [args] the server's package, when CMD is uvx, uv tool run, uv run --with, pipx run, npx, bunx or pnpm dlx

PyPI specs are name, name==1.0, "name>=1" and "name[extra]", each package named once. The pip flags are -U/--upgrade, -q/--quiet, -v/--verbose, --user, --no-cache-dir, --no-cache, --no-deps, --force-reinstall, --reinstall, --break-system-packages, --system, --dev. Quote ranges and extras: an unquoted > or [ is shell syntax. A spec without == is checked at the newest release it allows today (guard --resolve-unpinned), and the message names that version.

npm specs are name, name@1.2.3, name@tag and @scope/name[@...]. No version means the latest tag. A tag is checked at the version it points to today. A semver range (^1, ~1.2, 1.x, >=1, v1, vx) is not checked: there is no range resolver yet. Neither is a name ending in .tgz or .tar, which npm installs as a local file. Each tarball comes from registry.npmjs.org only and is checked against the registry's sha512 integrity before it is read, as check does for a package-lock.json. The sha1 shasum is used only when there is no integrity at all; an integrity with no sha512 is not verified.

Extras ("name[fast]") are checked: the package, and each direct dependency the extras add on this Python (its Requires-Dist with an extra == "fast" marker), at the newest release that dependency allows. The message says which package pulled one in. Extras that constrain one dependency more than once (demo-lib<2 and demo-lib!=1.9) are not verified: pip joins the ranges, and could pick a version neither alone does. The same goes across one call: a package named as a spec and also added by another spec's extras, or added by two specs' extras, in different ways ('example-pkg[fast]' 'demo-lib==1.2' where the extra asks for demo-lib>=1) is not verified.

Requirements files (-r FILE, several allowed, with or without plain specs) are read from the session's working directory. A file where every line has --hash is checked exactly as buckthorn check checks it. Other lines (name==1.0 or name>=1 with no hash) are checked as specs. The message says which file a package came from. Not checked: a file outside the project, a path with a .. in it, a symlink or a path through a symlinked folder, anything but a regular file, a file that cannot be read, a hash-pinned file named like an archive (requirements.zip), -e, -r or -c inside it, any option line (--index-url, -f and the like), an option after a spec (--config-settings, --global-option), a --hash other than sha256, ${VAR} anywhere, a comment line ending in \, URLs and local paths, and a mix of hashed and unhashed lines.

Size cap. One call checks at most 40 packages, counting requirements lines and the dependencies extras add. More is not checked, and the message says to run buckthorn check FILE or rely on the CI check. BUCKTHORN_HOOK_MAX_PACKAGES changes the cap, from 1 to 100.

Also in the command Read as
the same package twice, 'demo-lib<2' 'demo_lib!=1.9', also across -r files not checked
pip3.11 or python3.11 when Buckthorn runs on another Python not checked

What it does not check. Anything else that looks like an install is "not checked": chained or piped commands (&&, ;, |), $(...), backticks, redirections, sudo, env, VAR=value before the command, bash -c, eval, xargs, -e, -c, local paths and .whl files, URLs and git+ specs, --index-url and other indexes, --pre, any other flag, npm git+, github:, file:, npm: aliases, tarball URLs, local folders, workspaces (-w), --registry, npm exec, claude mcp add-json, add-from-claude-desktop, claude mcp with an option before add, an HTTP or SSE MCP server, a server run by docker or a local script, a server -e that sets PATH, HOME, XDG_CONFIG_HOME, NODE_OPTIONS, NODE_PATH, a proxy or TLS variable (HTTP_PROXY, HTTPS_PROXY, ALL_PROXY, NODE_TLS_REJECT_UNAUTHORIZED, NODE_EXTRA_CA_CERTS, SSL_CERT_FILE, SSL_CERT_DIR, REQUESTS_CA_BUNDLE, CURL_CA_BUNDLE), or a Python, uv, pip, npm, pnpm, yarn or bun variable (in any case), a uvx, uv or pipx server with --python other than Buckthorn's own Python, or with an option that changes which file is installed or how it is built (--no-binary, --no-binary-package, --no-build, --no-build-isolation, --python-platform, -C/--config-setting, --index-strategy, --allow-insecure-host, -b/--build-constraints, --keyring-provider) or one this hook does not know, an option whose value starts with -, and other installers (pipx, uvx, conda, rye, pixi, hatch). Messages never show -e values, option values or credentials: a URL shows only its scheme and host.

An install is also not checked when the tool could take it from somewhere else than the release guard reads:

  • Any PIP_* or UV_* variable in Claude Code's environment, except PIP_DISABLE_PIP_VERSION_CHECK, PIP_NO_COLOR, PIP_PROGRESS_BAR, PIP_QUIET, PIP_NO_INPUT, PIP_CACHE_DIR, PIP_NO_CACHE_DIR, PIP_REQUIRE_VIRTUALENV, PIP_ROOT_USER_ACTION, UV_CACHE_DIR, UV_NO_CACHE, UV_COLOR, UV_NO_PROGRESS, UV_PYTHON_INSTALL_DIR, UV_TOOL_DIR, UV_TOOL_BIN_DIR, UV_LINK_MODE and UV_CONCURRENT_*. The message names the variable, never its value.
  • For every tool, a proxy or TLS variable in Claude Code's environment, in any case: the same list as for claude mcp add -e above. A proxy set for a whole machine therefore makes every install not checked.
  • A pip.conf, uv.toml or .uv.toml in the working directory or any folder above it up to the project root ($CLAUDE_PROJECT_DIR, else the git root). The other config files below are looked for in the same folders.
  • An index, find-links, constraint, pre, no-binary, only-binary, prefer-binary, proxy, trusted-host, cert or config-settings in your own ~/.config/pip/pip.conf, ~/.pip/pip.conf, ~/Library/Application Support/pip/pip.conf or $XDG_CONFIG_HOME/pip/pip.conf, or in the pip.conf of the environment pip runs in ($VIRTUAL_ENV/pip.conf, or .venv/pip.conf for .venv/bin/pip, ~/venv/pip.conf for ~/venv/bin/pip). An index or other source setting in ~/.config/uv/uv.toml or $XDG_CONFIG_HOME/uv/uv.toml. The message names the file, never what is in it.
  • For uv, a pyproject.toml there whose [tool.uv] sets index, index-url, extra-index-url, find-links, sources, prerelease, resolution, exclude-newer, constraint-dependencies, override-dependencies, no-binary, no-binary-package, no-build-isolation, no-build-isolation-package, index-strategy, config-settings, allow-insecure-host or pip, or that cannot be read (a FIFO, a symlink, over 1 MB, not TOML, or nested too deeply). The same goes for a Pipfile.
  • A file or folder in the working directory with the same name as a spec's package, with or without extras or a version (pip reads demo-lib[fast] as ./demo-lib when that is there).
  • For poetry and pdm, a poetry.toml, pdm.toml or .pdm.toml, a [tool.poetry] source, a [tool.pdm] source or resolution, or any POETRY_* or PDM_* variable. For pipenv, a Pipfile source other than PyPI, or any PIPENV_* variable.
  • For npm, pnpm, yarn and bun, any NPM_CONFIG_*/npm_config_*, PNPM_CONFIG_*, YARN_* or BUN_CONFIG_* variable. An .npmrc or .yarnrc with any setting beyond a short safe-list (save-exact, save, save-prefix, fund, audit, progress, loglevel, engine-strict, package-lock, update-notifier, color, email, prefix, cache, init-*, and the login line for registry.npmjs.org): a registry, a scoped registry, tag and before all count. A .yarnrc.yml with any line but a plain top-level key: value whose key is on a short safe-list (nodeLinker, enableTelemetry, compressionLevel, enableImmutableInstalls, enableProgressBars, enableColors, nmMode, defaultSemverRangePrefix, httpTimeout, networkConcurrency, enableHardenedMode, enableScripts, enableInlineBuilds): nesting, quotes, escapes, anchors and tags all count. A bunfig.toml with an [install] registry, minimumReleaseAge or [install.scopes], or a top-level preload. Any .pnpmfile.cjs. The same files in your home folder (~/.npmrc, ~/.yarnrc, ~/.yarnrc.yml, ~/.bunfig.toml) count too, as do pnpm's ~/.config/pnpm/rc and ~/Library/Preferences/pnpm/rc, and $XDG_CONFIG_HOME/.bunfig.toml and $XDG_CONFIG_HOME/pnpm/rc when that is set. A config file over 1 MB, a symlink, or one that cannot be read counts as redirecting.

The global npm config ($PREFIX/etc/npmrc) and poetry's and pdm's user config are not read. Neither are overrides and resolutions in package.json: they change only dependencies, which are not checked anyway.

Guard picks the file and, for an unpinned spec, the release that would install on Buckthorn's own Python. If your project's Python or platform differs, pip can install another wheel or an older release than the one checked. Transitive dependencies are not checked: only the packages named, and for extras their direct dependencies. npm lifecycle scripts of dependencies are not read either, only the named package's own. uv add, poetry add and npm install x also resolve and install the rest of your project. That is what the CI lockfile check is for.

Detection is best effort. The hook looks at the first word of the command. When the command has shell syntax, a wrapper (env, sudo, exec, command, xargs, nohup, time, arch, ssh, bash and the like) or inline code (-c, -e), it looks at every word. Names are matched without case (PIP runs pip on macOS), with any path, .exe or version (pip3.12) taken off. Globs, braces, $'...' and variables before install or add in the same command are not checked. The shell has more ways to run a program than this reads, so treat it as a speed bump.

These pass with no output: commands where the first word is not an installer (git commit -m 'bump uv', cat uv.lock, echo pip is great), pip list, show, freeze, check, help, --version, config list and cache dir, uv --version, tree, python list, cache dir, lock --check, export, uv pip list, show and freeze, and npm test, run, ls and --version.

uv sync, a plain uv run, a bare npm install and npm ci install what the lockfile pins, which the CI lockfile check covers. But when a manifest changed after the lockfile, uv and npm resolve again first, so an agent could edit pyproject.toml and then run uv sync. These pass with no output only when the lockfile (uv.lock; package-lock.json or npm-shrinkwrap.json) sits next to the nearest manifest (pyproject.toml, package.json) from the working directory up, and is not older than it or than any manifest below it (workspace members), compared to the nanosecond. It skips dot-folders such as .venv, and node_modules, venv, site-packages, __pycache__, build, dist, target and vendor. A symlinked folder below the lockfile, a folder that cannot be read, or more than 500 manifests or 10,000 folders is not checked. uv sync and uv run with --locked, --frozen or --no-sync, and npm ci, skip the age rule (they install the lockfile as it is, or fail). All of them still go through the variable and config file rules above, except the pyproject.toml and Pipfile settings, which the age rule covers. Anything else is not checked. This compares file times, so it is best effort as well: an agent that edits a manifest and then touches the lockfile gets past it. uv sync and uv run with an index, --upgrade, --upgrade-package, --prerelease, --resolution, --directory, --project, --config-file, --config-setting/-C, --env-file or a similar option, and uv run with --with, --from, --script/-s, a uv option this hook does not know, inline code (-c, -e, -E, attached code, and combined flags such as -Ic, -Bc or -ne; -Werror is not code), a .py file, a URL, or an installer or wrapper word in any argument (split on spaces, quotes, commas and brackets too), are not checked. So is uv run of an interpreter, shell or runtime (python, bash, node, perl and the like), even uv run python -m pytest: such a program runs whatever code it is given. Run uv run pytest instead.

What happens.

guard says Claude Code sees
allow nothing: your normal permission rules apply
warn (--mode warn, or --allow-not-verified) ask, with the findings
block deny, with the findings
not checked ask (BUCKTHORN_HOOK_UNCHECKED=deny to deny, =allow for no output)
could not check deny

The hook never answers "allow", so it never skips your own permission rules. Block is the default. For warn, set BUCKTHORN_GUARD_MODE=warn or install with buckthorn hook install --mode warn.

It fails closed. A crash, bad input from Claude Code, an answer from guard it cannot read, or a check that runs past 100 seconds denies the install. BUCKTHORN_HOOK_TIMEOUT changes that limit, up to 110 seconds so the hook still answers inside the entry's own timeout. A value that is not a positive number of seconds is ignored. The entry's "onFailure": "block" (Claude Code 2.1.295 or later) blocks the call when the hook itself cannot start or passes its 120-second timeout. The catch: if buckthorn is uninstalled or not on Claude Code's PATH, every Bash call and every file edit is blocked until you remove the entry. Run buckthorn hook uninstall, or delete the buckthorn hook claude entry from .claude/settings.json by hand. Guard runs as python -I -m buckthorn (isolated, so a buckthorn/ folder in your project or PYTHONPATH is never imported in its place). That also skips user site-packages: install Buckthorn in a venv or with pipx, not with pip install --user.

buckthorn hook install refuses to write when the settings file, or any folder from the project root down to it, is a symlink. It warns when the settings set disableAllHooks.

Accepting a finding. A deny names each finding (rule, file and line) and the command to accept it after you have reviewed it:

buckthorn guard example-pkg==1.0 --write-allowlist buckthorn-allow.json

Read the file and keep it in the project root. When buckthorn-allow.json is there (in $CLAUDE_PROJECT_DIR, else the session's working directory) the hook passes it to guard as --allowlist. A Bash command that mentions buckthorn-allow, --write-allowlist, buckthorn hook uninstall or .claude/settings is always asked about, even with BUCKTHORN_HOOK_UNCHECKED=allow, so Claude cannot quietly accept its own findings or remove the hook that way. So is a command that names a .claude folder at all (rm -rf .claude, mv, ln, git checkout -- .claude, git restore .claude, cd .claude), or uses a glob or $ next to buckthorn- or .claude, and every command run while the working directory (as given, or with links resolved) is inside a .claude folder. That includes worktrees Claude Code makes under .claude/worktrees/: in one, every Bash call is asked about. Put worktrees elsewhere if that gets in the way. So is a glob or brace pattern that could match .claude or buckthorn-allow.json: a dot part that could match .claude (.cl*, .??*, .*, {.claude,x}, ~/.c*), or a last part that could match buckthorn-allow.json in any folder (bu*, *allow*, *.json, config/*.json, [b]*). Patterns the shell reads differently from this check are asked about unread: a character class ([[:alpha:]]), a brace range ({a..c}, so {1..10} too) and a last part made only of bracket groups or only ?; [^x] is read as [!x]. ls *.py, pytest tests/*, ls .github/workflows/*.yml and jq '.items[0]' f.txt stay silent; jq . config/*.json is asked about, since *.json could name the allowlist. This is a text match, so it is best effort too: a bare * (rm -rf *), a glob in a variable, or a shell with dotglob set can still match these files unseen. A buckthorn-allow.json that is a symlink denies the install.

Known gap: git stash, git checkout ., git restore ., git clean or git reset --hard can revert an uncommitted change to .claude/settings*.json or buckthorn-allow.json without naming either. Commit those files.

File edits. The second entry denies an Edit, Write, MultiEdit or NotebookEdit of a buckthorn-allow.json anywhere, or of any .claude/settings*.json (settings.json, settings.local.json) anywhere. The path is read from the session's working directory, with ~, .. and symlinks resolved, in any case. NotebookEdit is read by its notebook_path, the others by file_path; a call that names both, differently, is denied. A call with no path it can read is denied too. Every other edit gets no output.

Known gap: other tools (MCP file-system tools, for example) can still write these files, and Bash commands that write them are only caught by the text match above. Review changes to buckthorn-allow.json in code review like any other file.

Also: POSIX and Bash only, no PowerShell. Nothing is sent anywhere but PyPI and registry.npmjs.org, and there is no verdict cache: every install fetches and scans again, so each one waits for the download and the scan.

Known-malware snapshot (optional)

Buckthorn reads what a package does. It cannot know that a release was already reported as malware. OSV publishes the OpenSSF malicious-packages reports (advisory ids starting with MAL-), so Buckthorn can keep an offline copy and check it first. It is a complement to the scan, not a replacement: a package that is not in the snapshot is not known to be clean, and it is scanned exactly as before.

buckthorn osv refresh          # download and build the snapshot
buckthorn osv status           # where it is, how old, how many advisories
buckthorn guard example-pkg==1.0
  • What is downloaded: OSV's all.zip for PyPI and npm, from https://osv-vulnerabilities.storage.googleapis.com. npm's is the big one, about 223 MB in late 2026. Only the MAL-* entries are kept, in one SQLite file in your user cache folder. Set BUCKTHORN_OSV_DIR to move it: guard and check read it from there.
  • Nothing is sent. refresh is a plain GET of a fixed URL. No package names, lockfile or project name. It is the only command that reaches OSV: guard and check read the snapshot from disk.
  • Opt-in: running refresh turns it on. --osv or BUCKTHORN_OSV=1 asks for it, --no-osv or BUCKTHORN_OSV=0 turns it off.
  • Fails closed. Once it is in use (asked for, or a snapshot file is there), a snapshot that is missing, damaged, a symlink, does not match its hash, or has no data for an ecosystem the run needs (npm for a package-lock.json) stops the whole run before anything is downloaded: exit 2, OSV snapshot not consulted: <why>. Neither --allow-not-verified nor warn mode changes that, and local wheels, NuGet files and MCP configs in the same run are not read either. JSON output (guard --json, check --format json) is {"error": ..., "osv": {...}}. Run buckthorn osv refresh, or pass --no-osv.
  • A hit blocks, in warn mode too: it is a reported fact, not a heuristic. The package is not downloaded. Rule BKT-OSV-001. Only an allowlist entry with that rule, the package and its version overrides it, matched against the exact package and version the advisory hit, and then the package is fetched and scanned like any other. --write-allowlist never writes one.
  • Where: guard name==version, and every pin check reads in requirements.txt, uv.lock, poetry.lock, package-lock.json and npm-shrinkwrap.json, bundled npm packages included. Each name a pin goes by is looked up: the lockfile's, and the one in the file name or tarball URL it would download. An sdist name like demo-lib-2-1.tar.gz can be read more than one way, so each reading with a valid version is looked up, and its PKG-INFO must name the pin's release. A bundled npm package is looked up by the package.json in its parent's tarball. When any of those disagree with the lockfile, the file is not trusted (not_verified). Not NuGet or MCP configs yet.
  • Stale: older than 7 days (BUCKTHORN_OSV_STALE_DAYS) still counts, with a notice to refresh (on stderr for guard, so it stays silent on allow; not printed with --json, where it is in osv.message). JSON output has an osv object with status (ok, stale, missing, unreadable or disabled), created, age_days and message.
  • Air-gapped: buckthorn osv refresh --from-file pypi=all.zip builds it from a file you copied in. A refresh of one ecosystem keeps the other's data, and the snapshot's age is that of its oldest part. A refresh that reads no advisory at all fails and keeps the old snapshot. Two at once are refused (a .osv-refresh.lock file stays in the folder).
  • Not a vulnerability scanner. CVEs and other advisories are dropped. Use pip-audit or osv-scanner for those.

In CI, refresh before the check. The snapshot goes to the runner's cache folder, where the Action's check finds it. Pin both lines to the same version (PyPI has no v; the Action tag does):

- run: pipx run --spec buckthorn==0.4.0 buckthorn osv refresh
- uses: hedgerow-dev/buckthorn@v0.4.0
  with:
    lockfile: uv.lock

Known limits

  • The hook is a speed bump, not a sandbox. POSIX and Bash only, no PowerShell. buckthorn check on the lockfile in CI is the real check of the resolved tree.
  • Dependencies of dependencies are not followed by guard (for package specs) or the hook. For extras, only the direct dependencies they add are checked. A lockfile given to guard or check still includes every pin.
  • npm semver ranges (^1, ~1.2) are not resolved, so the hook asks about them (not checked) and guard reports them as not_verified.
  • The hook's lockfile and settings rules can be bypassed. uv sync, a plain uv run and a bare npm install pass silently when the lockfile is not older than the manifest, so an agent that edits pyproject.toml and then runs touch uv.lock gets past it. git stash, git checkout ., git restore ., git clean and git reset --hard can revert the hook's settings or the allowlist. Commit those files.
  • No verdict cache. Every run fetches (or reads the download cache) and scans again.
  • The snapshot is malware only (MAL-*), not CVEs. Local wheels and sdists, NuGet and MCP configs are not looked up yet.
  • Uninstall the hook first. The hook entry runs buckthorn hook claude, so buckthorn must be on Claude Code's PATH. If Buckthorn is removed, or not on that PATH, while the entry stays, every Bash call and file edit is blocked. Run buckthorn hook uninstall (or remove the entry from .claude/settings.json) before you remove Buckthorn.
  • Install with pipx or in a venv, not pip install --user. Once the hook starts, it runs guard as python -I -m buckthorn with the same interpreter, which skips user site-packages.

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-allowlist is 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.
  • Real npm takeovers (preview). On Shai-Hulud it flagged 790 of 810 hijacked releases it had never seen, and diff against the version before points at the payload itself. On 588 other npm takeovers it flagged 339: most misses add a malicious dependency rather than change the package. The run found one gap (binding.gyp commands), now fixed: 376 with the fix. Details in eval/real-attacks/RESULTS.md.
  • 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 --with or pipx run, it fetches the PyPI release that would run and scans it, then every package that uvx or pipx would 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.

check reads package-lock.json and npm-shrinkwrap.json (lockfile version 2 or 3). Each tarball is fetched from registry.npmjs.org only and checked against its sha512 integrity before it is read. An entry with no resolved URL is fetched from there by name and version. Git, local and other-registry sources are reported as not checked. The Action and the pre-commit hook take these files too.

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.

NuGet packages

scan reads .nupkg files: the .nuspec, the PowerShell scripts Visual Studio runs from tools/, and the MSBuild files NuGet imports into every build (build/, buildTransitive/ and the package files they import).

buckthorn scan newtonsoft.json.13.0.4.nupkg

A command, download or inline task code at build is flagged. Analyzers and task assemblies are compiled code the build runs, and they are not read, so a package that ships them is not_verified. On the top 1,000 NuGet packages it gave 903 clean, 8 flagged and 89 not_verified, most of those analyzers (eval/nuget-noise/NOTE.md). It has not been tested on malicious NuGet packages yet.

check reads packages.lock.json and packages.config. Each package is fetched from api.nuget.org only. A packages.lock.json entry is checked against its contentHash before it is read. packages.config pins no hash, so what nuget.org serves is scanned, with a note. The rules are the BKT-NUGET-* 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 PyPI name and version. The file this machine would install, fetched and hash-checked as check does.
  • check_mcp_config: the text of an MCP config, checked as check does.

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.4.0

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

Source distribution (sdist)

Source distribution for buckthorn 0.4.0
File Size Uploaded Provenance Actions
buckthorn-0.4.0.tar.gz 418.9 kB With provenance Details for buckthorn-0.4.0.tar.gz

Built distribution (wheel)

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

Total release size: 640.5 kB

Release files / buckthorn-0.4.0.tar.gz

Download URL buckthorn-0.4.0.tar.gz
Size 418.9 kB
Tags Source
SHA-256 checksum
How to use checksums
45ce2a1a857d58514bf66e99145e2860b9e893af0e2a96b9164d542e7c2d236e
BLAKE2b-256 checksum
How to use checksums
e77bc1f7f7fba997562209d58876ec28271f4fbda86c8f9762462f8aa8112347
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 Dec 2, 2026.

Transparency log

Release files / buckthorn-0.4.0-py3-none-any.whl

Download URL buckthorn-0.4.0-py3-none-any.whl
Size 221.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1c770b6188c671b43ea8dcdfa016ace5bc97af5979522250bc5d349e9e10fa16
BLAKE2b-256 checksum
How to use checksums
3621fec52e2d1f3f1b046e9277b7bcfedbab4d73186e11a128853fe4741dbac1
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 Dec 2, 2026.

Transparency log

Security for buckthorn 0.4.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.

Select from 2 files

Attestation for buckthorn-0.4.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 Dec 2, 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