fix(media): route storage upload plans through the SSRF-safe fetch guard - #517
Merged
Conversation
The 0.0.18 fix for GHSA-rmm7 guarded the media storage READ path and left its write sibling on a raw fetch. A plugin holding only media.storage.adapter supplies the upload plan's step URLs, and the executor fetched them directly, so the grant conveyed network.outbound reach it never asked for: arbitrary PUT/POST at loopback, private, link-local, or cloud-metadata addresses, carrying plugin-chosen headers and the media bytes. executeStep now calls guardedFetch, exactly as mediaStorageReader does: internal addresses refused before a connection opens, connection pinned to the validated IP, every redirect hop re-checked. No host allowlist on either side, since an object-store endpoint is an arbitrary operator-chosen public host. Also corrects the mediaStorageRegistry doc comment, which asserted a networkAllowedHosts gate the code never implemented. The new architecture gate fails on any bare fetch( under server/handlers/cms/. Fixing one call site is what let this reopen, so the rule is file-scoped rather than call-site-scoped.
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 bug
A plugin holding only
media.storage.adaptersupplies the step URLs in a media upload plan, and the executor fetched them with a rawfetch(). The grant therefore carriednetwork.outboundreach it never asked for: arbitrary PUT/POST at loopback, private, link-local, or cloud-metadata addresses, with plugin-chosen headers and the media bytes as the body.This is the write-side sibling of GHSA-rmm7. That fix guarded the read path in 0.0.18 and left the write path untouched, one call site away.
The fix
executeStepnow callsguardedFetch, the same guardmediaStorageReaderuses: internal addresses refused before a connection opens, connection pinned to the validated IP, every redirect hop re-checked. No host allowlist on either side, since an object-store endpoint is an arbitrary operator-chosen public host.The new architecture gate fails on any bare
fetch(underserver/handlers/cms/, not just this call site, because fixing one call site is what let the class reopen. Also corrects themediaStorageRegistrydoc comment that asserted anetworkAllowedHostsgate the code never implemented.Reported as GHSA-9pq7-m5wf-r7f6.
Verification
Reproduced against a live loopback listener, before and after: