Skip to main content

Rust-backed secrets detection plugin for MCP Gateway

Project description

cpex-secrets-detection

Rust-backed secrets detection plugin for MCP Gateway / CPEX.

What it does

This plugin scans hook payloads for likely secrets and can either:

  • block processing when a secret is found
  • redact matched values in the returned payload
  • attach findings metadata to the hook result

Supported hooks:

  • prompt_pre_fetch: scans payload.args
  • tool_post_invoke: scans payload.result
  • resource_post_fetch: scans payload.content.text

It walks nested values, not just top-level strings. Coverage includes:

  • plain strings
  • dict
  • list
  • tuple
  • custom Python objects with __dict__
  • slot-based objects with __slots__
  • Pydantic-style objects that expose model_dump() and model_copy()

When redaction is enabled, the plugin preserves payload shape as much as possible instead of flattening everything to plain dicts.

Exact detector coverage

The plugin ships these regex-based detectors:

  • aws_access_key_id
  • aws_secret_access_key
  • google_api_key
  • github_token
  • stripe_secret_key
  • slack_token
  • private_key_block
  • generic_api_key_assignment
  • jwt_like
  • hex_secret_32
  • base64_24

Default behavior:

  • enabled by default:
    • aws_access_key_id
    • aws_secret_access_key
    • google_api_key
    • github_token
    • stripe_secret_key
    • slack_token
    • private_key_block
  • disabled by default because they are broader and more false-positive-prone:
    • generic_api_key_assignment
    • jwt_like
    • hex_secret_32
    • base64_24

What it does not do

This plugin is intentionally narrow. It does not:

  • verify whether a matched credential is real, active, or revoked
  • call external services
  • decode or unpack data before scanning
    • no base64 decode pass
    • no hex decode pass
    • no gzip, zip, or archive inspection
  • scan binary resource bodies
    • resource_post_fetch only scans content.text
  • inspect arbitrary object internals unless they are exposed through supported Python state surfaces such as model_dump(), __dict__, or __slots__
  • guarantee detection of every secret format
    • coverage is limited to the listed regex patterns
  • use entropy scoring, ML classification, or semantic analysis
  • infer secret validity from surrounding prose

It also does not emit the original matched secret in outward-facing findings metadata or violation examples. Those surfaces contain secret types only.

Config

Available config keys:

  • enabled: map of detector name to true or false
  • redact: whether to replace matches in returned payloads
  • redaction_text: replacement text used when redact=true
  • block_on_detection: whether to stop processing on detection
  • min_findings_to_block: threshold for blocking

Defaults:

enabled:
  aws_access_key_id: true
  aws_secret_access_key: true
  google_api_key: true
  github_token: true
  stripe_secret_key: true
  generic_api_key_assignment: false
  slack_token: true
  private_key_block: true
  jwt_like: false
  hex_secret_32: false
  base64_24: false
redact: false
redaction_text: "***REDACTED***"
block_on_detection: true
min_findings_to_block: 1

Result shape

On detection, the plugin may return:

  • modified_payload with redacted values when redact=true
  • metadata.count
  • metadata.secrets_redacted=true when redaction happened
  • metadata.secrets_findings=[{"type": "..."}] when reporting findings without redaction
  • a PluginViolation with code="SECRETS_DETECTED" when blocking

Build

uv sync --dev
make install
make test-all

Project details


Download files

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

Source Distribution

cpex_secrets_detection-0.2.2.tar.gz (58.8 kB view details)

Uploaded Source

Built Distributions

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

cpex_secrets_detection-0.2.2-cp311-abi3-win_amd64.whl (777.2 kB view details)

Uploaded CPython 3.11+Windows x86-64

cpex_secrets_detection-0.2.2-cp311-abi3-manylinux_2_34_x86_64.whl (851.7 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ x86-64

cpex_secrets_detection-0.2.2-cp311-abi3-manylinux_2_34_s390x.whl (889.1 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ s390x

cpex_secrets_detection-0.2.2-cp311-abi3-manylinux_2_34_ppc64le.whl (875.0 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ ppc64le

cpex_secrets_detection-0.2.2-cp311-abi3-manylinux_2_34_aarch64.whl (790.3 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ ARM64

cpex_secrets_detection-0.2.2-cp311-abi3-macosx_11_0_arm64.whl (747.8 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

Details for the file cpex_secrets_detection-0.2.2.tar.gz.

File metadata

  • Download URL: cpex_secrets_detection-0.2.2.tar.gz
  • Upload date:
  • Size: 58.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cpex_secrets_detection-0.2.2.tar.gz
Algorithm Hash digest
SHA256 6e60ff7e9335557b074714f870ccdd8cd57eb1986e21464d41e9dbff2042ad07
MD5 b7131a41f0e028ed8d16fab174561d86
BLAKE2b-256 060d691179276bb71d55c115a6eff39e72e6cd4458dcf991540aa49fbc4a4041

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_secrets_detection-0.2.2.tar.gz:

Publisher: release-rust-python-package.yaml on IBM/cpex-plugins

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

File details

Details for the file cpex_secrets_detection-0.2.2-cp311-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for cpex_secrets_detection-0.2.2-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 3875b760d0c644ce0e86089382a8a58ffe6bbd7df23c5691dcb17e54a20a519c
MD5 be750d91c6c05d915487d9261916fd79
BLAKE2b-256 b1d85a1aa89bcf98aeee455723855ebd5b6982925cc15436f54ba3950c679b61

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_secrets_detection-0.2.2-cp311-abi3-win_amd64.whl:

Publisher: release-rust-python-package.yaml on IBM/cpex-plugins

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

File details

Details for the file cpex_secrets_detection-0.2.2-cp311-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for cpex_secrets_detection-0.2.2-cp311-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 9a62f1c37df933898a9b62158129260ae16f597987d21a1c332e22d4116015aa
MD5 f86dfdd1625bba10d77ec92830ab74e8
BLAKE2b-256 6d50da019be1398589c8fff70995264a43b9fe8e98fb0a5e23121ca30a6589fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_secrets_detection-0.2.2-cp311-abi3-manylinux_2_34_x86_64.whl:

Publisher: release-rust-python-package.yaml on IBM/cpex-plugins

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

File details

Details for the file cpex_secrets_detection-0.2.2-cp311-abi3-manylinux_2_34_s390x.whl.

File metadata

File hashes

Hashes for cpex_secrets_detection-0.2.2-cp311-abi3-manylinux_2_34_s390x.whl
Algorithm Hash digest
SHA256 1fccfb2cc805c4af4828f298196f326d0075c3c875ef83d8e107d2a70154138a
MD5 1cb770da705daa054ae863c1427f8e6e
BLAKE2b-256 f4eebc5f9ecd30896f6c409a5f28f1e00dcd8ac0bb32213538d6d18b9bb2f0e7

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_secrets_detection-0.2.2-cp311-abi3-manylinux_2_34_s390x.whl:

Publisher: release-rust-python-package.yaml on IBM/cpex-plugins

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

File details

Details for the file cpex_secrets_detection-0.2.2-cp311-abi3-manylinux_2_34_ppc64le.whl.

File metadata

File hashes

Hashes for cpex_secrets_detection-0.2.2-cp311-abi3-manylinux_2_34_ppc64le.whl
Algorithm Hash digest
SHA256 77f0bea71a227517879f703e5855cc92e1b7589096a9179748da678ea6b8d369
MD5 38f32df0589c60deb5a963ec6c63f037
BLAKE2b-256 d32e42fbfe3ecc7388e61ca45288a5c3f385b7abf6868644ed97c7d30c7e131f

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_secrets_detection-0.2.2-cp311-abi3-manylinux_2_34_ppc64le.whl:

Publisher: release-rust-python-package.yaml on IBM/cpex-plugins

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

File details

Details for the file cpex_secrets_detection-0.2.2-cp311-abi3-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for cpex_secrets_detection-0.2.2-cp311-abi3-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 42081d3b3b0e03fa718db5f1cb2aee8f8efa72fe7516147b8e16c656c3363ed2
MD5 056102d5b8e8ad8de69ded432bb6084c
BLAKE2b-256 f767296dcd4d53a132627a4c372e9c04caa36d865a768d2bc6c4bff1be91c43b

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_secrets_detection-0.2.2-cp311-abi3-manylinux_2_34_aarch64.whl:

Publisher: release-rust-python-package.yaml on IBM/cpex-plugins

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

File details

Details for the file cpex_secrets_detection-0.2.2-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cpex_secrets_detection-0.2.2-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 14047cfe4c938936d35dcf96bf388bf26b018d89fdc1071192de0c2bf1106c61
MD5 fefecf278fd6f646fb0d4b2cb9761bd3
BLAKE2b-256 d53d9730077cb5930fe962dbc3c3db70a34ba798bc7f80431796b2497705f3ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_secrets_detection-0.2.2-cp311-abi3-macosx_11_0_arm64.whl:

Publisher: release-rust-python-package.yaml on IBM/cpex-plugins

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page