Skip to main content

keyfence

CI License: MIT Python 3.12+

A local proxy that stops secrets from reaching LLM APIs. It checks every request to an AI provider before it leaves your machine and blocks, redacts or placeholder-swaps API keys, passwords and other secrets. Works with Claude Code, Cursor, Codex, Aider, curl and anything else that speaks HTTP.

How keyfence sits between your tools and the provider

Install

pip install keyfence

Python 3.12 or newer. mitmproxy comes as a dependency.

Use

keyfence import              # register your secrets from .env and credential files (hashes only)
keyfence exec -- claude      # run a tool through the proxy
keyfence canary .env         # plant a fake secret; if a tool ever sends it, you will know
keyfence install-hooks claude-code   # stop Claude Code from reading secret files at all

On first run mitmproxy creates a CA certificate in ~/.mitmproxy/. Trust it once so HTTPS can be inspected (macOS shown, other systems in the setup guide):

sudo security add-trusted-cert -d -p ssl \
  -k /Library/Keychains/System.keychain ~/.mitmproxy/mitmproxy-ca-cert.pem

Modes

mode behaviour
block request gets a 403 and is not sent
redact (default) secret becomes [REDACTED:<kind>]
placeholder secret becomes <<SECRET_id>> and the real value is restored in the response, streaming included

Documentation

  • Setup: CA certificate, manual proxy setup, Docker, all commands.
  • Detection: the vault, pattern rules, entropy check, what is excluded, the audit log.
  • Configuration: every option, environment variables, the system prompt notice.
  • Benchmark: recall by secret format and false positive rate by content type, against gitleaks, reproducible with python bench/run.py.
  • Limitations: what keyfence does not cover and what to combine it with.
  • Development: tests, coverage gate, integration script, releasing.
  • Changelog

License

MIT. Bundled detection rules come from gitleaks, also MIT.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

keyfence-0.3.1.tar.gz (68.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

keyfence-0.3.1-py3-none-any.whl (51.5 kB view details)

Uploaded Python 3

File details

Details for the file keyfence-0.3.1.tar.gz.

File metadata

  • Download URL: keyfence-0.3.1.tar.gz
  • Upload date:
  • Size: 68.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for keyfence-0.3.1.tar.gz
Algorithm Hash digest
SHA256 53f5360d83ac6beb0d4ba6dcf4a5895caf457973190c315155311bd80f33e36a
MD5 9fb06cfec4cd06477f993c4c7a6b08b9
BLAKE2b-256 c2892dc5e856960a525e6d32b77078da5a46be1598ffc7187c5e8aa4e0cf90eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for keyfence-0.3.1.tar.gz:

Publisher: release.yml on aminueza/Keyfence

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file keyfence-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: keyfence-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 51.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for keyfence-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b5425e2e4512b99c41c9a0ee9c01f44c9d5612d94d32ab2eb1ed9be042995915
MD5 f291b54f82f2350030951adb76a7bf15
BLAKE2b-256 1918b9b7176b79196bfc4393b35f219adc86d1222bf05f52f101997845d173b5

See more details on using hashes here.

Provenance

The following attestation bundles were made for keyfence-0.3.1-py3-none-any.whl:

Publisher: release.yml on aminueza/Keyfence

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.3.3

2 files

0.3.2

2 files

This release

0.3.1 This release

2 files

0.3.0

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

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