Background
I am attempting to perform a path traversal attack on a vulnerable service hosted in IIS.
The service is something like this:
GET /api/download/{file-name}
The underlying code is something like this:
return File.Read("some/directory/" + fileName);
As written, this service is clearly vulnerable.
Kestrel Attack
I can perform a path traversal attack when running locally using dotnet run, which I gather uses the Kestrel web server. My attack payload is ..\..\secret.txt, which is encoded and visible in the log:
Request starting HTTP/1.1 GET http://localhost/api/download/..%5C..%5Csecret.txt
IIS Attack
I cannot reproduce this attack on the same app when hosted in IIS. It appears that IIS somehow normalizes the URI by interpreting the ..\, which means it never hits my API. In other words, it attempts to hit the following endpoint:
GET http://localhost/secret.txt
I have tried a variety of different encodings for the ..\ character sequence, but no luck.
Question
How can I work around this IIS behavior to perform a path traversal attack on this vulnerable app, hosted in IIS?