appwrite / appwrite/php-clamav

🐛 Bug Report: ClamAv::fileScanInStream does not detect eicar.com file

Open
#26 3 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
PHP
Stars
73
Forks
31
Avg merge
30m
Merged PRs (30d)
2

Description

### 👟 Reproduction steps

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

```php
$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?

- [X] I checked and didn't find similar issue

### 🏢 Have you read the Code of Conduct?

- [X] I have read the [Code of Conduct](https://github.com/appwrite/appwrite/blob/HEAD/CODE_OF_CONDUCT.md)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.