dotnet / dotnet/runtime

HttpListener can misroute requests

Open
#131,313 4 comments 0 reactions 0 assignees View on GitHub
area-System.Net
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

### Description

HttpListner has ability to route requests to different instances. ListenerPrefix.cs has logic to find best match but it uses StartsWith and stripped slash so at do incorrect matching.

### Reproduction Steps

register two similar prefixes like /abc and /ab and the second can match the first one.

### Expected behavior

the /ab should not match other prefixes starting with same pattern

### Actual behavior

we can do incorrect match

### Regression?

_No response_

### Known Workarounds

_No response_

### Configuration

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start in ListenerPrefix.cs and trace the best-match logic used when HttpListener routes requests. Reproduce the issue with the /abc and /ab prefixes, then add coverage for that case and verify that /ab does not match a request intended for /abc.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.