azure-sdk-for-net
azure-sdk-for-net copied to clipboard
[BUG] Invalid user-agent header generated when OSDescription has unmatched parentheses
Library name and version
Azure.Core 1.28.0
Describe the bug
When RuntimeInformation.OSDescription has a string containing "(" with no matching ")", TelemetryDetails constructs an invalid User-Agent string.
For example, if the OSDescription is "MyOSDescription (2023-", the resulting User-Agent header will be "azsdk-net-Security.KeyVault.Certificates/4.3.0 (.NET 6.0.0; MyOSDescription (2023-)". The mismatched parentheses cause the header to fail to be parsed by a server that expects headers to conform to the HTTP specification.
Expected behavior
User-Agent header should be valid according to the HTTP specification. Characters in OSDescription that could lead to an invalid header should be correctly escaped.
Actual behavior
Parentheses in OSDescription are not escaped and can lead to invalid User-Agent headers
Reproduction Steps
Run on an OS platform where OSDescription has an unmatched parentheses. Inspect the User-Agent header added to all REST API calls.
Environment
.NET 6.0.13 OSDescription: Linux 6.1.10-1-liquorix-amd64 # 1 ZEN SMP PREEMPT_DYNAMIC liquorix 6.1-23ubuntu1~kinetic (2023-
//cc: @annelo-msft, @JoshLove-msft
Thank you for your feedback. Tagging and routing to the team member best able to assist.