`IPAddress.TryParse(ROS<byte>)` accepts invalid UTF-8

Open
#111,288 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
csharp
Domain
networking

Research direction

Start with the IPv6 parsing logic in src/libraries/Common/src/System/Net/IPv6AddressHelper.Common.cs around lines 159-175, and reproduce the supplied IPAddress.Parse example. Determine the intended handling for invalid UTF-8 in the byte-parsing entry point, then add coverage showing the chosen behavior and verify the existing IPAddress parsing tests.

Written by the indexing model from the issue text.

Description

area-System.Net bug

For example:

IPAddress.Parse([.. "::A%"u8, 255]); // Does not throw

Now that IPAddress accepts parsing bytes (new in .NET 10 - #102144), we seem to also be accepting invalid UTF-8 here:
https://github.com/dotnet/runtime/blob/f1c94c45d66ef415272df6cb61821e632697b6ff/src/libraries/Common/src/System/Net/IPv6AddressHelper.Common.cs#L159-L175

Not sure this is a real issue, but given that the parameters are explicitly named as utf8 (bool TryParse(ReadOnlySpan<byte> utf8Text, ...)) the user may be expecting that a parsed value is also valid UTF-8.

Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/runtime

All issues in dotnet/runtime

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.