Skip to content

[release/2.1] Expect100Continue with Windows auth and request body > 1024 bytes fails #26662

Closed
dotnet/corefx
#38744

Description

@mconnew

In this code: https://github.com/dotnet/corefx/blob/7ee84596d92e178bce54c986df31ccc52479e772/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnection.cs#L534-L549
If the Expect100Continue header is set, and the response code is >= 300 and there's a request body with known length greater than 1024 bytes, if the request body hasn't begun to be sent yet, it sets _connectionClose to true. When using authentication, the challenge response comes with an HTTP status code of 401. As (401 >= 300) evaluates to true, whenever using authentication with request body size > 1024 bytes, _connectionClose will be set to true. In this code: https://github.com/dotnet/corefx/blob/7ee84596d92e178bce54c986df31ccc52479e772/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/AuthenticationHelper.NtAuth.cs#L68-L75
If there was a valid authentication challenge and a response is available to send, a call is made to HttpConnection.DrainResponseAsync. In that method: https://github.com/dotnet/corefx/blob/7ee84596d92e178bce54c986df31ccc52479e772/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnection.cs#L1528-L1531
If _connectionClose is true, it throws and aborts the request.
This is breaking Windows authentication for WCF with requests which are larger than 1024.

Activity

  1. davidsh commented on Jun 29, 2018

    @davidsh
    Contributor
  2. karelz commented on Jun 30, 2018

    @karelz
    Member

    @mconnew mentioned to me offline that it is a regression 2.0->2.1
    What is the impact on WCF scenarios/customers? How common are the scenarios?
    Are there any workarounds on WCF side or on customer side?
    (just trying to understand the scope & impact)

  3. davidsh commented on Jun 30, 2018

    @davidsh
    Contributor

    @mconnew mentioned to me offline that it is a regression 2.0->2.1

    It could only be a regression on Linux from using CurlHandler on .NET Core 2.0 (which supported Expect: 100-continue) to using SocketsHttpHandler on .NET Core 2.1.

    On Windows, with .NET Core 2.0 (WinHttpHandler), Expect: 100-continue is not supported.

  4. mconnew commented on Jun 30, 2018

    @mconnew
    MemberAuthor

    @davidsh, while Expect: 100-Continue is not supported by WinHTTP in actually implementing the functionality to hold off sending the request body, if you add the Expect header, it will still functionally be able to send the request and get the response when using authentication. Now on Windows, that is no longer the case. So while the purpose of the header couldn't be used, things were still functional if you did use it. So this is a regression on Windows in that you could get a response before, you can't now.

  5. geoffkizer commented on Jun 30, 2018

    @geoffkizer
    Contributor

    @mconnew, I'm curious: Why are you setting Expect: 100-continue in this scenario?

  6. mconnew commented on Jul 1, 2018

    @mconnew
    MemberAuthor

    Without it, the entire request body will be sent for the initial request and for the challenge response. If the request message is for example 10MB, that's double the data you are then sending and double the amount of time it takes to get a response. Additionally, according to the customer who saw this issue, in their testing setting Connection: Close header without Expect: 100-Continue also has the same problem.

  7. karelz commented on Jul 6, 2018

    @karelz
    Member

    @mconnew can you please answer the questions above for us to prioritize it properly?

    • What is the impact on WCF scenarios/customers? How common are the scenarios?
    • Are there any workarounds on WCF side or on customer side?
  8. mconnew commented on Jul 9, 2018

    @mconnew
    MemberAuthor

    Impact
    Anybody using Windows authentication with requests > 1024 bytes. I don't know how common this is as we don't have any telemetry around which authentication method is used.

    Work around
    Revert to earlier release of WCF which didn't use the Expect header. In an earlier release we sent a HEAD request before every real request as an attempted mitigation to the problems caused by lack of universal support for the Expect header. So basically roll back. The prior approach with the HEAD request was only best effort and would still sometimes have problems as well as introduced new problems.

  9. karelz commented on Jul 9, 2018

    @karelz
    Member

    I don't know how common this is as we don't have any telemetry around which authentication method is used.

    If you have customers complaining, let's use that as indicator. How many impacted so far? Is there public issue where it happens or is it internal via support?
    How badly is the specific customer impacted? (RSP/SLA/other metric) Or was it just something that was noticed during testing?

    Regarding workaround: Does it mean "use older WCF package"? Is that even supported scenario?

  10. mconnew commented on Jul 11, 2018

    @mconnew
    MemberAuthor

    The issue where this is reported is dotnet/wcf#2923 and there's 3 customers there who have reported it. I would expect any new instances of customers having the problem would see that issue and use the workaround.
    Using the older WCF package is completely supported. We aren't a part of .Net Core, we're more like a third party library which also happens to have an implementation in the full framework when your runtime is netfx. That means all earlier WCF packages can run on later versions of .NET Core. In addition to that, as we target .NET standard and not .NET Core and .NET Standard is still at 2.0, as I made sure we didn't add any usage of classes added to .NET Core 2.1 someone can use our latest package on .NET Core 2.0 and they wouldn't get any runtime type errors. They might get functional problems if there's missing capabilities in e.g. HttpClientHandler, but it should generally run fine both ways.

  11. mconnew commented on Jul 11, 2018

    @mconnew
    MemberAuthor

    Btw, 3 reported issues in a short period of time is quite high for WCF.

  12. danmoseley commented on Jul 17, 2018

    @danmoseley
    Contributor

    @karelz if this is to go into 2.1.x it will need a mail to corefx shiproom. Do you plan to do that?

  13. danmoseley commented on Jul 17, 2018

    @danmoseley
    Contributor

    Removing label until this is ready for big shiproom.

  14. geoffkizer commented on Jul 17, 2018

    @geoffkizer
    Contributor

    Additionally, according to the customer who saw this issue, in their testing setting Connection: Close header without Expect: 100-Continue also has the same problem.

    Do you expect this (i.e. setting Connection: close and doing NT auth) to work?

  15. geoffkizer commented on Jul 17, 2018

    @geoffkizer
    Contributor

    @mconnew, I'm not entirely sure what you want us to do in this scenario. When we get an early response with Expect: 100-continue, we either need to (a) finish sending the request body, so we can keep the connection alive, or (b) close the connection and stop sending the request body.

  16. 12 remaining items

  17. removed their assignment
    on Mar 8, 2019
  18. stofte commented on Apr 25, 2019

    @stofte

    I just found my function app stuffed full of classes like "PatchedHttpBinding". What a mess.

  19. self-assigned this
    on Jun 6, 2019
  20. self-assigned this
    on Jul 9, 2019
  21. davidsh commented on Jul 9, 2019

    @davidsh
    Contributor

    Fixed in master for .NET Core 3.0 with PR dotnet/corefx#38744

    Re-opening for release/2.1 and release/2.2 consideration.

  22. reopened this on Jul 9, 2019
  23. changed the title [-]Expect100Continue with Windows auth and request body > 1024 bytes fails[/-] [+][release/2.1] Expect100Continue with Windows auth and request body > 1024 bytes fails[/+] on Jul 9, 2019
  24. davidsh commented on Jul 16, 2019

    @davidsh
    Contributor

    Fix for release/2.1 checked in with PR dotnet/corefx#39341

  25. karelz commented on Jul 30, 2019

    @karelz
    Member

    The fix will be part of 2.1.13 and 2.2.7 releases.

  26. transferred this issue fromdotnet/corefxon Jan 31, 2020
  27. added this to the 2.1.x milestone on Jan 31, 2020
  28. ghost locked as resolved and limited conversation to collaborators on Dec 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

blockingbugtenet-compatibility

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions