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.5.tar.gz (46.5 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.5-cp311-abi3-win_amd64.whl (759.8 kB view details)

Uploaded CPython 3.11+Windows x86-64

cpex_secrets_detection-0.3.5-cp311-abi3-manylinux_2_34_x86_64.whl (832.3 kB view details)

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

cpex_secrets_detection-0.3.5-cp311-abi3-manylinux_2_34_s390x.whl (867.2 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ s390x

cpex_secrets_detection-0.3.5-cp311-abi3-manylinux_2_34_ppc64le.whl (858.9 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ ppc64le

cpex_secrets_detection-0.3.5-cp311-abi3-manylinux_2_34_aarch64.whl (777.7 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ ARM64

cpex_secrets_detection-0.3.5-cp311-abi3-macosx_11_0_arm64.whl (734.4 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: cpex_secrets_detection-0.3.5.tar.gz
  • Upload date:
  • Size: 46.5 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.5.tar.gz
Algorithm Hash digest
SHA256 16b20eb2d13594e316bb9dfeafa9eab55f5f9150e29e74c1572a5511034898cf
MD5 fb0b2024ebfbcf68d447095320ca9f71
BLAKE2b-256 a267c6d29fe561350d76faaa2541047908d45fc2dd5565e890176466ceeb3211

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_secrets_detection-0.3.5-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 483d1212bdd7cd09561f7e5a52fdac215b8dec4a83809f28d3e333eb059b120e
MD5 60916322927f7cd34389f4da33a7e4f0
BLAKE2b-256 04e82851159db2b08ccf2cb7acde31677ebb6fccc37a19f6247212212019e950

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_secrets_detection-0.3.5-cp311-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 56977ba193f6d0ec32393c6168663f35372bfb31822c706b0e6c9a66f18ebe89
MD5 5a7b2299e18a27933130cae845e63fd4
BLAKE2b-256 6d02269f14b7299c79da491671a90fa6eb61d0b4ca3a51dbeb4582ae5389149c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_secrets_detection-0.3.5-cp311-abi3-manylinux_2_34_s390x.whl
Algorithm Hash digest
SHA256 f0dedd2d472f438e696aec12763cedb60ad28cfa958009b0c29fce0817f54953
MD5 794d6a4a8cf65832e9f9a66917c7dab2
BLAKE2b-256 9dc077d03186a4012d2bb77842f3940b81fce8d780830aba1cd3c9c6d4c127db

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_secrets_detection-0.3.5-cp311-abi3-manylinux_2_34_ppc64le.whl
Algorithm Hash digest
SHA256 2a4fd1651bf1b44b962411ba419ac0d8ac7485c6292ace96c7909fa2c39c7ac0
MD5 7953dc019b63b399968eb046daaceefd
BLAKE2b-256 c7aa1b9eb09a66f4bcb562740cbb58b88a83f4dd2c5a1a08494dd723c5eec1b5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_secrets_detection-0.3.5-cp311-abi3-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 2e4ceb7b187d6dbc77d2b9b1a2daaadec1884c9f5beb5bfa852bc5827449f2e6
MD5 0f2848d3e6c04f0cf38b938e0c6a3c62
BLAKE2b-256 fc54ef97895ab6197f37d6a425e0d4928e37be91dd433ef8df1e322f685f58e0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_secrets_detection-0.3.5-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5410e4ed622054d54cdc836eabf85bff2436df0b0ce10652ffeff7e3e45f8f0e
MD5 9c7d2b1d5084f28b11ed327ff578d468
BLAKE2b-256 052b30fb49490966fee411d674085f3b52d78c85e473eb0b0991622501c1cc56

See more details on using hashes here.

Provenance

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