Ghost Foundation node-sqlite3 code execution vulnerability
A code execution vulnerability exists in the Statement Bindings functionality of node-sqlite3 5.1.1, where a specially crafted JavaScript object can cause arbitrary code execution via the toString() method. In Ghost CMS, due to JSON restrictions, this only manifests as a remote denial of service that crashes the Node.js service.
Originally disclosed on Cisco Talos
A code execution vulnerability exists in the Statement Bindings functionality of Ghost Foundation node-sqlite3 5.1.1. A specially-crafted Javascript file can lead to arbitrary code execution.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
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
The library calls toString() on user-supplied objects during parameter binding without validating that the method is safe, allowing attacker-controlled JavaScript to execute.
Impact
In Ghost CMS, this vulnerability only causes a remote denial of service, crashing the Node.js service; in other contexts, it could lead to arbitrary code execution.
What the attacker needed
Ability to send JSON input to the application; Application uses node-sqlite3 for database queries
The fix
The vulnerability was fixed in a vendor patch release.
How it was found
- Send a request with a JSON body containing an array with an object that has a toString property set to null.
- The library binds the parameter, calls toString() on the object, which returns undefined, leading to a null value being pushed.
- The next element in the array causes an exception, and the null value is then used in a type check, leading to a crash.
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.
This report describes a bug in a library that lets Node.js programs talk to SQLite databases. When the library processes query parameters, it can be tricked into running JavaScript code that an attacker supplies, because it calls a method called toString() on an object without checking what that method does. In the Ghost CMS case, the attacker cannot run arbitrary code due to JSON limits, but can still crash the whole service.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.