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.3.tar.gz (96.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_encoded_exfil_detection-0.3.3-cp311-abi3-win_amd64.whl (777.6 kB view details)

Uploaded CPython 3.11+Windows x86-64

cpex_encoded_exfil_detection-0.3.3-cp311-abi3-manylinux_2_34_x86_64.whl (850.5 kB view details)

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

cpex_encoded_exfil_detection-0.3.3-cp311-abi3-manylinux_2_34_s390x.whl (892.9 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ s390x

cpex_encoded_exfil_detection-0.3.3-cp311-abi3-manylinux_2_34_ppc64le.whl (875.7 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ ppc64le

cpex_encoded_exfil_detection-0.3.3-cp311-abi3-manylinux_2_34_aarch64.whl (792.3 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ ARM64

cpex_encoded_exfil_detection-0.3.3-cp311-abi3-macosx_11_0_arm64.whl (755.1 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for cpex_encoded_exfil_detection-0.3.3.tar.gz
Algorithm Hash digest
SHA256 195f7b45bae526d6e5cf559ed6a665726368e026cd7b2e153f2272d8f385b303
MD5 f3ee01e0b1a8202affc7d8578df53392
BLAKE2b-256 ae2c5d0e0d4ce7c5dff03c25816134c59f46d941c20471fe43941bf0fdaf3982

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_encoded_exfil_detection-0.3.3-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 fd4d32271bf8933c1ce157a8a508bc1fcb2ea255eaef6e6a7bf10f6d622c5e3c
MD5 39f2324d49a77dd1a2716a23f0cd1791
BLAKE2b-256 ae3a79b81c4c8682623ff80f5e3d25edd79f015d718a6f5928f3e0e6ea54c256

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_encoded_exfil_detection-0.3.3-cp311-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 2e94253f7df69eb03d84f6a53249ecd6a45b4f42d532a926aa258a2264d725a7
MD5 ac32f25a6aa74acb8ec49f793533af45
BLAKE2b-256 71c5174fee7fda766d313333e8cdca0535f3da60116b337e0010811cdb0dcac1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_encoded_exfil_detection-0.3.3-cp311-abi3-manylinux_2_34_s390x.whl
Algorithm Hash digest
SHA256 ca4d802e07cc5193c92211355ba847cad8b1c84e359c29bba2aeb776dfcf001a
MD5 c4859b7f1fce1be14d112ca013602576
BLAKE2b-256 7c09d600bf8361eed44693d992d067948b23ca57cd61ef05f75f7370639bed1a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_encoded_exfil_detection-0.3.3-cp311-abi3-manylinux_2_34_ppc64le.whl
Algorithm Hash digest
SHA256 7125bfc806a16d0fb96fe8162910ae629b8dd992ae779414de0e8250af16acd7
MD5 0d624845d21986540eb419a66473801b
BLAKE2b-256 c8cbfde2699836cbca79fc37cb072d640748e455b1e9721ee85ec72aa6365775

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_encoded_exfil_detection-0.3.3-cp311-abi3-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 a0f3f33aba3c2da8d966d2f998c54172f4d4b2324ea9d40c58994fb31fc38112
MD5 10973ccccb8564dc4115c99350cd5223
BLAKE2b-256 1c0eb0afcddc5645a298ff4ae330057e10302173c23dd929935c4eecd3bd36f7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_encoded_exfil_detection-0.3.3-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e37a41b7a56fd4303a881af530cb3b9d30936c5bae44e01800b635bcc7a437a1
MD5 6a4f24e892cbd2930d91e57a1a51c93b
BLAKE2b-256 3819db0d024c6948950e12c8624f9eca126ee69f9af800af36e5fcca41dba772

See more details on using hashes here.

Provenance

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