Project

General

Profile

Actions

Bug #8635

closed
DB DB

NULL dereference on HashListTableLookup result in DetectEngineSignatureIsDuplicate

Bug #8635: NULL dereference on HashListTableLookup result in DetectEngineSignatureIsDuplicate

Added by Denis Balashov 9 days ago. Updated about 17 hours ago.

Status:
Closed
Priority:
Normal
Target version:
Affected Versions:
Effort:
Difficulty:
Label:

Description

In DetectEngineSignatureIsDuplicate() (detect-parse.c), HashListTableLookup()
is called in four places and the result is dereferenced unconditionally.

The code relies on an invariant — that every Signature in sig_list has a
corresponding dup_sig_hash_table entry — but the invariant is neither
asserted nor guarded. One location has a comment "sw_old == NULL case is
impossible", which acknowledges the assumption but does not enforce it.

If the invariant is ever violated due to a bug in adjacent code, the process
will crash with a NULL dereference.

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

Proposed fix: add DEBUG_VALIDATE_BUG_ON() at each site to catch violations
in debug builds, and NULL guards to prevent a crash in production builds.

pull request
https://github.com/OISF/suricata/pull/15557

Actions

Also available in: PDF Atom