-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[release/9.0-staging] Prevent format injection in hosting Windows PAL printf functions when redirected to file #119786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[release/9.0-staging] Prevent format injection in hosting Windows PAL printf functions when redirected to file #119786
Conversation
… redirected to file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a format injection vulnerability in the hosting Windows PAL printf functions when output is redirected to a file. The issue occurs when paths in deps.json or framework names in runtimeconfig.json contain '%' characters, which are interpreted as format specifiers and can cause crashes.
- Replaces direct
pal::file_vprintf
call with a saferfile_printf
wrapper that uses%s
format specifier - Adds a new
file_printf
helper function to properly handle string formatting - Prevents format injection attacks when trace output is redirected to files
Approved. Please get code review and check test results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
CC @jeffschwMSFT. |
/azp run runtime |
Azure Pipelines successfully started running 1 pipeline(s). |
/ba-g failures matched to existing issue, but BA is not green because this is a servicing branch |
836cc98
into
dotnet:release/9.0-staging
Fixes Issue #119566
main PR #119568
Description
Customer Impact
Prevents crashes when a path in deps.json or a framework name in runtimeconfig.json contains a '%' character.
Regression
Yes, introduced by #102295
Testing
Manual validation with testing
Risk
Low risk. This is a standard fix for this scenario, and it's only reachable on .NET 9 with an opt-in
COREHOST_TRACE=1
environment variable.Package authoring no longer needed in .NET 9
IMPORTANT: Starting with .NET 9, you no longer need to edit a NuGet package's csproj to enable building and bump the version.
Keep in mind that we still need package authoring in .NET 8 and older versions.