Sanitize user input at log call sites - #400
Merged
Christdej merged 1 commit intoJun 12, 2026
Merged
Conversation
Contributor
|
Should be covered by this PR: #398 Also, I would prefer if the commit message were a bit more to the point and followed the commit message best practice |
Contributor
Author
Yes, approved your PR. Lets merge that first and see what security scanning alterts remain. |
Christdej
force-pushed
the
fix/codeql-log-forging-at-log-sites
branch
from
June 12, 2026 07:06
6f337bf to
631707d
Compare
andchiind
approved these changes
Jun 12, 2026
Christdej
force-pushed
the
fix/codeql-log-forging-at-log-sites
branch
from
June 12, 2026 07:58
631707d to
5c56cd6
Compare
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
Resolves the 13 open
cs/log-forging(CWE-117) CodeQL alerts inAnalysisTriggerService.cs(10) andThermalReferenceMetadataService.cs(3) by applyingSanitize.SanitizeUserInputdirectly at eachlogger.Log*call site.Prior in-function upstream sanitization (e.g.
input.X = Sanitize.SanitizeUserInput(input.X)at the top of service methods) is removed in favour of sanitizing only at the log call where the value is consumed. CodeQL's taint analysis loses the custom helper across.Select(...).ToList()projections, helper-method return values, DB round-trips, and private-helper parameters, so log-site sanitization is what reliably clears the alerts. Consolidating to log-site only also drops the duplication.Controller-level entry-point sanitization added by #372/#398 is in different files and is unchanged.
Verification
dotnet build api/api.csproj: 0 warnings / 0 errors.dotnet test: 88/88 pass.Code-scanning alerts addressed
ThermalReferenceMetadataService.cs:AnalysisTriggerService.cs: