-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error with sendmail: "Potential code injection in From header" #326
Comments
This change come from here #295 (comment) Mr @sreichel could you please review this issue? |
Found some info why it has been added ... https://scandiweb.com/blog/surprise-emails-that-can-execute-mailing-solution-vulnerability/ @topicode can you add some details about the params you pass to |
We configure our application via an
That's it. This creates the sendmail transport from the config, by passing an (empty) options array to the transport:
This leads to an empty string in $this->parameters , which in turn does (of course) not qualify as a valid email address.
One possible general solution/workaround I see here would be the usage of escapeshellarg() - but that might be a problem when In any case, a check for empty |
I just faced the problem myself after ZF1 Future migration, so going to find some solution. |
@topicode parameters are always string beyond the constructor. Now looking into that and the whole email validation seems quite BS to me, as it's by default expected, that parameters = from email. And that's not the case. |
sendmail header sanitization quick-fix, as described in #326
Addressed by #366 |
Hi, we also encountered the same problem when trying to set the envelope sender using the additional parameters here. The already merged quick fix from @develart-projects, won't work for our case either, since we don't pass an empty additional params. Thanks |
@yhabteab that's actually what I was afraid about. Question is how to address that. I'll release the quickfix, so will partially work. But will keep this one open for further development. |
Adding some more resources, trying to figure out what to do here. https://framework.zend.com/security/advisory/ZF2016-04 |
@topicode seems, like 5th param of PHP mail() is already sanitized that way. From the PHP manual: `
` |
Option 1: ZF2 solution - double quotes validation if (preg_match('/\\\"/', $address->getEmail())) {
throw new Exception\RuntimeException("Potential code injection in From header");
} |
Option 2: If I got all correctly, we are looking for 3 double-quotes in the string, so this can be solution as well. As we are aiming to cover -f possibility, we can go for combined validation:
By this, we are still covering most cases as they are now, but allowing to run it properly for the "-f" users as well. Opening discussion before implementing anything. But not the long one, as I would like to close this one. |
No one has any clues on this? If not, I'll implement option 2. |
…onRework addressed 5th sendmail param validation using -f (#326)
@yhabteab released in 1.23.3, pls reopen if you still have problem with that |
Hii @develart-projects thanks for your effort, but it still doesn't work for us. zf1-future/library/Zend/Mail/Transport/Sendmail.php Lines 146 to 150 in 622a60b
The last PS: I am also unable to reopen this issue :) |
@yhabteab what is the exact string you are passing, pls? Or maybe you can adjust first if to match your string (?) |
@yhabteab ok, I see where the problem is. I think I'll stop to do fixes in a rush :) Anyway, please send me the exact string you are using, just for sure. |
We're passing the params to new Zend_Mail_Transport_Sendmail('-f ' . escapeshellarg($this->getFrom())); and the resulting string looks like this: |
This will fix it: #374 |
@yhabteab pls validate 1.23.5, before I close it |
It Works! Thanks! |
With the latest Version 1.22.0 of zf1-future I get the following error when using Sendmail:
The problem is the added validation of
$this->parameters
:zf1-future/library/Zend/Mail/Transport/Sendmail.php
Lines 122 to 135 in 6545737
According to the documentation of the mail()-function, the fifth parameter is for additional parameters to the sendmail program. So, while it is entirely possible that this string contains an email address, it is definitely not the only valid value, and I propose to remove this validation (and the replacement of spaces).
The text was updated successfully, but these errors were encountered: