Repository navigation
Open
Description
Security: multiple validation gaps (path prefix, link href sanitization, OAuth state)
Hi maintainers, reporting 3 validation gaps found by static review + isolated logic reproduction (no live exploitation). No PoC included. Happy to move to private advisories if preferred (no SECURITY.md found).
1. Local-mode path check allows sibling-prefix paths + unauthenticated handler
Vulnerability: Prefix check without directory boundary.
Files:
packages/keystatic/src/api/api-node.ts:129-135(getIsPathValidusesfilepath.startsWith(x)withoutx + '/'check)packages/keystatic/src/api/api-node.ts:91-112,175-223(localModeApiHandler/update/blob/treecheck onlyno-cors/content-typeheaders, no auth)packages/keystatic/src/api/read-local.ts:110-140,packages/keystatic/src/app/tree-key.tsx:67-82,packages/keystatic/src/app/path-utils.ts:5-7(allowed dirs have no trailing slash, e.g.posts)packages/keystatic/src/api/generic.ts:85-94(local mode returned with noNODE_ENVgate)
Impact: A path likeposts-evil/...passes when onlypostsis allowed; withstorage:{kind:'local'}(default in templates) the API allows file read/write/delete within base directory without authentication if the endpoint is reachable.
Mitigation: Requirefilepath === dir || filepath.startsWith(dir + '/'), resolve + contain final path underbaseDirectory(path.relative), deny symlinks, and gate local API to development/loopback or add authentication.
2. DocumentRenderer renders link href without sanitization
Vulnerability: Stored javascript: URL rendered verbatim.
Files:
packages/keystatic/src/renderer.tsx:261-266(<renderers.inline.link href={node.href}>, defaultlink: 'a'at:85, nosanitizeUrl/isValidURL)packages/keystatic/src/form/fields/document/DocumentEditor/pasting/html.ts:153-161+pasting/utils.ts:26-37(paste stores anyhref, no validation)packages/keystatic/src/form/fields/document/DocumentEditor/isValidURL.ts:1-5(correct guard exists but only editor-side)packages/keystatic/src/api/generic.ts:264-272vs:274-289(access-token cookie withoutHttpOnly, refresh withHttpOnly) +packages/keystatic/src/app/auth.ts:16-17(client reads viadocument.cookie)
Impact: Attacker-authoredjavascript:link persisted in document content renders as live<a href="javascript:...">for consumers usingDocumentRenderer; click executes JS in site origin which can read the non-HttpOnlyGitHub access token.
Mitigation: Validate/sanitizehrefat ingest and at render (e.g.sanitizeUrl/allowlisthttp(s)/mailto/tel/relative), and setHttpOnlyon access-token cookie or move token out of cookie reach.
3. GitHub OAuth callback does not validate state + redirect_uri follows Host headers
Vulnerability: Missing OAuth CSRF binding.
Files:
packages/keystatic/src/api/generic.ts:216-255(callback never rejects missing/mismatchedstate, exchangescodeunconditionally;state==='close'at:248-253also exchanges)packages/keystatic/src/api/generic.ts:363-398(login sends nostate/cookie whenfrom==='/'at:380-382;stateonly used forfromlookup viaks-<state>cookie at:222-226)packages/next/src/api.tsx:17-20+packages/keystatic/src/api/generic.ts:367-378(redirect_uri=${reqUrl.origin}/...built fromx-forwarded-host/host)packages/keystatic/src/api/generic.ts:32-33(regex gatesfromfor open-redirect, but not CSRF)
Impact: Attackercodecan be exchanged in victim browser (login CSRF, victim session bound to attacker authorization);redirect_uriorigin follows attacker-influenced headers where deployments trust them.
Mitigation: Always generate/send/verifystate(reject missing/mismatched with 401 before token exchange, includingfrom==='/'andcloseflows), and buildredirect_urifrom configured absolute URL with Host allowlist instead of request headers.
Versions checked: @keystatic/core 0.6.9 / main (Nov 2026). No existing GHSA found for these.
Metadata
Metadata
Assignees
Labels
No labels
Activity
tynianov1 commentedon Nov 20, 2026
Opened three PRs for the items in this issue:
statein the GitHub callback (CVE-2026-129945)javascript:hrefs render as is. React 19 blocks them.Each one is independent and has tests. Happy to adjust anything.
Ikram-4 commentedon Nov 23, 2026
@tynianov1 i was wondering if they're any security intern position open in your organization,I'm interested in your organization... The work which you guys are doing is great.