Lucene search

K
osvGoogleOSV:GO-2021-0226
HistoryJan 13, 2022 - 3:44 a.m.

Cross-site scripting in net/http/cgi and net/http/fcgi

2022-01-1303:44:58
Google
osv.dev
19
cross-site scripting
net/http/cgi
net/http/fcgi
content-type header
http.detectcontenttype
attacker-controlled file
vulnerability

AI Score

6

Confidence

High

EPSS

0.006

Percentile

79.0%

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.