Skip to main content
VulnParse-Pin emblem VulnParse-Pin emblem
VulnParse-Pin
VulnParse-Pin Threat Model.md
View source on GitHub ↗

Threat Model

This threat model defines the v2.1.0 (Apache-2.0) attack surfaces, trust boundaries, mitigations, and residual risks for VulnParse-Pin (vpp) deployments.

Scope

In scope:

  • Local workstation, container, Kubernetes/systemd, and CI/CD execution across all 13 subcommands (scan, demo, diff, ui, gui, export, verify, defer, intel, ml, mcp, assets, simulate)
  • Streaming ingestion of untrusted scanner files (XML, SARIF 2.1.0, JSONL, CSV, JSON) and offline CMDB/cloud inventory exports (netbox-json, netbox-csv, aws-ec2, gcp-compute, azure-vm, csv, nmap-xml)
  • Persistent DuckDB .vpp.db workspace and .wal/.tmp sidecars
  • Threat-intelligence feed retrieval (FeedCacheManager) and 5 SQLite indexes (nvd, epss, kev, ghsa, osv)
  • Signed offline ML model artifacts (aci_v3_core, pre_kev_v1_core, optional .onnx companions)
  • Workspace context configs (assets.yaml, decisions.yaml) and custom Jinja2 --template-dir
  • Localhost HTTP and stdio interfaces (vpp mcp, vpp gui) and unified workbench HTML (mcp/ui_app.py)
  • Output artifacts (HTML/Markdown Dossiers & Roadmaps, Remediation plans, standalone simulator-html, CSV, JSON, RunManifest, signed webhooks)

Out of scope:

  • Host OS kernel hardening and physical/hypervisor isolation
  • Upstream scanner accuracy or compromise of authoritative NVD/CISA/FIRST/GitHub publishers before download
  • Consumer browser or spreadsheet security outside VPP’s exported artifacts

