OpenSSH ‘sftp-server’ Remote Security Vulnerability
The sftp-server in read-only mode only rejected open requests that used write-only or read/write access modes, so a client could still create zero-length files by supplying create or truncate flags. An attacker with SFTP access could therefore create files on a server that was meant to be read-only.
xorl.wordpress.com
Published on xorl.wordpress.com
In the ChangeLog of OpenSSH 7.6 there is only one security fix, and I couldn’t find any associated CVE ID to it. It is basically a design flaw of sftp-server when in read-only mode.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The read-only check only compared the access mode against write-only and read/write, ignoring the O_CREAT and O_TRUNC flags that also modify the filesystem.
Impact
A user of a read-only SFTP server could create zero-length files, which the read-only mode was supposed to prevent.
What the attacker needed
SFTP server started with the -R read-only flag; valid SFTP access to the server
The fix
The check was changed to reject any open request whose access mode is not read-only or that includes the create or truncate flags.
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 write-up has not been written yet. The Original tab links to the source.
SFTP is a way to transfer files over an encrypted connection. A server can be started in a 'read-only' mode, meaning users should only be able to download files, not change anything. The check that enforced this only looked at whether a file was being opened for writing, and missed other ways of opening a file that still create or empty it, so users could still create empty files.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.