You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<!DOCTYPEqhelp PUBLIC "-//Semmle//qhelp//EN" "qhelp.dtd">
2
2
<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
-
<samplesrc="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
+
<samplesrc="SSTIBad.java" />
20
22
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
-
<samplesrc="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
+
<samplesrc="SSTIGood.java" />
28
+
</example>
29
+
<references>
30
+
<li>Portswigger: <ahref="https://portswigger.net/web-security/server-side-template-injection">Server Side Template Injection</a></li>
0 commit comments