mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2300] [Issue]: SSRF — load_url_binary/http_binary fetches content-supplied URLs with the internal-host guard disabled (allow_local=true) #1136
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#1136
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Romuromylus on GitHub (Jun 5, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2300
Originally assigned to: @Romuromylus on GitHub.
Summary
Severity: High — Security (SSRF).
http_binary, the backend fetcher behind theload_url_binarycommand, callsis_allowed_outbound_url(url, true), which short-circuits all loopback / private / reserved / link-local / metadata host blocking. Content-supplied image URLs (character cards, gallery items, game backgrounds, message attachments) flow straight into it, so the backend can be made to fetchhttp://127.0.0.1:<port>/...orhttp://169.254.169.254/latest/meta-data/and return the raw response body to the caller.Expected behavior
Fetches of content-supplied URLs should block loopback/private/reserved/link-local/metadata hosts by default (
is_allowed_outbound_url(url, false)), disable redirect auto-following and re-validate each redirect target, and pin the resolved IP to defeat DNS rebinding — exactly as the hardened webhook path incustom_tools.rsalready does. Any genuinely-local target should require an explicit opt-in flag like the existingWEBHOOK_LOCAL_URLS_ENABLED.Actual behavior
http_binary(src-tauri/src/commands/storage/http.rs:33-47) callsis_allowed_outbound_url(url, true). Incrates/security/src/lib.rs:83-97,allow_local = truereturnstruefor any http(s) host — the repo's own test atlib.rs:456-458asserts it accepts169.254.169.254and127.0.0.1. So the only check left is the scheme (it rejectsfile://etc.).Additional gaps on the same path:
reqwest::Clientis built with the default redirect policy (no.redirect(Policy::none())), so a public URL that 302-redirects to an internal host is followed with no re-validation.allowed_binary_mime,http.rs:88-96) only inspects the target-controlledContent-Typeand permitsapplication/octet-stream, so internal responses are returned base64 to the caller. Even when bytes are rejected, success/failure and timing leak internal reachability.Reachability (URL is fully content-controlled):
load_url_binary(commands/storage/commands/profile.rs:24-44) passes the raw frontendurl.load_url_binary_for_stateonly interceptsasset://localhost/andhttp://asset.localhost/prefixes and falls through tohttp_binaryfor every real http(s) URL. Frontend callers:urlBinaryApi.load -> invoke("load_url_binary")(url-binary-api.ts:53-64), reached fromstorage-api.ts:330-339(message attachmenturl/imageUrl),storage-api.ts:287-295(galleryrecord.url), andgame-api.ts:1529-1535(background resolution). The only frontend filter (game-api.ts:1507-1510 isRemoteImageReferenceUrl) checks the http(s) prefix only — it does not block private/loopback/metadata hosts.Steps to reproduce
http://169.254.169.254/latest/meta-data/orhttp://127.0.0.1:<port>/....Impact area
Environment
47b16701Logs, screenshots, or video
Static source audit; no runtime logs. All claims are cited to file:line above.
Regression notes
Found via static audit of the refactor branch; not verified against main. The correct fix pattern already exists in-repo — the webhook path in
commands/storage/custom_tools.rssets redirectPolicy::none()(line 144), re-validates each redirect target (158-185), pins the resolved IP viaresolve_to_addrs(146) withis_local_or_reserved_ipchecks (225/243), and gates local targets behindWEBHOOK_LOCAL_URLS_ENABLED(195-210). This is therefore an inconsistent application of an existing control, not a missing capability.Additional context
Server mode escalates impact:
load_url_binaryis exposed viahttp_dispatch.rs:96/767, so a deployed host becomes an IMDS / internal-service proxy for any client past the request gate.Suggested fix: in
http_binary, callis_allowed_outbound_url(url, false), build the client with.redirect(reqwest::redirect::Policy::none()), re-validate each redirectLocationagainst the same policy, and pin the DNS-resolved address — mirroringcustom_tools.rs.Template check
Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:
@Romuromylus commented on GitHub (Jun 6, 2026):
Fixed by #2374, merged into
refactor(squash04cb07dd).