Details
Run
cd /tmp/tina-tm
npx esbuild entry.js --bundle --outfile=site/bundle.js --format=esm --loader:.ts=ts
node run.cjs
Observed output (captured verbatim)
{
"renderedAnchorHref": "javascript:window.__pwned=document.domain+' | localStorage[tinacms-auth]='+localStorage.getItem('tinacms-auth');void 0",
"scriptExecutedOnClick": true,
"capturedByPayload": "127.0.0.1 | localStorage[tinacms-auth]=DEMO-EDITOR-TOKEN",
"control_sanitizeUrl_output": ""
}
Expected vulnerable output — renderedAnchorHref is the attacker-supplied javascript: string unchanged (no scheme validation at the sink), scriptExecutedOnClick is true, and capturedByPayload contains the page's own domain plus the value read out of localStorage['tinacms-auth'] (script ran in the site origin with full read access to that origin's storage). All held.
Control — control_sanitizeUrl_output is "". The repository's own sanitizeUrl, invoked in the same browser realm on the same class of input, rejects the scheme. That is exactly what packages/tinacms/src/rich-text/index.tsx:335 and packages/@tinacms/astro/src/LinkNode.astro:19 do for the identical AST, which isolates the defect to the missing call rather than to the input or the harness.
Second control, internal to the same file: an html node carrying <a href="javascript:alert(1)">x</a> is stripped by the DOMPurify call at :68, so the same payload delivered as raw HTML is blocked while the same payload delivered as a link node is not.
Cleanup
rm -rf /tmp/tina-tm
The PoC was re-run after this report was drafted; the JSON above is that run.
Impact
Stored cross-site scripting via an unvalidated URL scheme in a link attribute. A user whose only capability is editing content gains script execution in every visitor's browser session on the site's origin. Because TinaCMS's documented layout serves the admin from the same origin (public/admin/) and stores the editor token in localStorage under tinacms-auth (packages/tinacms/src/auth/authenticate.ts:5, written at packages/tinacms/src/internalClient/authProvider.ts:117), a clicking visitor who is themselves an editor or administrator exposes that credential — the PoC reads it.
Impacted: any site rendering TinaCMS rich-text through <tina-markdown>. That component exists precisely for non-React sites, i.e. the deployments that do not get tinacms's sanitized React renderer.
Credits
- Thai Son Dinh from VinSOC Labs (R&D)