Skip to content

Commit

Permalink
Escape X-Forwarded-Host header as well
Browse files Browse the repository at this point in the history
It seems unlikely an attacker will actually manage
to insert a line break at that point.
But since this isn't a common code path.
We may as well escape it for HTML.
  • Loading branch information
jappeace committed Apr 19, 2022
1 parent 900ea23 commit b875b96
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.8.3

+ HTML escape X-forwarded-host response as well.

## 1.8.2

+ Fix XSS issue in the default response for host not found.
Expand Down
7 changes: 6 additions & 1 deletion Keter/Proxy.hs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,12 @@ defaultUnknownHostBody host =
unknownHostResponse :: ByteString -> ByteString -> Wai.Response
unknownHostResponse host body = Wai.responseBuilder
status200
[("Content-Type", "text/html; charset=utf-8"), ("X-Forwarded-Host", host)]
[("Content-Type", "text/html; charset=utf-8"),
("X-Forwarded-Host",
-- if an attacker manages to insert line breaks somehow,
-- this is also vulnerable.
escapeHtml host
)]
(copyByteString body)

escapeHtml :: ByteString -> ByteString
Expand Down
2 changes: 1 addition & 1 deletion keter.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Cabal-version: >=1.10
Name: keter
Version: 1.8.2
Version: 1.8.3
Synopsis: Web application deployment manager, focusing on Haskell web frameworks
Description: Hackage documentation generation is not reliable. For up to date documentation, please see: <http://www.stackage.org/package/keter>.
Homepage: http://www.yesodweb.com/
Expand Down

0 comments on commit b875b96

Please sign in to comment.