Skip to main content

Go Fiber CVE-2026-42554

MEDIUM
Cross-site Scripting (XSS) (CWE-79)
2026-05-05 https://github.com/gofiber/fiber GHSA-qjv7-627w-8qjv
5.3
CVSS 4.0 · Vendor: https://github.com/gofiber/fiber
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Recon
    Send HTTP request with Accept: text/html header
  2. Delivery
    Fiber Accepts() method reads attacker-supplied Accept header
  3. Exploit
    AutoFormat() selects HTML branch
  4. Install
    Body data stringified without escaping
  5. C2
    HTML sent to browser as text/html; charset=utf-8
  6. Execute
    Browser parses and executes injected script
  7. Impact
    XSS payload executes in application origin

Vulnerability Assessment

Weakness
CWE
OWASP Top 10:2025
A05:2025 - Injection
ASVS 5.0
V1 - Encoding and Sanitization Output encoding, context-aware escaping
MITRE ATT&CK

2 techniques across 2 tactics: Initial Access, Execution

The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up.

Exploitation Conditions

Exploitation requires three specific conditions: (1) the application must call c.AutoFormat(v) or r.AutoFormat(v) where v contains or stringifies to attacker-influenced data (e.g., query parameters, form fields, path variables, or database records populated from user input); (2) the attacker must send an HTTP request with Accept: text/html header to force the HTML branch (this header is not present by default in most HTTP clients, but is easily added by an attacker using curl, browser tools, or a custom client); and (3) no other defense (such as CSP with script-src restrictions or output encoding at a higher layer) must be in place. The vulnerability does NOT require the developer to explicitly declare HTML format support-AutoFormat negotiates this from the attacker's Accept header. Developers who tested their handlers only with JSON requests (the typical path) are unaware their handler is vulnerable to XSS via HTML content negotiation.

Impact

This is a high-impact XSS vulnerability with clear real-world exploitation risk. Although CVSS and EPSS scores are not provided, the attack vector is network-accessible, requires no authentication (AV:N/PR:N), has low complexity (AC:L), does not require user interaction beyond sending a crafted HTTP header (UI:N), and affects any application calling AutoFormat() with request-influenced data. The vulnerability is particularly dangerous because developers opt into content negotiation but do not consciously opt into HTML generation-the method name AutoFormat suggests safe, format-agnostic behavior, yet the HTML branch silently treats data as markup. A proof-of-concept exists demonstrating script injection in a realistic scenario (query parameter → struct field → AutoFormat). The fact that five of six format branches correctly escape output underscores that this is a careless oversight rather than a design limitation. No active exploitation is reported in public databases at submission, but the simplicity of the attack and the ubiquity of Fiber in Go microservices create significant practical risk. Organizations using Fiber to serve user-influenced data through AutoFormat should treat this as critical for internet-facing endpoints.

Exploit ScenarioDerived

An attacker crafts an HTTP request to an endpoint that uses AutoFormat() to return user data, such as /api/user?name=<script>alert(document.domain)</script>, and includes the header Accept: text/html. The Fiber framework selects the HTML branch due to the Accept header, stringifies the attacker-controlled name parameter, and returns <p>{1 <script>alert(document.domain)</script>}</p> with Content-Type: text/html, causing the browser to execute the injected script in the context of the application's origin. No user interaction beyond sending the HTTP request is required.

This Month Plan within 30 days. Why: MEDIUM severity (CVSS 4.0-6.9).
Patch available 0.2% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – May 05, 2026

Reflected cross-site scripting in Go Fiber's AutoFormat() method allows remote attackers to inject arbitrary HTML and JavaScript by sending Accept: text/html headers with attacker-controlled data passed to AutoFormat(). The vulnerability affects Fiber v3 through 3.1.0 and v2 through 2.52.12, where the HTML output branch concatenates user data directly into markup without escaping, while all other format branches (JSON, XML, MsgPack, CBOR) properly sanitize output. A proof-of-concept demonstrates script injection via query parameters when HTML content negotiation is selected by an attacker.

RemediationAI

