|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-02-18 04:27 UTC] php at richardneill dot org
Description: ------------ I've just been looking at the headers of some email sent out by my own system (using PHP's mail() function). I note that the email contains headers including the following: HTTP-Posting-Client: USERS_IP_ADDRESS HTTP-Posting-URI: MY_WEBSITE:80/PATH/TO/FILE.php HTTP-Posting-User-Agent: Mozilla/5.0 (compatible; Konqueror/4.6; Linux) KHTML/4.6.5 (like Gecko) Mageia/4.6.5-1.3.mga1 I can't locate any documentation of where these headers get added, or how to configure them (despite already searching the entire PHP documentation, and grepping the php.ini files) I'm filing this first as a documentation "bug", though I really consider it as a significant security hole / information leak which could compromise the privacy of the sender. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 22 11:00:01 2025 UTC |
You're right - sorry for wasting your time - this is a patch in the most unlikely place. Mandriva (and thence Mageia) have patched the source, in file php-mail.diff; here are the relevant lines. + if (PG(http_globals)[TRACK_VARS_SERVER]) { + zval **remote_addr, **server_name, **server_port, + **script_name, **http_user_agent; + + if (zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "REMOTE_ADDR", sizeof("REMOTE_ADDR"), (void **) &remote_addr)==SUCCESS) { + convert_to_string_ex(remote_addr); + fprintf(sendmail, "HTTP-Posting-Client: %s\n", Z_STRVAL_PP(remote_addr)); + } + if (zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "SERVER_NAME", sizeof("SERVER_NAME"), (void **) &server_name)==SUCCESS) { + convert_to_string_ex(server_name); + fprintf(sendmail, "HTTP-Posting-URI: %s", Z_STRVAL_PP(server_name)); + if (zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "SERVER_PORT", sizeof("SERVER_PORT"), (void **) &server_port)==SUCCESS) { + convert_to_string_ex(server_port); + fprintf(sendmail, ":%s", Z_STRVAL_PP(server_port)); + } + if (zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "SCRIPT_NAME", sizeof("SCRIPT_NAME"), (void **) &script_name)==SUCCESS) { + convert_to_string_ex(script_name); + fprintf(sendmail, "%s", Z_STRVAL_PP(script_name)); + } + fprintf(sendmail, "\n"); + } + if (zend_hash_find(PG(http_globals)[TRACK_VARS_SERVER]->value.ht, "HTTP_USER_AGENT", sizeof("HTTP_USER_AGENT"), (void **) &http_user_agent)==SUCCESS) { + convert_to_string_ex(http_user_agent); + fprintf(sendmail, "HTTP-Posting-User-Agent: %s\n", Z_STRVAL_PP(http_user_agent)); + } + } [I'll add a pointer to this bug report into the mail() user-docs, so that other people can at least find this more easily.]I agree - this feature isn't very useful, even upstream. I have found an ugly workaround: Postfix supports checking (and removing) headers. (There is probably a similar fix for all other MTAs) 1. Enable header-checks, in /etc/postfix/main.cf : header_checks = regexp:/etc/postfix/header_checks 2. Specify the headers to strip, in /etc/postfix/header_checks : /^HTTP-Posting-Client:/ IGNORE /^HTTP-Posting-URI:/ IGNORE /^HTTP-Posting-User-Agent:/ IGNORE