Skip to content

Fix log forging vulnerability (CodeQL alert #1) in GraderFunction.cs - #19

Merged
Lee Stott (leestott) merged 2 commits into
mainfrom
copilot/fix-code-scanning-alerts-another-one
Aug 24, 2026
Merged

Fix log forging vulnerability (CodeQL alert #1) in GraderFunction.cs#19
Lee Stott (leestott) merged 2 commits into
mainfrom
copilot/fix-code-scanning-alerts-another-one

Conversation

Copilot AI commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

CodeQL flagged alert #1 (cs/log-forging) in GraderFunctionApp/GraderFunction.cs: the user-controlled trace query parameter was written directly into log messages, allowing an attacker to inject \r/\n sequences and forge fake log entries.

Changes

  • Sanitize trace before logging by stripping carriage return and newline characters, while keeping the original value intact for ExtractEmail.
string trace = req.Query["trace"];
var email = ExtractEmail(trace);
string sanitizedTrace = trace?.Replace("\r", "").Replace("\n", "");
log.LogInformation("start:" + sanitizedTrace);
xml = await RunUnitTestProcess(context, log, credentials, email, filter);
log.LogInformation("end:" + sanitizedTrace);

Verification

  • Re-ran CodeQL analysis after the fix: 0 alerts remaining.
  • Alert Initial commit. #1 was confirmed a genuine issue (not a false positive) — no other alerts were in scope for this change.

Co-authored-by: leestott <2511341+leestott@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix code scanning alert(s) flagged in repository Fix log forging vulnerability (CodeQL alert #1) in GraderFunction.cs Aug 24, 2026
@leestott
Lee Stott (leestott) marked this pull request as ready for review August 24, 2026 11:46
@leestott
Lee Stott (leestott) merged commit 5c41f01 into main Aug 24, 2026
5 of 6 checks 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.

2 participants