Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB
CVE-2024-22199 Overview
CVE-2024-22199 is a Cross-Site Scripting (XSS) vulnerability in the gofiber/template package, which provides universal methods to use multiple template engines with the Fiber web framework through the Views interface. The flaw affects the Django template engine wrapper around pongo2, which did not enable auto-escaping by default. Web applications rendering user-supplied data through the engine could execute attacker-controlled scripts in victims' browsers. The maintainers addressed the issue by defaulting autoescape to true, mitigating XSS risk for downstream Fiber applications. The weakness is classified under [CWE-20: Improper Input Validation].
Critical Impact
Attackers can inject arbitrary JavaScript into rendered pages, enabling session theft, credential harvesting, and client-side redirects against users of vulnerable Fiber web applications.
Affected Products
- Gofiber Django template engine (github.com/gofiber/template/django)
- Fiber web applications using the Django Views adapter without manual escaping
- Go projects consuming the gofiber:django module prior to the patched release
Discovery Timeline
- 2024-01-11 - CVE-2024-22199 published to the National Vulnerability Database (NVD)
- 2026-06-17 - Last updated in NVD database
Technical Details for CVE-2024-22199
Vulnerability Analysis
The gofiber/template/django package wraps the pongo2 Django-like template engine for use with the Fiber web framework. Templates rendered through the engine did not automatically HTML-escape variable output. Developers who passed untrusted input such as query parameters, form fields, or stored user content into templates produced raw HTML in the response body.
When a victim loads a crafted page or follows a malicious link, the browser parses attacker-controlled markup as script. This yields reflected or stored XSS depending on how the application sources the tainted data. The user interaction requirement limits automated exploitation but does not prevent phishing-style delivery.
According to the Exploit Prediction Scoring System (EPSS), the probability of exploitation is approximately 0.484% (40.4th percentile), reflecting the common pattern of client-side vulnerabilities in web framework components.
Root Cause
The Django engine instantiated pongo2 templates without enabling auto-escaping. Variables rendered with {{ variable }} emitted raw bytes rather than HTML-encoded output. The patch introduces an autoEscape field on the engine struct and defaults it to true, aligning behavior with Django's secure-by-default rendering model.
Attack Vector
Exploitation occurs over the network against a vulnerable Fiber application. An attacker crafts a request containing JavaScript payload characters such as <script> tags or event handlers. The application reflects the payload into a Django template that renders without escaping. When a victim visits the resulting URL or page, the payload executes in the victim's browser session.
// Patch excerpt from django/django.go (gofiber/template PR #326)
core.Engine
// forward the base path to the template Engine
forwardPath bool
+ // set auto escape globally
+ autoEscape bool
// templates
Templates map[string]*pongo2.Template
}
Source: gofiber/template commit 28cff3a. The fix adds an engine-level autoEscape flag that is enabled by default, ensuring template variable output passes through HTML escaping before reaching the response body.
Detection Methods for CVE-2024-22199
Indicators of Compromise
- Inbound HTTP requests containing script-tag payloads, javascript: URIs, or HTML event handlers such as onerror= and onload= in parameters later reflected in HTML responses.
- Outbound HTTP responses from Fiber applications containing unescaped user-controlled values inside HTML contexts.
- Web server access logs showing repeated probing of query parameters with encoded angle brackets (%3Cscript%3E).
Detection Strategies
- Perform software composition analysis on Go module graphs to flag versions of github.com/gofiber/template/django released before the autoescape patch.
- Review template files for use of the Django engine and audit rendered variables that originate from c.Query, c.FormValue, c.Params, or database-backed user content.
- Run dynamic application security testing (DAST) against staging environments, submitting canonical XSS payloads and verifying HTML encoding in responses.
Monitoring Recommendations
- Enable web application firewall (WAF) rules that identify reflected XSS payloads in request parameters and alert on matches against application endpoints.
- Log and monitor Content Security Policy (CSP) violation reports to detect inline script execution attempts in production.
- Correlate browser-side error telemetry with server-side rendering logs to spot unexpected script injection patterns.
How to Mitigate CVE-2024-22199
Immediate Actions Required
- Upgrade github.com/gofiber/template/django to the patched release that enables autoEscape by default and rebuild all dependent Fiber services.
- Audit all Django templates and explicitly escape any remaining variables that render user-controlled data in HTML, attribute, JavaScript, or URL contexts.
- Deploy a strict Content Security Policy that disallows inline scripts to reduce the impact of residual XSS flaws.
Patch Information
The fix is published in commit 28cff3ac4d4c117ab25b5396954676d624b6cb46 and documented in GitHub Security Advisory GHSA-4mq2-gc4j-cmw6. The patch adds an engine-level autoEscape boolean and defaults it to true, so variable output is HTML-escaped unless developers opt out explicitly.
Workarounds
- Manually apply the |escape filter to every template variable that renders untrusted data when upgrading is not immediately possible.
- Validate and sanitize user input server-side, rejecting or encoding characters such as <, >, ", ', and & before storage or reflection.
- Enforce HTTP response headers including Content-Security-Policy, X-Content-Type-Options: nosniff, and X-XSS-Protection to reduce browser-side risk.
# Update the gofiber template module to the patched version
go get -u github.com/gofiber/template/django/v3@latest
go mod tidy
go build ./...
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB

