Skip to content

detect/parse: guard HashListTableLookup results in duplicate sig check - #15557

Closed
kenifor wants to merge 1 commit into
OISF:mainfrom
kenifor:fix-dup-sig-hash-null-deref
Closed

detect/parse: guard HashListTableLookup results in duplicate sig check#15557
kenifor wants to merge 1 commit into
OISF:mainfrom
kenifor:fix-dup-sig-hash-null-deref

Conversation

@kenifor

@kenifor kenifor commented Jun 4, 2026

Copy link
Copy Markdown

Ticket: 8635

Make sure these boxes are checked accordingly before submitting your Pull Request -- thank you.

Contribution style:

Our Contribution agreements:

Changes (if applicable):

Link to ticket: https://redmine.openinfosecfoundation.org/issues/8635

Describe changes:

  • Guard all four HashListTableLookup() call sites in DetectEngineSignatureIsDuplicate() against a NULL return value.
  • Add DEBUG_VALIDATE_BUG_ON() at each site to catch invariant violations in debug builds.
  • Add NULL guards in production code to prevent a crash if the invariant (every Signature in sig_list has a corresponding dup_sig_hash_table entry) is ever broken by adjacent code.

Flagged by Svace static analyzer at detect-parse.c:3250,3253.

SV_REPO=
SV_BRANCH=
SU_REPO=
SU_BRANCH=

DetectEngineSignatureIsDuplicate() calls HashListTableLookup() in four
places and dereferences the result unconditionally, assuming an invariant
that every Signature in sig_list has a corresponding dup_sig_hash_table
entry. The invariant is plausible but was neither asserted nor guarded.

Add DEBUG_VALIDATE_BUG_ON() to catch violations in debug builds, and
NULL guards to prevent a crash in production if the invariant is ever
broken by a bug in adjacent code.

Flagged by Svace static analyzer.

Ticket: 8635
@kenifor
kenifor requested a review from victorjulien as a code owner June 4, 2026 12:45
@catenacyber

Copy link
Copy Markdown
Contributor

I do not see the value of this PR and this ticket.

If the "cannot be null" hypothesis gets broken, I think we will get some existing tests to fail with the null deref

And there is no CI integration of this SVACE analysis tool, so we cannot ensure that we will not regress...
(your #15560 is more interesting for CI ;-) )

Am I missing something ?

@victorjulien

Copy link
Copy Markdown
Member

I wouldn't mind having just the debug validation bug on additions. If we know something can't happen, we can add such statements to assist analyzers and also trigger when we make changes.

@catenacyber catenacyber 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.

please just add the DEBUG_VALIDATE_BUG_ON

@victorjulien

Copy link
Copy Markdown
Member

continues in #15585

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants