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.

Runtime Requirements

This plugin depends on cpex>=0.1.0rc1,<0.2 and imports hook models from cpex.framework. The compiled Rust extension is mandatory; there is no Python fallback implementation.

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.3.2.tar.gz (104.1 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.3.2-cp311-abi3-win_amd64.whl (781.9 kB view details)

Uploaded CPython 3.11+Windows x86-64

cpex_secrets_detection-0.3.2-cp311-abi3-manylinux_2_34_x86_64.whl (857.4 kB view details)

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

cpex_secrets_detection-0.3.2-cp311-abi3-manylinux_2_34_s390x.whl (893.1 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ s390x

cpex_secrets_detection-0.3.2-cp311-abi3-manylinux_2_34_ppc64le.whl (880.4 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ ppc64le

cpex_secrets_detection-0.3.2-cp311-abi3-manylinux_2_34_aarch64.whl (794.4 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ ARM64

cpex_secrets_detection-0.3.2-cp311-abi3-macosx_11_0_arm64.whl (753.8 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: cpex_secrets_detection-0.3.2.tar.gz
  • Upload date:
  • Size: 104.1 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.3.2.tar.gz
Algorithm Hash digest
SHA256 bf6f3120590756b9f7b80c1b58bc71414902f998bebf4d4dbe8809a5ab369624
MD5 537a827bc832c08fdf68907720137a98
BLAKE2b-256 d620dbfcfd174a02596ee358181e74f4fde9f8d3f53c09b5e6add5db9b6638b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_secrets_detection-0.3.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.3.2-cp311-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for cpex_secrets_detection-0.3.2-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 257219b92851b93ce8d74032f980d228fbdb433bbe49f5668855302c8719eccf
MD5 1a5e85e7d5c09d01dbcf0a956444be20
BLAKE2b-256 294c1a23260da8037053db48dbdf87843c97793973b8c67db2d9e7d74526e2dc

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_secrets_detection-0.3.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.3.2-cp311-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for cpex_secrets_detection-0.3.2-cp311-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 e65eba3cbcfb5b7395a5d97c024d4a70655b2050615fab13d83a827a716c28c5
MD5 5e2203f7cd9384073992841c9d936766
BLAKE2b-256 b2fef5a84ca55e3fc1374569bf7346e7ef3a3d3e58b13e0755559a991bade5ed

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_secrets_detection-0.3.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.3.2-cp311-abi3-manylinux_2_34_s390x.whl.

File metadata

File hashes

Hashes for cpex_secrets_detection-0.3.2-cp311-abi3-manylinux_2_34_s390x.whl
Algorithm Hash digest
SHA256 e3dd869a3eb852a6fe105634a48b8b5616ae8dc28aca564d7691786c0c57d197
MD5 107cef44a2db60d8ab979b3234e3ca4b
BLAKE2b-256 a62b8f48fade3520742b6312bd3419e6b77ca8c21790e4d51cc0d5d6ad61e277

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_secrets_detection-0.3.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.3.2-cp311-abi3-manylinux_2_34_ppc64le.whl.

File metadata

File hashes

Hashes for cpex_secrets_detection-0.3.2-cp311-abi3-manylinux_2_34_ppc64le.whl
Algorithm Hash digest
SHA256 0b15c3e1655993c1529c7559c6da1ef335507bf1a7e8d7846722a29a9c1309b2
MD5 fc09e8b12e9d57bb78b893b62b1cc6e0
BLAKE2b-256 6ae6c36b371ad036152e83999c29d67140bfc580ed0f78d946079685962bf922

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_secrets_detection-0.3.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.3.2-cp311-abi3-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for cpex_secrets_detection-0.3.2-cp311-abi3-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 b110a4e33addd5554c1eee4e87a200eac4e9b0ed4bd3063d78c8683c602e1318
MD5 a3631b5e4109005207648d9adadfb532
BLAKE2b-256 32baa9498256080513642e73fb4a58afb5445917e33849608eb3b68b0d0ebf23

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_secrets_detection-0.3.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.3.2-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cpex_secrets_detection-0.3.2-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8e0fad6240702bdcfc414051fb902db370223af72c8d10ec682a62441308a4f9
MD5 7dac11243325d3092e202820796f2c79
BLAKE2b-256 851677a52a114232427d839d94dd724b4bc2e2596d326a8d9d6df34460672fca

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_secrets_detection-0.3.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