Cisco-Talos / clamav

ClamAV - Documentation is here: https://docs.clamav.net
https://www.clamav.net/
GNU General Public License v2.0
4.43k stars 706 forks source link

Drupal 10 : Files of size above 25 MB could not be uploaded #1408

Open Aswathy-git opened 22 hours ago

Aswathy-git commented 22 hours ago

I am using ClamAV module (https://www.drupal.org/project/clamav) version 2.0.2 in Drupal 10.3.6. I have a file upload field in which 'Maximum upload size' is 100 MB and it allows file type 'zip'. When uploading zip files of size below 25 MB, it is uploading successfully. But when we upload zip files of size above 25 MB, it is showing the following error :

The specified file C6-A systems view(1).zip could not be uploaded.
The anti-virus scanner could not check the file, so the file cannot be uploaded. Contact the site administrator if this problem persists.

I have applied the following solutions :

1. Set MaxScanSize 100M, MaxFileSize 100M, StreamMaxLength 100M in clamd.conf
2. Checked any timeout settings in clamd.conf
3. Restart ClamAV after making these changes:
systemctl restart clamav-daemon
4. Set SecRequestBodyLimit 104857600 # 100 MB, SecRequestBodyInMemoryLimit 104857600 # 100 MB, LimitRequestBody 104857600 in apache
5. Set upload_max_filesize = 100M, post_max_size = 100M, max_input_vars = 5000 in php.ini

In the path "/admin/config/media/clamav", if we are updating "Behaviour when ClamAV is unavailable" to 'Allow unchecked files", above 25 MB zip files are uploading. But we want to check "Block unchecked files".

clam

Following are the existing configurations in our server :

# clamconf -n
Checking configuration files in /etc

Config file: clamd.d/scan.conf
------------------------------
LogSyslog = "yes"
TCPSocket = "3310"
TCPAddr = "127.0.0.1"
User = "clamscan"

Config file: freshclam.conf
---------------------------
DatabaseMirror = "database.clamav.net"

mail/clamav-milter.conf not found

Software settings
-----------------
Version: 0.103.11
Optional features supported: MEMPOOL IPv6 AUTOIT_EA06 BZIP2 LIBXML2 PCRE2 ICONV JSON 

Database information
--------------------

Database directory: /var/lib/clamav
daily.cld: version 27375, sigs: 2065835, built on Thu Aug 22 14:16:22 2024
main.cvd: version 62, sigs: 6647427, built on Thu Sep 16 18:02:42 2021
bytecode.cvd: version 335, sigs: 86, built on Tue Feb 27 21:07:24 2024
Total number of signatures: 8713348

Platform information
--------------------
uname: Linux 4.18.0-477.13.1.el8_8.x86_64 #1 SMP Tue May 30 14:53:41 EDT 2023 x86_64
OS: linux-gnu, ARCH: x86_64, CPU: x86_64
zlib version: 1.2.11 (1.2.11), compile flags: a9
platform id: 0x0a2184840800000000080500

Build information
-----------------
GNU C: 8.5.0 20210514 (Red Hat 8.5.0-18) (8.5.0)
CPPFLAGS: -I/usr/include/libprelude
CFLAGS: -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection  -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
CXXFLAGS: -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection
LDFLAGS: -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,--as-needed  -lprelude
Configure: '--build=x86_64-redhat-linux-gnu' '--host=x86_64-redhat-linux-gnu' '--program-prefix=' '--disable-dependency-tracking' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib64' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/var/lib' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--enable-milter' '--disable-clamav' '--disable-static' '--disable-zlib-vcheck' '--disable-unrar' '--enable-id-check' '--enable-dns' '--with-dbdir=/var/lib/clamav' '--with-group=clamupdate' '--with-user=clamupdate' '--disable-rpath' '--disable-silent-rules' '--enable-clamdtop' '--enable-prelude' 'build_alias=x86_64-redhat-linux-gnu' 'host_alias=x86_64-redhat-linux-gnu' 'CXXFLAGS=-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' 'LDFLAGS=-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,--as-needed' 'CFLAGS=-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' 'PKG_CONFIG_PATH=:/usr/lib64/pkgconfig:/usr/share/pkgconfig'
sizeof(void*) = 8

Engine flevel: 132, dconf: 132

Already posted query : https://www.drupal.org/project/clamav/issues/3485859.

Any solution? Thanks in advance.

micahsnyder commented 15 hours ago

The MaxFileSize 100 setting doesn't appear in the clamconf -n output. It appears your config path is: /etc/clamd.d/scan.conf so make sure you put the MaxFileSize setting in there.

For MaxScanSize, you'll want it to be much larger than 100. That value should be greater than ~2x the sum of the size of any archive plus its contents. I'd go with like maybe MaxScanSize 1000 for your configuration.