VDB
Sign up
HIGH

GHSA-66ff-xgx4-vchm

protobuf.js: Code injection through bytes field defaults in generated toObject code

Quick fix

GHSA-66ff-xgx4-vchm — protobufjs: upgrade to the fixed version with the command below.

npm install protobufjs@7.5.6

Details

## Summary

protobufjs generated JavaScript for `toObject` conversion could include an unsafe expression derived from a schema-controlled `bytes` field default value. A crafted descriptor with a non-string default value for a `bytes` field could cause attacker-controlled code to be emitted into the generated conversion function.

## Impact

An attacker who can provide or influence a protobuf descriptor may be able to execute arbitrary JavaScript in the context of the process using protobufjs.

This requires the application to load an attacker-controlled schema or descriptor and then convert a message of the affected type with defaults enabled. Applications that only use trusted, application-defined schemas are not directly affected by this issue.

## Preconditions

- The application must allow an attacker to control or influence a protobuf JSON descriptor or equivalent reflected schema. - The descriptor must define a `bytes` field with an attacker-controlled default value. - The application must call `toObject` with defaults enabled for the affected type.

## Workarounds

Do not load protobuf schemas or JSON descriptors from untrusted sources with affected versions. If untrusted schemas must be accepted, validate or restrict field options before loading them and run schema processing in an isolated environment.

Are you affected?

Enter the version of the package you're using.

Affected packages

npm/protobufjs
Introduced in: 0Fixed in: 7.5.6
Fixnpm install protobufjs@7.5.6
npm/protobufjs
Introduced in: 8.0.0Fixed in: 8.0.2
Fixnpm install protobufjs@8.0.2

References