Skip to content

Conversation

@engineering87
Copy link
Owner

No description provided.

@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.


_logger?.LogInformation($"Connection {Context.ConnectionId} added to group {groupName}");
_logger?.LogInformation("Connection {ConnectionId} added to group {GroupName}",
Context.ConnectionId, LogSanitizer.Sanitize(groupName));

Check failure

Code scanning / CodeQL

Log entries created from user input High

This log entry depends on a
user-provided value
.

Copilot Autofix

AI 4 months ago

To fully mitigate log forging risks as per CodeQL's guidance and best practices, we should:

  • Ensure that user input used in logging is not only stripped of control characters, but also of curly braces ({} and }), which are special in Microsoft logging templates and may cause confusion or malformed logs.
  • Optionally, clearly delimit user input (e.g., quote or bracket it) in logs.

Edit required:

  • Update LogSanitizer.Sanitize in src/WART-Core/Utilities/LogSanitizer.cs to remove { and } characters from input strings, in addition to control characters.
  • No changes needed in how Sanitize is used in WartHubBase.cs, since it is already applied.

No additional dependencies are required.


Suggested changeset 1
src/WART-Core/Utilities/LogSanitizer.cs
Outside changed files

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/WART-Core/Utilities/LogSanitizer.cs b/src/WART-Core/Utilities/LogSanitizer.cs
--- a/src/WART-Core/Utilities/LogSanitizer.cs
+++ b/src/WART-Core/Utilities/LogSanitizer.cs
@@ -16,7 +16,7 @@
             if (string.IsNullOrEmpty(input)) return input;
 
             return new string(input
-                .Where(c => !char.IsControl(c))
+                .Where(c => !char.IsControl(c) && c != '{' && c != '}')
                 .ToArray());
         }
     }
EOF
@@ -16,7 +16,7 @@
if (string.IsNullOrEmpty(input)) return input;

return new string(input
.Where(c => !char.IsControl(c))
.Where(c => !char.IsControl(c) && c != '{' && c != '}')
.ToArray());
}
}
Copilot is powered by AI and may make mistakes. Always verify output.
@engineering87 engineering87 merged commit 7b0dbd9 into main Aug 24, 2025
6 of 7 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