fix: [sourcecache] validate URLs before archiving to block SSRF - #873
Open
elhoim wants to merge 1 commit into
Open
fix: [sourcecache] validate URLs before archiving to block SSRF#873elhoim wants to merge 1 commit into
elhoim wants to merge 1 commit into
Conversation
The module hands the link/url attribute straight to url_archiver.Archive.fetch() with no scheme, host, or private-IP validation at all. An analyst enriching an attribute that points at http://127.0.0.1:6379/ or an internal-only host has the module fetch it on the MISP server's behalf and hand the response back as a cached attachment, exposing internal services through what looks like ordinary enrichment output. A new is_safe_url() check, mirroring the hardened checks already used in qrcode.py and html_to_markdown.py, rejects non-http(s) schemes and resolves the hostname to reject any non-globally-routable address before __archiveLink() is ever called; the handler now returns a "Blocked URL" error instead of fetching. Verified with flake8 on the changed file and the full suite against a local modules server: 161 passed, 4 skipped, 5 subtests passed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018dfYpyaSZd1nxSRLr8suj8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
sourcecacheexpansion module passes the attacker-controlledlink/urlattribute straight to the archiver with no validation:__archiveLinkhands this value directly tourl_archiver.Archive.fetch(). Since MISP users routinely enrich attacker-suppliedlink/urlattributes, this lets a malicious event trigger a server-side request to any URL the MISP instance can reach — e.g.http://127.0.0.1:6379/, cloud metadata endpoints, or other internal-only services — and the fetched response is stored back into MISP as a cached attachment, effectively an SSRF-to-data-exfiltration primitive reachable by enriching a hostile attribute.Impact
An analyst who runs the
sourcecachemodule on an attribute from an untrusted event can unknowingly cause the MISP server to reach internal-only services and have the response persisted into the event as an "attachment" or "malware-sample" attribute, disclosing internal service data through the MISP UI.Fix
Added an
is_safe_url()check — scheme must behttp/httpsand the hostname must resolve only to globally-routable IPs (viaipaddress.is_global) — mirroring the hardened validation already used inqrcode.py. The module now returns a"Blocked URL"misperror instead of fetching when the check fails; no other behaviour changes.Verification
flake8(run from the worktree root sopyproject.toml's[tool.flake8] extend-ignoreapplies): clean, no warnings on the changed file.Found during a review of the repository; other findings are being submitted as separate PRs.
🤖 Generated with Claude Code
https://claude.ai/code/session_018dfYpyaSZd1nxSRLr8suj8