Skip to content
Account takeover Disclosed report Intermediate CVE-2023-27535

CVE-2023-27535: FTP too eager connection reuse

libcurl's FTP connection reuse logic did not consider the FTP account or alternative-to-user options, so a connection authenticated with one account could be reused for a request specifying a different account. An attacker could potentially access content using the wrong cached credentials.

nyymi Follow

Originally disclosed on HackerOne

  • Triaged in 4 days
  • Fixed in 14 days
  • Disclosed after 17 days

Summary:

libcurl FTP(S) protocol will reuse connection even if different CURLOPT_FTP_ACCOUNT (libcurl) or --ftp-account (curl) is specified for different connections and the server requests account authentication via reply code 332. It appears that STRING_FTP_ALTERNATIVE_TO_USER (libcurl) or --ftp-alternative-to-user (curl) is also affected and should also result in caching being refused.

Steps To Reproduce:

  1. terminal 1: echo -e "foo\n" | nc -v -l -p 9998; echo -e "bar\n" | nc -v -l -p 9998
  2. terminal 2: echo -ne "220 a\n331 b\n332 c\n230 d\n257 \"/\"\n229 (|||9998|)\n200 e\n213 4\n150 f\n226 g\n229 (|||9998|)\n213 4\n150 f\n226 g\n" | nc -v -l -p 9999
  3. terminal 3: curl -v --ftp-account alice "ftp://ftp@server:9999/file1" -: --ftp-account bob "ftp://ftp@server:9999/file2"

As a result connection authenticated as user alice will be used when fetching file2 regardless that user bob was specified for fetching it.

Remediation

  • Don't reuse connection if CURLOPT_FTP_ACCOUNT or STRING_FTP_ALTERNATIVE_TO_USER are different.

Supporting Material/References:

Impact

Accessing content with wrong cached credentials.

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

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the connection reuse cache key did not include the FTP account or alternative-to-user settings, so connections were considered interchangeable despite different credentials.

Impact

Accessing content with wrong cached credentials.

What the attacker needed

Different FTP account specified for a connection; server requests account via 332

How it was found

  1. Set up a listener that accepts two connections and sends 'foo' then 'bar'.
  2. Set up a fake FTP server that responds with a sequence including a 332 code requesting an account.
  3. Run curl with two different --ftp-account values for two file URLs on the same server.
  4. Observe that the connection authenticated as the first account is reused for the second file.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

When you connect to an FTP server, you sometimes need to provide an account name. libcurl, a library for transferring data, keeps connections open to reuse them for later requests. This report shows that libcurl would reuse a connection even if the new request asked for a different account, so the server might treat you as the previous user.

What is Account takeover?

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.

More by nyymi

View all

51 more disclosed reports, best first.

More from curl

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Account takeover

The lesson behind this report.

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.