On 6 April 2022 VMware published VMSA-2022-0011, a batch of fixes for Workspace ONE Access and Identity Manager — the products many organisations use as their single sign-on front door. The most serious, CVE-2022-22954, was a server-side template injection that VMware rated 9.8: anyone with network access could trigger it, no login required, and the result could be remote code execution. A week later VMware updated the advisory to confirm exploitation in the wild.
The timeline is the lesson. CISA's later advisory says that, according to a trusted third party, attackers reverse engineered the updates to develop an exploit within 48 hours and began exploiting unpatched devices. CISA's own incident responders saw the flaw used to drop a web shell on or around 13 April. The fix itself told attackers where to look. For an internet-facing identity system, a monthly patch cycle was already too slow.
- CVE
- CVE-2022-22954 (VMware advisory VMSA-2022-0011)
- Product
- Workspace ONE Access 21.08.0.1, 21.08.0.0, 20.10.0.1 and 20.10.0.0; VMware Identity Manager 3.3.6, 3.3.5, 3.3.4 and 3.3.3.
- Class
- Server-side template injection; code injection (CWE-94).
- Severity
- CVSS 3.1: 9.8 (Critical) from both NVD and VMware. No authentication required.
- Timeline
- Fixed 6 April 2022; exploitation confirmed by VMware 13 April; added to CISA's Known Exploited Vulnerabilities catalogue 14 April 2022.
- Fix
- Apply VMware's patches for the affected versions (KB88099); a temporary workaround was published as KB88098.
The root cause, in one sentence
A value supplied by an unauthenticated visitor was evaluated by the server's template engine as template code, instead of being passed to the template as data to display.
Template engines — FreeMarker, Jinja2, Twig, Velocity, Thymeleaf and many more — exist so that developers can mix fixed layout with variables. Used as designed, the template is written by the developer and the visitor only supplies variables. The trouble starts when a string from the request is stitched into the template text itself. Most engines can call methods, read objects and, in some configurations, create classes; CISA's write-up shows attackers abusing exactly that in FreeMarker. The FreeMarker project's own FAQ puts it plainly: treat templates as part of the source code.
We are not publishing an exploit request. The vendor advisory and CISA's advisory AA22-138B describe what happened and give detection guidance. This post is about the bug class and how to test for it safely.
The five places template injection hides
1. Input concatenated into a template string
The classic form: a developer builds a template on the fly — a greeting, an error message, a page title — by joining a request value into the template text and then rendering it. It looks like string formatting and passes a casual code review. The safe version passes the value in as a variable, so the engine prints it rather than interprets it.
2. Templates your customers can edit
Many products let administrators or tenants customise notification emails, invoices or landing pages. That is a feature, but it makes the template author an untrusted user. Unless the engine is locked down — a logic-less engine, a sandbox, restricted access to objects and classes — a tenant administrator may be able to run code on infrastructure shared with every other tenant.
3. Error and edge-case pages
Main workflows get reviewed; error handlers, OAuth callbacks and fallback pages often do not. These pages love to echo the bad value back to the user, and they are frequently reachable without logging in. CVE-2022-22954 lived on a path an unauthenticated visitor could reach directly.
4. Rendering that happens somewhere else
Emails, PDF exports, scheduled reports and webhooks are rendered later, often by a different service. The HTTP response shows nothing unusual, so a test that only reads the immediate response sees nothing. The evaluated result appears in an inbox, a downloaded file or a log — or only in the server's behaviour.
5. A second engine downstream
Output escaped correctly for HTML can still be evaluated by another layer: a client-side framework that interprets expressions in the page, or a second server-side pass that renders an already rendered string. Each layer has its own syntax and its own idea of what is data. Test the whole path to the final renderer, not just the first.
One arithmetic probe is not a template-injection test. Engines use different delimiters and expression syntax, and blind or out-of-band rendering never reflects a result in the response. A scanner that tries one syntax and reads one response can report clean while an email template evaluates every expression it is sent.
How we test for it
- Find every renderer. We map where input can reach a template: pages, error handlers, notification and email templates, PDF and document generation, white-label branding and preview features. Unauthenticated paths come first.
- Distinguish evaluation from reflection. We send harmless canary expressions whose evaluated result differs from the literal text, in the syntaxes of the common engines, and compare what is stored, displayed and delivered.
- Follow output out of band. Where content is rendered later, we route it to mailboxes and storage we control and inspect the result there, including PDFs and exports.
- Identify the engine without escalating. Error messages and syntax-specific behaviour usually reveal which engine is in use and whether a sandbox is present. That determines the realistic impact.
- Stop at proof of evaluation. On a client's systems we demonstrate that an expression is evaluated, then stop. We do not run operating-system commands on production to make a point; impact is stated from the engine's documented capabilities and configuration, and agreed with the client first.
- Report the precise fix. The finding names the input, the template and the engine, with evidence and a regression check that the same string now renders literally.
Evidence and remediation belong together. Our reporting approach shows how we make a finding reproducible without publishing dangerous material.
Six things to check in your application this week
- List every feature that renders text with a template engine, including emails, PDFs, error pages and exports.
- Confirm request values are passed to templates as variables, never joined into the template source.
- If customers can edit templates, use a logic-less engine or the engine's sandbox, and restrict access to objects and classes — for FreeMarker, follow its FAQ on untrusted templates.
- Patch internet-facing identity and SSO systems within days of a critical advisory, and watch CISA's Known Exploited Vulnerabilities catalogue.
- Alert on the web or application service starting shells or unexpected child processes, and on new files in web-served directories.
- Add a regression test that template syntax submitted to each input is displayed literally.
Template injection is easy to miss because the vulnerable code looks like ordinary string handling. We test where your input is rendered, including the places it is rendered later.
References
- VMware (Broadcom) — VMSA-2022-0011 security advisory
- CISA — AA22-138B: Threat actors chaining unpatched VMware vulnerabilities for full system control
- CISA — Emergency Directive 22-03: Mitigate VMware vulnerabilities
- NVD — CVE-2022-22954 detail
- Apache FreeMarker — FAQ: allowing users to upload templates
- PortSwigger Research — Server-side template injection
- OWASP — WSTG: Testing for server-side template injection