Skip to content

Commit 3290854

Browse files
committed
Apply more code review suggestions
1 parent f3c6262 commit 3290854

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/site/asciidoc/security.adoc

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,15 @@ Specific security considerations involved in our threat model are detailed below
5959
When using a log message containing template parameters like `{}`, only the format string is evaluated for parameters to be substituted.
6060
The message parameters themselves are not evaluated for parameters; they are only included in the format string corresponding to their template position.
6161
The conversion of message parameters into a string is done on-demand depending on the layout being used.
62-
When structure-preserving transformations of log message data are required, the `Message` API should be used for logging structured data.
62+
When structure-preserving transformations of log message data are required, the `Message` API should be used for logging structured data combined with a structured layout (e.g., `JsonTemplateLayout`).
63+
Format strings should be compile-time constants, and under no circumstances should format strings be built using user-controlled input data.
6364
6465
=== Unstructured Logging
6566
6667
When using an unstructured layout such as `PatternLayout`, no guarantees can be made about the output format.
6768
This layout is mainly useful for development purposes and should not be relied on in production applications.
6869
For example, if a log message contains new lines, these are not escaped or encoded specially unless the configured pattern uses the `%encode{pattern}{CRLF}` wrapper pattern converter (which will encode a carriage return as the string `\r` and a line feed as the string `\n`) or some other `%encode` option.
70+
Note that `%xEx` is appended to the pattern unless already present.
6971
Similarly, other encoding options are available for other formats, but pattern layouts cannot make assumptions about the entire output.
7072
As such, when using unstructured layouts, no user-controlled input should be included in logs.
7173
It is strongly recommended that a structured layout (e.g., `JsonTemplateLayout`) is used instead for these situations.
@@ -115,14 +117,6 @@ When configurations are modified through JMX, the JMX server should be safely co
115117
When configurations are provided through JNDI, these should only use the `java` scheme for sharing configurations in a JavaEE or JakartaEE application service.
116118
JNDI-sourced configurations should not use other JNDI providers such as LDAP, DNS, or RMI, as all these providers are difficult to properly secure.
117119
118-
=== Cryptographic Logs
119-
120-
When using custom plugins to calculate message authentication codes, signatures, or encrypted logs, proper key management must be considered.
121-
Cryptography is a tricky subject, and key management lies at the heart of most design problems to solve when using it.
122-
If a custom plugin relies on a pre-shared key or password of some sort, it is likely broken beyond repair if being used for cryptographic purposes.
123-
Proper key management typically uses public key infrastructure (PKI) such as X.509 certificates, though this is not the only option.
124-
It is beyond the scope of Log4j to implement key management as this would depend on other infrastructure in use for validating or decrypting logs combined with the deployment and runtime environment of the logging application.
125-
126120
=== Compressing Logs
127121
128122
If log compression is used along with custom encryption where logs contain user-controlled input, then this can lead to a https://en.wikipedia.org/wiki/CRIME[CRIME attack] style vulnerability where a chosen-plaintext attack is combined with information leakage caused by how the compression algorithm handles different inputs.

0 commit comments

Comments
 (0)