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.2.tar.gz (95.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_encoded_exfil_detection-0.3.2-cp311-abi3-win_amd64.whl (776.9 kB view details)

Uploaded CPython 3.11+Windows x86-64

cpex_encoded_exfil_detection-0.3.2-cp311-abi3-manylinux_2_34_x86_64.whl (849.5 kB view details)

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

cpex_encoded_exfil_detection-0.3.2-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.2-cp311-abi3-manylinux_2_34_ppc64le.whl (874.8 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ ppc64le

cpex_encoded_exfil_detection-0.3.2-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.2-cp311-abi3-macosx_11_0_arm64.whl (754.3 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

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

File metadata

File hashes

Hashes for cpex_encoded_exfil_detection-0.3.2.tar.gz
Algorithm Hash digest
SHA256 504124abc154c1e57d23a49d32d91826929a286a14972a3bdbe563a04944f996
MD5 d4234cd796ab2c817f441158c678aac1
BLAKE2b-256 e24fe16ddfdcdaf94385214abde325d020e4342b19ca195b8a10dc7435069938

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_encoded_exfil_detection-0.3.2-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 ec16b05044f6d534b2577ef15bdb11eb23d09580cfc3b7cf3919ccd40b38ca42
MD5 d55bcbf2e1c5a577b645fcd64a16de36
BLAKE2b-256 297834fbbb27edc1fd0f4f39ab3c8d9068bcf67e2131151e20abad4265d790d7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_encoded_exfil_detection-0.3.2-cp311-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 ec21914370cd3f75b3fc5198b31373e03a7f4425396be8303d53a89c260c2bcb
MD5 84c5f4b5aea66c57abc9f736d609d3ad
BLAKE2b-256 aeac309fd834bb662d88631b8344b14ce480f2062e71caf3e286d2e66e4364db

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_encoded_exfil_detection-0.3.2-cp311-abi3-manylinux_2_34_s390x.whl
Algorithm Hash digest
SHA256 9ddff4774026ebb3ac23cb6bbc8c2eb8db06dffdefe3688ef800f07ccc779962
MD5 fef2afb6a511f19e720212768dde3204
BLAKE2b-256 c01038ee6a660fe2e8da168df9ff043995a3b704a69a56042eed45190a885883

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_encoded_exfil_detection-0.3.2-cp311-abi3-manylinux_2_34_ppc64le.whl
Algorithm Hash digest
SHA256 01bbc5bc7d2b2541e464944dec62da3441c91227a41574f1bee5d53557c8b537
MD5 6b1072e28ff48630f822ad8d2563d17f
BLAKE2b-256 e23562348fab975f7c7b6bc3843ce2ba7fa39c92fc82b18f81a9688aeb1e398e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_encoded_exfil_detection-0.3.2-cp311-abi3-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 62c8c2c26e2a831f8066642925c6cb270e0045fdef66db5f2e3e8d4f8e0f5953
MD5 9cdfb68b7b2a6e412e040265b7972f7a
BLAKE2b-256 3c7b5553ee8caad691f3b42eee720f0f751a9407f49cf096eff67f3d2e23f8e3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_encoded_exfil_detection-0.3.2-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4450954aa6526acef09148c66e5bf30cfb3a236b07207c0fb5e3549dd7a85f93
MD5 800555e348be866574e5c9231d48491d
BLAKE2b-256 b5d4503fafb901ae76097d0581bbac7eddfce036d90f96ebcbf6a6319f554a28

See more details on using hashes here.

Provenance

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