Server-Side Template Injection Lab
A greeting-card service pastes your name into its template. Prove your input runs as code with {{7*7}}, then leak the app's secret key.
A greeting-card service builds its template by concatenating your name into it. The classic {{7*7}} probe shows whether input is printed or executed, and one more step leaks the application's secret configuration.
How to use it
- Render a card with a normal name.
- Send {{7*7}} and see whether 49 comes back.
- Read the app configuration, then compare the safe variable-passing version.
What to take away
Why concatenation is the bug
Template engines are small programming languages. Pasting user input into the template source lets the user write code; passing it as a variable keeps it as data.
Detection before exploitation
Different engines answer {{7*7}}, ${7*7} and <%= 7*7 %> differently, which is how testers fingerprint the engine before trying anything else.
Often remote code execution
In Jinja2, Twig, Freemarker and others, reaching the language runtime from a template usually means running commands on the server.
Frequently asked questions
How is SSTI different from XSS?
XSS runs in the victim's browser. SSTI runs on the server, inside the template engine, so its impact is usually far greater.
How do I prevent it?
Keep templates fixed and pass user data as variables. If users must author templates, use a sandboxed, logic-less engine with no access to application objects.
Where this fits in the course
This security lab pairs with Path 11 — Web Security — see all 26 learning paths.
It runs entirely in your browser: nothing is uploaded, no account is needed, and it is free.
Related
- Command Injection Sandbox — A "ping this host" tool glues your input into a real shell command. Chain a second command onto the intended one.
- Insecure Deserialization Toy — A "remember me" cookie is a trusted, deserialized object. Add one field to grant yourself admin with zero login.
- XXE Playground — An XML upload feature that expands external entities. Smuggle a local file read through a "harmless" XML document.
- Vulnerable Web App — A tiny deliberately-broken app for practicing XSS and login-bypass. Runs entirely in-browser; no server to attack, nothing to install.