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

Đang mở
#4,464 2 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@lunarbae628 đang làm issue này rồi.

Từ ngày 7/11/2026.

  • #4471 của @lunarbae628 — đang mở
  • #4472 của @lunarbae628 — đang mở

Đánh giá

Issue này chưa được đánh giá.

Mô tả

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 \].

Ngôn ngữ chính
Java
Star
3.6k
Fork
1.8k
Merge trung bình
5 ngày 6 giờ
Pull request đã merge (30 ngày)
24

Chuẩn bị môi trường

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/logging-log4j2

Tất cả issue của apache/logging-log4j2

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.