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

Defer or avoid file MD5 calculation when cache is disabled #1167

Merged

Conversation

antchan2
Copy link
Contributor

@antchan2 antchan2 commented Feb 6, 2024

If the clean cache is not used (CL_ENGINE_DISABLE_CACHE=1), it is not necessary to calculate the file's MD5 checksum in preparation for cache lookup. This change modifies cli_magic_scan to skip the MD5 calculation if the cache is disabled.

@micahsnyder micahsnyder marked this pull request as ready for review March 12, 2024 16:44
@micahsnyder micahsnyder self-requested a review April 19, 2024 16:21
@micahsnyder micahsnyder force-pushed the optimize_clam_cache_disabled_ branch from 797d8df to 16d1392 Compare April 19, 2024 19:53
antchan2 and others added 2 commits May 1, 2024 20:17
If SCAN_COLLECT_METADATA is enabled, and caching is disabled, we zero-out
the hash after recording it.
This results in a non-NULL and invalid-hash that may be passed to
`cli_scan_fmap()` for the "raw mode" scan.
It's an uncommon code path, but would result in comparing hash-sigs with
a zeroed hash rather than the valid hash.
This bug could result in a missed hash-based sig matches.

There is no reason to invalidate or zero-out the hash if we happen to
calculate it. We avoid the cache-lookup by checking the engine setting,
not by checking if we have a hash.
@micahsnyder micahsnyder force-pushed the optimize_clam_cache_disabled_ branch from 31bb8cb to 25dc1e9 Compare May 2, 2024 00:17
@micahsnyder micahsnyder merged commit d628bbc into Cisco-Talos:main May 6, 2024
19 of 24 checks passed
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

Successfully merging this pull request may close these issues.

2 participants