PHP :: Bug #77074 :: XSS through error messages
| Bug #77074 | XSS through error messages | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2018-10-27 19:08 UTC | Modified: | 2024-07-29 12:29 UTC |
|
||||||||||
| From: | david at grudl dot com | Assigned: | bukka (profile) | |||||||||||
| Status: | Assigned | Package: | Output Control | |||||||||||
| PHP Version: | 7.1 | OS: | ||||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[2018-10-27 19:08 UTC] david at grudl dot com
Description:
------------
Displaying error messages is vulnerable to XSS, although the 'html_errors' is enabled.
Solution is to convert especial charactes < & in error message (ie to use htmlspecialchars)
Test script:
---------------
<?php
echo ${'<script>alert(123);</script>'};
Expected result:
----------------
In web browser it should not pop up the alert window, but it should report:
"Notice: Undefined variable: <script>alert(123);</script> in test.php on line 3
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2018-10-27 19:15 UTC] requinix@php.net
-Summary: david@grudl.com +Summary: XSS through error messages
[2018-10-27 19:20 UTC] nikic@php.net
[2018-10-27 19:31 UTC] david at grudl dot com
-Summary: XSS through error messages +Summary: david@grudl.com -PHP Version: 7.3.0RC4 +PHP Version: 5.6.5
[2018-10-27 19:31 UTC] david at grudl dot com
[2018-10-27 19:35 UTC] requinix@php.net
-Summary: david@grudl.com +Summary: XSS through error messages -PHP Version: 5.6.5 +PHP Version: 7.1
[2018-10-27 19:56 UTC] spam2 at rhsoft dot net
[2018-10-27 21:21 UTC] spam2 at rhsoft dot net
[2018-10-27 21:43 UTC] requinix@php.net
It should always encode because then that will always show the original value. If OP's already bizarre situation was even worse, like echo ${'<script>alert(123);</script>'}; then I should see those "lt"s and "gt"s in the error message ("&lt/gt;" in the output) because that's what the variable was actually named.[2018-10-27 21:47 UTC] nikic@php.net
[2018-10-27 22:21 UTC] spam2 at rhsoft dot net
[2024-07-29 12:29 UTC] bukka@php.net
-Assigned To: +Assigned To: bukka
[2024-07-29 12:29 UTC] bukka@php.net