revoltchat / autumn

Pluggable file server micro-service.
GNU Affero General Public License v3.0
54 stars 38 forks source link

feat: introduce active threat protection #27

Closed insertish closed 1 year ago

insertish commented 1 year ago

Configure some sort of anti-malware service that autumn can call out to for non-media files.

insertish commented 1 year ago

This looks promising, auto-updating ClamAV in a Docker container: https://github.com/rordi/docker-antivirus

Doesn't seem to work?

Screenshot 2023-06-05 at 11 18 43

On to the next one...

insertish commented 1 year ago

Next best thing is probably just using ClamAV directly, but this will have a heavy memory footprint (not sure if we have space for this).

https://hub.docker.com/r/clamav/clamav

Ok this isn't great already, would have to somehow load the container up, with signatures, and only then call ClamAV.

Screenshot 2023-06-05 at 11 26 24

It may be worth therefore to just make a separate service that pulls recently uploaded files from S3 (OR a task in the file server that does additional processing on the file after it is uploaded).

ClamAV also definitely won't detect everything, I'm fairly certain both of these files are malware but one of them comes back as "OK":

Screenshot 2023-06-05 at 11 28 49
insertish commented 1 year ago

Alternatively, use clamav bindings directly in Autumn:

clamav crate: https://docs.rs/clamav/latest/clamav/engine/struct.Engine.html#method.scan_file (this creates additional issues with linking ☹️)

clamav-client (run clamd in container): https://crates.io/crates/clamav-client

insertish commented 1 year ago

ClamAV client is really promising, it lets you just stream the file over the network by default.

Screenshot 2023-06-05 at 12 21 58

This would be paired with a clamd container.

insertish commented 1 year ago

Forked clamav-client for dealing with buffers directly, also opened a PR to upstream my changes if they're interested, https://github.com/toblux/rust-clamav-client/pull/1.

insertish commented 1 year ago
Screenshot 2023-06-05 at 13 28 24