#49785 [Bgs->Asn]: htmlspecialchars() should check byte sequence more strictly
| From: | moriyoshi@php.net | Date: | Fri, 09 Oct 2009 05:46:09 +0000 |
| Subject: | #49785 [Bgs->Asn]: htmlspecialchars() should check byte sequence more strictly | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-143403@lists.php.net to get a copy of this message | ||
ID: 49785
Updated by: moriyoshi@php.net
Reported By: hello at iwamot dot com
-Status: Bogus
+Status: Assigned
Bug Type: Strings related
Operating System: *
PHP Version: 5.3.0
-Assigned To:
+Assigned To: moriyoshi
New Comment:
This is a valid bug IMO.
Previous Comments:
------------------------------------------------------------------------
[2009-10-06 19:51:56] hello at iwamot dot com
If #43896, Jani's comment doesn't make sense. I suppose that you
developers can change htmlspecialchars() to be more STRICT.
------------------------------------------------------------------------
[2009-10-06 12:38:05] hello at iwamot dot com
Could you tell me the report number?
------------------------------------------------------------------------
[2009-10-06 12:12:24] jani@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same.
Thank you for your interest in PHP.
------------------------------------------------------------------------
[2009-10-06 11:40:05] hello at iwamot dot com
Description:
------------
Suppose htmlspecialchars() should check byte sequence more strictly for
security reasons. An XSS exploit code has been unveiled.
http://d.hatena.ne.jp/t_komura/20091004/1254665511
[ja]
I wrote a primitive patch.
http://iwamot.com/misc/html.c.patch.20091006
I don't know whether it is useful though :)
Reproduce code:
---------------
// overlong UTF-8 sequence
echo htmlspecialchars("A\xC0\xAF&", ENT_QUOTES, 'UTF-8');
// invalid Shift_JIS sequence
echo htmlspecialchars("B\x80&", ENT_QUOTES, 'Shift_JIS');
echo htmlspecialchars("C\x81\x7f&", ENT_QUOTES, 'Shift_JIS');
// invalid EUC-JP sequence
echo htmlspecialchars("D\x80&", ENT_QUOTES, 'EUC-JP');
echo htmlspecialchars("E\xA1\xFF&", ENT_QUOTES, 'EUC-JP');
echo htmlspecialchars("F\x8E\xFF&", ENT_QUOTES, 'EUC-JP');
echo htmlspecialchars("G\x8F\xA1\xFF&", ENT_QUOTES, 'EUC-JP');
Expected result:
----------------
output nothing
Actual result:
--------------
A_&B_&C&D_&E__&F__&G___&
("_" means an invalid byte)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49785&edit=1