Javascript string decode leaves parser in a bad state if there are invalid or truncated UTF-8 characters
@lukesandberg ya está trabajando en esto.
Desde el 7/10/2022.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
What version of protobuf and what language are you using?
Version: v3.7.1.
Language: Javascript
What operating system (Linux, Windows, ...) and version?
Chrome
What runtime / compiler are you using (e.g., python version or gcc version)
Webpack/Typescript/Chrome
What did you do?
When a protobuf with a string field is parsed and that string field ends with an incomplete UTF8 character, readString in the binary decoder will advance the read cursor past the end of the string field, causing the rest of the message to fail to parse.
What did you expect to see
Possibly an assert in the string reader, but allow rest of message to parse correctly despite invalid content in the string field.
What did you see instead?
Usually an assert is thrown, but the error is bogus as the binary reader has advanced into field data and is trying to interpret it as field number/metadata. The error does not identify the string field that actually caused the problem.
The function is located here, in jspb.BinaryDecoder.prototype.readString:
https://github.com/protocolbuffers/protobuf/blob/master/js/binary/decoder.js#L830
The problem arises due to a combination of advancing the cursor without bounds checking:
} else if (c < 240) { // UTF-8 with three bytes.
var c2 = bytes[cursor++];
var c3 = bytes[cursor++];
which can allow for cursor to advance past end. At the exit of the function, the reader's internal cursor is set:
this.cursor_ = cursor;
At this point, cursor is a byte or two into the next field, and parsing fails.
Anything else we should know about your project / environment
The other end of this communication channel is using the C++ protobuf library, which does optionally warn but ultimately allows for potentially invalid utf-8 data to be serialized.
- Lenguaje dominante
- JavaScript
- Estrellas
- 471
- Forks
- 91
- Merge medio
- 1 d 12 h
- PR fusionados (30 d)
- 6
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de protocolbuffers/protobuf-javascript
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 30/100
protocolbuffers/protobuf-javascript#248 · 1 comentario · 13 reacciones ·
-
question
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
protocolbuffers/protobuf-javascript#222 · 9 comentarios ·
-
Why map.js sort keys?Abiertoenhancement port-fix triaged
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
protocolbuffers/protobuf-javascript#185 · 1 comentario ·
-
enhancement port-fix triaged
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
protocolbuffers/protobuf-javascript#182 · 3 comentarios · 1 reacción ·
Todos los issues de protocolbuffers/protobuf-javascript
Issues similares
-
bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
PedestrianDynamics/pyFDS-Evac#476 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
aiko-chan-ai/DiscordBotClient#380 ·
-
Offisielle trærAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
-
Daemon delete dialog: "Remove all ExApps" checkbox and `removeExApps` parameter have no effectAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 3 días
-
Add: Atlas TVAbiertochannels:add check:passed
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 4 días