Limit the nesting depth of `JsonReader` and document it as internal
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
- 55/100
Direzione di ricerca
Start with JsonReader in the 2.x and 3.x packages named in the issue, then inspect JsonTemplateLayoutCodecFuzzer and its existing tests. Add coverage for input one nesting level above the proposed limit and check the fuzzer’s input bound. Done means excessive nesting raises IllegalArgumentException, the fuzzer no longer expects stack overflows, and Javadocs describe the parser as internal and for trusted input; the package move is only a consideration.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Log4j contains a minimal JSON parser, JsonReader, used to parse Log4j's own configuration: JSON configuration files, the MutableThreadContextMapFilter configuration, property mappings, and JSON Template Layout templates and resolver configuration. In 2.x it lives in org.apache.logging.log4j.layout.template.json.util; in 3.x in org.apache.logging.log4j.kit.json, which log4j-kit exports (OSGi @Export, version 3.0.0) under the module description "Helpers to implement Log4j 2.x API".
The parser recurses through readToken(), readArray() and readObject() without a depth limit, so a deeply nested document (a few thousand levels with the default thread stack) ends in a StackOverflowError instead of the IllegalArgumentException thrown for other malformed input. JsonTemplateLayoutCodecFuzzer currently works around this by bounding the length of its input (see OSS-Fuzz issue 370272570). Moreover, nothing in the Javadoc says that the parser is meant only for Log4j's own, operator-supplied input, and the exported 3.x package can give the impression that it is a general-purpose JSON parser.
Proposal:
- Add a nesting-depth counter to
JsonReader, incremented on entry toreadArray()andreadObject(), and throw anIllegalArgumentExceptiononce it exceeds a fixed limit (e.g. 128, far above the nesting of any real configuration file), in both 2.x and 3.x. Add a test parsing a document one level above the limit. - Relax the input length bound of
JsonTemplateLayoutCodecFuzzerand remove its comment about expected stack overflows. - State in the Javadoc of
JsonReaderand of its package that it is an internal component intended only for trusted input. Before 3.0.0 GA, consider moving the 3.x class to a non-exported (internal) package.
This issue originates from a private security report classified as a hardening.
- Lingua principale
- Java
- Stelle
- 3.6k
- Fork
- 1.8k
- Merge medio
- 5g 6h
- PR unite (30g)
- 24
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/logging-log4j2
-
additivity attributeApertawaiting-for-maintainer
Difficoltà 2/5 1-3 ore Idoneità per principianti 63/100
apache/logging-log4j2#4475 ·
I maintainer di solito rispondono entro 1 giorno
-
Migrate `log4j-api-test` tests to JUnit 5Forse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertaapi priority: P3 tests waiting-for-maintainer
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
apache/logging-log4j2#4430 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
`Rfc5424Layout` does not escape the `newLineEscape` replacement in SD-PARAM-VALUEForse già presa @lunarbae628 l’ha presa 5 giorni fa. Apertabug layouts priority: P3
apache/logging-log4j2#4464 · 2 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
`evaluateOnStartup="true"` saves logs under wrong file names after missing scheduled rollForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertaappenders:Rolling bug priority: P1 waiting-for-maintainer
Difficoltà 3/5 1-2 giorni Idoneità per principianti 30/100
apache/logging-log4j2#4449 ·
I maintainer di solito rispondono entro 1 giorno
-
`PluginBuilder` reads builder fields that `GraalVmProcessor` does not register, so `LevelMatchFilter`, `SystemPropertyArbiter` and others fail in GraalVM native imagesForse già presa @typat l’ha presa 13 giorni fa. Apertabug graalvm plugins priority: P2 waiting-for-maintainer
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
apache/logging-log4j2#4441 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di apache/logging-log4j2
Issue simili
-
[Bug]: Nullable implicit operator on string extensible enums still throws for a null stringForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertabug emitter:client:csharp
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
microsoft/typespec#12572 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG]: Java SDK MountRequest always sends update-optional fields, resetting stored mount settingsApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
GCC 15.2: -Wcast-qual warning - cast discards const qualifier from pointer target type (H5trace.c)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug] RemotingHelper.connect swaps the socket send and receive buffer configurationForse già presa @amalsaidov l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
needs-area-label
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 2 giorni