Skip to content

Commit fb13e7f

Browse files
committed
Docs changes
1 parent e311155 commit fb13e7f

File tree

3 files changed

+31
-29
lines changed

3 files changed

+31
-29
lines changed

java/ql/lib/semmle/code/java/frameworks/Velocity.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** Definitions related to the Apache Velocity Templating library. */
1+
/** Definitions related to the Apache Velocity templating library. */
22

33
import java
44
private import semmle.code.java.dataflow.ExternalFlow
Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
11
<!DOCTYPE qhelp PUBLIC "-//Semmle//qhelp//EN" "qhelp.dtd">
22
<qhelp>
3-
<overview>
4-
<p>
5-
Template Injection occurs when user input is embedded in a template in an unsafe manner.
6-
An attacker can use native template syntax to inject a malicious payload into a template, which is then executed server-side. This permits the attacker to run arbitrary code in the server's context.</p>
7-
</overview>
8-
<recommendation>
9-
<p>
10-
To fix this, ensure that an untrusted value is not used as a template. If the application requirements do not allow this, use a sandboxed environment where access to unsafe attributes and methods is prohibited.
11-
</p>
12-
</recommendation>
13-
<example>
14-
<p>
15-
In the example given below, an untrusted HTTP parameter
16-
<code>code</code>
17-
is used as a Velocity template string. This can lead to remote code execution.
18-
</p>
19-
<sample src="SSTIBad.java" />
3+
<overview>
4+
<p>
5+
Template Injection occurs when user input is embedded in a template's code in an unsafe manner.
6+
An attacker can use native template syntax to inject a malicious payload into a template, which is then executed server-side.
7+
This permits the attacker to run arbitrary code in the server's context.
8+
</p>
9+
</overview>
10+
<recommendation>
11+
<p>
12+
To fix this, ensure that untrusted input is not used as part of a template's code. If the application requirements do not allow this,
13+
use a sandboxed environment where access to unsafe attributes and methods is prohibited.
14+
</p>
15+
</recommendation>
16+
<example>
17+
<p>
18+
In the example given below, an untrusted HTTP parameter <code>code</code> is used as a Velocity template string.
19+
This can lead to remote code execution.
20+
</p>
21+
<sample src="SSTIBad.java" />
2022

21-
<p>
22-
In the next example the problem is avoided by using a fixed template string
23-
<code>s</code>
24-
. Since, the template is not attacker controlled in this case, we prevent untrusted code execution.
25-
</p>
26-
<sample src="SSTIGood.java" />
27-
</example>
28-
<references>
29-
<li>Portswigger : [Server Side Template Injection](https://portswigger.net/web-security/server-side-template-injection)</li>
30-
</references>
23+
<p>
24+
In the next example the problem is avoided by using a fixed template string <code>s</code>.
25+
Since the template's code is not attacker-controlled in this case, the untrusted code execution is prevented.
26+
</p>
27+
<sample src="SSTIGood.java" />
28+
</example>
29+
<references>
30+
<li>Portswigger: <a href="https://portswigger.net/web-security/server-side-template-injection">Server Side Template Injection</a></li>
31+
</references>
3132
</qhelp>

java/ql/src/Security/CWE/CWE-094/TemplateInjection.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
/**
22
* @name Server-side template injection
3-
* @description Untrusted input used as a template parameter can lead to remote code execution.
3+
* @description Untrusted input interpreted as a template can lead to remote code execution.
44
* @kind path-problem
55
* @problem.severity error
66
* @precision high
77
* @id java/server-side-template-injection
88
* @tags security
9+
* external/cwe/cwe-1336
910
* external/cwe/cwe-094
1011
*/
1112

0 commit comments

Comments
 (0)