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.4.tar.gz (37.2 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.4-cp311-abi3-win_amd64.whl (745.7 kB view details)

Uploaded CPython 3.11+Windows x86-64

cpex_encoded_exfil_detection-0.3.4-cp311-abi3-manylinux_2_34_x86_64.whl (820.7 kB view details)

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

cpex_encoded_exfil_detection-0.3.4-cp311-abi3-manylinux_2_34_s390x.whl (858.2 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ s390x

cpex_encoded_exfil_detection-0.3.4-cp311-abi3-manylinux_2_34_ppc64le.whl (845.0 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ ppc64le

cpex_encoded_exfil_detection-0.3.4-cp311-abi3-manylinux_2_34_aarch64.whl (767.8 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ ARM64

cpex_encoded_exfil_detection-0.3.4-cp311-abi3-macosx_11_0_arm64.whl (726.5 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for cpex_encoded_exfil_detection-0.3.4.tar.gz
Algorithm Hash digest
SHA256 fe4a5e432f1e5d266ee0095c922106b9878c84ddeaf734751bea68a80370abe7
MD5 308588619676f5528921ca1d0fb717b5
BLAKE2b-256 cb0d090c19198d4f359776fb3397c666cbe4b9cae890a540969043510983fccb

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_encoded_exfil_detection-0.3.4-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 53256e096be3a0d463846d4c24af8d2eccba94d7da22280c3955eb05ee4265e8
MD5 3b6b0e862f8188bfef340fa77848cc6c
BLAKE2b-256 c115cc516ee53d0ed23c73e95110a4eb327243336920f12e9fd0abb23f45d7a2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_encoded_exfil_detection-0.3.4-cp311-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 2c4e1ffec03395b042dd9185d324c6af40a86fcf643af553aabcbbbaa694f051
MD5 1bc167ff62eff5c3729f9be7ada88c2e
BLAKE2b-256 a58798606004b1ca432c110568c9e3b299e1134ffafa18e7168d06fb3066d8fb

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_encoded_exfil_detection-0.3.4-cp311-abi3-manylinux_2_34_s390x.whl
Algorithm Hash digest
SHA256 6d9d02a180ec36f7b4349339b5026e67c875758ee51d91e8d9611cee84aa64d0
MD5 9d265ef286b1783f5cea08b7e09529ff
BLAKE2b-256 a1bfa94c7cb6991ed0b604558d912959de35dc1537c4fb6abe5fb5e07abf0c44

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_encoded_exfil_detection-0.3.4-cp311-abi3-manylinux_2_34_ppc64le.whl
Algorithm Hash digest
SHA256 e19f3a9f5d346f80e198c7b8de5d897e4dec5b2757a10064bffcfa2455f1776a
MD5 027a4b533d09d5f03da5ff4c7a090a74
BLAKE2b-256 d4ab2315380baea705b3332e5825aab60fade992e8c6a8d75d22e4d811bfb573

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_encoded_exfil_detection-0.3.4-cp311-abi3-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 a11abae0a0d35914a52acd2cd533b3d55f188c0bde8d7e5482658fb35e1257af
MD5 29653b22cce1c64381358f56b47bafe9
BLAKE2b-256 a344f27a74ca74a683012bcc60e78adebce28bb3a8467fa5536a0437ba8e2440

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_encoded_exfil_detection-0.3.4-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8ac3d30057818a7ecf7667baa405d3bcb4fd0c9e84d0789dbf16dc05b6ad504b
MD5 135984903f5f37a84ff5b87709bfc748
BLAKE2b-256 4e5dc91290de9e4d308672caebb37a7f94b00e688af10bf156c7fc21888bb416

See more details on using hashes here.

Provenance

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