Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit 2282def

Browse files
authored
Merge pull request #180 from owen-mc/email-injection
Move email injection query out of experimental folder
2 parents a88bf4c + 49abd0b commit 2282def

File tree

18 files changed

+102
-65
lines changed

18 files changed

+102
-65
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
lgtm,codescanning
2+
* The query "Email injection" (`go/email-injection`) has been moved out of the experimental folder. The query detects when untrusted input can be incorporated directly into an email.

ql/src/experimental/CWE-640/EmailInjection.qhelp renamed to ql/src/Security/CWE-640/EmailInjection.qhelp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<p>
55
Using untrusted input to construct an email can cause multiple security
66
vulnerabilities. For instance, inclusion of an untrusted input in an email body
7-
may allow an attacker to conduct Cross Site Scripting (XSS) attacks, while
7+
may allow an attacker to conduct cross-site scripting (XSS) attacks, while
88
inclusion of an HTTP header may allow a full account compromise as shown in the
99
example below.
1010
</p>
@@ -19,13 +19,13 @@
1919
In the following example snippet, the <code>host</code> field is user controlled.
2020
</p>
2121
<p>
22-
A malicious user can send an HTTP request to the targeted web site,
23-
but with a Host header that refers to their own web site. This means the
22+
A malicious user can send an HTTP request to the targeted website,
23+
but with a Host header that refers to their own website. This means the
2424
emails will be sent out to potential victims, originating from a server
25-
they trust, but with links leading to a malicious web site.
25+
they trust, but with links leading to a malicious website.
2626
</p>
2727
<p>
28-
If the email contains a password reset link, and should the victim click
28+
If the email contains a password reset link, and the victim clicks
2929
the link, the secret reset token will be leaked to the attacker. Using the
3030
leaked token, the attacker can then construct the real reset link and use it to
3131
change the victim's password.
@@ -38,7 +38,7 @@
3838
</example>
3939
<references>
4040
<li>
41-
OWASP
41+
OWASP:
4242
<a href="https://owasp.org/www-community/attacks/Content_Spoofing">Content Spoofing</a>
4343
.
4444
</li>

ql/src/experimental/CWE-640/EmailInjection.ql renamed to ql/src/Security/CWE-640/EmailInjection.ql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* @problem.severity error
99
* @tags security
1010
* external/cwe/cwe-640
11+
* @precision high
1112
*/
1213

1314
import go

ql/test/experimental/CWE-640/EmailInjection.expected

Lines changed: 0 additions & 43 deletions
This file was deleted.

ql/test/experimental/CWE-640/EmailInjection.qlref

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package main
2+
3+
import (
4+
"net/http"
5+
"net/smtp"
6+
)
7+
8+
func mail(w http.ResponseWriter, r *http.Request) {
9+
host := r.Header.Get("Host")
10+
token := backend.getUserSecretResetToken(email)
11+
body := "Click to reset password: " + host + "/" + token
12+
smtp.SendMail("test.test", nil, "[email protected]", nil, []byte(body))
13+
}

0 commit comments

Comments
 (0)