Uh oh!
There was an error while loading. Please reload this page.
.NET: sanitize redirectUrl for logs - #2356
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds security hardening to prevent log injection attacks by sanitizing the redirectUrl before logging. When redirecting requests to include a trailing slash, the URL is now sanitized to remove newline characters that could be used to inject malicious content into logs.
- Introduces a
GeneratedRegexpattern to match and remove newline characters (\r\n) - Changes the class to
partialto support the source-generated regex - Sanitizes the
redirectUrlbefore logging to prevent log injection vulnerabilities
Uh oh!
There was an error while loading. Please reload this page.
Reuben Bond (ReubenBond)
left a comment
There was a problem hiding this comment.
I am not 100% sure on the right approach for sanitizing log lines. I think it's fine to just delete that log line, tbh. It's a false alarm anyway, because path == _basePath which is a constant and cannot contain newlines.
Korolev Dmitry (DeagleGross)
commented
Nov 20, 2025
I also consider this a false alarm, but I think DevUI should have more logs, not less, to improve dev experience and debugging. That's why decided to leave it. Decided to do the simple regex for now - we can improve later once we find out best practice for sanitization |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
* sanitize redirectUrl for logs * use basepath * sanitize both path and reddirect url
Uh oh!
There was an error while loading. Please reload this page.