0002-Hsts-match-header-names-case-insensitively.patch 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. From 5e8697e3aa4e92643c52d34aacfa26890e7d417d Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= <marten.nordheim@qt.io>
  3. Date: Fri, 5 May 2023 11:07:26 +0200
  4. Subject: [PATCH] Hsts: match header names case insensitively
  5. Header field names are always considered to be case-insensitive.
  6. Pick-to: 6.5 6.5.1 6.2 5.15
  7. Fixes: QTBUG-113392
  8. Change-Id: Ifb4def4bb7f2ac070416cdc76581a769f1e52b43
  9. Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
  10. Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
  11. Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
  12. Fixes: https://security-tracker.debian.org/tracker/CVE-2023-32762
  13. Upstream: https://github.com/qt/qtbase/commit/1b736a815be0222f4b24289cf17575fc15707305
  14. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  15. ---
  16. src/network/access/qhsts.cpp | 4 ++--
  17. tests/auto/network/access/hsts/tst_qhsts.cpp | 6 ++++++
  18. 2 files changed, 8 insertions(+), 2 deletions(-)
  19. diff --git a/src/network/access/qhsts.cpp b/src/network/access/qhsts.cpp
  20. index 39905f35480..82deede1729 100644
  21. --- a/src/network/access/qhsts.cpp
  22. +++ b/src/network/access/qhsts.cpp
  23. @@ -327,8 +327,8 @@ quoted-pair = "\" CHAR
  24. bool QHstsHeaderParser::parse(const QList<QPair<QByteArray, QByteArray>> &headers)
  25. {
  26. for (const auto &h : headers) {
  27. - // We use '==' since header name was already 'trimmed' for us:
  28. - if (h.first == "Strict-Transport-Security") {
  29. + // We compare directly because header name was already 'trimmed' for us:
  30. + if (h.first.compare("Strict-Transport-Security", Qt::CaseInsensitive) == 0) {
  31. header = h.second;
  32. // RFC6797, 8.1:
  33. //
  34. diff --git a/tests/auto/network/access/hsts/tst_qhsts.cpp b/tests/auto/network/access/hsts/tst_qhsts.cpp
  35. index 252f5e8f579..97a2d2889e5 100644
  36. --- a/tests/auto/network/access/hsts/tst_qhsts.cpp
  37. +++ b/tests/auto/network/access/hsts/tst_qhsts.cpp
  38. @@ -216,6 +216,12 @@ void tst_QHsts::testSTSHeaderParser()
  39. QVERIFY(parser.expirationDate() > QDateTime::currentDateTimeUtc());
  40. QVERIFY(parser.includeSubDomains());
  41. + list.pop_back();
  42. + list << Header("strict-transport-security", "includeSubDomains;max-age=1000");
  43. + QVERIFY(parser.parse(list));
  44. + QVERIFY(parser.expirationDate() > QDateTime::currentDateTimeUtc());
  45. + QVERIFY(parser.includeSubDomains());
  46. +
  47. list.pop_back();
  48. // Invalid (includeSubDomains twice):
  49. list << Header("Strict-Transport-Security", "max-age = 1000 ; includeSubDomains;includeSubDomains");
  50. --
  51. 2.46.0