Skip to content

libclamav: report skipped PCRE evaluation through AlertExceedsMax - #1803

Draft
AAH20 wants to merge 2 commits into
Cisco-Talos:mainfrom
AAH20:agent/report-pcre-max-filesize-limit
Draft

libclamav: report skipped PCRE evaluation through AlertExceedsMax#1803
AAH20 wants to merge 2 commits into
Cisco-Talos:mainfrom
AAH20:agent/report-pcre-max-filesize-limit

Conversation

@AAH20

@AAH20 AAH20 commented Aug 16, 2026

Copy link
Copy Markdown

Summary

Report Heuristics.Limits.Exceeded.PCREMaxFileSize through the existing
AlertExceedsMax mechanism when the PCRE matcher skips subsignature evaluation
because a file or buffer exceeds PCREMaxFileSize.

Closes #1785.

Root cause

Both PCRE size-limit branches return CL_EMAXSIZE. The generic scanner result
handler intentionally converts non-fatal max conditions to success so remaining
analysis can continue. Unlike MaxFileSize and MaxScanSize, the PCRE-specific
limit did not first append an exceeds-max heuristic or metadata record. A scan
could therefore report OK without an operational indication that PCRE
subsignatures were not evaluated.

Changes

  • Report the limit through cli_append_potentially_unwanted_if_heur_exceedsmax
    for both fmap and buffer PCRE paths.
  • Preserve existing behavior when AlertExceedsMax is disabled.
  • Add regression coverage for alert enabled, alert disabled, and normal
    below-limit PCRE evaluation.
  • Document that AlertExceedsMax covers PCREMaxFileSize and that exceeding it
    reduces detection coverage.

Validation

  • Full native ClamAV debug build completed successfully on macOS arm64.
  • python3 -m unittest -v clamscan.regex_test: 6 tests passed.
  • New regression test confirms:
    • above limit + alert enabled: heuristic reported, exit 1;
    • above limit + alert disabled: compatibility behavior retained, exit 0;
    • below limit: PCRE signature evaluated and detected.
  • git diff --check passed.

@val-ms val-ms left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am open to this change, although I would ask that you not call out the PCRE limit in the documentation/config/help-string. We already have similar alerts for other limits, not just the size and time limits. You can find a short list in the older release notes: https://github.com/Cisco-Talos/clamav/blob/main/NEWS.md#01041 So if anything, those documentation/config/help-string messages should really be more general about alerts on exceeded limits overall because I wouldn't want to call out every possible limit in those places.

Keep the libclamav PCRE reporting unchanged, but make the user-facing
docs/help strings general so they do not call out individual limits.

Addresses val-ms review feedback on Cisco-Talos#1803.

Signed-off-by: Ahmed Hassan <th3reality72@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

@AAH20 AAH20 left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @val-ms — good call. I've generalized all four doc/help-string/config-sample locations so they no longer single out PCREMaxFileSize (or any individual limit). The libclamav reporting itself is unchanged — it still emits Heuristics.Limits.Exceeded.PCREMaxFileSize through the existing AlertExceedsMax path, matching the pattern the other limit heuristics already use.

Happy to iterate further.

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.

PCREMaxFileSize (default 100MB) silently skips PCRE signature evaluation — verdict stays "OK", and AlertExceedsMax does NOT cover this case

2 participants