Skip to main content

High-performance URL reputation and phishing detection for MCP Gateway

Project description

URL Reputation (Rust)

Static URL policy checks for ContextForge and MCP Gateway resource fetches.

Features

  • Blocks resource fetches before execution with the resource_pre_fetch hook
  • Allows trusted domains or URL regex patterns to bypass later checks
  • Blocks configured domains, subdomains, or URL regex patterns
  • Blocks non-HTTPS URLs by default
  • Optional domain heuristics for high entropy, static IANA TLD validity, and Unicode security
  • Case-insensitive domain normalization for allowlist and blocklist entries
  • Pure static policy checks; no external reputation provider or threat-intel feed calls

Build

make install

Runtime Requirements

This plugin depends on cpex>=0.1.0,<0.2 and imports hook models from cpex.framework. The compiled Rust extension is mandatory; there is no Python fallback implementation.

Usage

The plugin runs on resource_pre_fetch before a resource URI is fetched.

Typical uses:

  • block known bad domains and subdomains
  • allow trusted internal URL patterns before enforcing HTTPS
  • reject insecure http:// resource fetches
  • enable lightweight domain heuristics for suspicious generated or Unicode domains

Configuration

config:
  whitelist_domains:
    - "example.com"
  allowed_patterns:
    - "^https://trusted\\.internal/.*"
  blocked_domains:
    - "malicious.example.com"
  blocked_patterns:
    - "casino"
    - "crypto"
  use_heuristic_check: false
  entropy_threshold: 3.65
  block_non_secure_http: true
Field Type Default Description
whitelist_domains set [] Domains and subdomains that bypass remaining checks
allowed_patterns list [] Regexes matched against the full trimmed URL; a match bypasses remaining checks
blocked_domains set [] Domains and subdomains that are always blocked unless allowlisted first
blocked_patterns list [] Regexes matched against the full trimmed URL; a match blocks the request
use_heuristic_check bool false Enable entropy, TLD, and Unicode domain checks for non-IP hosts
entropy_threshold float 3.65 Maximum allowed Shannon entropy for the domain
block_non_secure_http bool true Block URLs whose scheme is not https

Logic Workflow

  1. Trim and parse the URL.
  2. Extract the host/domain.
  3. Detect IPv4 or IPv6 hosts so domain heuristics can be skipped.
  4. Allow exact or parent-domain matches in whitelist_domains.
  5. Allow matches in allowed_patterns; this also bypasses HTTPS enforcement.
  6. Block non-HTTPS schemes when block_non_secure_http=true.
  7. Block exact or parent-domain matches in blocked_domains.
  8. Block matches in blocked_patterns.
  9. If heuristics are enabled for a non-IP host, block high-entropy domains, illegal static TLDs, or unsafe Unicode domains.

Returned Metadata

Allowed URLs return continue_processing=true.

Blocked URLs return continue_processing=false with a PluginViolation using code URL_REPUTATION_BLOCK. Violation details include the URL or domain involved in the decision.

Limitations

  • Reputation data is static configuration only; there are no external provider lookups.
  • The IANA TLD list is compiled into the plugin and can lag newly delegated TLDs.
  • allowed_patterns intentionally runs before HTTPS enforcement, so trusted patterns can allow http:// URLs.
  • IP addresses skip domain heuristics.

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_url_reputation-0.3.4.tar.gz (42.0 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

cpex_url_reputation-0.3.4-cp311-abi3-win_amd64.whl (844.6 kB view details)

Uploaded CPython 3.11+Windows x86-64

cpex_url_reputation-0.3.4-cp311-abi3-manylinux_2_34_x86_64.whl (925.9 kB view details)

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

cpex_url_reputation-0.3.4-cp311-abi3-manylinux_2_34_s390x.whl (981.1 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ s390x

cpex_url_reputation-0.3.4-cp311-abi3-manylinux_2_34_ppc64le.whl (959.9 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ ppc64le

cpex_url_reputation-0.3.4-cp311-abi3-manylinux_2_34_aarch64.whl (876.5 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.34+ ARM64

cpex_url_reputation-0.3.4-cp311-abi3-macosx_11_0_arm64.whl (828.2 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: cpex_url_reputation-0.3.4.tar.gz
  • Upload date:
  • Size: 42.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cpex_url_reputation-0.3.4.tar.gz
Algorithm Hash digest
SHA256 58fe361c4b925c2b7373c7c97b40ed9879c873b09318cad202961328feeb53aa
MD5 de25ae89e6303814655629e1d08918f6
BLAKE2b-256 49bdd70782815a66ddc8696afc0a951f216148c388809abaa5b5c857bf036812

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_url_reputation-0.3.4-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 d059fbd921ddd20f941a06e18ddad8aa49bc8a0b79d19f340e65706847ea084f
MD5 77d8cb4c293332c86a4b05624ee6011e
BLAKE2b-256 e1b1daaec8558ae6d569449e8e471176700f681fbfcb04443fd2b8e313eb3e05

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_url_reputation-0.3.4-cp311-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 b91db67405dc00e93d147cc4fb6688ac8983c6935d8b41709db33f3c0c249313
MD5 04169f97148bf89e926bab09482dc186
BLAKE2b-256 8be4f25c6e9208094d22434a89192f10cb5ae27f081773afa08eb72378474bf8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_url_reputation-0.3.4-cp311-abi3-manylinux_2_34_s390x.whl
Algorithm Hash digest
SHA256 e97bf605d931d8a478236cbc34e6170a07189fd3670fda9bb2cc3c03ae054ea7
MD5 bda97b08a581ad8aaa99abc8d166d9fb
BLAKE2b-256 9d2d13eaea84a0a818b93807d7ad6c020642e46dd16f08654376bf33e81d27f6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_url_reputation-0.3.4-cp311-abi3-manylinux_2_34_ppc64le.whl
Algorithm Hash digest
SHA256 1501ec97bf746dbb6fba9127c4b73a0b9ef7c39ac8131475348e98bc8d88e46b
MD5 f2329a25d7f4f98bc7bfcda1a7ff6ffd
BLAKE2b-256 10a3260fff66ad84c20b6492d4e2fcd00fdc0606ec10817ddd5e6afbb7e61cf6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_url_reputation-0.3.4-cp311-abi3-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 7504ac0916e6fea7f3221a78079a479bfb28e3eb3eb842d3f26c4ee330d0310e
MD5 177e570337edefdde56351e510bc5521
BLAKE2b-256 4b0db4586f59fbcfacff5cd7da5950197f74b149282773c732b64296a013d1b2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for cpex_url_reputation-0.3.4-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6f17f62d285309fc0bb17a8cfba462534a2a19b9968a8929d13461527d8c7587
MD5 5b150a2bb044b895d2b02e5af91a3601
BLAKE2b-256 658132dfa8f90205c6c66315996c6fd41e2ce6ae63b6865b4eaee86869bbc5ee

See more details on using hashes here.

Provenance

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