php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67059 String pointer problem in object $_SERVER when using a proxy (buffer overflow)
Submitted: 2014-04-11 12:49 UTC Modified: 2021-08-22 04:22 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: potsky at me dot com Assigned: cmb (profile)
Status: No Feedback Package: Apache2 related
PHP Version: 5.5.11 OS: Mac OS 10.9
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: potsky at me dot com
New email:
PHP Version: OS:

 

 [2014-04-11 12:49 UTC] potsky at me dot com
Description:
------------
Hi,

when using a proxy server between a client and the PHP server, the $_SERVER['SERVER_NAME'] is not set correctly and I think there is a serious pointer problem.

Echoing $_SERVER['SERVER_NAME'] tells "potskymac.local:5757" but it tells that the string is 11 chars length. This is wrong of course.

Parsing the string char by char returns the name of the internal PHP server dev.musicme instead.

This problem has been teste on 5.5.9 and 5.5.11.

Test script:
---------------
<?php
$a = $_SERVER['SERVER_NAME'];

var_dump( $a );

var_dump( chr( ord( $a[0] ) ) );
var_dump( chr( ord( $a[1] ) ) );
var_dump( chr( ord( $a[2] ) ) );
var_dump( chr( ord( $a[3] ) ) );
...

var_dump( '' . $_SERVER['SERVER_NAME'] );

die();

Expected result:
----------------
On a direct connection, the result is right and is :

string 'potskymac.local' (length=15)
string 'p' (length=1)
string 'o' (length=1)
string 't' (length=1)
string 's' (length=1)
string 'k' (length=1)
string 'y' (length=1)
string 'm' (length=1)
string 'a' (length=1)
string 'c' (length=1)
string '.' (length=1)
string 'l' (length=1)
string 'o' (length=1)
string 'c' (length=1)
string 'a' (length=1)
string 'l' (length=1)

It should be the same when using a proxy.

Actual result:
--------------
When using a proxy, the string is broken with echo, print_r, var_dump, etc... It seems there are 2 pointers for the same string. Just take a look on the cur result, the value is 11 chars length and is my proxy server dev.musicme :

string 'potskymac.local:5757' (length=11)
string 'd' (length=1)
string 'e' (length=1)
string 'v' (length=1)
string '.' (length=1)
string 'm' (length=1)
string 'u' (length=1)
string 's' (length=1)
string 'i' (length=1)
string 'c' (length=1)
string 'm' (length=1)
string 'e' (length=1)

( ! ) Notice: Uninitialized string offset: 11



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-08-09 14:13 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-08-09 14:13 UTC] cmb@php.net
Is this still an issue with any of the actively supported PHP
versions[1]?

[1] <https://www.php.net/supported-versions.php>
 [2021-08-22 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-2021 The PHP Group
All rights reserved.
Last updated: Wed Sep 22 11:03:37 2021 UTC