Commit Graph

18175 Commits

Author SHA1 Message Date
Florian Bruhin 1e1eb0570c Update docs
(cherry picked from commit 41b05f9548)
2021-10-21 16:46:26 +02:00
Florian Bruhin d1ceaab04b CVE-2021-41146: Add --untrusted-args to avoid argument injection
On Windows, if an application is registered as an URL handler like this:

    HKEY_CLASSES_ROOT
        https
            URL Protocol = ""
            [...]
            shell
                open
                    command
                    (Default) = ".../qutebrowser.exe" "%1"

one would think that Windows takes care of making sure URLs can't inject
arguments by containing a quote. However, this is not the case, as
stated by the Microsoft docs:
https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa767914(v=vs.85)

    Security Warning: Applications that handle URI schemes must consider how to
    respond to malicious data. Because handler applications can receive data
    from untrusted sources, the URI and other parameter values passed to the
    application may contain malicious data that attempts to exploit the handling
    application.

and

    As noted above, the string that is passed to a pluggable protocol handler
    might be broken across multiple parameters. Malicious parties could use
    additional quote or backslash characters to pass additional command line
    parameters. For this reason, pluggable protocol handlers should assume that
    any parameters on the command line could come from malicious parties, and
    carefully validate them. Applications that could initiate dangerous actions
    based on external data must first confirm those actions with the user. In
    addition, handling applications should be tested with URIs that are overly
    long or contain unexpected (or undesirable) character sequences.

Indeed it's trivial to pass a command to qutebrowser this way - given how
trivial the exploit is to recreate given the information above, here's a PoC:

    https:x" ":spawn calc

(or qutebrowserurl: instead of https: if qutebrowser isn't registered as a
default browser)

Some applications do escape the quote characters before calling
qutebrowser - but others, like Outlook Desktop or .url files, do not.

As a fix, we add an --untrusted-args flag and some early validation of the raw
sys.argv, before parsing any arguments or e.g. creating a QApplication (which
might already allow injecting Qt flags there).

We assume that there's no way for an attacker to inject flags *before* the %1
placeholder in the registry, and add --untrusted-args as the last argument of
the registry entry. This way, it'd still be possible for users to customize
their invocation flags without having to remove --untrusted-args.

After --untrusted-args, however, we have some rather strict checks:

- There should be zero or one arguments, but not two (or more)
- Any argument may not start with - (flag) or : (qutebrowser command)

We also add the --untrusted-args flag to the Linux .desktop file, though it
should not be needed there, as the specification there is sane:

https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#exec-variables

    Implementations must take care not to expand field codes into multiple
    arguments unless explicitly instructed by this specification. This means
    that name fields, filenames and other replacements that can contain spaces
    must be passed as a single argument to the executable program after
    expansion.

There is no comparable mechanism on macOS, which opens the application without
arguments and then sends an "open" event to it:
https://doc.qt.io/qt-5/qfileopenevent.html

This issue was introduced in qutebrowser v1.7.0 which started registering it as
URL handler: baee288890 / #4086

This is by no means an issue isolated to qutebrowser. Many other projects have
had similar trouble with Windows' rather unexpected behavior:

Electron / Exodus Bitcoin wallet:
- http://web.archive.org/web/20190702112128/https://medium.com/0xcc/electrons-bug-shellexecute-to-blame-cacb433d0d62
- https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-1000006
- https://medium.com/hackernoon/exploiting-electron-rce-in-exodus-wallet-d9e6db13c374

IE/Firefox:

- https://bugzilla.mozilla.org/show_bug.cgi?id=384384
- https://bugzilla.mozilla.org/show_bug.cgi?id=1572838

Others:
- http://web.archive.org/web/20210930203632/https://www.vdoo.com/blog/exploiting-custom-protocol-handlers-in-windows
- https://parsiya.net/blog/2021-03-17-attack-surface-analysis-part-2-custom-protocol-handlers/
- etc. etc.

See CVE-2021-41146 / GHSA-vw27-fwjf-5qxm:
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-41146
https://github.com/qutebrowser/qutebrowser/security/advisories/GHSA-vw27-fwjf-5qxm

