`Rfc5424Layout` does not escape the `newLineEscape` replacement in SD-PARAM-VALUE

Abierto
#4,464 2 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@lunarbae628 ya está trabajando en esto.

Desde el 7/11/2026.

  • #4471 de @lunarbae628 — abierto
  • #4472 de @lunarbae628 — abierto

Evaluación

Este issue todavía no se ha evaluado.

Descripción

bug layouts priority: P3

Rfc5424Layout escapes ", \ and ] in structured data parameter values, as required by RFC 5424, section 6.3.3, but applies the newLineEscape replacement afterwards (escapeNewlines(escapeParamValue(value), escapeNewLine) in appendMap). The replacement is therefore emitted verbatim inside the PARAM-VALUE. With the documented newLineEscape="\n", a value A<CR><LF>B from a StructuredDataMessage or from the MDC (includeMDC="true") is written as k="A\nB", with an unescaped backslash. Conforming receivers read this as a literal backslash followed by n, as RFC 5424 requires for invalid escape sequences, but the output does not conform to the sender requirements. A replacement containing ] or " would also be emitted unescaped. The free-form MSG part is not affected, since it has no escaping rules. This issue originates from a private security report classified as a bug.

Fix: apply the newline replacement first and the SD-PARAM-VALUE escaping second, i.e. escapeParamValue(escapeNewlines(value, escapeNewLine)), in both 2.x and main. With newLineEscape="\n" the value is then emitted as A\\nB, which conforming receivers decode to A\nB. Receivers that do not decode RFC 5424 escapes will see \\n instead of \n in structured data values; this should be mentioned in the changelog. Add a test with newLineEscape="\n" and CR/LF in both an MDC value and a StructuredDataMessage value, asserting that the emitted PARAM-VALUE contains only the escapes \", \\ and \].

Lenguaje dominante
Java
Estrellas
3.6k
Forks
1.8k
Merge medio
5 d 6 h
PR fusionados (30 d)
24

Preparar el entorno

  • Sin Dockerfile ni archivo de Docker Compose
  • Tiene una plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de apache/logging-log4j2

Todos los issues de apache/logging-log4j2

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.