Skip to content

fix: keep the values of a SAML message from starting a line of the log - #16

Merged
marevol merged 1 commit into
mainfrom
fix/keep-message-values-off-the-log-lines
Nov 12, 2026
Merged

marevol merged 1 commit into
mainfrom
fix/keep-message-values-off-the-log-lines

Conversation

@marevol

@marevol marevol commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Summary

The warnings that quote a SAML message could be made to start a new log record by a caller that is not logged in, because a line break in a value the sender controls was written to the log as it is.

  • Util#validateXML logged the schema errors unchanged. The XML parser quotes the offending value, so a line break in an anyURI or NCName value (Audience, Destination, Recipient, InResponseTo, the Algorithm of a signature, ...) ended the record. The schema check runs before the signature check, so the message does not have to be signed; a caller only needs a pending AuthnRequest of its own session.
  • Util#sanitizeForLog is new. It replaces control characters and the Unicode line and paragraph separators with a space and bounds the length. It is applied to the schema errors, the XML load and validateXML failures, the deprecated algorithm notice and the signature check failure.
  • A failed decryption is one line at warn and the stack trace moves to debug, as Util#loadXML already does. A malformed EncryptedAssertion wrote about a hundred lines per request.

Test

  • UtilsTest covers sanitizeForLog and the errors the schema check quotes. mvn -pl core test: 423 tests, 0 failures.
  • Checked against a running service provider with the patched classes: a response with a line break in each of 12 values, not signed, wrote a forged record for 9 of them before the change and none after; a malformed EncryptedAssertion wrote 98 lines before and 3 after.

The assertion consumer service of a service provider is anonymous, and the
schema check, the algorithm check and the parser quote what the sender wrote.
Util#validateXML logged the schema errors as they are, so a line break in an
attribute or in an element value (for example Audience, Destination,
Recipient or the Algorithm of a signature) ended the log record and let the
sender write another one. The signature is checked after the schema, so the
message does not have to be signed.

- add Util#sanitizeForLog, which replaces control characters and the Unicode
  line and paragraph separators with a space and bounds the length
- use it for the warnings that quote the message: the schema errors, the XML
  load and validateXML failures, the deprecated algorithm notice and the
  signature check failure
- log a failed decryption as one line at warn and keep the stack trace at
  debug, as Util#loadXML already does: a malformed EncryptedAssertion wrote
  about a hundred lines per request
@marevol marevol self-assigned this Nov 12, 2026
@marevol marevol added this to the 3.1.3 milestone Nov 12, 2026
@marevol
marevol merged commit b350c34 into main Nov 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant