Executive brief
Fiber is a popular web framework for the Go programming language used to build high-performance web applications. A vulnerability in its content negotiation feature allows attackers to inject malicious scripts into web pages. If an application uses the AutoFormat function to display user-provided data, an attacker can force the application to return malicious HTML/JavaScript instead of the intended data format (like JSON), potentially leading to account takeover or unauthorized actions on behalf of users.
Technical details
A Cross-Site Scripting (XSS) vulnerability exists in Go Fiber's `AutoFormat()` (v3) and `Format()` (v2) methods. The vulnerability occurs because the framework's content negotiation logic includes an 'html' branch that wraps stringified input data in `<p>` tags without performing HTML entity encoding. While other formats like JSON and XML use safe encoders, the HTML branch performs direct string concatenation. An attacker can trigger this branch by providing a `text/html` value in the `Accept` request header. If the data passed to these methods contains attacker-controlled input, arbitrary HTML or JavaScript can be executed in the context of the victim's browser. The issue is fixed in versions 2.52.12 and 3.1.0 by implementing proper HTML escaping.
Affected products
- gofiber fiber <= 2.52.12, <= 3.1.0
Timeline
- 2026-04-25: advisory: GitHub Security Advisory published
- 2026-05-11: disclosed: CVE-2026-42554 published to NVD