Skip to content

Unusual but valid headers in requests are not available to PHP when running via CGI #13221

Open
@TFLI-DB

Description

@TFLI-DB

Description

The following code:

<?php
print_r($_SERVER);

Requested with:

curl -s -H 'X-Test: 1' -H 'X-%%Test%%: 1' 'http://127.0.0.1/' | grep 'HTTP_'

Resulted in this output:

[HTTP_X_TEST] => 1
[HTTP_ACCEPT] => */*
[HTTP_USER_AGENT] => curl/7.83.1
[HTTP_HOST] => 127.0.0.1

But I expected this output instead:

[HTTP_X_TEST] => 1
[HTTP_X_%%TEST%%] => 1
[HTTP_ACCEPT] => */*
[HTTP_USER_AGENT] => curl/7.83.1
[HTTP_HOST] => 127.0.0.1

This appears to be unique to CGI, or alternatively mod_php is immune.

PHP Version

PHP 8.1.26

Operating System

Alpine Linux 3.18

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions