phpinfo() doesn't play nicely with strict CSPs
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- C
- Star
- 40.4k
- Fork
- 8.1k
- Merge trung bình
- 2 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 96
Mô tả
Description
The output generated by phpinfo() includes inline styles and data: URLs for two images. While this is self-contained, it's incompatible with Content-Security-Policy headers that are configured securely, specifically, if your CSP doesn't include 'unsafe-inline' for style-src and data: for img-src, the output looks bad:
Two of the 6 locations in the output (i.e. not many) that uses inline styles:
<tr>
<td class="e">highlight.comment</td>
<td class="v">
<span style="color: #FF8000">#FF8000</span>
</td>
<td class="v">
<span style="color: #FF8000">#FF8000</span>
</td>
</tr>
styling like this would need to be turned into classes, though as you can see this output already makes use of classes, so this is trivial to fix.
A good way to resolve this would be to extend phpinfo so that it can serve these resources separately depending on the request context, so for example a request that contains a request param like phpinfo=styles could serve the style sheet, and phpinfo=logo could serve a logo image.
This approach would be compatible with a super-strict CSP like this (in fact there's nothing preventing phpinfo from generating this header itself):
Content-Security-Policy: default-src 'none'; image-src 'self'; style-src 'self';
The downside of this approach is that it would end up making multiple requests to serve the same page content. I don't know if there is a way that the existing approach could be preserved while allowing for this more secure approach as well.
An alternative would be for the page to generate CSP nonces or SRI hashes for the data and style elements. That's probably more complicated, though it would allow the page to remain self-contained.
Since phpinfo is a development feature, it's not very important to fix this, but it's an easy opportunity to encourage secure development practices while also making the generated page immune to injections.
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu từ điểm vào phpinfo() và theo dõi cách HTML, các kiểu inline và các URL hình ảnh data: của nó được tạo ra. So sánh các phương án có thể dùng để cung cấp tài nguyên và các phương án nonce hoặc hash với CSP nghiêm ngặt được mô tả trong issue. Được xem là hoàn tất khi trang được tạo ra hiển thị chính xác mà không cần cho phép unsafe-inline hoặc data:.
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, security
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 35/100