Skip to content

Commit

Permalink
Fix XSS issue on qute://history
Browse files Browse the repository at this point in the history
Fixes #4011

(cherry picked from commit 5a7869f)
  • Loading branch information
The-Compiler committed Jun 21, 2018
1 parent 1053873 commit 4c93602
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
6 changes: 4 additions & 2 deletions qutebrowser/browser/qutescheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
_HANDLERS: The handlers registered via decorators.
"""

import html
import json
import os
import time
Expand Down Expand Up @@ -241,8 +242,9 @@ def history_data(start_time, offset=None):
end_time = start_time - 24*60*60
entries = hist.entries_between(end_time, start_time)

return [{"url": e.url, "title": e.title or e.url, "time": e.atime}
for e in entries]
return [{"url": html.escape(e.url),
"title": html.escape(e.title) or html.escape(e.url),
"time": e.atime} for e in entries]


@add_handler('history')
Expand Down
10 changes: 10 additions & 0 deletions tests/end2end/data/issue4011.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>&lt;img src=&quot;x&quot; onerror=&quot;console.log('XSS')&quot;&gt;foo</title>
</head>
<body>
foo
</body>
</html>
5 changes: 5 additions & 0 deletions tests/end2end/features/history.feature
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,8 @@ Feature: Page history
And I wait until qute://history is loaded
Then the page should contain the plaintext "3.txt"
Then the page should contain the plaintext "4.txt"

Scenario: XSS in :history
When I open data/issue4011.html
And I open qute://history
Then the javascript message "XSS" should not be logged

1 comment on commit 4c93602

@The-Compiler
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This issue has been assigned CVE-2018-1000559.

Please sign in to comment.