-
Notifications
You must be signed in to change notification settings - Fork 324
Email HTML Injection detection in IAST #8205
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
Merged
sezen-datadog
merged 73 commits into
master
from
sezen.leblay/APPSEC-56330-email-injection
Feb 5, 2025
Merged
Changes from 4 commits
Commits
Show all changes
73 commits
Select commit
Hold shift + click to select a range
508a671
Email Injection detection in IAST
sezen-datadog a0f62f4
email injection checks
sezen-datadog 59ea624
instrumentation class put in place
sezen-datadog 14df382
EMAIL_HTML_INJECTION
sezen-datadog 700dd63
pr comments easy ones
sezen-datadog b4225d2
only focus on transport send
sezen-datadog 34ac9fb
pr comments
sezen-datadog bcca415
first attempt at instrumentation
sezen-datadog 4b9c23c
correction on argument
sezen-datadog 14458ed
Update dd-java-agent/instrumentation/javax-mail/src/main/java/datadog…
sezen-datadog b548721
Update dd-java-agent/instrumentation/javax-mail/src/main/java/datadog…
sezen-datadog 4182134
advice class added for easier debugging
sezen-datadog 791a5fa
html escapes with vulnerability mark
sezen-datadog cd9f249
instrumentation skeleton
sezen-datadog 74cebb5
instrumentation of body elements
sezen-datadog ea76961
instrumentation of body elements
sezen-datadog e98038d
test start
sezen-datadog 2111e77
test continue
sezen-datadog b814fd0
test continue
sezen-datadog 460737d
test continue
sezen-datadog be50dc3
test OK
sezen-datadog fba4788
define the tests I want
sezen-datadog 5fb78f1
content test OK
sezen-datadog a1ab334
content test OK
sezen-datadog d64327a
content test OK
sezen-datadog 6f8e74f
content test OK
sezen-datadog 49291c1
smoke test controller
sezen-datadog bbf5486
smoke test controller
sezen-datadog ee69fd5
smoke test
sezen-datadog ac708fe
smoke test
sezen-datadog ba2da19
Merge branch 'master' into sezen.leblay/APPSEC-56330-email-injection
sezen-datadog 553c7d8
Update dd-java-agent/instrumentation/javax-mail/src/main/java/datadog…
sezen-datadog e3eaf20
Update dd-java-agent/instrumentation/javax-mail/src/main/java/datadog…
sezen-datadog 95248a2
pr
sezen-datadog 4993aec
pr
sezen-datadog 4883918
pr
sezen-datadog 56b3521
build correction
sezen-datadog cb9a54f
Update dd-java-agent/agent-iast/src/main/java/com/datadog/iast/model/…
sezen-datadog 482a231
build correction
sezen-datadog 69044c0
Merge branch 'master' into sezen.leblay/APPSEC-56330-email-injection
sezen-datadog bccb5ae
build correction
sezen-datadog 990bbb7
Merge branch 'master' into sezen.leblay/APPSEC-56330-email-injection
sezen-datadog 6727eff
pr
sezen-datadog 6337ba5
pr
sezen-datadog b8595c7
pr
sezen-datadog 3384382
build
sezen-datadog c9895be
build
sezen-datadog 3f78b54
build
sezen-datadog 7950096
unit tests pass
sezen-datadog f6da333
de sally no more
sezen-datadog f9b7617
de sally no more
sezen-datadog 2ff2278
smoke tests
sezen-datadog a8b13ca
smoke tests
sezen-datadog c54f206
smoke tests
sezen-datadog 4fdb7f7
Merge branch 'master' into sezen.leblay/APPSEC-56330-email-injection
sezen-datadog 28a67ba
muzzle
sezen-datadog 2e7468c
manu's suggestions
sezen-datadog 59e42e0
beautify
sezen-datadog 845b2d0
EMAIL_HTML_INJECTION instead of EMAIL_INJECTION
sezen-datadog 34796da
EMAIL_HTML_INJECTION instead of EMAIL_INJECTION
sezen-datadog 631b775
pr
sezen-datadog 86321f6
Merge branch 'master' into sezen.leblay/APPSEC-56330-email-injection
sezen-datadog 42b355d
unit test correction - propagation fails though
sezen-datadog aedcb1e
activation dependencies added
sezen-datadog f0aa378
test
sezen-datadog 457e9f6
tests
sezen-datadog aac7112
Merge branch 'master' into sezen.leblay/APPSEC-56330-email-injection
sezen-datadog 8b17208
javax removed from smoke tests (cant have both javax + jakarta)
sezen-datadog 3f9815d
oops
sezen-datadog 73b3cb1
oops
sezen-datadog bc708c5
PR
sezen-datadog 943227d
Merge branch 'master' into sezen.leblay/APPSEC-56330-email-injection
sezen-datadog a37d29a
Merge branch 'master' into sezen.leblay/APPSEC-56330-email-injection
sezen-datadog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
dd-java-agent/agent-iast/src/main/java/com/datadog/iast/sink/EmailInjectionModuleImpl.java
sezen-datadog marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| package com.datadog.iast.sink; | ||
|
|
||
| import com.datadog.iast.Dependencies; | ||
| import com.datadog.iast.model.VulnerabilityType; | ||
| import datadog.trace.api.iast.sink.EmailInjectionModule; | ||
| import javax.annotation.Nullable; | ||
| import javax.mail.Message; | ||
| import javax.mail.MessagingException; | ||
| import javax.mail.internet.MimeMultipart; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| public class EmailInjectionModuleImpl extends SinkModuleBase implements EmailInjectionModule { | ||
|
|
||
| private static final Logger LOGGER = LoggerFactory.getLogger(EmailInjectionModule.class); | ||
|
|
||
| public EmailInjectionModuleImpl(final Dependencies dependencies) { | ||
| super(dependencies); | ||
| } | ||
|
|
||
| @Override | ||
| public void onSendEmail(@Nullable final MimeMultipart message) { | ||
| if (message == null) { | ||
| return; | ||
| } | ||
| try { | ||
| for (int i = 0; i < message.getCount(); i++) { | ||
| checkInjection(VulnerabilityType.EMAIL_HTML_INJECTION, message.getBodyPart(i)); | ||
| } | ||
| } catch (MessagingException e) { | ||
| LOGGER.debug("Exception while checking injections of mime multipart message", e); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void onSendEmail(@Nullable final Message message) { | ||
| if (message == null) { | ||
| return; | ||
| } | ||
| checkInjection(VulnerabilityType.EMAIL_HTML_INJECTION, message); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| muzzle { | ||
| pass { | ||
| coreJdk() | ||
| } | ||
| } | ||
|
|
||
| apply from: "$rootDir/gradle/java.gradle" | ||
| apply plugin: 'call-site-instrumentation' | ||
|
||
|
|
||
| addTestSuiteForDir('latestDepTest', 'test') | ||
|
|
||
| dependencies { | ||
| testRuntimeOnly project(':dd-java-agent:instrumentation:iast-instrumenter') | ||
| } | ||
|
|
||
|
|
||
| tasks.compileTestJava.configure { | ||
sezen-datadog marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| setJavaVersion(it, 8) | ||
| } | ||
34 changes: 34 additions & 0 deletions
34
...mail/src/main/java/datadog/trace/instrumentation/javax/mail/JavaxMailInstrumentation.java
sezen-datadog marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| package datadog.trace.instrumentation.javax.mail; | ||
|
|
||
| import static datadog.trace.agent.tooling.bytebuddy.matcher.HierarchyMatchers.implementsInterface; | ||
| import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named; | ||
|
|
||
| import com.google.auto.service.AutoService; | ||
| import datadog.trace.agent.tooling.Instrumenter; | ||
| import datadog.trace.agent.tooling.InstrumenterModule; | ||
| import net.bytebuddy.description.type.TypeDescription; | ||
| import net.bytebuddy.matcher.ElementMatcher; | ||
|
|
||
| @AutoService(InstrumenterModule.class) | ||
| public class JavaxMailInstrumentation extends InstrumenterModule.Iast | ||
| implements Instrumenter.ForTypeHierarchy, Instrumenter.HasMethodAdvice { | ||
|
|
||
| public JavaxMailInstrumentation(String instrumentationName, String... additionalNames) { | ||
| super("javaxmailinstrumentation", "javaxmail"); | ||
sezen-datadog marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| @Override | ||
| public String hierarchyMarkerType() { | ||
| return "org.java.mail"; | ||
| } | ||
|
|
||
| @Override | ||
| public ElementMatcher<TypeDescription> hierarchyMatcher() { | ||
| return implementsInterface(named(hierarchyMarkerType())); | ||
| } | ||
|
|
||
| @Override | ||
| public void methodAdvice(MethodTransformer transformer) { | ||
| // TODO | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sezen-datadog marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
internal-api/src/main/java/datadog/trace/api/iast/sink/EmailInjectionModule.java
sezen-datadog marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package datadog.trace.api.iast.sink; | ||
|
|
||
| import datadog.trace.api.iast.IastModule; | ||
| import javax.annotation.Nullable; | ||
| import javax.mail.Message; | ||
| import javax.mail.internet.MimeMultipart; | ||
|
|
||
| public interface EmailInjectionModule extends IastModule { | ||
| void onSendEmail(@Nullable MimeMultipart body); | ||
|
|
||
| void onSendEmail(@Nullable Message message); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.