Focus on where untrusted input is rendered and what runtime interprets it. If the browser and front-end framework evaluate the expression, you are looking at client-side template injection. If a back-end templating engine processes the input before response generation, the risk is server-side template injection. The distinction matters because the exploit path and impact are different.
Why This Matters for Security Teams
Template injection testing is not just a syntax check. It is a path-selection problem that determines whether testers are validating browser-side expression evaluation or back-end rendering behaviour. That distinction changes the exploit chain, the likely blast radius, and the evidence needed to prove impact. NIST SP 800-53 Rev 5 Security and Privacy Controls frames this as a control validation issue: the control only matters if the right processing layer is being assessed.
Security teams often misclassify the path when a payload appears to “work” somewhere in the stack but does not reflect the true interpreter. Client-side template injection usually depends on front-end JavaScript frameworks and browser execution context, while server-side template injection points to a templating engine that renders untrusted data before the response is sent. The practical risk is that teams spend time hardening the wrong layer and miss the one that can expose session data, secrets, or internal network reachability. NHIMG has shown how quickly exposed tokens and embedded secrets become real incidents in JetBrains GitHub plugin token exposure and Hard-Coded Secrets in VSCode Extensions. In practice, many security teams encounter the real injection path only after a payload has already been triaged as a false positive or a harmless front-end quirk.
How It Works in Practice
Start by identifying what interprets the input. If the payload is rendered in the DOM after page load, inspect the client-side framework, routing, and any expression syntax it supports. If the payload is processed before the HTTP response is returned, focus on the server-side templating engine, its sandboxing model, and whether user-controlled fields reach render functions. Current guidance suggests treating the interpreter boundary as the primary test decision point, not the payload shape alone.
For client-side paths, confirm whether the browser is evaluating a framework-specific expression, then determine whether the issue is a template injection or a broader DOM-based problem. For server-side paths, test whether untrusted input is reaching a render context, whether auto-escaping is active, and whether escaping can be bypassed through filters, partials, helpers, or nested render calls. This is where NIST SP 800-53 Rev 5 Security and Privacy Controls is useful in practice, because it pushes teams toward evidence-driven verification of input handling rather than assumption-based review.
- Map every untrusted input to its first render point.
- Determine whether the browser, a front-end framework, or a back-end engine interprets the expression.
- Check whether the payload survives transport, encoding, and sanitisation unchanged.
- Validate impact separately for client-side execution and server-side rendering.
For deeper NHI context, the patterns that drive unsafe automation and exposed credentials are similar to the failures documented in Code Formatting Tools Credential Leaks and the Ultimate Guide to NHIs, where unmanaged execution paths and overexposed secrets become the real issue. These controls tend to break down when the application mixes server-side rendering with hydration or partial client-side re-rendering, because the same input can be interpreted in more than one runtime.
Common Variations and Edge Cases
Tighter template testing often increases validation overhead, requiring organisations to balance precision against application complexity. The hardest cases are hybrid apps, where a server renders the initial page and the browser later rehydrates it. In those environments, the same payload may look client-side during testing but originate from a server-side render source. Best practice is evolving, and there is no universal standard for this yet, so testers should document the exact interpreter and execution phase.
Another edge case is when the apparent template issue is actually a sanitisation bypass, a reflected XSS path, or a misconfigured CSP problem. Do not assume client-side injection just because the payload appears in the DOM. Likewise, do not assume server-side injection just because the response contains templating artefacts. A reliable test plan should include framework fingerprinting, response timing checks, and controlled mutation of the input to see where expression evaluation happens. NHIMG’s research on JetBrains Marketplace AI Plugin Campaign shows how quickly execution context and trust boundaries can be abused when teams focus on the surface symptom instead of the interpreter. Use the same discipline here: test the runtime that evaluates the content, not just the place where it is displayed.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP Agentic AI Top 10, OWASP Non-Human Identity Top 10 and CSA MAESTRO address the attack and risk surface, while NIST AI RMF and NIST CSF 2.0 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Agentic AI Top 10 | LLM-01 | Template injection mirrors unsafe prompt and expression handling at runtime. |
| OWASP Non-Human Identity Top 10 | NHI-03 | Injected templates often expose or misuse secrets and identity tokens. |
| CSA MAESTRO | AI-SEC-04 | Runtime execution boundaries matter when autonomous or AI-driven components render content. |
| NIST AI RMF | AI RMF helps govern dynamic evaluation and unintended model or tool execution. | |
| NIST CSF 2.0 | PR.AC-3 | Least privilege limits impact if a template path is exploited. |
Find every render path that can expose secrets and rotate or remove credentials reachable by templates.