Bug 3451 - Log which sftp command has been denied due to blacklist
Summary: Log which sftp command has been denied due to blacklist
Status: CLOSED WORKSFORME
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sftp-server (show other bugs)
Version: 9.0p1
Hardware: amd64 Linux
: P5 enhancement
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-06-24 18:40 AEST by Miranda
Modified: 2022-10-04 21:58 AEDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Miranda 2022-06-24 18:40:14 AEST
When restricting the allowed sftp-server commands with the whitelist/blacklist options (-p / -P)

and the client requests a disallowed command, it is only logged "sent status Permission denied":

internal-sftp[1234]: sent status Permission denied

For transparency (if multiple commands are not allowed, to be able to distinguish), it would be better that the denied command would be logged, too, e.g.

internal-sftp[1234]: sent status Permission denied (mkdir)

I think it would be sufficient to only log the command without any parameters (like directory names), like above, to be clear that the command in general is forbidden, regardless of it's parameters.

Here is my -p whitelist, which does not contain rmdir/mkdir and works fine, aside of the non-saying log.

Subsystem sftp internal-sftp
ForceCommand internal-sftp -u 0002 -f LOCAL5 -l INFO -p open,close,read,write,lstat,fstat,setstat,fsetstat,opendir,readdir,remove,realpath,stat,rename,readlink,symlink,posix-rename,statvfs,fstatvfs,hardlink,fsync

I could not see in the release notes

https://www.openssh.com/releasenotes.html

that this logging would have changed since the version I am currently using, which is 7.6p1-4ubuntu0.5 on Ubuntu 18 Server.
Comment 1 Damien Miller 2022-06-27 08:03:42 AEST
The refused request is already logged at loglevel VERBOSE. Add "-l verbose" to your sftp-server command-line and you will see it. E.g.

> Refusing denylisted mkdir request
Comment 2 Miranda 2022-06-28 21:55:19 AEST
Can confirm solution ist sftp-server log level VERBOSE for
7.6p1-4ubuntu0.5 on Ubuntu 18 Server.
Comment 3 Damien Miller 2022-10-04 21:58:56 AEDT
Closing bugs from openssh-9.1 release cycle