-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
PHPMailer - A critical vulnerability #4963
Comments
Is it a related issue? |
How is this a CodeIgniter problem? CodeIgniter does not have any third party email packages, like PHPMailer, bundled with it. |
|
But only if you've intentionally turned off validation and aren't validating yourself, right? Which would be a self-inflicted vulnerability. $this->email->from('"attacker\" -oQ/tmp/ -X/var/www/cache/phpcode.php some"@email.com');
// protected '_debug_msg' =>
// array (size=1)
// 0 => string 'Invalid email address: "attacker\" -oQ/tmp/ -X/var/www/cache/phpcode.php some"@email.com<br />' (length=95) |
It may be not so obvious,
I'm sure someone can find a valid email address that Even SQL injection are self-inflicted vulnerability, that's why any decent library shall not expect/pretend that the user provide parameters already escaped. If a vendor has a |
Well it doesn't, it uses That said, I'm always for practical implementation of specs rather than literal. It might be worth adding the |
I found out that the This is all you need to do:
A quick search on github shown that this is a common use case. |
The docs appear to be wrong.
What vulnerability are you demonstrating? Are you left with the body of your message in a file on your server at I find that CodeIgniter will not send the email at all with a vulnerable attack string due to its implementation of |
The underlying issue really has nothing to do with PHPMailer, and it's quite possible that numerous frameworks and applications are vulnerable to similar exploits without ever using email. I've gotten very little sleep since I started working on this, so I'll leave you with this while I take a quick nap so you can get a head start searching for vulnerable code. I'll join the search in a bit. |
CodeIgniter/system/libraries/Email.php Line 1854 in 24c8666
|
Fix for that issue in PHPMailer: PHPMailer/PHPMailer@833c35f |
Yeah I tried replicating with the sendmail passthru you link to, even with and without attempting to escape, but cannot induce the vulnerability on my environment. Get some sleep, thanks for the links, I'll try to touch base later today. :) |
I can share my docker container, so you can try by yourself: https://github.com/Federkun/codeigniter-rce |
Thanks @Federkun, that indeed works. Curious, the same code on my environments send the email but do not create a file on the filesystem regardless of the path. |
@derekjones sendmail needs to have permission to create the file in the specified directory. It'd be interesting to see which user it's actually created under; if it's created in the context of the sendmail daemon, then we've likely found a privilege escalation vulnerability in sendmail. Or, in your case, a privilege-deescalation anti-vulnerability. |
Discovered why I was having trouble reproducing; looks like the postfix-compatible interface for sendmail has disabled Many thanks to @Zenexer for bringing this issue to light and for the approach to prevent it. Hopefully it will raise the priority of addressing the underlying issues in PHP itself. |
Way to report a security issue during holiday season ... @derekjones Long time no see; thanks for stepping in! The docs on Here's what I think:
(none of the above applies to SMTP, or should it?) You may note that I've included the Is this sufficient? Am I missing something? Edit: Is it worth looking into a restricted shell (Wikipedia link)? |
The commit above should do it IMO. Still unsure whether we should disable 'sendmail' on Windows? |
@narfbg That should be fine. I haven't found a way to exploit On Windows, sendmail.exe will handle its own parsing, rather than the shell, so you can actually program a secure escape function as long as you're not using PHP's It's safe to use
|
@Zenexer Great, thank you! We'll release version 3.1.3 with this patch soon, most likely Monday. |
Any chance you'll patch 2.2.6? |
@narfbg Thanks! "Paul Buonopane from NamePros" is fine. |
@tmairegasnighto No. We abandoned 2.x more than a year ago, and there have been more security patches released since then. |
@tmairegasnighto You should migrate your projects to CodeIgniter 3+ as soon as possible, but in the meanwhile here is a patch for CodeIgniter 2.x (in case you still have projects you need to support): https://gist.github.com/sergio-bobillier/32e47e1743cb0b67837145cc111dbf7e |
That's great, thank you. I actually spent all weekend trying to port to CI3 but failed as the language switching module the original developer used isn't compatible :( . It was pretty popular, so I suspect a lot of people are in the same boat and supporting CI2 sites. Thank you so much for the patch! |
... and now that project may never be updated, because there's "no reason" to. @tmairegasnighto More vulnerabilities have been patched since 2.x was abandoned; this one just generated a lot of noise. I urge you to focus on getting your project up to date. |
@narfbg, actually the fix above didn't seem to match the mailer class from 2.2.6, and with no way to convert to 3.x it actually became easier to move the entire site to Wordpress than to figure out how the custom language switching code was working (and not working in 3.x). Sad outcome, but at least now I'm effectively standardized on one CMS. |
Please read: http://thehackernews.com/2016/12/phpmailer-security.html
Please update: /system/libraries/Email.php
The text was updated successfully, but these errors were encountered: