Repository navigation
fix(media): refuse uploads whose data URL declares a type outside a fixed media allowlist - #295
Merged
Github-Samuel merged 1 commit intoSep 25, 2026
Conversation
…ixed media allowlist
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.
Summary
sniff.matchesonly checks the type family of a data URL (image/video/audio) against the payload's magic bytes, while the full declared type is what reaches the CDN as the object'sContent-Type(e.g.server/upload.jsforwards it into the multipart part for the Qbox CDN).That lets a player upload GIF bytes labelled
data:image/svg+xml;base64,...: the sniff passes (familyimage, GIF signature), and if the CDN serves the object with the declared type, the owner's CDN account ends up hosting an SVG document that can run script.This adds a fixed allowlist of media types to
sniff.matches. The type is compared without its parameters, soaudio/webm;codecs=opusfrom MediaRecorder still passes.Type of Change
Related Issues
None.
Testing
Ran
sniff.matchesin a standalone Lua 5.4 runtime against these cases. Before this change, only theimage/svg+xmlcase differs, and it is accepted:image/gifimage/jpegIMAGE/JPEGvideo/webmaudio/webm;codecs=opusimage/svg+xmltext/htmlvideo/webmimage/pngwithout;base64Not yet tested on a live server.
Breaking Changes
None for the phone's own uploads (JPEG/PNG stills, WebM/MP4 clips, WebM/Ogg/MP4 audio). A third-party caller of
exports['sd-phone']:uploadMediathat declares a type outside the allowlist is now refused.Checklist