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.1.tar.gz (100.7 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.1-cp311-abi3-win_amd64.whl (777.7 kB view details)

Uploaded CPython 3.11+Windows x86-64

cpex_secrets_detection-0.3.1-cp311-abi3-manylinux_2_34_x86_64.whl (851.9 kB view details)

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

cpex_secrets_detection-0.3.1-cp311-abi3-manylinux_2_34_s390x.whl (889.2 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ s390x

cpex_secrets_detection-0.3.1-cp311-abi3-manylinux_2_34_ppc64le.whl (874.9 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ ppc64le

cpex_secrets_detection-0.3.1-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.3.1-cp311-abi3-macosx_11_0_arm64.whl (748.4 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: cpex_secrets_detection-0.3.1.tar.gz
  • Upload date:
  • Size: 100.7 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.1.tar.gz
Algorithm Hash digest
SHA256 033dae49dcd8b3098ba2c1d45d815138efd143d36d64289cd1750b7f4bb99af0
MD5 f69fccbd1f8e3bc56c8a16b033a9e8ff
BLAKE2b-256 976d56bd055baa85c09dc3b58183ebd09f8c4de061f758755c9497b8fc4c6397

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_secrets_detection-0.3.1-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 8a23bdf2c7afabe8b125a9e3b7149c4e3b171b8118259451a6d41b005187e3fd
MD5 3bfe50e8e9a615fb62063c9d0f662a14
BLAKE2b-256 04b7b17bba185d177e2a6e638fab35e193552fcb55c2023f455f8bab32a170c9

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_secrets_detection-0.3.1-cp311-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 c913eb0f5b57ab15bc2eed2979e3476c9d76ad5d03d71e99e59beb186ecf3870
MD5 83db5c943d57aba8faf9c122b5536bfd
BLAKE2b-256 2b36cfad02f152acdcefcb40c2607fbec1f9da28fbbf62d815d38110f2dab695

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_secrets_detection-0.3.1-cp311-abi3-manylinux_2_34_s390x.whl
Algorithm Hash digest
SHA256 8674e65c4c4d02f6654e9380c5c6349ff51941e921517491f51a88b6774a92e5
MD5 d5a3ad3e246ec8a6b1eb66c9e3b6d2a7
BLAKE2b-256 8065c620aae218b407db27f85f672ed6ee45250c7fde0e89712d3925f425a33e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_secrets_detection-0.3.1-cp311-abi3-manylinux_2_34_ppc64le.whl
Algorithm Hash digest
SHA256 13886f836549c266bd342d89be8dccab454e18981c7b7b8984972744dd9f83ce
MD5 a5369980f3e302256f1f69136c17f3d2
BLAKE2b-256 6e990ab84ec08432f7df09b77ab80fa6dbe95a79889f67c1a9fd4a64c7f718a4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_secrets_detection-0.3.1-cp311-abi3-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 8d5502e9e2e7177fc2f8a294afa7faeaea134c296f49ff3355fade4d15cfd363
MD5 5a9cece97ba9fee9af3c201b9850ec76
BLAKE2b-256 2cc45f0bf93fb6e1ce9fee53ebf52a21212b26a75f3b913cb5ae1c84b275cba7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_secrets_detection-0.3.1-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 71ca7165f57043dc98d842aad471c98361d10dc11072851fce166b6cba1357d0
MD5 0f675b8ee4d879516271acaf780e3e59
BLAKE2b-256 076d26bafdc8911960f45c68afafeec411763d0666463b979e196649c505fe58

See more details on using hashes here.

Provenance

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