appwrite / php-clamav

ClamAV network and pipe client for PHP
https://github.com/appwrite
MIT License
65 stars 30 forks source link

šŸ› Bug Report: ClamAv::fileScanInStream does not detect eicar.com file #26

Open vagiguere opened 1 year ago

vagiguere commented 1 year ago

šŸ‘Ÿ Reproduction steps

Download the "eicar.com" or the "eicar.com.txt" file from https://www.eicar.org/download-anti-malware-testfile/

$clam = new Network($host, $port);
$is_clean = $clam->fileScanInStream('path/to/eicar/file');

The function is supposed to return false, instead it returns true. This behavior happen with both "eicar.com" and "eicar.com.txt" files but not with zip files.

The problem seem to happen with text files of less than 8192 bytes.

In Appwrite\ClamAv\ClamAv:107 the fread return an empty string which is sent to the socket. The problem is ClamAv does not detect the eicar file if this empty string is packed and send through the socket.

šŸ‘ Expected behavior

in the example above the $is_clean variable should be false.

šŸ‘Ž Actual Behavior

In the exemple above the $is_clean variable is true.

šŸŽ² PHP ClamAV version

Different version (specify in environment)

šŸ’» Operating system

Linux

šŸ§± Your Environment

Version : appwrite/php-clamav:2.0.0 PHP 8.2 (also with 8.1) in a docker container Clamav in another docker container : https://hub.docker.com/r/clamav/clamav/

šŸ‘€ Have you spent some time to check if this issue has been raised before?

šŸ¢ Have you read the Code of Conduct?

pehbehbeh commented 3 months ago

Same problem here. Have you been able to find a solution?

vagiguere commented 3 months ago

Yes, the PR here (https://github.com/appwrite/php-clamav/pull/27). I'm gonna test the changes from https://github.com/appwrite/php-clamav/pull/27#issuecomment-1994168446 and hope the appwrite team will accept the PR.