Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

frontend: Fixing protobufjs Improperly Controlled Modification of Object Prototype Pollution #3014

Closed
wants to merge 1 commit into from

Conversation

hackersontwohouse
Copy link

@hackersontwohouse hackersontwohouse commented May 17, 2024

A user-controlled protobuf message can be used by an attacker to pollute the prototype of Object.prototype by adding and overwriting its data and functions. Exploitation can involve: (1) using the function parse to parse protobuf messages on the fly, (2) loading .proto files by using load/loadSync functions, or (3) providing untrusted input to the functions ReflectionObject.setParsedOption and util.setProperty.

GitHub Issue

#3013

…ect Prototype Pollution

A user-controlled protobuf message can be used by an attacker to pollute the prototype of Object.prototype by adding and overwriting its data and functions. Exploitation can involve: (1) using the function parse to parse protobuf messages on the fly, (2) loading .proto files by using load/loadSync functions, or (3) providing untrusted input to the functions ReflectionObject.setParsedOption and util.setProperty. 

## Vulnerability Description
 * Using the parse function

```js
const protobuf = require("protobufjs");
protobuf.parse('option(a).constructor.prototype.verified = true;');
console.log({}.verified);
// returns true
``` 
 * Using the `setParsedOption` function of a `ReflectionObject`

```js
const protobuf = require("protobufjs");
function gadgetFunction(){
  console.log("User is authenticated");
}
// This will fail, but also pollute the prototype of Object
try {
  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. 
```

 * Using the function `util.setProperty`

```js
const protobuf = require("protobufjs");
protobuf.util.setProperty({}, "constructor.prototype.verified", true);
console.log({}.verified);
// returns true
```  
 
 * With the `proto.poc` file containing the following line:

```
option(foo).constructor.prototype.verified = true;
```
CWE-1321
`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H`
@hackersontwohouse hackersontwohouse requested a review from a team as a code owner May 17, 2024 06:24
@mikecutalo
Copy link
Contributor

mikecutalo commented May 17, 2024

Hey thanks for the fix! Lets also update

"protobufjs": "6.11.3"

edit:

Also the proto tooling

PROTOBUFJS_RELEASE=6.11.3

Copy link

This PR has been marked as stale after 7 or more days of inactivity. Please have a maintainer add the on hold label if this PR should remain open. If there is no further activity or the on hold label is not added, this PR will be closed in 3 days.

@github-actions github-actions bot added the stale Issue hasn't had activity in awhile label May 27, 2024
@github-actions github-actions bot closed this May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Issue hasn't had activity in awhile
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants