Potential NULL dereference in libssh's sftp server
The SFTP server in libssh did not check whether a large memory allocation for a read request succeeded. A malicious authenticated client could request up to 4GB reads, causing a NULL dereference and crashing the server connection, or causing denial of service for other users on thread-based servers.
- Disclosed after 2 months
Summary by the program
Subject: Potential NULL dereference in libssh's sftp server CVE ID#: CVE-2023-3603
Versions: master only
Summary: Processing SFTP server read may cause NULL dereference
Description
Missing allocation check in sftp server processing read requests may cause NULL dereference on low-memory conditions. The malicious client can request up to 4GB SFTP reads, causing allocation of up to 4GB buffers, which is being unchecked for failure.
This will likely crash the authenticated user sftp server's connection (if implemented as forking as we recommend). For thread-based servers, this might cause DoS also for legitimate users.
Patch Availability
Patches addressing the issues have been posted to: https://www.libssh.org/security/ Given this code is not in any released versions, no security release have been issued.
Credits
Originally reported by Wei Chong Tan. Patches provided by Jakub Jelen of the libssh team.
Full security advisory: https://www.libssh.org/security/advisories/CVE-2023-3603.txt
The report
Missing allocation check in sftp server processing read requests may cause NULL dereference on low-memory conditions. The malicious client can request up to 4GB SFTP reads, causing allocation of up to 4GB buffers, which is being unchecked for failure.
Impact
This will likely crash the authenticated user sftp server's connection (if implemented as forking as we recommend). For thread-based servers, this might cause DoS also for legitimate users.
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
Impact
This will likely crash the authenticated user's SFTP server connection, and for thread-based servers it might cause denial of service for legitimate users.
What the attacker needed
Authenticated SFTP client; low-memory conditions on server
The fix
The missing allocation check was fixed by patches from the libssh team; no security release was issued because the code was not in any released version.
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 a program needs memory, it asks the operating system for some. If the request is very large and memory is low, the system may refuse and give back nothing (a NULL pointer). If the program then tries to use that nothing as if it were real memory, it crashes. Here, the SFTP server did not check whether its large memory request succeeded, so a client asking for a huge read could crash the server.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.