
SSTI occurs when user input is concatenated into a template’s source instead of being passed to it as data, letting an attacker run template expressions on the server. In most engines that leads from a one-line arithmetic probe to full remote code execution. These are our working notes: how it happens, how we prove it, and how to stop it. No code-execution payloads.
How SSTI happens
A template engine separates two things: the template source (code) and the context (data). SSTI appears the moment user input crosses from the data side to the code side.

Root cause in code
The bug is one line: the developer builds the template string from user input, so the engine parses that input as template syntax. This Flask/Jinja2 route is vulnerable.
from flask import Flask, request, render_template_string
app = Flask(__name__)
@app.route("/hello")
def hello():
name = request.args.get("name", "guest")
template = "<h1>Hello " + name + "</h1>" # user input becomes template SOURCE
return render_template_string(template)
The fix keeps the template static and passes the input as a variable. Jinja2 then treats it as data and auto-escapes it.
@app.route("/hello")
def hello():
name = request.args.get("name", "guest")
return render_template_string("<h1>Hello {{ name }}</h1>", name=name) # input is DATA
The same pattern appears in every language: string concatenation or formatting into a template before rendering. Common places to find it:
Detection methodology
Testing follows three steps: detect evaluation, identify the engine, then assess impact. Fuzz every reflected parameter with template syntax first; a server error on unbalanced braces is an early hint.

Two contexts need different handling:
Blind SSTI returns no output. Confirm it with a time delay or an out-of-band DNS callback to a host you control.
PoC walkthrough
An arithmetic probe that comes back calculated is sufficient proof of SSTI. Run this only against your own lab or a target you are authorised to test.
1. Start the lab. Save the vulnerable route above as app.py.
pip install flask
flask --app app run --port 5000
2. Send a baseline request. The input is reflected unchanged.
curl -g 'http://127.0.0.1:5000/hello?name=guest'
# <h1>Hello guest</h1>
3. Send the arithmetic probe. The server returns the result of the expression, not the expression.
curl -g 'http://127.0.0.1:5000/hello?name={{7*7}}'
# <h1>Hello 49</h1> <- evaluated server-side: SSTI confirmed
4. Fingerprint the engine. Jinja2 repeats a string when multiplied; Twig does the maths.
curl -g "http://127.0.0.1:5000/hello?name={{7*'7'}}"
# <h1>Hello 7777777</h1> <- Jinja2
5. Re-test against the fixed route. The probe is printed as text.
curl -g 'http://127.0.0.1:5000/hello?name={{7*7}}'
# <h1>Hello {{7*7}}</h1> <- not vulnerable
Automating the check
The same test is easy to script for your own lab or an authorised engagement. A simple checker works like this:
- Pick two random four-digit numbers for every request, so a page that happens to contain “49” cannot cause a false positive.
- Send the multiplication in each common template syntax: double curly braces, dollar-brace and ERB-style tags.
- Look for the calculated product in the response. If it appears, the input was evaluated on the server.
- Report which syntax evaluated and stop there. The checker only detects evaluation and never attempts code execution.
Code-execution payloads are left out of this post on purpose. Evaluation plus engine identification is enough evidence for a critical finding in a report.
Impact and real-world cases
SSTI usually ends in unauthenticated remote code execution, which is why the two enterprise cases below were both rated critical and exploited in the wild.

SSTI is often misreported as reflected XSS because the same parameter reflects HTML. Test every reflected-input finding with a template probe before closing it as XSS.
Remediation
Never build a template from user input; pass input as data to a static template. Everything else is defence in depth.

For the pentest report: rate confirmed SSTI as critical, include the request and response pair for the arithmetic probe, name the engine, and map it to CWE-1336 (improper neutralization of special elements used in a template engine) and OWASP WSTG-INJT-18 (listed as WSTG-INPV-18 in WSTG v4.2).
PoCForge runs authorised web application and attack-surface assessments. For SSTI, we find every feature that builds or renders templates from user input, confirm evaluation with arithmetic probes only, identify the engine, and report clear, prioritised fixes — starting with keeping templates static and passing input as data.
Get in touchSources
- PortSwigger Research, Server-Side Template Injection: portswigger.net/research/server-side-template-injection
- Black Hat USA 2015 whitepaper, Server-Side Template Injection: RCE for the Modern Web App: blackhat.com (PDF)
- OWASP WSTG, Testing for Server-side Template Injection (WSTG-INJT-18): wstg.owasp.org
- OWASP Server-Side Template Injection Prevention Cheat Sheet: cheatsheetseries.owasp.org
- MITRE CWE-1336: Improper Neutralization of Special Elements Used in a Template Engine: cwe.mitre.org/data/definitions/1336
- Atlassian advisory, CVE-2023-22527: confluence.atlassian.com
- NVD, CVE-2023-22527: nvd.nist.gov/vuln/detail/CVE-2023-22527
- CISA, Adds One Known Exploited Vulnerability to Catalog, 24 January 2024: cisa.gov
- CISA Known Exploited Vulnerabilities Catalog: cisa.gov/known-exploited-vulnerabilities-catalog
- NVD, CVE-2022-22954: nvd.nist.gov/vuln/detail/CVE-2022-22954
- VMware Security Advisory VMSA-2022-0011: vmware.com/security/advisories/VMSA-2022-0011.html
- CISA, Threat Actors Chaining Unpatched VMware Vulnerabilities (AA22-138B): cisa.gov
