|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44366 Regex bypass using POISON NULL BYTE
Submitted: 2008-03-08 03:12 UTC Modified: 2008-03-08 11:47 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: charlesfol at hotmail dot fr Assigned:
Status: Not a bug Package: *Regular Expressions
PHP Version: 5.2.5 OS: nux/win
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
17 + 2 = ?
Subscribe to this entry?

 [2008-03-08 03:12 UTC] charlesfol at hotmail dot fr
I discovered that in this PHP version, regex could be bypassed using \0 (%00) a.k.a. POISON NULL BYTE.

Reproduce code:

$is_alphanum_var = ereg("^[a-zA-Z0-9]+$",$var);
print "$is_alphanum_var\n$var";


Expected result:
Normally if code contains ad chars such as %,", or _ it will be detected by the regex.

Actual result:
But if we use this URL:

$is_alphanum_var RETURNS 1, BUT $var CONTAINS _-

Security HOLE.

Warmly, Charles "real" FOL.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-03-08 11:02 UTC] charlesfol at hotmail dot fr
OK, in fact I found that this was a known problem.
I apologize about your wasted time =)
 [2008-03-08 11:47 UTC]
As the reporter said ;-)
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 22 04:01:31 2024 UTC