Skip to content

Commit b8e5b10

Browse files
unknwonmpsonntag
authored andcommitted
http: always set header X-Content-Type-Options to nosniff (#6008)
1 parent d02c113 commit b8e5b10

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ All notable changes to Gogs are documented in this file.
4242
- [Security] Potential XSS attack via `.ipynb`. [#5170](https://github.com/gogs/gogs/issues/5170)
4343
- [Security] Potential SSRF attack via webhooks. [#5366](https://github.com/gogs/gogs/issues/5366)
4444
- [Security] Potential CSRF attack in admin panel. [#5367](https://github.com/gogs/gogs/issues/5367)
45+
- [Security] Potential stored XSS attack in some browsers. [#5397](https://github.com/gogs/gogs/issues/5397)
4546
- [Security] Potential RCE on mirror repositories. [#5767](https://github.com/gogs/gogs/issues/5767)
4647
- [Security] Potential XSS attack with raw markdown API. [#5907](https://github.com/gogs/gogs/pull/5907)
4748
- Open/close milestone redirects to a 404 page. [#5677](https://github.com/gogs/gogs/issues/5677)

internal/context/context.go

+4
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,10 @@ func Contexter() macaron.Handler {
336336

337337
c.renderNoticeBanner()
338338

339+
// 🚨 SECURITY: Prevent MIME type sniffing in some browsers,
340+
// see https://github.com/gogs/gogs/issues/5397 for details.
341+
c.Header().Set("X-Content-Type-Options", "nosniff")
342+
339343
ctx.Map(c)
340344
}
341345
}

0 commit comments

Comments
 (0)