Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Cr-Lf injection could be happend via From, User-Agent ini settings #17976

Open
mdsnins opened this issue Mar 5, 2025 · 0 comments
Open

Cr-Lf injection could be happend via From, User-Agent ini settings #17976

mdsnins opened this issue Mar 5, 2025 · 0 comments

Comments

@mdsnins
Copy link
Contributor

mdsnins commented Mar 5, 2025

Description

As #81518, and #81680 (Still not fixed), from, user_agent ini value can lead CrLf injection and may lead HTTP header injection in fopen's http wrapper.

The following code:

  • PHP side
<?php
ini_set("from", "invalid_from\r\nTest-1: first_line");
ini_set("user_agent", "invalid_ua\r\nTest-2: another_line");

file_get_contents("http://localhost:1337");
  • Receiver
nc -nlvp 1337

Resulted in this output: (Receiver)

Listening on 0.0.0.0 1337
Connection received on 127.0.0.1 54468
GET / HTTP/1.1
From: invalid_from
Test-1: first_line
Host: localhost:1337
Connection: close
User-Agent: invalid_ua
Test-2: another_line

But I expected this output instead:

Either sanitized or blocked at ini value level

GET / HTTP/1.1
From: invalid_fromTest-1: first_line
Host: localhost:1337
Connection: close
User-Agent: invalid_uaTest-2: another_line

PHP Version

All PHP releases (including 8.5.0-dev)

Operating System

No response

@mdsnins mdsnins changed the title Cr-Lf injection could be happen via From, User-Agent ini settings Cr-Lf injection could be happend via From, User-Agent ini settings Mar 5, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

1 participant