DEV Community

david duymelinck
david duymelinck

Posted on

Javascript has a Typescript problem

I was reading

Breaking Down CVE-2026-25049: How TypeScript Types Failed n8n's Security | hetmehta.com

Deep technical analysis of CVE-2026-25049: How type confusion bypassed n8n's security patch and why TypeScript types aren't runtime security boundaries

favicon hetmehta.com

and I was shocked about the cause of the vulnerability.

The cliff notes

n8n allows executable code to be added to the workflows. This code was evaluated without any guardrails.

As the security solution they added Typescript enforcement to the sanitizing function.

Because the sanitizing function compiles to JavaScript the type information is removed and it just didn't run the sanitation actions when the code isn't a string.

Why Typescript created a problem

The obvious solution is using an input validation library. But this is last occurrence of the same developer error I seen so many times before.

It is not that Typescript is a bad language. The problem is that people forget it is an abstraction on top of the language that executes the code.

Even in environments that can run Typescript, the compilation to JavaScript is needed to execute the code.
So that gives people a false sense of security.

I use Typescript as an example to make the problem more visible. But the problem exists in most solutions that compile to JavaScript.

I don't blame developers for the problem. When a language provides a strong type system it becomes easy to forget the double check you need to do because of the compilation.

How we got here

The JavaScript maintainers keep the language weak typed because of several reasons. The only one that makes some sense to me is the type checking overhead. But the other popular script languages like PHP and Python have the option to use stronger typing. And in the case of PHP I know they made the language faster even with the type checking.

Because of the popularity of Typescript the JavaScript maintainers feel less pressure to implement a stronger type option to JavaScript.

The SPA hype should have made the JavaScript maintainers aware people are using for more complex solutions. But that did not do anything either.

AI data is trained on a lot of code that has this developer blind spot. Could that be the drop that overflows the bucket?

Until then be vigilant when you compile to JavaScript!

Top comments (0)