Skip to content

CONNECT fails if it can't send the entire request in one go #6950

Closed

Description

@ustcqidi

I did this

There are Proxy which need Kerberos Authentication, but the authentication flow sometimes failed . This not easy to reproduce.

After checking the wireshark captured file and source code of libcurl. We find the possible root cause of the issue.

CURLcode Curl_buffer_send(struct dynbuf *in,
                          struct connectdata *conn,
                          /* add the number of sent bytes to this
                             counter */
                          curl_off_t *bytes_written,
                          /* how much of the buffer contains body data */
                          size_t included_body_bytes,
                          int socketindex)
{
...
sendsize = CURLMIN(size, CURL_MAX_WRITE_SIZE);
...

else {
      if((size_t)amount != size)
        /* We have no continue-send mechanism now, fail. This can only happen
           when this function is used from the CONNECT sending function. We
           currently (stupidly) assume that the whole request is always sent
           away in the first single chunk.

           This needs FIXing.
        */
        return CURLE_SEND_ERROR;
    }
}

When the Kerberos Auth challenge is bigger than CURL_MAX_WRITE_SIZE (16384) , the request with auth will be failed. (Will be fallbacked to using NTLM in our user's proxy environment.)

image

curl/libcurl version

7.74.0

operating system

Windows

Activity

  1. bagder commented on May 3, 2021

    @bagder
    Member

    Any proposal on how to fix this?

  2. ustcqidi commented on May 6, 2021

    @ustcqidi
    Author

    @bagder
    We are fixing this by a workaround, just send the "real" size when sending "proxy-authorization header"

    here is the pull request #7019

    could you please help to review whether is it make sense ? Thanks.

  3. bagder commented on May 6, 2021

    @bagder
    Member

    btw, is this perchance in a CONNECT request?

  4. ustcqidi commented on May 6, 2021

    @ustcqidi
    Author

    yes, in the function of CONNECT of http_proxy.c

    static CURLcode CONNECT(struct connectdata *conn,
    int sockindex,
    const char *hostname,
    int remote_port)

  5. bagder commented on May 6, 2021

    @bagder
    Member

    I figured out how to write a test case for this issue that reproduces your problem and shows that http_proxy.c:CONNECT needs to be fixed:

    test363

    This test limits the initial CONNECT request send to 100 bytes, which breaks curl.

  6. self-assigned this
    on May 6, 2021
  7. changed the title [-]Output Kerberos Auth failed if the challenge is bigger than CURL_MAX_WRITE_SIZE[/-] [+]CONNECT fails if it can't send the entire request in one go[/+] on May 6, 2021
  8. ustcqidi commented on May 8, 2021

    @ustcqidi
    Author

    @bagder
    many thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions