Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

curl: CVE-2024-9681 HSTS subdomain overwrites parent cache entry #13

Open
UTsweetyfish opened this issue Nov 7, 2024 · 1 comment
Open
Assignees
Labels
合入 代码合入完成

Comments

@UTsweetyfish
Copy link

UTsweetyfish commented Nov 7, 2024

HSTS subdomain overwrites parent cache entry
============================================

Project curl Security Advisory, November 6th 2024 -
[Permalink](https://curl.se/docs/CVE-2024-9681.html)

VULNERABILITY
-------------

When curl is asked to use HSTS, the expiry time for a subdomain might
overwrite a parent domain's cache entry, making it end sooner or later than
otherwise intended.

This affects curl using applications that enable HSTS and use URLs with the
insecure `HTTP://` scheme and perform transfers with hosts like
`[x.example.com](http://x.example.com/)` as well as `[example.com](http://example.com/)` where the first host is a subdomain
of the second host.

(The HSTS cache either needs to have been populated manually or there needs to
have been previous HTTPS accesses done as the cache needs to have entries for
the domains involved to trigger this problem.)

When `[x.example.com](http://x.example.com/)` responds with `Strict-Transport-Security:` headers, this
bug can make the subdomain's expiry timeout *bleed over* and get set for the
parent domain `[example.com](http://example.com/)` in curl's HSTS cache.

The result of a triggered bug is that HTTP accesses to `[example.com](http://example.com/)` get
converted to HTTPS for a different period of time than what was asked for by
the origin server. If `[example.com](http://example.com/)` for example stops supporting HTTPS at its
expiry time, curl might then fail to access `http://example.com/` until the
(wrongly set) timeout expires. This bug can also expire the parent's entry
*earlier*, thus making curl inadvertently switch back to insecure HTTP earlier
than otherwise intended.

INFO
----

When triggered, this is a potential minor DoS security problem when trying to
use HTTPS when that no longer works or a cleartext transmission of data that
was otherwise intended to *possibly* be protected.

But:

`[example.com](http://example.com/)` as per above is deliberately setup for HSTS, and servers should
probably expect that clients will try upgrading to HTTPS for a while outside
of the time range set in its headers.

The access that fails in this scenario tries to use plain HTTP to the domain.
Clear text, unprotected, vulnerable. HTTP is an insecure protocol and as such
applications should **not** rely on nor trust such responses, which reduces
the severity of this issue.

Even without this problem, servers occasionally set HSTS headers but have
problems with their HTTPS offering so this is a scenario that an application
ends up in now and then completely without involving curl issues and therefore
needs to have logic for. An application can for example work around the
situation by simply toggling off HSTS.

This bug is **not** considered a *C mistake* (ie not likely to have been
avoided had we not been using C).

This flaw also affects the curl command line tool.

The Common Vulnerabilities and Exposures (CVE) project has assigned the name
CVE-2024-9681 to this issue.

CWE-1025: Comparison Using Wrong Factors

Severity: Low

AFFECTED VERSIONS
-----------------

The vulnerable code can only be reached when curl is told to use HSTS.

- Affected versions: curl 7.74.0 to and including 8.10.1
- Not affected versions: curl < 7.74.0 and >= 8.11.0
- Introduced-in: https://github.com/curl/curl/commit/7385610d0c74c6a25

libcurl is used by many applications, but not always advertised as such!

SOLUTION
------------

- Fixed-in: https://github.com/curl/curl/commit/a94973805df96269bf

RECOMMENDATIONS
---------------

We suggest you take one of the following actions immediately, in order of
preference:

  A - Upgrade curl and libcurl to version 8.11.0

  B - Apply the patch to your version and rebuild

  C - Avoid relying on HSTS

TIMELINE
---------

This issue was reported to the curl project on October 7, 2024. We contacted
distros@openwall on October 29, 2024.

curl 8.11.0 was released on November 6 2024 around 06:00 UTC, coordinated with
the publication of this advisory.

CREDITS
-------

- Reported-by: newfunction
- Patched-by: Daniel Stenberg

Thanks a lot!

-- 

  / [daniel.haxx.se](http://daniel.haxx.se/)
  | Commercial curl support up to 24x7 is available!
  | Private help, bug fixes, support, ports, new features
  | https://curl.se/support.html
@UTsweetyfish UTsweetyfish self-assigned this Nov 7, 2024
@UTsweetyfish UTsweetyfish added 流程中 代码提交后-合入前 合入 代码合入完成 and removed 流程中 代码提交后-合入前 labels Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
合入 代码合入完成
Projects
None yet
Development

No branches or pull requests

1 participant