php / php/php-src

Inconsistent handling of invalid headers causes unexpected behavior

Đang mở
#19,858 6 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Feature Status: Needs Triage
Ngôn ngữ chính
C
Star
40.4k
Fork
8.2k
Merge trung bình
2 ngày 15 giờ
Pull request đã merge (30 ngày)
103

Mô tả

Description

The following code:

<?php
header( "X-Foo;: hello" );
header( "X-Foo\t: hello" );
header( "X-Foo\n: hello" );

The 3rd one results in a warning (Header may not contain more than a single header, new line detected) and the header is not set.
The other 2 however are sent without a warning. The 2nd one will get fixed by nginx, however the 1st one passes through (see https://github.com/nginx/nginx/issues/899)

This not only is inconsistent, this also allows for certain attack vectors if the request is proxied and the proxy does not handle the invalid headers correctly (sorry, can't go into detail on this at this moment in time, due to pending security reports)

Since headers are apparently getting validated in PHP already (otherwise we wouldn't have an error for the 3rd one), this validation should be fixed to strictly check if the provided header adheres to the HTTP header standards

PHP Version
PHP 8.4, however affects previous PHP versions similarly
Operating System

No response

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện ba lệnh gọi header() được mô tả trong issue và kiểm tra đường dẫn xác thực header của PHP để xem dấu chấm phẩy, tab và ký tự xuống dòng được xử lý như thế nào. Công việc hoàn tất khi cú pháp header không hợp lệ luôn bị từ chối cùng với cảnh báo phù hợp và các header hợp lệ không bị ảnh hưởng; hãy bổ sung coverage cho ba ví dụ.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
c, php
Lĩnh vực
backend-api-design, security
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.