Skip to main content

High-performance encoded exfiltration detection for MCP Gateway

Project description

Encoded Exfiltration Detection (Rust)

High-performance encoded exfiltration detection for ContextForge and MCP Gateway.

Features

  • Detects suspicious encoded payloads in prompt args, tool outputs, and resource content
  • Scans common exfil encodings:
    • base64
    • base64url
    • hex
    • percent-encoding
    • escaped hex
  • Scores candidates using decoded length, entropy, printable ratio, sensitive keywords, and egress hints
  • Optional redaction instead of hard blocking
  • Recursive scanning of nested dicts, lists, and JSON-like string payloads
  • Allowlist regex support for known-safe encoded strings
  • Decode-depth and recursion-depth guardrails

Build

make install

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.

Usage

The plugin scans these hooks:

  • prompt_pre_fetch
  • tool_post_invoke
  • resource_post_fetch

Typical uses:

  • block suspicious encoded payloads before they leave the gateway
  • redact encoded secrets or staged exfil fragments from tool results
  • surface findings metadata for review and tuning

Detection Model

Each candidate encoded segment is decoded and scored. The detector looks for combinations of:

  • sufficient decoded length
  • suspicious entropy
  • printable decoded content
  • sensitive markers such as password, secret, token, authorization, or private key
  • egress hints such as curl, wget, webhook, upload, socket, or pastebin

The plugin can also inspect JSON strings recursively so encoded content nested inside serialized blobs is still visible to the detector.

Configuration

Important settings include:

  • enabled: per-encoding enable flags
  • min_encoded_length
  • min_decoded_length
  • min_entropy
  • min_printable_ratio
  • min_suspicion_score
  • max_scan_string_length
  • max_findings_per_value
  • redact
  • redaction_text
  • block_on_detection
  • min_findings_to_block
  • allowlist_patterns
  • extra_sensitive_keywords
  • extra_egress_hints
  • max_decode_depth
  • max_recursion_depth
  • parse_json_strings

Returned Metadata

When detections occur, the plugin can emit:

  • encoded_exfil_count
  • encoded_exfil_findings
  • encoded_exfil_redacted
  • implementation

Blocking responses use the ENCODED_EXFIL_DETECTED violation code.

Security Notes

  • Guardrails reject Rust-incompatible allowlist regexes at engine initialization time (during plugin construction). Features such as lookaround and backreferences are not supported.
  • Scan and recursion caps exist to keep detection bounded on large payloads.
  • Detailed findings can be reduced or sanitized before metadata emission depending on configuration.

Testing

make ci

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_encoded_exfil_detection-0.3.0.tar.gz (94.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_encoded_exfil_detection-0.3.0-cp311-abi3-win_amd64.whl (776.8 kB view details)

Uploaded CPython 3.11+Windows x86-64

cpex_encoded_exfil_detection-0.3.0-cp311-abi3-manylinux_2_34_x86_64.whl (853.9 kB view details)

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

cpex_encoded_exfil_detection-0.3.0-cp311-abi3-manylinux_2_34_s390x.whl (892.0 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ s390x

cpex_encoded_exfil_detection-0.3.0-cp311-abi3-manylinux_2_34_ppc64le.whl (875.0 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ ppc64le

cpex_encoded_exfil_detection-0.3.0-cp311-abi3-manylinux_2_34_aarch64.whl (791.4 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ ARM64

cpex_encoded_exfil_detection-0.3.0-cp311-abi3-macosx_11_0_arm64.whl (754.6 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

Details for the file cpex_encoded_exfil_detection-0.3.0.tar.gz.

File metadata

File hashes

Hashes for cpex_encoded_exfil_detection-0.3.0.tar.gz
Algorithm Hash digest
SHA256 c73db59946d1a020d8cb78adea043c0d70b53606ccc96c702201d7c12473899d
MD5 2b59aa5bfde963e2ee2297a7eaa09794
BLAKE2b-256 00369a0abb3459b01d58640c4e61e5b1122976ce1c721a00fedf2dbe05b7c266

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_encoded_exfil_detection-0.3.0.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_encoded_exfil_detection-0.3.0-cp311-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for cpex_encoded_exfil_detection-0.3.0-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1b758eb1760759b648ed8f9ba5d2bcc8d5c9ab36663e349d2b3f2f421354d714
MD5 c611d1c679dcc2ccfaca0b5475a1ad36
BLAKE2b-256 48fdd8a5dbadb08a2a399862e066057aece8771467a567bc6edb163f408aa89d

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_encoded_exfil_detection-0.3.0-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_encoded_exfil_detection-0.3.0-cp311-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for cpex_encoded_exfil_detection-0.3.0-cp311-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 cf08e46e2b4978fa66702fd9bfdf1891ac86d5d51dc624d41020e2e459478a1c
MD5 f906baf75f720dc5db5a0c8ed2d5e8b5
BLAKE2b-256 c41cd190843a8b43bb763666cf4d64df474d88e5b5adb1129dc766b5f0e02e44

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_encoded_exfil_detection-0.3.0-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_encoded_exfil_detection-0.3.0-cp311-abi3-manylinux_2_34_s390x.whl.

File metadata

File hashes

Hashes for cpex_encoded_exfil_detection-0.3.0-cp311-abi3-manylinux_2_34_s390x.whl
Algorithm Hash digest
SHA256 01c33c47c83709783db8e36d1607f0870b47eedd1886b8e5dad20592b98673d7
MD5 f8a62c8dc3d9522005fc4ba332e04eb9
BLAKE2b-256 3620c37d3e2dedaedd2b2f2921c0de84303bedfb137d75f9d641b09de6a1fdcd

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_encoded_exfil_detection-0.3.0-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_encoded_exfil_detection-0.3.0-cp311-abi3-manylinux_2_34_ppc64le.whl.

File metadata

File hashes

Hashes for cpex_encoded_exfil_detection-0.3.0-cp311-abi3-manylinux_2_34_ppc64le.whl
Algorithm Hash digest
SHA256 bfdc6ed9a7ff32c263193776eb07f5b3d519d8fc66fe6446303864f5e69c6cbf
MD5 795264bc224d79f4d48393814d535673
BLAKE2b-256 e3109d194cfa4ab92c700140f4c787ca6bb28d8478569977cba58cead5596dc7

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_encoded_exfil_detection-0.3.0-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_encoded_exfil_detection-0.3.0-cp311-abi3-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for cpex_encoded_exfil_detection-0.3.0-cp311-abi3-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 4677eeadaa744f6d9b87aa3136c7184208231149f6182730913a28f0e0ac83f4
MD5 8ec6fc159f62c777dc09f6de880a0f90
BLAKE2b-256 22f7cc0e84d0eebe5ea2b3a03b71765b5f49b96fa3a0ba37b3f28077fde1303c

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_encoded_exfil_detection-0.3.0-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_encoded_exfil_detection-0.3.0-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cpex_encoded_exfil_detection-0.3.0-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 be50b03ec6c2a63113384bbbcfd5d3240fc22f4eeea21dd33c84ddee8303cd7c
MD5 2430861d1b6caadcba0edbd4bbc47659
BLAKE2b-256 014cdc27f5fe5e3a7d90b11a385d4f711fb359e9e59fd1cea6ee76f692057f5a

See more details on using hashes here.

Provenance

The following attestation bundles were made for cpex_encoded_exfil_detection-0.3.0-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