Upgrade Go Fiber immediately to v3.2.0 or later for v3 users, and v2.52.13 or later for v2 users. These patch versions apply html.EscapeString() to the body parameter before concatenating it into the HTML paragraph wrapper, neutralizing special characters (<, >, &, ', ") and preventing script injection. Update your go.mod file and run go get -u github.com/gofiber/fiber/v3@v3.2.0 (or equivalent for v2) to apply the fix. If immediate patching is not feasible, implement a temporary workaround by auditing all AutoFormat() calls in your application and replacing them with explicit format handlers that do not use AutoFormat, or by ensuring that user-influenced data is not passed to AutoFormat. Additionally, implement a Content-Security-Policy (CSP) header with script-src 'self' to provide defense-in-depth, though this does not address the root cause. Refer to the GitHub advisory at https://github.com/gofiber/fiber/security/advisories/GHSA-qjv7-627w-8qjv for official remediation details and to confirm patch versions before deployment.

Affected Packages

go github.com/gofiber/fiber/v2 fix: 2.52.13
go github.com/gofiber/fiber/v3 fix: 3.2.0

Source: OSV (Open Source Vulnerabilities)

Affects your stack

Affects 2 packages in go

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

Go Fiber is a web framework that provides content negotiation via the AutoFormat() method, which inspects the Accept header and serializes response data in one of six formats: HTML, JSON, TXT, XML, MsgPack, or CBOR. The vulnerability exists in the HTML branch of the format selector, which constructs an HTML paragraph element by concatenating the stringified body parameter directly: <p> + b + </p>. The Accept header is fully attacker-controlled via the Accepts() method, and the body parameter is derived from caller-supplied data via string assignment or fmt.Sprintf("%v", body), which does not apply HTML encoding. The method is used for transparent content negotiation where developers do not explicitly declare that their handler supports raw HTML markup generation. Other branches route through proper encoders (JSON, XML, MsgPack, CBOR) or emit text/plain (TXT), which cannot execute scripts. The root cause is CWE-79 (Improper Neutralization of Input During Web Page Generation).

Know when the next one hits your stack

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

Severity by source

Vendor (https://github.com/gofiber/fiber) PRIMARY 5.3 MEDIUM
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N
SUSE MEDIUM

Primary rating from Vendor (https://github.com/gofiber/fiber).

CVSS VectorVendor: https://github.com/gofiber/fiber

Attack Vector
Network
Attack Complexity
Low
Attack Requirements
None
Privileges Required
None
User Interaction
Passive
Vulnerable system: Confidentiality
None
Vulnerable system: Integrity
None
Vulnerable system: Availability
None
Subsequent system: Confidentiality
Low
Subsequent system: Integrity
Low
Subsequent system: Availability
None

Lifecycle Timeline

1
CVSS changed
May 11, 2026 - 23:22 NVD
5.3 (MEDIUM)

DescriptionCVE.org

Summary

Description

A Cross-Site Scripting (CWE-79) vulnerability in Go Fiber allows a remote attacker to inject arbitrary HTML/JavaScript by supplying Accept: text/html on any request whose handler passes attacker-influenced data to the AutoFormat() feature. This affects github.com/gofiber/fiber/v3 (DefaultRes.AutoFormat) through version 3.1.0 and github.com/gofiber/fiber/v2 (Ctx.Format) through version 2.52.12.

The developer opts into content negotiation by calling AutoFormat(), but does not opt into raw HTML emission for a particular request; Fiber chooses that branch from attacker-controlled Accept. Five of the six branches of the same method already escape. JSON, XML, MsgPack, and CBOR all route through encoders that neutralize markup; the txt branch emits text/plain and cannot execute. The html branch is the sole outlier in a method whose name (AutoFormat) and symmetrical structure actively telegraph "safe, format-agnostic reply."

Details

The issue resides in res.go within (*DefaultRes).AutoFormat(). The method negotiates against the request Accept header, selects one of html | json | txt | xml | msgpack | cbor, and serializes the caller-supplied body accordingly.

The "html" branch concatenates the stringified body directly into HTML markup with no output encoding:

  • accept comes from r.c.Accepts(...), i.e. is fully attacker-controlled. An attacker can force the "html" branch on any AutoFormat() call regardless of which format the developer tested against.
  • b is produced from body via direct assignment (string / []byte) or fmt.Sprintf("%v", body). No html.EscapeString is applied.
  • The resulting string is sent as text/html; charset=utf-8, so browsers render it as active HTML.
go
// res.go
func (r *DefaultRes) AutoFormat(body any) error {

    accept := r.c.DefaultReq.Accepts("html", "json", "txt", "xml", "msgpack", "cbor")

    r.Type(accept)
    var b string
    switch val := body.(type) {
    case string:
        b = val
    case []byte:
        b = r.c.app.toString(val)
    default:
        b = fmt.Sprintf("%v", val)
    }

    switch accept {
    case "txt":
        return r.SendString(b)
    case "json":
        return r.JSON(body)
    case "xml":
        return r.XML(body)
    case "html":
        return r.SendString("<p>" + b + "</p>")
    case "msgpack":
        return r.MsgPack(body)
    case "cbor":
        return r.CBOR(body)
    }
    return r.SendString(b)
}

Impact

This impacts all current v3 releases ≤ 3.1.0 containing DefaultRes.AutoFormat, and all current v2 releases ≤ 2.52.12 where the identical "<p>" + b + "</p>" construction exists in (*Ctx).Format(). Exploitation requires that an application call c.AutoFormat(v) where v (or a field stringified by %v) contains request-influenced data.

A handler that uses AutoFormat() to serve multiple representations of the same data can be turned into an HTML XSS sink when the client sends Accept: text/html, even if the developer only tested the JSON path.

This may result in:

  • Reflected XSS in the application's origin via any request-derived value reaching AutoFormat.
  • Stored XSS where the reflected value originates from persisted input later passed to AutoFormat.

Proposed Patch

The injection surface is r.Type("html") followed by r.SendString(b) with unescaped caller data, where it constructs markup on the caller's behalf around a value whose HTML-ness the caller did not declare. A few options:

  • AutoFormat() should treat body as data, not markup, in the "html" branch and escape it before concatenating it into the framework-generated <p> wrapper. Callers that need raw negotiated HTML should use Format() with an explicit HTML handler.
  • Introduce a sibling method that escapes, leave AutoFormat alone for backward compatibility.

HTML-escape the value in the "html" branch before concatenating it into the <p> wrapper.

go
import "html"

// ...
case "html":
    return r.SendString("<p>" + html.EscapeString(b) + "</p>")

html.EscapeString escapes <, >, &, ', ", which is sufficient for an element-text context. Apply the same change to v2's (*Ctx).Format().

Proof of Concept

bash
# Create project directory
mkdir fiber-xss-poc && cd fiber-xss-poc
# Initialize Go module
go mod init fiber-xss-poc
# Install Fiber v3
go get github.com/gofiber/fiber/v3
# Create the PoC file
cat > main.go << 'EOF'
package main

import (
	"github.com/gofiber/fiber/v3"
)

type User struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

func main() {
	app := fiber.New()

	app.Get("/api/user", func(c fiber.Ctx) error {
		user := User{
			ID:   1,
			Name: c.Query("name", "anonymous"),
		}
		return c.AutoFormat(user)
	})

	app.Listen(":3000")
}
EOF
# Run it
go run main.go
}

Benign JSON

bash
curl -s 'http://127.0.0.1:3000/api/user?name=Alice' -H 'Accept: application/json'
{"id":1,"name":"Alice"}

HTML sink enables XSS

bash
curl -s 'http://127.0.0.1:3000/api/user?name=<script>alert(document.domain)</script>' -H 'Accept: text/html'
<p>{1 <script>alert(document.domain)</script>}</p>

Threat Intelligence Overview

EPSS Score
0.2%
Top 57% exploitable
Threat Intel
1
1 source
Data Quality
6 sources
Confidence: High
NVD CVE.org EPSS GHSA Vendor GitHub VulDB

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity MEDIUM
CISA KEV No
Public POC No
EPSS 0.2%
Patch available Yes
Active threat No
Deciding rule
MEDIUM severity (CVSS 4.0-6.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Scheduled
Exploitation· derived
None
System Exposure· derived
Open
Automatable· derived
No
Human Impact· derived
Medium

Priority Score

26
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +26
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

Cross-Site Scripting occurs when an application accepts untrusted data and sends it to a web browser without proper validation or encoding.

Affected Products (CPE)CVE.org

pkg:go/github.com_gofiber_fiber_v3
pkg:go/github.com_gofiber_fiber_v2

Vendor StatusVendor

SUSE

Severity: Moderate
Product Status
SUSE Linux Enterprise Server 16.1 Affected
SUSE Linux Enterprise Server for SAP applications 16.1 Affected

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy