Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image file scan takes longer with clamav version 0.105 or later. #877

Closed
sanjayb30788 opened this issue Mar 29, 2023 · 9 comments
Closed

Comments

@sanjayb30788
Copy link

sanjayb30788 commented Mar 29, 2023

Describe the bug

Image file scan is taking more time with clamav version 0.105 or higher compare to older versions 0.104.2 or 0.103.8
Issue dose not occur while scanning other file types.

Issue occurs on scanning any image file. Here is one example and output from both the version are as below
0.104.3 or 0.103.8
/ # clamscan --version
ClamAV 0.104.3/26858/Wed Mar 29 07:28:45 2023
/etc/clamav # clamdscan 1.png
/etc/clamav/1.png: OK

----------- SCAN SUMMARY -----------
Infected files: 0
Time: 0.044 sec (0 m 0 s)
Start Date: 2023:03:29 11:34:18
End Date: 2023:03:29 11:34:18

0.105.2 or 1.0.1
/etc/clamav # clamdscan --version
ClamAV 1.0.1/26858/Wed Mar 29 07:28:45 2023
/etc/clamav # clamdscan 1.png
/etc/clamav/1.png: OK

----------- SCAN SUMMARY -----------
Infected files: 0
Time: 0.156 sec (0 m 0 s)
Start Date: 2023:03:29 11:25:38
End Date: 2023:03:29 11:25:39

How to reproduce the problem

Scan any size png file
Scan file using clamdscan.
Scan time with version 0.105 or 1.0.1 version is very high compare to 0.104.2 or 103.8

@sanjayb30788 sanjayb30788 changed the title png file scan takes longer with clamav version 0.105 or later. Image file scan takes longer with clamav version 0.105 or later. Mar 29, 2023
@micahsnyder
Copy link
Contributor

micahsnyder commented Mar 29, 2023

This is not surprising. We added a new feature to create fuzzy hashes for PNG, JPEG, TIFF, and GIF images in 0.105 which you can find in the 0.105 release notes.

This is to support image fuzzy hash signatures: https://docs.clamav.net/manual/Signatures/LogicalSignatures.html#image-fuzzy-hash-subsignatures

@net1
Copy link

net1 commented Mar 30, 2023

Could we consider adding a feature that allows the user to disable the fuzzy image scanning option?

@sanjayb30788
Copy link
Author

sanjayb30788 commented Mar 30, 2023

Could we consider adding a feature that allows the user to disable the fuzzy image scanning option?

@net1 - Yes, Please add option to disable this feature.

@sanjayb30788
Copy link
Author

This is not surprising. We added a new feature to create fuzzy hashes for PNG, JPEG, TIFF, and GIF images in 0.105 which you can find in the 0.105 release notes.

This is to support image fuzzy hash signatures: https://docs.clamav.net/manual/Signatures/LogicalSignatures.html#image-fuzzy-hash-subsignatures

@micahsnyder - is it possible to disable this feature?

@shrgabor
Copy link

@micahsnyder
This feature made ClamAV much slower for these use cases. Is there a way to avoid this?
I checked the change that introduced the feature, but I'm not entirely familiar with the source code.
fd587c7#diff-9ea761d49c419551e2cc5b26230a94bcfcd4fd52f1d65ba237d7717bcef999b7R4642

Am I correct to assume based on the above changes, that it is not possible at the moment to turn this feature off?

@micahsnyder
Copy link
Contributor

I don't believe it is possible to turn it off at this time, without turning off support for scanning image files in general.

What I would like to do in the future is add an option to disable calculating the image fuzzy hash for images that are not found in other files. This would help for the use case where people are scanning all files on their hard drive.

The problem is that image fuzzy hash signatures are particularly effective in detection malicious emails. So any scanning services that sent email attachments to be scanned will want to have this feature enabled.

@shrgabor
Copy link

Dear @micahsnyder
My understanding of the feature is, that fuzzy hash signatures are only useful if there are logical signatures used. (*.ldb *.ldu; *.idb)
Based on this document: https://docs.clamav.net/manual/Signatures.html

If someone is not using logical signatures with ClamAV does fuzzy hash calculation has any value? Why is it still calculated then?

Can you please explain me?

@micahsnyder
Copy link
Contributor

@shrgabor Sorry I missed your question. If you are running clamav with your own custom databases and no logical signatures then no there would be no point in the fuzzy hash calculation. I suppose some logic could be added in there to disable it if there are no logical signatures or more specifically if there are no logical signatures that use the fuzzy hash feature.

The only exception I can think of is if clamav / libclamav are used to create fuzzy hashes for making signatures or else for other analysis/comparison purposes, such as when sigtool uses libclamav to generate fuzzy hashes. So some "analyst mode" to always create fuzzy hashes would be needed.

On a bit of a tangent: We've been thinking about having an analyst mode for clamav in general for recording and presenting metadata to analysts and developers along with warnings that only a developer or analyst may care for... but we have yet to implement that.

@micahsnyder
Copy link
Contributor

You can now disable the image fuzzy hash feature in clamav 1.4, or newer: #1186

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants