Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign up2.3.0 returns wrong content-type for built-in javascript libraries #4246
Comments
This comment has been minimized.
This comment has been minimized.
|
that is probably because of this commit |
krasi-georgiev
added
kind/bug
priority/P2
component/ui
labels
Jun 11, 2018
This comment has been minimized.
This comment has been minimized.
|
@krasi-georgiev any further info how that commit causes this? |
This comment has been minimized.
This comment has been minimized.
|
It's likely the nosniff. |
This comment has been minimized.
This comment has been minimized.
|
Okay, what was the motivation for adding those headers? Were we exposed to any security risk? |
This comment has been minimized.
This comment has been minimized.
|
General security hardening was the motivation. |
This comment has been minimized.
This comment has been minimized.
|
Yes, but what are the risks those headers are fixing? I personally haven't seen them before and don't know what they do and how they are causing this issue. I'm all for hardening, but would be good to understand what we are hardening against and how. |
This comment has been minimized.
This comment has been minimized.
hasso
commented
Jun 20, 2018
|
While reverting security headers commit temporarily is OK as hotfix, the real problem is the Content-Type. text/x-js and similar ones are obsolete for more than 10 years and application/javascript must be used. |
brian-brazil
added
kind/enhancement
and removed
kind/bug
labels
Jun 20, 2018
This comment has been minimized.
This comment has been minimized.
|
I tried to reproduce this, but I am not able to given the Prometheus versions and Go versions mentioned in the issue. Built from a clean git checkout, run locally, nothing in between. Startup and startup log:
Test request with header response:
As we see, the I tested with go1.10.1 and go1.10.3 too, no change. Testing v2.3.1 with go1.10.3:
The security headers have been removed as referenced previously in the ticket, and the @veksh, could you please share some more information about how you perform the forwarding from your client environment to your VM, and perhaps also describe your client setup, i.e. browser name and version? Thanks, |
This comment has been minimized.
This comment has been minimized.
|
With current 2.3.1 release (default config, just unpacked and started) I'm seeing different results on different platforms:
W/o security headers Google Chrome is OK with both. |
This comment has been minimized.
This comment has been minimized.
|
Ah. Right, thanks, @veksh, those differences between distros are great data points. Prometheus uses https://golang.org/pkg/net/http/#ServeContent for static files. ServeContent uses https://golang.org/pkg/mime/#TypeByExtension - which in turn references On Ubuntu this file maps Both of those distros are kinda ancient, which sort of explains why these mappings are not up to date with today's conventions. |
This comment has been minimized.
This comment has been minimized.
|
On SLES
and there are no Apache mappings on that host
|
This comment has been minimized.
This comment has been minimized.
|
@veksh I suspect that if you grep for "text/x-js" instead of "javascript" you may find that the /etc/mime.types contains a mapping for that type to "js" later in the file. Go's mime type loader simply scans the input files in order and adds things to a map, so later entries win. See https://golang.org/src/mime/type_unix.go and https://golang.org/src/mime/type.go for specifics If you comment out the "text/x-js" entry you may get the behavior you expect. |
This comment has been minimized.
This comment has been minimized.
|
@amorken you are absolutely right -- there are 2 entries for "js" in |
veksh
closed this
Jun 29, 2018
This comment has been minimized.
This comment has been minimized.
|
I'm not sure we should be depending on external (and apparently outdated) resources for something like this. Is there a better way to do this? |
brian-brazil
reopened this
Jun 29, 2018
brian-brazil
added
priority/P3
and removed
priority/P2
labels
Jun 29, 2018
amorken
added a commit
to amorken/prometheus
that referenced
this issue
Jun 29, 2018
This comment has been minimized.
This comment has been minimized.
|
Well, we can "simply" provide the MIME types ourselves: amorken@fc6b6bf It's not beautiful, but it should be functional. I can send a PR over and include the now-reverted c207920 commit too if there's interest. -@m |
This comment has been minimized.
This comment has been minimized.
|
Is it just the static endpoint that's affected, or is this something we need to set more broadly? |
This comment has been minimized.
This comment has been minimized.
|
Just the static endpoint. It is the only usage of |
veksh commentedJun 9, 2018
Bug Report
I've installed 2.3.0 in a VM with port 9090 forwarded to localhost, and
web interface does not work as expected: no javascript libraries are loaded (2.2.1 is OK).
On closer inspection, error console has 14 errors like
so most probably
Content-Typeheader for built-in javascript libraries is wrong.Command-line is
Environment
System information:
Linux 3.0.101-108.38-default x86_64
Prometheus version:
prometheus, version 2.3.0 (branch: HEAD, revision: 290d717)
build user: root@d539e167976a
build date: 20180607-08:46:54
go version: go1.10.2
Prometheus configuration file: