Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed code execution vulnerability due to Object coercion
refs GHSA-jqv5-7xpx-qj74 fixes TryGhost/Toolbox#491 - when you call `ToString()` on `Napi::Value`, it calls `napi_coerce_to_string` underneath, which has the ability to run arbitrary JS code if the passed in value is a crafted object - both remote code execution or denial-of-service are possible via this vulnerability - `toString()` on an Object returns `[object Object]` so instead of calling the function, we're going to hardcode it to prevent this issue Credits: Dave McDaniel of Cisco Talos
- Loading branch information
edb1934
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting.
edb1934
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can anyone explain this change? It's breaking for some of our projects.
Data stored in json is being returned as
[object Object]
.cc: @daniellockyer
edb1934
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened an issue: #1694
edb1934
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sounds completely nonsensical... exploiting this "vulnerability" requires the attacker to have the ability to provide node-sqlite3 with arguments that have a custom toString() containing the attacker's code. If an attacker can already introduce custom code into your application like that they already have all the access they could want and don't need node-sqlite3 for anything.
edb1934
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, this "fix" is extremely inappropriate. Even if we were to pretend that implicitly stringifying objects is a security vulnerability, the correct thing to do would be to throw a TypeError, not silently corrupt data being inserted into a database. This is horrible.