Skip to content

alt-svc: a huge "ma" makes every cache save fail (and currently empties the alt-svc file) #23429

Closed

Description

@sujit-jaunjal

I did this

An HTTPS server answers with

Alt-Svc: h2="alt.example:443"; ma=9223372036854775807

and curl is run with an existing alt-svc cache file:

$ cat altsvc.txt
h1 other.test 443 h2 other.test 443 "20301231 00:00:00" 0 0
h1 third.test 443 h1 third-alt.test 443 "20301231 00:00:00" 1 0
$ curl -s -o /dev/null --alt-svc altsvc.txt https://victim.test/
$ echo $?
0
$ wc -c altsvc.txt
0 altsvc.txt

With ma=86400 the same command keeps both entries and adds the new one.

What happens: the ma parser accepts values up to TIME_T_MAX (lib/altsvc.c:515) and the expiry then saturates to TIME_T_MAX (altsvc.c:655-656). On save, altsvc_out() cannot format that time, curlx_gmtime() fails (altsvc.c:282), Curl_altsvc_save() stops and unlinks the temp file (altsvc.c:425-432). Because Curl_fopen() has already opened the real file with "w" to stat it, the cache file is left empty, as described in #21610 and fixed by #22850.

#22850 alone does not fix this one: with it the file survives, but every later save still fails for as long as that entry is in memory, so the alt-svc cache silently stops being written. HSTS had the same situation and got a two year cap on max-age in 08d50a7; alt-svc has no such cap.

I expected the following

The entry is stored with a clamped expiry (for example the same two year cap HSTS uses), the save succeeds, and the other entries in the file are kept.

curl/libcurl version

curl 8.23.0 (built from the curl-8_23_0 tag), also master 780405b.

curl 8.23.0-DEV (Darwin) libcurl/8.23.0-DEV OpenSSL/3.6.4 zlib/1.2.12
Features: alt-svc AppleSecTrust AsynchDNS HSTS HTTPS-proxy IPv6 Largefile libz SSL threadsafe UnixSockets

operating system

macOS 27.0.1 arm64

(Found with the help of an AI assistant; I reproduced it myself on the 8.23.0 tag.)

Activity

  1. self-assigned this
    on Oct 16, 2026
  2. added a commit that references this issue on Oct 16, 2026
    900cfa8
  3. added a commit that references this issue on Oct 16, 2026
    76a74e2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions