Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Avro: invalid UTF-8 sequences (overlong, surrogates, > U+10FFFF, bad continuation bytes) not rejected in strings

Aperta
#862 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
57/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
java
Ambito
backend, security

Direzione di ricerca

Start with JacksonAvroParserImpl and trace the short-text loop, _finishLongText(), _decodeUTF8_3(), and _decodeUTF8_4(). Compare the short and long paths using the listed malformed byte sequences in string values and map keys; fix the broken invalid-lead-byte format string as well. Done when invalid UTF-8 is rejected consistently across both paths and the error reports the byte correctly.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

avro

The Avro parser (JacksonAvroParserImpl) accepts several invalid UTF-8 sequences in string values and map keys and decodes them into characters. RFC 3629 makes these sequences invalid.

Same class of bug as FasterXML/jackson-core#1782 and FasterXML/jackson-dataformats-text#763.

Reproduced on 2.x:

AvroMapper mapper = new AvroMapper();
AvroSchema schema = mapper.schemaFrom(
    "{\"type\":\"record\",\"name\":\"R\",\"fields\":[{\"name\":\"s\",\"type\":\"string\"}]}");
// zigzag length 4, then 'a' C0 AF 'b'
byte[] doc = {0x08, 'a', (byte) 0xC0, (byte) 0xAF, 'b'};
JsonParser p = mapper.getFactory().createParser(doc);
p.setSchema(schema);
p.nextToken(); p.nextToken(); p.nextToken();
p.getText(); // -> "a/b"
Bytes Result
C0 AF, E0 80 AF (overlong) /
F0 80 80 AF (overlong 4-byte) ￀\uDC2F
ED A0 80 (encoded surrogate) lone \uD800
F4 90 80 80 (above U+10FFFF) \uDC00\uDC00
F5 80 80 80 (lead byte F5-F7) \uDCC0\uDC00
C3 41, E2 41 41, F0 41 41 41 (missing continuation bytes) Á, ⁁, ᅣ\uDC41

The missing-continuation rows apply to strings that fit in the input buffer (the short-text loop). _finishLongText() rejects them. The other rows apply to both paths and to map keys.

Separately, the error for an invalid lead byte in the short-text path has a broken format string:

Invalid byte 0x2X in Unicode text block

String.format("Invalid byte 0x2X in Unicode text block", i) should be "... 0x%02X ...".

Suggested fix: check continuation bytes in the short-text loop. After decoding, check minimum values of 0x80, 0x800 and 0x10000 for 2-, 3- and 4-byte sequences, a maximum of 0x10FFFF, and reject 0xD800-0xDFFF, in both the short-text loop and _decodeUTF8_3()/_decodeUTF8_4().

Lingua principale
Java
Stelle
348
Fork
159
Merge medio
21h 39m
PR unite (30g)
41

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di FasterXML/jackson-dataformats-binary

Tutte le issue di FasterXML/jackson-dataformats-binary

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.