Skip to content

Template Injection

Description

A malicious user in control of a template can run malicious code on the server-side. Velocity, FreeMarker, and Pebble templates should be seen as scripts.

Examples

Insecure Code

scala
Velocity.evaluate("user_input")

Secure Code

scala
Velocity.evaluate("validated_input")

Remediation

Validate and sanitize all user-controlled input used in template evaluation to prevent code injection.

Rule Details

FieldValue
IDCODE-0074
CategoryInjection
SeverityCRITICAL
CWECWE-94
ConfidenceHIGH
ImpactHIGH
LikelihoodMEDIUM
ExploitabilityEASY
Tagstemplate injection, code injection
OWASPN/A