Skip to main content

Pentrova is launching soon. Join the waitlist for early access.Join the waitlist

Glossary · Injection

Server-Side Template Injection (SSTI)

An injection defect where user input reaches a server-side template engine, letting the attacker evaluate expressions and often escalate to RCE.

Explainer

What it is#

happens when the application concatenates user input into a template string before handing it to the engine. Jinja2, Twig, Freemarker, Velocity, ERB, and Handlebars all support expression syntax that most developers never intend to expose to untrusted input. The attacker probes with engine-specific fingerprints ({{7*7}}, ${7*7}, <%= 7*7 %>) and then walks the object graph the engine exposes.

Why it matters#

Many template engines grant access to the host language’s reflection primitives. From Jinja2, __mro__ and __subclasses__ reach the Python standard library; from Freemarker, Runtime.getRuntime().exec() is a few hops away. is therefore not just a rendering bug — it is a common path to full RCE inside the application container.

Mitigation direction#

Render user data, do not template it. Pass untrusted values as arguments to a pre-compiled template, never as template source. Enforce sandboxed engine modes where available, and strip dangerous builtins from the evaluation scope.

  • Cross-Site Scripting (XSS)

    An injection flaw where attacker-controlled data reaches a browser-side scripting sink, letting the attacker execute script in the victim's session origin.

  • Log4Shell (CVE-2021-44228)

    A remote code execution flaw in Apache Log4j 2.x where JNDI lookups inside logged strings caused servers to fetch and execute attacker classes.

  • SQL Injection (SQLi)

    An injection flaw where attacker-controlled input is concatenated into a SQL statement, letting the attacker read, modify, or exfiltrate database content.

  • XML External Entity (XXE)

    A defect in XML parsers that dereference external entity declarations, letting attackers read local files, trigger SSRF, or exhaust resources.

← Back to the glossary

Site search

↑↓ navigateEnter openEsc close