protobuf.js: Code injection in pbjs static output from crafted schema names
High severity
GitHub Reviewed
Published
May 12, 2026
in
protobufjs/protobuf.js
•
Updated May 14, 2026
Package
Affected versions
<= 1.2.0
>= 2.0.0, <= 2.0.1
Patched versions
1.2.1
2.0.2
Description
Published to the GitHub Advisory Database
May 12, 2026
Reviewed
May 12, 2026
Published by the National Vulnerability Database
May 13, 2026
Last updated
May 14, 2026
Summary
pbjsstatic code generation could emit unsafe JavaScript identifiers derived from schema-controlled names. When generating static JavaScript from a crafted schema or JSON descriptor, certain namespace, enum, service, or derived full names could be written into the generated output without sufficient sanitization.Impact
An attacker who can provide or influence schemas passed to
pbjsmay be able to cause generated JavaScript output to contain attacker-controlled code. The injected code would run if the generated file is later executed or imported by the application or build process.This affects the protobufjs CLI static code generation path. Applications that only use trusted schemas, or that do not execute generated output from untrusted schemas, are not directly affected.
Preconditions
pbjsstatic code generation on a schema or JSON descriptor influenced by an attacker.Workarounds
Do not run affected versions of
pbjsstatic code generation on untrusted schemas or descriptors. If untrusted schemas must be accepted, validate schema names before code generation and run generation in an isolated environment.References