Skip to content
DoS Disclosed report Intermediate

curl HSTS long file name clears contents

When curl saved HSTS data to a file whose name was near the filesystem length limit, the save routine could empty the file, so later requests using it were unaware of the HSTS status they should have used.

cxshakal Follow

Originally disclosed on HackerOne

  • Disclosed after 41 days

Summary by the program

HSTS long file name clears contents

VULNERABILITY When saving HSTS data to an excessively long file name, curl could end up removing all contents, making subsequent requests using that file unaware of the HSTS status they should otherwise use.

INFO The reason for this bug is that save function appended a suffix to the file name, created a temporary file and then in the last step renamed that to the final name. When the file name length was close to the limit of what is allowed on the file system, adding the extension would make it too long and then trigger this bug.

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

CWE-311: Missing Encryption of Sensitive Data

Severity: Low

Link to Security Advisory: https://curl.se/docs/CVE-2023-46219.html

The report

VULNERABILITY

When saving HSTS data to an excessively long file name, curl could end up removing all contents, making subsequent requests using that file unaware of the HSTS status they should otherwise use.

INFO

The reason for this bug is that save function appended a suffix to the file name, created a temporary file and then in the last step renamed that to the final name. When the file name length was close to the limit of what is allowed on the file system, adding the extension would make it too long and then trigger this bug.

Hackerone ticket #2236133

Impact

HSTS bypass

The original report as published on HackerOne, by cxshakal. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 3 min read.

Context

curl is a command line tool and library for transferring data with URLs. One of its features is HSTS (HTTP Strict Transport Security) support: curl can remember hosts that have told it to be contacted over HTTPS only, and it stores that state in a file so that later invocations of the tool can honour the same policy.

The report concerns what happens when curl saves that HSTS state to a file whose name is excessively long. The asset named in the report is the curl source repository, https://github.com/curl/curl, and the issue was handled through the Internet Bug Bounty program on HackerOne.

The weakness is classified as CWE-311: Missing Encryption of Sensitive Data, with a severity of Low. The CVE project assigned the name CVE-2023-46219 to the issue, and the report links to the security advisory at https://curl.se/docs/CVE-2023-46219.html.

Setup

The report does not describe any accounts, roles, tooling or specific curl versions. The precondition that matters is a file name for the HSTS state file that is close to the maximum length the file system allows.

Finding it

The behaviour that looked wrong is stated plainly in the report: when saving HSTS data to an excessively long file name, curl could end up removing all contents of that file. The consequence is that subsequent requests using that file would be unaware of the HSTS status they should otherwise use.

Exploitation

The report does not give a step by step exploitation walkthrough, and it contains no requests, payloads, commands or responses. What it does give is the mechanism, which is enough to understand the conditions under which the bug triggers.

Step 1: the save routine appends a suffix

The save function appended a suffix to the file name, created a temporary file, and then in the last step renamed that temporary file to the final name.

Step 2: the name is close to the file system limit

When the file name length was close to the limit of what is allowed on the file system, adding the extension would make it too long.

Step 3: the failure path clears the contents

That over-long name triggered the bug, and the result was that the contents of the HSTS file were removed.

Root cause

The save routine appended a suffix to the target file name to build the temporary file name. When the original name was already near the file system limit, the derived temporary name became too long, and the save operation left the HSTS file emptied rather than intact. When the original name is already near that limit, the derived temporary name exceeds it, and the save operation fails in a way that leaves the HSTS file emptied rather than intact.

Impact

The impact given in the report is HSTS bypass. Because the HSTS state file is emptied, subsequent requests made using that file are unaware of the HSTS status they should otherwise use. In other words, subsequent requests using that file would no longer be aware of the HSTS status they should otherwise use.

The severity assigned is Low.

Fix

It points to the security advisory at https://curl.se/docs/CVE-2023-46219.html for the details.

Variants to test

Concrete things to try:

  1. Any application that derives a temporary file name by appending a suffix or extension to a user-controlled or configuration-controlled file name. A positive result is that a name near the file system limit causes the write to fail and the original file to be truncated or emptied.
  2. State files whose names are set through configuration, environment variables or command line options, where the length is not validated before the temporary name is constructed. A positive result is the same loss of contents on save.
  3. Save routines that rename a temporary file over the final name as the last step. A positive result is that a failure before the rename leaves the final file in a cleared or inconsistent state rather than preserving the previous contents.

Hunting notes

