php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71563 Buffer Overrun in curl_exec() causing hang
Submitted: 2016-02-09 21:20 UTC Modified: 2016-02-28 04:22 UTC
From: paul at salesintel dot com Assigned:
Status: No Feedback Package: cURL related
PHP Version: 7.0.3 OS: Windows 10 x64
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: paul at salesintel dot com
New email:
PHP Version: OS:

 

 [2016-02-09 21:20 UTC] paul at salesintel dot com
Description:
------------
When a couple of cURL options are set in a specific and valid way, curl_exec() never returns and PHP does not throw any exception, causing indefinite hang.

Same code in php 5.6.x (in each x32/x64 ts/nts) worked as expected.

In php 7.0.3 (x32/x64 nts, ts not tried) hang occurs.



Test script:
---------------
<?php
repo();
function repo() {
	$location = 'https://mail.microsoft.com/ews/exchange.asmx';
	$request = "01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234";

	$ch = curl_init($location);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
	curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC | CURLAUTH_NTLM);
	curl_setopt($ch, CURLOPT_USERPWD, ' ');

	$response = curl_exec($ch);
}

Expected result:
----------------
Call to curl_exec($ch) returns.



Actual result:
--------------
Call to curl_exec($ch) never returns.

However....

If you change $location to an invalid endpoint or one that does not require NTLM, curl_exec() returns.

If you remove the 'CURLAUTH_BASIC' leaving only 'CURLAUTH_NTLM', curl_exec() returns;

If you remove 'CURLAUTH_NTLM' leaving only 'CURLAUTH_BASIC', curl_exec() returns;

If you set an empty string ('') instead of one with one or more characters to CURLOPT_USERPWD, curl_exec() returns.

$request is a string with 1025 characters. If you remove one character, leaving a (suspiciously sized) 1024 character length $request, curl_exec($ch) returns.



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-02-16 16:15 UTC] ab@php.net
-Status: Open +Status: Feedback
 [2016-02-16 16:15 UTC] ab@php.net
Thanks for the report. I'm unable to reproduce the behavior with the snippet you've posted. Neither with the original, nor when i replace the request string with like $request = str_repeat('x', 1025);. The script always terminates fast. Is there some other condition i could possibly have overseen?

Thanks.
 [2016-02-28 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Mar 31 11:01:25 2020 UTC