Project

General

Profile

Actions

Bug #8647

closed
UK UK

SMTP/email JSON logger frees caller-owned SCJsonBuilder on NULL state path

Bug #8647: SMTP/email JSON logger frees caller-owned SCJsonBuilder on NULL state path

Added by Urval Kheni 4 days ago. Updated 3 days ago.

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

Description

While reviewing the SMTP Eve JSON logging code, I noticed an ownership issue in EveEmailLogJsonData() in src/output-json-email-common.c.

When smtp_state NULL, the function frees the provided SCJsonBuilder and returns failure:


However, the builder is owned by the caller. For example, EveEmailLogJson() continues to operate on the same builder after the call:


This makes ownership handling inconsistent: the callee frees a caller-owned object while the caller assumes it remains valid for subsequent cleanup.

Suggested fix:

Do not free sjs in EveEmailLogJsonData().
Simply return failure when smtp_state NULL.
Optionally add defensive NULL checks in EveSmtpDataLogger() for state and vtx.
I have not verified whether the NULL-state path is reachable during normal runtime, so I am reporting this as a correctness / hardening issue rather than a confirmed security issue.


Files

SS Updated by Samaresh Kumar singh 3 days ago Actions #1

  • Assignee set to Samaresh Kumar singh

JI Updated by Jason Ish 3 days ago Actions #2

  • Status changed from New to In Review
  • Assignee changed from Samaresh Kumar singh to Urval Kheni

There is already a PR in review: https://github.com/OISF/suricata/pull/15599

SS Updated by Samaresh Kumar singh 3 days ago Actions #3

  • Status changed from In Review to New
  • Assignee changed from Urval Kheni to Jason Ish

VJ Updated by Victor Julien 3 days ago Actions #4

  • Status changed from New to In Review
  • Assignee changed from Jason Ish to Urval Kheni
  • Target version changed from TBD to 9.0.0-beta1

@Samaresh Kumar singh please leave the ticket if it was assigned to others.

UK Updated by Urval Kheni 3 days ago Actions #5

  • Status changed from In Review to Closed
Actions

Also available in: PDF Atom