The report shows impact by connecting the emptied file to a concrete security property: the HSTS status is no longer applied to subsequent requests, which the report calls an HSTS bypass.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 9 min read.

What happened, in plain words

curl is a small program that runs in a terminal and fetches things from the internet, such as web pages or files. It is used by people and by other programs to talk to web servers. One of its optional features is remembering a security rule called HSTS, which stands for HTTP Strict Transport Security. In simple terms, a website can tell a browser or a tool: "always talk to me over the secure, encrypted version of the connection (HTTPS), never the plain one (HTTP)". curl can remember which sites gave it that instruction, and it writes that memory into a file on your computer so that the next time you run curl, it still knows the rule.

The bug in this report is about what happens when curl tries to save that memory into a file whose name is extremely long. Under those conditions, curl could end up wiping out the contents of the file. The contents of the file would be removed. The practical result is that later requests made with that file would no longer know which sites are supposed to be HTTPS-only. The report calls this an HSTS bypass.

The issue was tracked through the Internet Bug Bounty program on HackerOne, a platform where security researchers report bugs and the affected project can respond. The affected code is the curl source repository at https://github.com/curl/curl. The weakness was classified as CWE-311, Missing Encryption of Sensitive Data, with a severity of Low. The CVE project, which gives public identifiers to known security flaws, assigned the name CVE-2023-46219 to this issue. The report links to the official security advisory at https://curl.se/docs/CVE-2023-46219.html.

Context

curl is a command line tool and library for transferring data with URLs. A URL is the address you type in a browser, like https://example.com/page. A command line tool is a program you run by typing its name and some options in a terminal window, rather than clicking buttons. A library is a bundle of code that other programs can reuse, so curl exists both as something you run yourself and as something other software can build on.

One of curl's features is HSTS support. HSTS is a rule a website can send to say "only ever contact me over HTTPS". HTTPS is the encrypted version of the web's normal conversation, the one that shows a padlock in your browser. curl can remember hosts that have told it to be contacted over HTTPS only, and it stores that state in a file so that later invocations of the tool can honour the same policy. "State" here simply means saved information about what happened before, kept so it can be used again later. Think of it like a notebook where curl writes down "this site must always be visited over the secure road".

The report concerns what happens when curl saves that HSTS state to a file whose name is excessively long. Every file on your computer has a name, and operating systems put a limit on how many characters that name can have. If you go past the limit, the system refuses to create the file. The asset named in the report is the curl source repository, https://github.com/curl/curl, and the issue was handled through the Internet Bug Bounty program on HackerOne.

The weakness is classified as CWE-311: Missing Encryption of Sensitive Data, with a severity of Low. CWE is a catalogue of common weakness types, each with a number, so people can talk about the same kind of mistake consistently. The CVE project assigned the name CVE-2023-46219 to the issue, and the report links to the security advisory at https://curl.se/docs/CVE-2023-46219.html. A security advisory is the official notice a project publishes to describe a flaw and what to do about it.

Setup

The report does not describe any accounts, roles, tooling or specific curl versions. The precondition that matters is a file name for the HSTS state file that is close to the maximum length the file system allows. The file system is the part of the operating system that organises files and folders on disk, and it is the thing that enforces the name length limit.

Finding it

The behaviour that looked wrong is stated plainly in the report: when saving HSTS data to an excessively long file name, curl could end up removing all contents of that file. The consequence is that subsequent requests using that file would be unaware of the HSTS status they should otherwise use. In everyday terms: the notebook where curl wrote down "always use the secure road for this site" gets erased, so the next trip no longer follows the rule.

Exploitation

The report does not give a step by step exploitation walkthrough, and it contains no requests, payloads, commands or responses. What it does give is the mechanism, which is enough to understand the conditions under which the bug triggers. A mechanism here means the sequence of internal actions that leads to the bad result.

Step 1: the save routine appends a suffix

The save function appended a suffix to the file name, created a temporary file, and then in the last step renamed that temporary file to the final name.

A suffix is extra text added to the end of a name, like turning notes into notes.tmp. A temporary file is a scratch file used during a job and usually thrown away afterwards. The rename at the end is the moment the scratch file takes the place of the real one. Think of writing a letter on a rough draft, then copying it cleanly onto the final sheet and swapping it into the envelope at the very end.

Step 2: the name is close to the file system limit

When the file name length was close to the limit of what is allowed on the file system, adding the extension would make it too long. An extension is the part after the dot, like .txt. If the original name already uses almost all the characters the file system permits, then adding even a few more characters pushes the temporary name over the limit.