Trust Boundaries

  • Untrusted: Scanner exports (XML, SARIF, JSONL, CSV), CMDB/cloud inventory exports (vpp assets compile), inline findings text/titles/locations, OSV offline .zip bundles, external advisory descriptions, unauthenticated HTTP requests/headers (Host, Origin, Transfer-Encoding), and SEP-1865 postMessage frames prior to hostOrigin verification.
  • Semi-trusted: Remote HTTPS intelligence mirrors (KEV, EPSS, NVD, Exploit-DB, GHSA API), local cached files/SQLite DBs on shared filesystems, and custom ML model artifacts before .sig.json / HMAC verification.
  • Configuration / Policy Boundary: config.yaml, scoring.json, tn_triage.json, assets.yaml, decisions.yaml, and custom --template-dir.
  • Trusted Runtime: Local Python process, PermFileHandler (0o600/0o700), DuckDB .vpp.db workspace, per-process X-VPP-CSRF token, and HMAC keys (VP_FEED_CACHE_HMAC_KEY, VP_SQLITE_HMAC_KEY, VP_WEBHOOK_HMAC_KEY, VP_MODEL_HMAC_KEY).
  • Output Sinks: Analyst browsers (HTML Dossiers/Roadmaps, vpp gui, standalone simulator-html), SEP-1865 MCP host iframes (ui://vpp/workbench.html), Markdown renderers (GitHub/GitLab PR comments), spreadsheet tools (CSV), and HTTPS webhook receivers.

Primary Threat Scenarios & v2.1 Mitigations

  1. XXE, DTD Expansion, & Malformed XML / Encoding Smuggling
    • Mitigation: defusedxml is absent; _xml_security.py runs inspect_xml_prolog() (up to 1 MiB, including BOM-less UTF-16LE/BE & UTF-32) rejecting <!ENTITY/SYSTEM/PUBLIC/internal subsets, and safe_iterparse() runs lxml.etree.iterparse (resolve_entities=False, no_network=True, load_dtd=False, huge_tree=False) with full-subtree assert_no_entity_nodes().
  2. Symlink Escapes, Path Traversal, & File Mode Races
    • Mitigation: PFH defaults to forbid_symlinks_read=True, forbid_symlinks_write=True, enforce_roots_on_write=True, file_mode=0o600, dir_mode=0o700. VppDatabase validates .vpp.db, .wal, .tmp, and all ancestors via _validate_duckdb_paths(), running umask(0o177) and open_for_write_non_pfh under _UMASK_LOCK. _validate_mcp_config_path() checks --assets, --decisions, and --workspace-root against symlinks/loops.
  3. Untrusted CMDB / Cloud Inventory Exports (vpp assets)
    • Threat: Malicious or corrupted inventory exports could attempt symlink traversal, oversized memory exhaustion, XXE via Nmap XML, terminal/ANSI escape injection in asset tags/hostnames, race conditions on rule promotion, or silent mislabeling of private-only cloud assets as internet_facing: false.
    • Mitigation: core/inventory_compiler.py enforces _MAX_INVENTORY_BYTES = 64 MiB, rejects NUL paths, symlinks, symlink loops, and non-regular files via O_NOFOLLOW, parses Nmap XML via inspect_xml_prolog() + safe_iterparse(), strips ANSI CSI/OSC/DCS/APC and C0/C1 control sequences (_strip_ansi_and_control), validates Draft 2020-12 assets.schema.json, locks rule promotion via fcntl.flock + atomic writes, and preserves internet_facing: null on ambiguous private-only cloud/CMDB assets unless explicitly tagged or overridden via --default-private-exposure.
  4. Localhost HTTP GUI & MCP Server Attacks (vpp gui / vpp mcp)
    • Threat: Malicious browser tabs or LAN peers targeting 127.0.0.1:8787 / 8765 via DNS rebinding, CSRF / simple-CORS requests, iframe clickjacking, HTTP request smuggling / duplicate headers, connection/batch/nesting DoS, unauthorized writes without --allow-write, or overwriting .vpp.db / decisions.yaml via export paths.
    • Mitigation: Both servers bind loopback (127.0.0.1) by default and refuse non-loopback --host without >=16-char --auth-token-env verified via hmac.compare_digest. HttpSecurityPolicy validates single Host and Origin headers; duplicate security/framing headers return 400, Transfer-Encoding returns 501, non-application/json POST returns 415, missing Content-Length returns 411, and payloads > 4 MiB (MAX_MESSAGE_BYTES) return 413. BoundedSemaphore(32) caps concurrency (503), socket timeout is 15.0s, JSON serialization sets allow_nan=False, and vpp mcp bounds batches (MAX_BATCH_ITEMS = 64), nesting (MAX_JSON_DEPTH = 64), and internal errors (-32603). vpp gui additionally enforces a per-process 256-bit X-VPP-CSRF header (hmac.compare_digest), X-Frame-Options: DENY, X-Content-Type-Options: nosniff, Referrer-Policy: no-referrer, Cache-Control: no-store, and strict HTTP CSP (frame-ancestors 'none'). Both surfaces default to read-only (blocking mutating tools/modals without --allow-write), vpp_export_dossier blocks protected DB/YAML/config paths (_assert_export_target_not_protected), and vpp_diff_and_drift(re_enrich=True) copies DB/WAL into 0o600 O_NOFOLLOW | O_EXCL temp files.
  5. Browser Workbench & SEP-1865 Iframe Attacks (mcp/ui_app.py)
    • Threat: Untrusted scan strings, host themes, or malicious postMessage frames attempting DOM XSS, wildcard postMessage origin spoofing, __proto__ prototype pollution, CSS url()/@import exfiltration, or <script> break-out in embedded simulator-html snapshots.
    • Mitigation: ui_app.py renders exclusively via document.createElement and textContent (zero innerHTML, zero external CDNs or http:///https:// URLs), stores maps in Object.create(null), validates numeric bars with Number.isFinite, strips/rejects CSS url(/expression/@import tokens, latches hostOrigin exclusively on the matching initRpcId response (blocking tools/call otherwise), bounds RPC calls with RPC_TIMEOUT_MS = 30000, escapes <script type="application/json"> data via _escape_json_for_script_tag() (\u0026/\u003c/\u003e/\u2028/\u2029), and sets strict <meta> CSP (connect-src 'none' in mcp and static-simulator).
  6. Cache & ML Model Weight Tampering / Downgrade Attacks
    • Mitigation: When VP_FEED_CACHE_HMAC_KEY or VP_SQLITE_HMAC_KEY is set, plain sha256 sidecars and unsigned SQLite DBs fail closed with zero auto-resign; tampered SQLite caches are quarantined to .tampered.<UTCSTAMP>. vpp intel status verifies read-only (?mode=ro). Similarly, ml/registry.py enforces < 2 MiB (MAX_MODEL_ARTIFACT_BYTES), rejects symlinks/non-regular/world-writable artifacts via O_NOFOLLOW, and verifies .sig.json SHA-256 or VP_MODEL_HMAC_KEY (hmac-sha256) fail-closed while defaulting to non-mutating ml.mode: shadow.
  7. HTTP Redirect Downgrade & Decompression / Zip-Bomb DoS
    • Mitigation: _open_https_stream() disables auto-redirects (allow_redirects=False) and enforces HTTPS per hop (MAX_NVD_META_BYTES = 1 MiB, MAX_REMOTE_FEED_BYTES = 200 MiB, MAX_DECOMPRESSED_FEED_BYTES = 2 GiB). OSVEnrichmentSource._validate_zip_member() blocks .., symlinks, drive prefixes, and zip-bombs.
  8. HTML XSS, Markdown Table/Link Injection, & CSV Formula Injection
    • Mitigation: renderer.py enables Jinja2 autoescape for HTML templates (zero external CDNs) and md_escape for Markdown templates/reports. csv_exporter.py neutralizes formula prefixes (=, +, -, @, \t, \r) unless both --no-csv-sanitize and --confirm-unsafe-csv are passed.
  9. SQL Injection in DuckDB Queries / Textual TUI
    • Mitigation: storage/repositories.py, diff_engine.py, renderer.py, mcp/tools.py, ui/gui_server.py, and ui/app.py use parameterized DuckDB queries and validated column/table allowlists (_ALLOWED_SQLITE_TABLES in vpp intel status).
  10. Evidence & Manifest Tampering / Waiver Staleness
    • Mitigation: RunManifest v2 hashes inputs, configs, outputs, and SHA-256 hash-chained ledger_events (including MCP_DEFERRAL_PROPOSED, GUI_DEFERRAL_RECORDED, and GUI_ASSET_RULE_PROMOTED). vpp verify validates manifests read-only (verifying listed output artifacts + symlinks) without writing to $HOME/XDG_*. DecisionsRegistry + vpp diff --fail-on stale-assumption catches expired or assumption-violated deferrals.

Security Assumptions

  • Execution user account and local secret store (VP_FEED_CACHE_HMAC_KEY, VP_SQLITE_HMAC_KEY, VP_WEBHOOK_HMAC_KEY, VP_MODEL_HMAC_KEY, and any --auth-token-env variable) are protected by host permissions.
  • --template-dir custom Jinja2 templates and assets.yaml/decisions.yaml are operator-controlled inputs.
  • POSIX 0o600/0o700 mode enforcement applies on Linux/macOS; Windows relies on NTFS ACLs.

Residual Risks

  • Upstream intelligence compromise: If an authoritative feed publisher (NVD, CISA, FIRST, GitHub, OSV) serves poisoned content over valid TLS before VPP caches it, VPP will faithfully sign and snapshot that content.
  • Operator opt-out flags: Passing --allow-symlinks-read, --no-csv-sanitize --confirm-unsafe-csv, --allow-regen, or --allow-write (on vpp mcp / vpp gui) intentionally relaxes fail-closed or read-only protections.
  • Unrestricted read roots by default: --enforce-root-read is opt-in (False by default) so CLI users can pass scan files from arbitrary paths; high-security enclaves should pass --enforce-root-read (and --workspace-root for vpp mcp / vpp gui).
  • Untrusted custom --template-dir: Supplying untrusted Jinja2 templates can alter rendered HTML/Markdown output.
  • Developer workstation: Keep defaults enabled (read_only MCP/GUI, ml.mode: shadow); install optional [ui] in an isolated pipx/uv tool or virtualenv; avoid --no-csv-sanitize.
  • CI/CD pipeline: Set VP_FEED_CACHE_HMAC_KEY, VP_SQLITE_HMAC_KEY, VP_MODEL_HMAC_KEY, and VP_WEBHOOK_HMAC_KEY; pass --offline against pre-verified caches or run vpp intel status; gate PRs with vpp diff --fail-on stale-assumption (or kev/p1); audit inventory drift with vpp assets audit --fail-on shadow; verify artifacts with vpp verify.
  • Restricted / air-gapped enclave: Run as non-root with readOnlyRootFilesystem, --portable on a dedicated 0o700 volume, --enforce-root-read, vpp mcp over stdio (or loopback vpp gui), and vpp verify for read-only audit verification.