Thanks to Ping Fan (Zetta) Ke of Valkyrie-X Security Research Group
(VXRL/@vxresearch) for finding and responsibly disclosing this issue.

(cherry picked from commit 8f46ba3f6d)

# Conflicts:
#	qutebrowser/qutebrowser.py
#	tests/unit/test_qutebrowser.py
2021-10-21 16:09:22 +02:00
Florian Bruhin 454d4c881f Add test for remembered ignored certificate errors
This is a continuation of the previous commit for #5403. The tests are split up
from the commit itself so that the fix can be backported with less conflicts.

See #5403

(cherry picked from commit 45a2be3f9f)
2020-05-02 19:23:30 +02:00
Florian Bruhin 19f01bb42d Security: Remember hosts with ignored cert errors for load status
Without this change, we only set a flag when a certificate error occurred.
However, when the same certificate error then happens a second time (e.g.
because of a reload or opening the same URL again), we then colored the URL as
success_https (i.e. green) again.

See #5403

(cherry picked from commit 021ab572a3)
2020-05-02 19:23:12 +02:00
Florian Bruhin 3508352615 Speculative fix for permission crash
In some scenarios (which I can't seem to reproduce), the URL we get in
shared.feature_permission is an invalid one.

In that case, we set "urlstr = None", but that means we call message.* with
url=None but option=... set. Since that's invalid usage (we can't set a
per-domain option without knowing the URL) it bails out, causing a crash.

(cherry picked from commit 068f3ded89)
2019-07-22 23:11:40 +02:00
Florian Bruhin 1023c2ef80 Fix lint
(cherry picked from commit 81a5ada67f)
2019-07-18 17:35:30 +02:00
Florian Bruhin d4966852d7 build_release: Re-add windows patching
Looks like we need some patching again nowadays...
This reverts commit 7763287b10.

(cherry picked from commit d37843d137)
2019-07-18 15:41:54 +02:00
Florian Bruhin 636db82c06 Add workaround for missing QtCore with PyInstaller
See https://github.com/pyinstaller/pyinstaller/issues/4293
and 0abf8e7363

