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.1.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.1-cp311-abi3-win_amd64.whl (776.6 kB view details)

Uploaded CPython 3.11+Windows x86-64

cpex_secrets_detection-0.2.1-cp311-abi3-manylinux_2_34_x86_64.whl (851.3 kB view details)

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

cpex_secrets_detection-0.2.1-cp311-abi3-manylinux_2_34_s390x.whl (888.1 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ s390x

cpex_secrets_detection-0.2.1-cp311-abi3-manylinux_2_34_ppc64le.whl (873.7 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ ppc64le

cpex_secrets_detection-0.2.1-cp311-abi3-manylinux_2_34_aarch64.whl (789.6 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ ARM64

cpex_secrets_detection-0.2.1-cp311-abi3-macosx_11_0_arm64.whl (747.4 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: cpex_secrets_detection-0.2.1.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.1.tar.gz
Algorithm Hash digest
SHA256 5adaee9e024f2ea13f8f3a276f1338b5b067c2aa577809eb3fa94e5fceb350b7
MD5 4f133f8f1e67af073949de47dc26a982
BLAKE2b-256 368d30214c2e76749a300c3e524911af5c515b38edafac4b5b42505a4ee4978f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_secrets_detection-0.2.1-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e15059e92aafe7cd552be122e414acc98770db80bf986146c968ebbf3f75b7e4
MD5 3d61a68ed115343fd65d4c604b9a0f02
BLAKE2b-256 c43b1c9e90c7d0b844b96f50396ef5286828e277e1091ac7584ab1cd146e1dd8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_secrets_detection-0.2.1-cp311-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 19c9a7a93309d42b39dba343e989742ff6650f57f0001ef30450a94bd4cafadf
MD5 cf341241e0354c6112069c50d65ac519
BLAKE2b-256 3cf728c266d0ae7bc17efaa24f9aa1fa4e820861315ece3cb6778878e68d78f4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_secrets_detection-0.2.1-cp311-abi3-manylinux_2_34_s390x.whl
Algorithm Hash digest
SHA256 8bc53d43bd6658fdffbeb60251a01f01cf2a1e239faec80048b82382289f23b9
MD5 9558a43c780f8a40e1c87b445212d138
BLAKE2b-256 dd0de324fac87785d47ccdfe5b75bef76c51ae60bffd1787711e1a973989c5e9

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_secrets_detection-0.2.1-cp311-abi3-manylinux_2_34_ppc64le.whl
Algorithm Hash digest
SHA256 86c581c81dc6a8ff3f6dec3f06caedda8b7f20a55e79329124bc11d4032798d8
MD5 25de1f1829c75c7a0eb9b38e55fc67a1
BLAKE2b-256 d5f3d13915f15e73a77756652125480c711c0a45b33e38e90820d193ed5274a0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_secrets_detection-0.2.1-cp311-abi3-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 df13c950328824597f0f804fcccd17b04b8d72380442c8fed7e9f0b83ffc5178
MD5 cbb6934763b7b78416a03ade9ae48c41
BLAKE2b-256 a650d57d0eb769cc52414810b1fa7a2181cb930ccb8068c9c2feb2eed4db2625

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_secrets_detection-0.2.1-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 710b49708b5226b0d3154c2f6e3fd9fc8ee7a824e6261cf63bc03ee18d196f92
MD5 b68c592dae05fcac377cb94d4398a7ed
BLAKE2b-256 f43cbb1606bb28e4a975ef7eef28247f0c72e7437a7c1b2b4b89190cfd340497

See more details on using hashes here.

Provenance

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