Skip to content

fix: heap buffer overflow in acmp pm#3545

Open
airween wants to merge 1 commit intoowasp-modsecurity:v2/masterfrom
airween:v2/acmppmfix
Open

fix: heap buffer overflow in acmp pm#3545
airween wants to merge 1 commit intoowasp-modsecurity:v2/masterfrom
airween:v2/acmppmfix

Conversation

@airween
Copy link
Copy Markdown
Member

@airween airween commented Apr 12, 2026

what

This PR fixes a possible heap buffer overflow in ACMP (Aho Corasick) pattern matching function.

why

See #3544 for details - same changes for v2.

@airween airween added the 2.x Related to ModSecurity version 2.x label Apr 12, 2026
@airween airween requested review from Copilot and fzipi April 12, 2026 20:45
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a potential heap buffer overflow in the ACMP (Aho–Corasick) pattern insertion path by ensuring allocations and copies respect the provided pattern length rather than relying on C-string semantics.

Changes:

  • Fix prefix buffer allocation for trie nodes to allocate based on the current depth (i) rather than strlen(pattern).
  • Fix full-pattern storage to allocate and copy using the explicit length (via memcpy + terminator) instead of strlen/strcpy.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.x Related to ModSecurity version 2.x

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants