Check for root user when processing SHUTDOWN command.#347
Check for root user when processing SHUTDOWN command.#347toddr wants to merge 1 commit intoCisco-Talos:mainfrom
Conversation
By default, any arbitrary user is able to use the userspace socket file to shutdown the clamd daemon. This adds a check for connections to the local socket server, ensuring that only root is able to do this.
|
I'm uncertain what the policy was on non-root users doing this but wanted to share a patch we're using. Possibly this needs to be a config file setting but I lack the knowledge to add that to this patch. |
|
It should probably be a config option if we take this patch. Thank you for sharing it. I will bring it up with the team in our next standup. We're also considering giving ClamD a REST (HTTP) API and have had some discussion about implementing certificate-based authentication at that time. But we need to dedicate some time to plan what to do with an application sandbox prototype developed by my colleague @zaddach which may necessitate an overhaul or full Rust re-write of ClamD, or simply a new server program as an alternative to ClamD. That decision will tie in with what we do for the socket API for ClamD and ultimately if we should use this patch with a new config option, or if we should find a different mechanism to authorize administrative-type commands. |
|
Looks like the build fails on Mac & Windows, and fails a test on Linux with:
|
|
I'm closing this PR due to inactivity, and because I do not believe this is the right solution to prevent other users on the local box from running these commands. Outside of the build issues on Mac and Windows, this solution would prevent regular users from using the STATS and SHUTDOWN commands when running But this also does not prevent anyone who can access the TCP socket from running these commands when The only solution I can think to allow users to run scans but prevent them from running these commands is to add An additional note regarding the STATS command: In case you're concerned that an unauthorized user may index another user's private directory by running Finally, for administrators that wish to run a Take for example this scenario. An admin may wish to configure The or maybe instead to instead allow users from the This would effectively prevent untrusted user accounts from interacting with the We are open to future work to move control commands such as SHUTDOWN and STATS to a separate socket so that access can be more tightly controlled. But this will have ripple effects on all applications that use them today, including |
The `clamd` protocol lacks authentication or authorization controls needed to limit access to more administrative commands. Depending on your use case, disabling some commands like `SHUTDOWN` may improve the security of the scanning daemon. This commit adds options to enable/disable the `SHUTDOWN`, `RELOAD`, `STATS` and `VERSION` commands in `clamd.conf`. When a client sends one of the following commands but it is disabled, `clamd` will respond with "COMMAND UNAVAILABLE". The new `clamd.conf` options are: - `EnableShutdownCommand`: Enable the `SHUTDOWN` command. Setting this to no prevents a client to stop `clamd` via the protocol. Default: yes - `EnableReloadCommand` Enable the `RELOAD` command. Setting this to no prevents a client to reload the database. This disables Freshclam's `NotifyClamd` option. `clamd` monitors for database directory changes, so this should Default: yes - `EnableStatsCommand` Enable the `STATS` command. Setting this to no prevents a client from querying statistics. This disables the `clamdtop` program. Default: yes - `EnableVersionCommand` Enable the `VERSION` command. Setting this to no prevents a client from querying version information. This disables the `clamdtop` program and will cause `clamdscan` to display a warning when using the `--version` option. Default: yes Resolves: #922 Resolves: #1169 Related: #347
By default, any arbitrary user is able to use the userspace socket file
to shutdown the clamd daemon. This adds a check for connections to the
local socket server, ensuring that only root is able to do this.