This sheet is past its review date. Deadlines or advice may have changed since 5 Nov 2026.
TypeScript: which security bugs does the compiler not catch?
Before your next release, parse every untrusted input with a runtime schema, make typescript-eslint's type-aware no-unsafe-* rules errors and check authorization in each handler, not only in middleware. Judge everything else by whether outside data can reach a shell, a query, a file path, a URL, an object merge, eval or raw HTML unchecked.
If you only do five things
Keep input away from shells, SQL, `eval` and raw HTML.
Cross-site scripting, SQL injection, OS command injection and code injection rank 1st, 2nd, 9th and 10th in the 2025 CWE Top 2513. Use parameterized queries and
execFilewith an argument array, neverevalinput, and render user text as JSX children.Patch the framework within days.
CVE-2025-55182 (React2Shell), an unauthenticated remote code execution bug in React Server Components rated CVSS 10, was disclosed on 3 December 202514. CISA listed it as exploited two days later and now flags known ransomware use16. Patch within the patching sheet's deadlines and run Node.js 22, 24 or 2617.
Review a TypeScript pull request
Where does outside data enter?
Find the handlers, Server Actions, webhooks and queue consumers the change touches, including Next.js folders in brackets12, and check that each parses its input first.
Did it add `any`, `as`, `!` or `@ts-expect-error`?
Ask why for each one near outside data, then follow that data to the sinks in the traps below.
Who may do this, to which record?
Missing authorization ranks 4th in the CWE Top 2513. Check ownership of the record, not just the login. Server Actions can be called with a direct POST, not just from your UI, so each one checks for itself12.
Does it run code it didn't write?
Neither
vm24 nor the Permission Model is a sandbox: the model is a seat belt for trusted code29, and October's release closed two more gaps in it22. Run untrusted code in its own container without secrets.What leaves the server?
Return only the fields the client needs, and keep secrets out of
NEXT_PUBLIC_variables, which reach the browser12. Send new dependencies through the supply-chain sheet's checks.
TypeScript traps and what to use instead
JSON.parse(body) as Order. The cast checks nothing, so a missing field or a wrong type flows on1. UseOrder.parse(JSON.parse(body))and treatason outside data as a bug.exec("convert " + file).execruns a shell, and Node.js says never to pass it unsanitized input18. UseexecFile("convert", [file]), orspawnwithoutshell: true, and reject afilethat starts with-. A React Native CLI command injection is on CISA's exploited list16.merge(target, req.body)andobj[a][b] = value.__proto__orconstructor.prototypekeys in input can add properties to every object in the process. oRPC's deserializer polluted the prototype before Zod validation ran (CVE-2026-28794, critical)19. Use aMaporObject.create(null)20, and make merge code skip those keys.path.join(root, req.query.name). Path traversal ranks 6th in the CWE Top 2513. Resolve the path withpath.resolveorfs.realpathand reject it unless it starts with the root folder pluspath.sep.fetch(req.body.webhookUrl). It can reach internal services and the cloud metadata address169.254.169.254. Allowlist hosts, validate the IP address you connect to and disable redirects21 withredirect: "error". WHATWG URL rules read0127.0.0.1as87.0.0.1, some OS resolvers as127.0.0.122.new RegExp(input)and nested quantifiers like(a+)*. One crafted string can take exponential time and block the event loop. Cap the input length and use there2package for patterns users supply23.eval,new Functionandnode:vm.vmis not a security mechanism24. Remote code execution through n8n's expression evaluation is on CISA's exploited list16. Run user code only in its own container.--disallow-code-generation-from-stringsblocksevalandnew Function25.dangerouslySetInnerHTMLand user-supplied URLs. React says raw HTML must come from a trusted source and be sanitized26. Accept onlyhttps:URLs, parsed withnew URL(), and enforce Trusted Types withrequire-trusted-types-for 'script'27.
Tools that catch it
- tsc.
strictplusnoUncheckedIndexedAccess, whichstrictomits6. - typescript-eslint.
strictTypeCheckedwithparserOptions.projectService: trueenables theno-unsafe-*rules,no-implied-evalandno-non-null-assertion. Addno-unsafe-type-assertionyourself7. - CodeQL.
js/command-line-injection,js/path-injection,js/request-forgery,js/prototype-polluting-assignmentandjs/polynomial-redoscover TypeScript too28. - Node.js flags.
--disable-proto=deleteremoves__proto__25 but notconstructor.prototype20.--permissionwith--allow-fs-readlimits what your code reads throughnode:fs29.
What you can skip
- Hand-written type guards for request bodies. They drift from the types they guard. Derive types from the schema with
z.infer. - eslint-plugin-security as your main check. Its README warns of many false positives30. Triage typed lint and CodeQL findings first.
- Freezing built-in prototypes.
--frozen-intrinsicsis experimental25 and freezing can break libraries20. Fix the merges instead. - Escaping shell arguments yourself. Drop the shell instead.
What changed in 2026
- React Server Components had a second critical bug. An unauthenticated remote code execution flaw, exploitable only in rare cases, was fixed on 14 October in 19.0.9, 19.1.10, 19.2.9 and 19.3.115.
- Next.js shipped more middleware bypasses and critical fixes. Five middleware or proxy bypasses came in May and July, and five critical remote code execution fixes from August to October10. Run at least 16.4.1 or 15.5.2811.
- TypeScript turned
stricton by default. TypeScript 6.0 did so in March4. TypeScript 7.0, the native compiler, has no API until 7.1, so typescript-eslint needs TypeScript 6 alongside5. - Node.js 20 reached end of life on 30 April. Node.js 26 has been Active LTS since 28 October, and 22 ends on 30 April 202717.
- Trusted Types work in every major browser. They became Baseline in February27, and React passes
TrustedHTMLto the DOM unchanged26.
What this looks like for your code
New project
- Start on Node.js 26 with
strict,noUncheckedIndexedAccessandstrictTypeCheckedas errors. - Write one schema per input and derive the types from it.
- In Next.js, keep data access and secrets in a
server-onlylayer that authorizes12.
Existing codebase
- Turn on the
no-unsafe-*rules as warnings and fix request handlers first. - Search for
exec(,shell: true,eval(,dangerouslySetInnerHTMLandas any. - Check authorization in handlers, not only middleware, and leave Node.js 20.