-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
16c3d5a
commit ecdd6cd
Showing
9 changed files
with
152 additions
and
15 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
tracer/src/Datadog.Trace/Iast/Aspects/AWSSDK.SimpleEmail/AmazonSimpleEmailAspect.cs
This file contains 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,40 @@ | ||
// <copyright file="AmazonSimpleEmailAspect.cs" company="Datadog"> | ||
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. | ||
// </copyright> | ||
#nullable enable | ||
|
||
using System; | ||
using Datadog.Trace.AppSec; | ||
using Datadog.Trace.Iast.Dataflow; | ||
|
||
namespace Datadog.Trace.Iast.Aspects; | ||
|
||
/// <summary> Email html injection class aspect </summary> | ||
[AspectClass("AWSSDK.SimpleEmail", AspectType.Sink, VulnerabilityType.EmailHtmlInjection)] | ||
[global::System.ComponentModel.Browsable(false)] | ||
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] | ||
public class AmazonSimpleEmailAspect | ||
{ | ||
/// <summary> | ||
/// Launches a email html injection vulnerability if the email body is tainted, it's not escaped and the email is html compatible. | ||
/// No need to instrument methods Send(string from, string recipients, string subject, string body) and similar | ||
/// since those methods would send the email as plain text. | ||
/// </summary> | ||
/// <param name="message">the email message that is going to be sent</param> | ||
/// <returns>the MailMessage</returns> | ||
[AspectMethodInsertBefore("Amazon.SimpleEmail.AmazonSimpleEmailServiceClient::SendEmailAsync(Amazon.SimpleEmail.Model.SendEmailRequest,System.Threading.CancellationToken", 1)] | ||
public static object? Send(object? message) | ||
{ | ||
try | ||
{ | ||
IastModule.OnEmailHtmlInjection(message, EmailInjectionType.AmazonSimpleEmail); | ||
return message; | ||
} | ||
catch (Exception ex) when (ex is not BlockException) | ||
{ | ||
IastModule.LogAspectException(ex, $"{nameof(MailkitAspect)}.{nameof(Send)}"); | ||
return message; | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
tracer/src/Datadog.Trace/Iast/Aspects/AWSSDK.SimpleEmail/ISendEmailRequest.cs
This file contains 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,35 @@ | ||
// <copyright file="ISendEmailRequest.cs" company="Datadog"> | ||
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. | ||
// </copyright> | ||
|
||
using Datadog.Trace.DuckTyping; | ||
|
||
namespace Datadog.Trace.Iast.Aspects; | ||
|
||
#nullable enable | ||
|
||
internal interface ISendEmailRequest | ||
{ | ||
IMessage Message { get; } | ||
} | ||
|
||
internal interface IMessage | ||
{ | ||
IBody Body { get; } | ||
} | ||
|
||
internal interface IBody | ||
{ | ||
IHtml Html { get; } | ||
} | ||
|
||
internal interface IHtml | ||
{ | ||
IContent Content { get; } | ||
} | ||
|
||
internal interface IContent | ||
{ | ||
string Data { get; } | ||
} |
This file contains 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 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 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,15 @@ | ||
// <copyright file="EmailInjectionType.cs" company="Datadog"> | ||
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. | ||
// </copyright> | ||
|
||
#nullable enable | ||
|
||
namespace Datadog.Trace.Iast; | ||
|
||
internal enum EmailInjectionType | ||
{ | ||
AmazonSimpleEmail, | ||
MailKit, | ||
SystemNetMail | ||
} |
This file contains 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 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 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 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