Skip to content
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

Header validation tripping on known safe emails due to References header #171

Closed
garrettlr opened this issue Oct 10, 2018 · 7 comments
Closed

Comments

@garrettlr
Copy link

Hey @bbottema ,

I've had this come up a few times now and I'm not sure exactly why or how to avoid it.

for a recent example see below:

<DOKOGW56MP_5bbd3cc7769cf_c3c93fc52d8cb9781275fb_sprut@zendesk.com>

for background, I've used simple-java-mail to power an intranet site which only replies to emails we've received from third parties we work with, primarily to centralize identity, so header validation is of minor concern to us.

is it possible to just fail quietly?

thanks!

@bbottema
Copy link
Owner

bbottema commented Oct 11, 2018

Hi @garrettlr, can you provide a stacktrace or else which validation fails in the code? Doesn't look invalid to me at first glance.

Bug or not, it might be a useful addition to be able to treat injection attacks as warning by configuration (assuming your report is about a failed injection detection).

@bbottema
Copy link
Owner

@garrettlr, I can't proceed with this until you provide some more info. I would like to understand better what is going on here and preferably be able to reproduce it on my own laptop.

@madalinl
Copy link

madalinl commented Feb 27, 2019

Hi @bbottema, maybe I can help you with some info.
I've stumbled on this error trying to reply to an valid e-mail:

org.simplejavamail.mailer.MailerException: Suspected of injection attack, field: email.header.References with suspicious value: <aaabbbccc@xxxyyyzzz.eurprd07.prod.outlook.com> <dddeeefff@xxxyyyzzz.eurprd07.prod.outlook.com> at org.simplejavamail.mailer.Mailer.scanForInjectionAttack(Mailer.java:337) ~[simple-java-mail-5.1.3.jar!/:na] at org.simplejavamail.mailer.Mailer.validate(Mailer.java:305) ~[simple-java-mail-5.1.3.jar!/:na] at org.simplejavamail.mailer.Mailer.sendMail(Mailer.java:238) ~[simple-java-mail-5.1.3.jar!/:na] at org.simplejavamail.mailer.Mailer.sendMail(Mailer.java:230) ~[simple-java-mail-5.1.3.jar!/:na]
The References header contains 2 values separated by '\r\n'.

Library version is 5.1.3

Hope this helps

@bbottema
Copy link
Owner

bbottema commented Mar 9, 2019

@madalinl, \r\n characters are attack vectors for header injections (CRLF Injection) and is exactly what triggers the exception (added by #88). Can you explain a little bit more about why this would be a valid use case?

@ScottPeterJohnson
Copy link

This happened to me when using the EmailBuilder.replyingTo() construct on a message that already contains a References header. JavaMail builds a new References header with both values, which is "folded", and thus probably contains a newline.

@bbottema
Copy link
Owner

Thanks @ScottPeterJohnson, I'll see if I can reproduce the bug.

@bbottema bbottema changed the title header validation tripping on known safe emails Header validation tripping on known safe emails due to References header May 22, 2019
bbottema added a commit that referenced this issue May 22, 2019
…g. Also added test to verify the "References" header is filled properly by replying multiple times in a thread.
@bbottema
Copy link
Owner

Fix released in v5.1.7. Please verify!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants