You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The SCP download path in the libssh backend accepts a server-declared file size of 18446744073709551615 (UINT64_MAX). The value survives parsing and ends up as -1 in curl's curl_off_t, which collides with curl's "unknown download size" sentinel. As a result the partial-file check and the excess-data check are both skipped, and curl exits 0 even when the server sends a different amount of data than it declared.
Verified on 8.21.0-DEV and again on current master 5d4eaac8f (2026-10-18, libssh 0.11.2 backend), with a paramiko-based SCP server:
Server declares
Server sends
Exit code
Result
18446744073709551615
100 bytes
0
No CURLE_PARTIAL_FILE, no excess flag (checks skipped)
18446744073709551615
500 bytes
0
Excess detection skipped
200
100 bytes
18
CURLE_PARTIAL_FILE, as expected
100
100 bytes
0
Normal transfer
18446744073709551615, continuous send
unlimited
63
--max-filesize still enforced (mitigation works)
The interesting part is the first row: a pipeline that trusts the exit code (backup scripts, mirrors) silently accepts a truncated or short transfer whenever the server declares this size.
Two more things:
The SFTP path validates the declared size (sftp_download_stat() has if(size < 0) checks), but the SCP path does not validate anything. I do not think the asymmetry is intentional, it looks like the SCP path was simply missed.
The libssh2 backend's master branch recently gained a strict parser for the SCP C line (ssh2_scp_parse_c_fields) that rejects anything but digits, which blocks negative and overflowing declarations on that backend. The libssh backend still accepts UINT64_MAX.
Suggested fix: validate the declared size in the SCP path the same way the SFTP path does, before it reaches maxdownload and k->size.
Activity
libssh: refuse SCP downloads large than CURL_OFF_T_MAX