Fix segfault when TMPDIR contains printf format specifiers#122909
Fix segfault when TMPDIR contains printf format specifiers#122909
Conversation
Co-authored-by: steveisok <471438+steveisok@users.noreply.github.com>
|
Is a TMPDIR that has format specifiers really valid? |
|
I do agree that:
but then the question remains: TMPDIR will give us something with a format specifier. We'd add pipes, dump, and all that here. We take environment to be a trusted block by the user, but does it succeed at creating files in such a dir? |
Directories with a format specifier are valid. It's unclear if the change creates additional problems later. Should we just disallow format specifiers / special characters? |
|
Given that % is not a reserved character on Unix or Windows, this PR is closer to being correct. We should test running an app with it - but generally we should just honor that this is a valid directory. |
|
Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it. |
Description
PAL_GetTransportNamewas concatenating TMPDIR directly into a format string, causing segfaults when TMPDIR contained format specifiers like%d.Before:
After:
Customer Impact
.NET crashes immediately on any invocation (including
dotnet --info) when TMPDIR contains format specifiers. Affects users in environments like NixOS where TMPDIR may be set to paths containing%characters.Regression
No. Issue exists in all versions using this code path.
Testing
Verified with test program demonstrating TMPDIR="/tmp/%d" no longer causes segfault. CoreCLR builds successfully.
Risk
Low. Changes are surgical and only affect the transport pipe name construction. Format string is now evaluated separately before concatenation, eliminating the vulnerability without changing the final path structure.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.