Skip to content

fix: keep message-controlled text from starting a log line and bound the replay cache key - #17

Merged
marevol merged 2 commits into
mainfrom
fix/logout-message-log-and-replay-key
Nov 16, 2026
Merged

marevol merged 2 commits into
mainfrom
fix/logout-message-log-and-replay-key

Conversation

@marevol

@marevol marevol commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The assertion consumer service and the logout service are anonymous, and an unsigned message is accepted as far as parsing and validation, so the sender controls every value in it. Three things followed from that.

  • Log line forging in the logout validation. LogoutRequest#isValid and LogoutResponse#isValid logged validationException.getMessage() unchanged. The message quotes the Issuer text, so a line break in an Issuer started a new record of the log. The values are now logged through Util.sanitizeForLog (added in fix: keep the values of a SAML message from starting a line of the log #16).
  • Log line forging through a caught exception. The signature helpers in Util (and getExpireTime) passed the caught exception as the throwable of a WARN or ERROR call. The XML security library quotes the SignatureMethod algorithm URI in its message, an xs:anyURI accepts a line break, and the layout prints the throwable text as it is. These calls now log sanitizeForLog(e) at WARN and keep the stack trace at DEBUG, as the decryption helpers already do.
  • Replay cache growth. The ID of a message is registered in the replay cache for the whole validity window, signed or not, and nothing limited its length. One small deflated request could pin an ID of about 100 KB. InMemoryReplayCache now keeps an ID longer than 128 characters as its SHA-256 digest. Replay detection is unchanged; an entry costs a digest at most.

Test

  • InMemoryReplayCacheTest#testLongIdIsKeptAsDigest: a long ID is still detected as a replay, two long IDs with the same beginning are not mixed up, and the cache holds no long key.
  • UtilsTest#testSanitizeForLogOfTheSignatureAlgorithmTheSecurityLibraryQuotes: the library does quote the algorithm with its line break, the sanitized text has none, and the refusal itself is unchanged.
  • The core module's 425 tests pass.
  • The log output cannot be asserted in a unit test (the test classpath has a NOP logger, as noted in fix: keep the values of a SAML message from starting a line of the log #16). Checked against a running server instead, with a patched plugin jar: of six unsigned logout messages with a line break in the Issuer or a Destination, three wrote a forged line before the change and none after; 300 requests carrying a 100 KB ID kept about 31 MB before and about 1.6 MB after. The signature algorithm case was checked in a standalone run of the library with SLF4J 2 and Logback, not against a server: the WARN is a single line after the change, and the line break appears only in the DEBUG stack trace.

…ing the replay cache

An unsigned LogoutRequest or LogoutResponse is accepted from anyone, so the
sender controls every value in it.

- LogoutRequest and LogoutResponse logged the validation message as it was.
  The message quotes the Issuer text and other values, so a line break in an
  Issuer started a new record of the log. Log it through Util.sanitizeForLog,
  as Util already does for the other warnings.
- The ID of every message that passes validation is kept in the replay cache
  for the validity window, signed or not. With no limit on its length, one small
  deflated request could pin an ID of about 100 KB. The in-memory cache now keeps
  an ID longer than 128 characters as its SHA-256 digest, so replay detection is
  unchanged and an entry costs a digest at most.
…og line

The signature helpers in Util logged the caught exception as the
throwable argument of a WARN call. The XML security library quotes the
SignatureMethod algorithm URI of the message in the exception text, an
xs:anyURI accepts a line break, and the default layout prints the
throwable text as it is, so an unauthenticated sender could start a new
line of the log from the assertion consumer service.

Log the exception through sanitizeForLog at WARN and keep the stack
trace at DEBUG, as the decryption helpers already do. The same change
applies to the other helpers that logged a caught exception at WARN,
and to getExpireTime, which logged the message of a DateTimeParseException
quoting its input at ERROR.
@marevol marevol changed the title fix: keep an unsigned logout message from starting a log line or filling the replay cache fix: keep message-controlled text from starting a log line and bound the replay cache key Nov 15, 2026
@marevol
marevol added this pull request to stack #21 November 16, 2026 14:18
@marevol marevol added this to the 3.1.3 milestone Nov 16, 2026
@marevol marevol self-assigned this Nov 16, 2026
@marevol
marevol merged commit fd12641 into main Nov 16, 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