(cherry picked from commit e58aa9c8ae)
2019-07-18 15:41:54 +02:00
Florian Bruhin 80f7dd7236 Check stdout/stderr of processes when running smoke test
(cherry picked from commit 730018e37e)
2019-07-18 15:41:54 +02:00
Florian Bruhin 6dce8779e9 build_release: Improve sdist building
(cherry picked from commit dfabbff63b)
2019-07-18 12:25:29 +02:00
Florian Bruhin ef049220a8 update_version: Print tag
(cherry picked from commit 412dd58b0b)
2019-07-18 12:09:43 +02:00
Florian Bruhin 4f0536385f Add missing format
(cherry picked from commit 9cba5a074a)
2019-07-18 12:09:43 +02:00
Florian Bruhin 87f8d758f9 update_version: Print better commands
(cherry picked from commit 09ff9a87a5)
2019-07-18 12:03:39 +02:00
Florian Bruhin 4b66456122 update_version: Fix message
(cherry picked from commit d7e68a5326)
2019-07-18 12:03:39 +02:00
Florian Bruhin 8c006acf01 Release v1.7.0 2019-07-18 11:42:06 +02:00
Florian Bruhin 730ff7fe3d update_version: Show git commit 2019-07-18 11:41:46 +02:00
Florian Bruhin 7c4716c1c4 bumpversion: Adjust commit message 2019-07-18 11:40:05 +02:00
Florian Bruhin af6a9c6b4c update_version: Fix output 2019-07-18 11:36:09 +02:00
Florian Bruhin 91a5e0d098 tests: Wait until userscript runner finished
Otherwise, temporary files and processes get cleaned up after the test is
finished, leading to warning messages.
2019-07-18 11:00:50 +02:00
Florian Bruhin 876290340a Add more dev requirements 2019-07-18 10:02:37 +02:00
Florian Bruhin c161433f4f Update content.headers.user_agent completion 2019-07-18 10:01:17 +02:00
Florian Bruhin 68a973567d Remove old tox workaround
Fixed in tox v3.4.0 (2018-09-20)
2019-07-18 09:52:23 +02:00
Florian Bruhin 56a2c50508 Use Qt 5.12 for PyInstaller
Mainly due to https://bugreports.qt.io/browse/QTBUG-76913
2019-07-18 09:50:05 +02:00
Florian Bruhin 06ff46ad98 Use FullyEncoded to get URL segments
See #4917, #4795
2019-07-18 09:48:05 +02:00
Florian Bruhin ea45eb1261 Update install instructions
Fixes #4899
2019-07-17 19:06:12 +02:00
Florian Bruhin ccd2822a5e Update changelog 2019-07-17 17:47:50 +02:00
Florian Bruhin 185d5eff86 Update release checklist 2019-07-17 16:34:30 +02:00
Florian Bruhin f21255b3e2 Update changelog 2019-07-17 16:33:36 +02:00
Florian Bruhin aefdf7565a Turn off DNS prefetch by default
See #4657
2019-07-17 10:46:58 +02:00
Florian Bruhin e4d4f71879 Ignore unused import 2019-07-17 10:45:40 +02:00
Florian Bruhin afbc611d9f Only connect selectClientCertificate if argument class is available
In PyQt, QWebEngineClientCertificate is guarded by "%If (PyQt_SSL)", so it
might not be available in all cases.
2019-07-16 16:11:35 +02:00
Florian Bruhin 27091109a8 Update QtWebKit warning 2019-07-16 15:15:29 +02:00
Florian Bruhin dd6f191793 Fix Qt 5.9/5.10 requirement files 2019-07-16 14:31:11 +02:00
Florian Bruhin 68b0be563d Qt 5.13: Disable PDFium
See #4911, #4221
Fixes #4910
2019-07-16 13:23:27 +02:00
Florian Bruhin eaf3efc267 Register request interceptor on GUI thread if possible.
See #4221
2019-07-16 13:00:44 +02:00
Florian Bruhin 2d7ed87c36 Avoid Qt 5.13
Let's stay with 5.12 for PyPI-installed virtualenvs for now, see:
https://bugreports.qt.io/browse/QTBUG-76913
2019-07-16 11:13:28 +02:00
Florian Bruhin 17c02cbddd Use separate requirements files for different Qt versions 2019-07-16 11:08:47 +02:00
Florian Bruhin 326a9a8a79 requirements: Add github3.py and bump2version to -dev 2019-07-16 10:55:32 +02:00
Florian Bruhin 29c6afe476 Fix lint 2019-07-16 10:52:24 +02:00
Florian Bruhin c9c821254f Update MANIFEST.in for NSIS changes 2019-07-16 10:50:41 +02:00
Florian Bruhin 5329f7b1c3 bumpversion: Update changelog 2019-07-16 10:47:26 +02:00
Florian Bruhin 2077070b6d update_version: Get new version from qutebrowser.py 2019-07-16 10:47:26 +02:00
Florian Bruhin 46dfafd907 bumpversion: Update releases in appdata.xml
Using lxml means rewriting the file, which loses comments.
2019-07-16 10:47:09 +02:00
Florian Bruhin d22f500bbc update_version: Update appdata filename 2019-07-16 10:47:09 +02:00
Florian Bruhin 5c60e847eb update_version: Fix cwd handling 2019-07-16 10:47:09 +02:00
Florian Bruhin a0b8601db3 bumpversion: Update current_version 2019-07-16 10:47:06 +02:00
Florian Bruhin 032669d49f update_version: Use sys.executable 2019-07-16 10:47:06 +02:00
Florian Bruhin 3c91dddd79 Rename requirements-optional to requirements-dev 2019-07-16 10:47:06 +02:00
Florian Bruhin 6e8ebaf335 update_version: Fix broken argument 2019-07-16 10:46:39 +02:00
Florian Bruhin ed52cd0de1 update_3rdparty: Fix lint 2019-07-16 10:46:34 +02:00