Server Side JavaScript Code Injection
A server-side JavaScript code injection in fastify's serialization schema allows an attacker who controls a property name to achieve remote command execution. The attacker can run arbitrary code as the web server user.
- Triaged in 31 days
- Fixed in 5 months
- Paid in 8 months
- Disclosed after 6 months
I would like to report a Service Side JavaScript Code Injection in fastify.
It allows an attacker that can control a single property name in the serialization schema to achieve Remote Command Execution in the context of the web server.
Module
module name: fastify
version: 2.2.0
npm page: https://www.npmjs.com/package/fastify
Module Description
An efficient server implies a lower cost of the infrastructure, a better responsiveness under load and happy users. How can you efficiently handle the resources of your server, knowing that you are serving the highest number of requests as possible, without sacrificing security validations and handy development? Enter Fastify. Fastify is a web framework highly focused on providing the best developer experience with the least overhead and a powerful plugin architecture. It is inspired by Hapi and Express and as far as we know, it is one of the fastest web frameworks in town.
Module Stats
39,119 downloads in the last week
Vulnerability
Vulnerability Description
Description about how the vulnerability was found and how it can be exploited, how it harms package users (data modification/lost, system access, other.
Steps To Reproduce:
Detailed steps to reproduce with all required references/steps/commands. If there is any exploit code or reference to the package source code this is the place where it should be put.
Patch
Escape ", ' and ` in properties names in schema definition.
Supporting Material/References:
State all technical information about the stack where the vulnerability was found
- OS: Kali Rolling
- NodeJS: 11.9
- NPM: 6.5.0
- fast-json-stringify: 1.14.0
Wrap up
Select Y or N for the following statements:
- I contacted the maintainer to let them know: Y (sent message to Matteo Collina)
- I opened an issue in the related repository: N
Impact
If an attacker can control somehow the schema definition, he/she can achieve arbitrary code execution as the user running the web server.
Attachments

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely, property names from the schema are inserted into generated JavaScript code without escaping quotes or backticks, allowing code injection.
Impact
An attacker who can control the schema definition could achieve arbitrary code execution as the user running the web server.
What the attacker needed
Attacker controls a property name in schema
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Fastify is a web framework that can turn data into JSON using a schema. If an attacker can choose the name of a property in that schema, they can sneak in JavaScript code that the server then runs. This gives the attacker the same powers as the web server process.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.