Step 3: the failure path clears the contents

That over-long name triggered the bug, and the result was that the contents of the HSTS file were removed. Error handling is the part of a program that decides what to do when something goes wrong, and a code path is the route the program takes through its instructions. What matters for a beginner is the outcome: the contents of the HSTS file were removed.

Root cause

The save routine appended a suffix to the target file name to build the temporary file name. When the original name was already near the file system limit, the derived temporary name became too long, and the save operation left the HSTS file emptied rather than intact. When the original name is already near that limit, the derived temporary name exceeds it, and the save operation fails in a way that leaves the HSTS file emptied rather than intact.

Impact

The impact given in the report is HSTS bypass. Because the HSTS state file is emptied, subsequent requests made using that file are unaware of the HSTS status they should otherwise use. In other words, subsequent requests using that file would no longer be aware of the HSTS status they should otherwise use. A bypass means getting around a protection: here, the protection is not attacked directly, it is simply forgotten because the record of it was lost.

An attacker model is a description of who might misuse the flaw and how. The severity assigned is Low.

Fix

It points to the security advisory at https://curl.se/docs/CVE-2023-46219.html for the details.

Variants to test

Concrete things to try:

  1. Any application that derives a temporary file name by appending a suffix or extension to a user-controlled or configuration-controlled file name. A positive result is that a name near the file system limit causes the write to fail and the original file to be truncated or emptied. Truncated means cut short, and user-controlled means the user can choose the value.
  2. State files whose names are set through configuration, environment variables or command line options, where the length is not validated before the temporary name is constructed. A positive result is the same loss of contents on save. An environment variable is a named setting the operating system passes to programs, and a command line option is a flag you type after a program's name.
  3. Save routines that rename a temporary file over the final name as the last step. A positive result is that a failure before the rename leaves the final file in a cleared or inconsistent state rather than preserving the previous contents.

Hunting notes

Persistence means keeping data after the program stops, and serialise means turning it into a form that can be written to disk. Cookies are small pieces of data a site asks a browser to keep, and credentials are login details.

The report shows impact by connecting the emptied file to a concrete security property: the HSTS status is no longer applied to subsequent requests, which the report calls an HSTS bypass.

Glossary

  • curl: a command line tool and library for transferring data with URLs.
  • URL: the address of something on the internet, such as https://example.com/page.
  • Command line tool: a program run by typing its name and options in a terminal rather than clicking in a window.
  • Library: reusable code that other programs can build on.
  • HSTS (HTTP Strict Transport Security): a rule a site can send telling clients to contact it only over HTTPS.
  • HTTPS: the encrypted version of the web's normal conversation.
  • State: saved information about what happened before, kept for later use.
  • File system: the part of the operating system that organises files and enforces limits such as maximum name length.
  • Suffix: extra text added to the end of a name.
  • Extension: the part of a file name after the dot, such as .txt.
  • Temporary file: a scratch file used during a job and usually discarded afterwards.
  • Rename: giving a file a new name, often to swap a scratch file into the place of the real one.
  • Error handling: the part of a program that decides what to do when something goes wrong.
  • Code path: the route a program takes through its instructions.
  • Root cause: the underlying mistake that produces a bug.
  • Impact: the practical effect a flaw has on security or on users.
  • HSTS bypass: getting around the HSTS protection, here because the saved record of it was lost.
  • Attacker model: a description of who might misuse a flaw and how.
  • CWE-311: a catalogue entry for Missing Encryption of Sensitive Data.
  • CVE: a public identifier given to a known security flaw, here CVE-2023-46219.
  • Security advisory: an official notice from a project describing a flaw and what to do about it.
  • Severity: a rating of how serious a flaw is, here Low.
  • Internet Bug Bounty: a program on HackerOne for reporting security bugs in widely used software.
  • HackerOne: a platform where researchers report bugs and projects respond.
  • Persistence code: the part of a program that saves data to disk and reloads it later.
  • Serialise: turn data into a form that can be written to disk.
  • Cookies: small pieces of data a site asks a browser to keep.
  • Credentials: login details such as usernames and passwords.
  • User-controlled: a value the user can choose.
  • Configuration: settings that shape how a program behaves.
  • Environment variable: a named setting the operating system passes to programs.
  • Command line option: a flag typed after a program's name to change its behaviour.
  • Truncated: cut short, with the end removed.
  • Payload: the data sent in a request to trigger or test behaviour.

More by cxshakal

View all

1 more disclosed report, best first.

More from Internet Bug Bounty

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.