Conversation
|
reviewed the utf8 hardening. the 2-byte, 3-byte, and 4-byte overlong cases are all rejected correctly against the GHSA scenarios -- path traversal (0xC0 0xAF), NUL injection (0xC0 0x80, 0xE0 0x80 0x80), overlong slash via E0/F0 lead (0xE0 0x81 0xAF, 0xF0 0x80 0x80 0xAF) all return U+FFFD now. two observations on edge cases that the current diff does not cover: 1. lone surrogates in the 3-byte branch. input const utf8 = require('@protobufjs/utf8');
const t = Buffer.from([0xED, 0xA0, 0x80]);
console.log(utf8.read(t, 0, t.length).charCodeAt(0).toString(16)); // "d800"minimal patch alongside the existing - str += c3 >= 0x800 ? String.fromCharCode(c3) : replacementChar;
+ str += (c3 >= 0x800 && (c3 < 0xD800 || c3 > 0xDFFF))
+ ? String.fromCharCode(c3)
+ : replacementChar;2. above-U+10FFFF in the 4-byte branch. input minimal patch: - if (t2 < 0x10000)
+ if (t2 < 0x10000 || t2 > 0x10FFFF)
str += replacementChar;
else {i can send the regression test cases i drafted in the private fork (commit nothing in this PR contradicts the report's findings on the 2/3/4-byte overlong rejection -- the approach is cleaner than my draft. just flagging the two edge cases above for completeness before merge. if you'd prefer, i can open a follow-up PR against |
|
This seems to be broken protos:build:protos: > pbjs --force-message --null-semantics -t static-module -w wrapper.js --force-number --dependency protobufjs/minimal.js --es6 -o ./protos.js ../../../protos/* Edit: version mismatch between protobufjs-cli and protobufjs. Some version constraints when making incompatible changes would be welcome |
Tightens validation and code generation handling for input edge cases, and refreshes generated fixtures and TypeScript definitions.