-
Notifications
You must be signed in to change notification settings - Fork 293
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
Email HTML Injection detection in IAST #8205
base: master
Are you sure you want to change the base?
Conversation
internal-api/src/main/java/datadog/trace/api/iast/VulnerabilityMarks.java
Outdated
Show resolved
Hide resolved
internal-api/src/main/java/datadog/trace/api/iast/sink/EmailInjectionModule.java
Outdated
Show resolved
Hide resolved
dd-java-agent/agent-iast/src/main/java/com/datadog/iast/sink/EmailInjectionModuleImpl.java
Outdated
Show resolved
Hide resolved
...ax-mail/src/main/java/datadog/trace/instrumentation/javax/mail/JavaxMailInstrumentation.java
Show resolved
Hide resolved
Nice work @sezen-datadog! you are in the right direction, we can discuss offline the caveats if you want 😃 My comments related to the new iast module can be extended if we need an Object instead of an String Just in case no one had shared with you before, this is an interesting document when we need to implement new iast vulnerabilities |
...ax-mail/src/main/java/datadog/trace/instrumentation/javax/mail/JavaxMailInstrumentation.java
Outdated
Show resolved
Hide resolved
...ax-mail/src/main/java/datadog/trace/instrumentation/javax/mail/JavaxMailInstrumentation.java
Show resolved
Hide resolved
...ax-mail/src/main/java/datadog/trace/instrumentation/javax/mail/JavaxMailInstrumentation.java
Outdated
Show resolved
Hide resolved
…/trace/instrumentation/javax/mail/JavaxMailInstrumentation.java Co-authored-by: Alejandro González García <[email protected]>
…/trace/instrumentation/javax/mail/JavaxMailInstrumentation.java Co-authored-by: Alejandro González García <[email protected]>
setContext and setText of Part StringEscapeUtilsCallsite |
result, | ||
input, | ||
false, | ||
VulnerabilityMarks.XSS_MARK | VulnerabilityMarks.EMAIL_HTML_INJECTION_MARK); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we could define a mark like:
public static final int HTML_ESCAPED_MARK = XSS_MARK | EMAIL_HTML_INJECTION_MARK;
Anytime we escape for HTML we have to escape both, and the list of vulnerabilities might grow in the future.
|
||
where: | ||
mimetype | content | ||
"html" | "<html><body>Hello, Content!</body></html>" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you try with non html mime types?, in that case we should not call the module.
|
||
then: | ||
hasTainted { tainted -> | ||
tainted.value == messageText |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what you are testing here (the request parameter is also tainted with the value, so probably you want to assert something else in here).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah
What Does This Do
Controls the mails to detect tainted content for javax mail methods, in particular, Transport.send
Motivation
Email HTML injection is a vulnerability where user input is included in the content of an email without proper validation and sanitization. This vulnerability can have severe consequences as it opens the door for various attacks, including phishing, social engineering exploits, and the exploitation of email client vulnerabilities.
This modification provides a control of the body of the email that is meant to be sent. If an injection occurred in the mail body and no sanitization has taken place, the sink will raise an alert.
Jira ticket: APPSEC-56330