Injection also in contrib/web/php-user/mlmmj.php?
Hi,
the changelog for mlmmj 1.2.16 contains the entry
o Fixed injection in contrib/web/perl-user (Gerd von Egidy)
and removed the line
- . "Cc: $from\n"
from contrib/web/perl-user/mlmmj.cgi. But the same logic is present in the PHP script as well:
$addheader .= "Cc: ".$this->email."\n";
This should probably be removed for the same reasons.
While looking at this, I saw the regular expression used to try to validate e-mail addresses in the PHP script:
"^[a-z0-9\._-]+".chr(64)."+[a-z0-9\._-]+\.+[a-z]{2,4}$"
This does not allow a plus (+) in the local part which is permitted (and also used by mlmmj itself). There are also TLDs that have more than four characters: .travel, .museum, not to begin with international TLDs like .xn--zckzah (which are just in testing for now). The PHP script should *not* make (wrong) assumptions about what TLDs exist.
Regards,
Ansgar
PS: Please CC me on replies.
Hi Ansgar,
Quoted 1 line · Ansgar Burchardt
o Fixed injection in contrib/web/perl-user (Gerd von Egidy)
...
Quoted 3 lines
But the same logic is present in the PHP script as well:
$addheader .= "Cc: ".$this->email."\n";
As far as I can see, there is no injection here, because the $this->email variable is protected by the is_email() function. But Christoph Thiel is probably the guy to ask; He is the author of the code.
It might still be a good idea to keep the two sets of code as much in sync as possible, though.
Quoted 10 lines
While looking at this, I saw the regular expression used to try to validate e-mail addresses in the PHP script:
"^[a-z0-9\._-]+".chr(64)."+[a-z0-9\._-]+\.+[a-z]{2,4}$"This does not allow a plus (+) in the local part which is permitted (and also used by mlmmj itself). There are also TLDs that have more than four characters: .travel, .museum, not to begin with international TLDs like .xn--zckzah (which are just in testing for now). The PHP script should *not* make (wrong) assumptions about what TLDs exist.
I fully agree. Would you be up for fixing this problem?
Morten
Signature · 3 lines
Morten Shearman Kirkegaard <[email protected]> CTO, FableTech http://fabletech.com/
Hi,
Quoted 10 lines
While looking at this, I saw the regular expression used to try to validate e-mail addresses in the PHP script:
"^[a-z0-9\._-]+".chr(64)."+[a-z0-9\._-]+\.+[a-z]{2,4}$"This does not allow a plus (+) in the local part which is permitted (and also used by mlmmj itself). There are also TLDs that have more than four characters: .travel, .museum, not to begin with international TLDs like .xn--zckzah (which are just in testing for now). The PHP script should *not* make (wrong) assumptions about what TLDs exist.
Good catch. Since the use is the same I think it we should use the same regex for perl and php. And then verify once if it fits all valid mail addrs.
The attached patch uses the same regex for php as I introduced for perl with 1.2.16. Please have a deep look at it.
Kind regards,
Gerd
contrib/web/php-user/mlmmj.php +1 -1
@@ -37,7 +37,7 @@ function is_email($string="") { - if (eregi("^[a-z0-9\._-]+".chr(64)."+[a-z0-9\._-]+\.+[a-z]{2,4}$", $string)) + if (preg_match("/^[-!#$%&\'*+\.\/0-9=?A-Z^_a-z{|}~]+@[-0-9A-Za-z]+\.[-\.0-9A-Za-z]+$/", $string)) { return TRUE; }