Skip to content

fix: exclude image/svg+xml from default media upload allowlist - #2250

Draft
marcusbellamyshaw-cell wants to merge 1 commit into
emdash-cms:mainfrom
Emdash-Bug-Testing:fix/svg-upload-allowlist
Draft

fix: exclude image/svg+xml from default media upload allowlist#2250
marcusbellamyshaw-cell wants to merge 1 commit into
emdash-cms:mainfrom
Emdash-Bug-Testing:fix/svg-upload-allowlist

Conversation

@marcusbellamyshaw-cell

@marcusbellamyshaw-cell marcusbellamyshaw-cell commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Excludes image/svg+xml from the default media upload allowlist
(GLOBAL_UPLOAD_ALLOWLIST), which previously admitted it via a bare
"image/" prefix match. There's no upload-time content validation for SVG
anywhere in core, so a Contributor+ user could upload an SVG with an
embedded <script> tag. The allowlist now enumerates the safe raster types
explicitly (image/png, image/jpeg, image/gif, image/webp) instead of
prefix-matching all of image/*. Fields that explicitly configure
image/svg+xml in their own allowedMimeTypes are unaffected — this only
changes the default fallback.

Found during a site-level pentest of an Emdash-based site (everybittexas.com)
— flagged as a Low-severity finding since the current serve-time route
already excludes SVG from SAFE_INLINE_TYPES, forcing
Content-Disposition: attachment + a sandboxed CSP, so it wasn't directly
exploitable through the known serve path. Still worth closing at the
upload-time boundary rather than relying solely on serve-time headers as a
single point of failure. No related issue open upstream — filing directly.

Type of change

  • Bug fix

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • I have added a changeset (if this PR changes a published package)

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: Claude Sonnet 5

Screenshots / test output

New test packages/core/tests/unit/media/media-allowlist.test.ts — 3 tests,
confirms SVG rejected, PNG/JPEG/GIF/WebP/video/audio/PDF still allowed.
Full tests/unit/media/** + the two media-upload-* integration tests:
14 files, 151 tests, all passing.

GLOBAL_UPLOAD_ALLOWLIST used a bare "image/" prefix match, which
unintentionally included image/svg+xml. There is no upload-time content
validation for SVG, so a Contributor+ user could upload an SVG with an
embedded <script>. Enumerate the safe raster types explicitly instead.
Field-specific allowedMimeTypes overrides are unaffected.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Jul 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4b1d6ac

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 17 packages
Name Type
emdash Patch
@emdash-cms/cloudflare Patch
@emdash-cms/sandbox-workerd Patch
@emdash-cms/plugin-mcp-smoke Patch
@emdash-cms/fixture-perf-site Patch
@emdash-cms/perf-demo-site Patch
@emdash-cms/cache-demo-site Patch
@emdash-cms/do-demo-site Patch
@emdash-cms/do-solo-demo-site Patch
@emdash-cms/admin Patch
@emdash-cms/auth Patch
@emdash-cms/blocks Patch
@emdash-cms/gutenberg-to-portable-text Patch
@emdash-cms/x402 Patch
create-emdash Patch
@emdash-cms/auth-atproto Patch
@emdash-cms/plugin-embeds Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jul 27, 2026

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@2250

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@2250

@emdash-cms/auth-atproto

npm i https://pkg.pr.new/@emdash-cms/auth-atproto@2250

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@2250

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@2250

@emdash-cms/contentful-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/contentful-to-portable-text@2250

emdash

npm i https://pkg.pr.new/emdash@2250

create-emdash

npm i https://pkg.pr.new/create-emdash@2250

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@2250

@emdash-cms/plugin-cli

npm i https://pkg.pr.new/@emdash-cms/plugin-cli@2250

@emdash-cms/plugin-types

npm i https://pkg.pr.new/@emdash-cms/plugin-types@2250

@emdash-cms/registry-client

npm i https://pkg.pr.new/@emdash-cms/registry-client@2250

@emdash-cms/registry-lexicons

npm i https://pkg.pr.new/@emdash-cms/registry-lexicons@2250

@emdash-cms/registry-verification

npm i https://pkg.pr.new/@emdash-cms/registry-verification@2250

@emdash-cms/sandbox-workerd

npm i https://pkg.pr.new/@emdash-cms/sandbox-workerd@2250

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@2250

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@2250

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@2250

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@2250

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@2250

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@2250

@emdash-cms/plugin-field-kit

npm i https://pkg.pr.new/@emdash-cms/plugin-field-kit@2250

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@2250

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@2250

commit: 4b1d6ac

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant