Repository navigation
fix: keep message-controlled text from starting a log line and bound the replay cache key - #17
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
LogoutRequest#isValidandLogoutResponse#isValidloggedvalidationException.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 throughUtil.sanitizeForLog(added in fix: keep the values of a SAML message from starting a line of the log #16).Util(andgetExpireTime) passed the caught exception as the throwable of a WARN or ERROR call. The XML security library quotes theSignatureMethodalgorithm URI in its message, anxs:anyURIaccepts a line break, and the layout prints the throwable text as it is. These calls now logsanitizeForLog(e)at WARN and keep the stack trace at DEBUG, as the decryption helpers already do.InMemoryReplayCachenow 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.coremodule's 425 tests pass.