|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 09:00:01 2025 UTC |
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.