GO-2021-0226

Source
https://pkg.go.dev/vuln/GO-2021-0226
Import Source
https://vuln.go.dev/ID/GO-2021-0226.json
JSON Data
https://api.osv.dev/v1/vulns/GO-2021-0226
Aliases
Published
2022-01-13T03:44:58Z
Modified
2024-05-20T16:03:47Z
Summary
Cross-site scripting in net/http/cgi and net/http/fcgi
Details

When a Handler does not explicitly set the Content-Type header, the the package would default to “text/html”, which could cause a Cross-Site Scripting vulnerability if an attacker can control any part of the contents of a response.

The Content-Type header is now set based on the contents of the first Write using http.DetectContentType, which is consistent with the behavior of the net/http package.

Although this protects some applications that validate the contents of uploaded files, not setting the Content-Type header explicitly on any attacker-controlled file is unsafe and should be avoided.

References
Credits
    • RedTeam Pentesting GmbH

Affected packages

Go / stdlib

Package

Affected ranges

Type
SEMVER
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
1.14.8
Introduced
1.15.0-0
Fixed
1.15.1

Ecosystem specific

{
    "imports": [
        {
            "path": "net/http/cgi",
            "symbols": [
                "response.Write",
                "response.WriteHeader",
                "response.writeCGIHeader"
            ]
        },
        {
            "path": "net/http/fcgi",
            "symbols": [
                "response.Write",
                "response.WriteHeader",
                "response.writeCGIHeader"
            ]
        }
    ]
}