Project

General

Profile

Actions

Bug #9070

closed
VJ VJ

lua/config: log_path() leaks a _getcwd buffer per call on Windows

Bug #9070: lua/config: log_path() leaks a _getcwd buffer per call on Windows

Added by Victor Julien 2 months ago. Updated 8 days ago.

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

Description

  • Status: present in main (9b7938aec); Windows-only
  • Class: C-heap leak per call (unbounded, not accounted by the Lua sandbox)
  • Component: src/util-lua-config.c:36-43 -> src/util-conf.c:38-54 (SCConfigGetLogDirectory)

Description

On Windows, when default-log-dir is not set, SCConfigGetLogDirectory() allocates a buffer per call:

if (SCConfGetNonNull("default-log-dir", &log_dir) != 1) {
#ifdef OS_WIN32
    log_dir = _getcwd(NULL, 0);      /* mallocs */
    if (log_dir == NULL)
        log_dir = DEFAULT_LOG_DIR;
#else
    log_dir = DEFAULT_LOG_DIR;
#endif
}
return log_dir;

config.log_path() (src/util-lua-config.c:36-43) copies the string into Lua and then loses the pointer; no caller frees it and there is no ownership contract. Trigger: Windows + minimal config without -l/default-log-dir, a rule or output script calling config.log_path() per packet/event -> one leaked _getcwd buffer per call. The allocation is not routed through the sandbox allocator, so security.lua.max-bytes cannot bound it.

Fix direction

Cache/own the value (e.g. have SCConfigGetLogDirectory() cache the _getcwd result once, or make log_path() use a fixed buffer), or return DEFAULT_LOG_DIR on Windows too.

Test

Windows-gated lua-config-log-path-repeat or a C unit test with an allocation counter; POSIX behavior is unaffected.


Subtasks 1 (0 open — 1 closed)

Bug #9320: lua/config: log_path() leaks a _getcwd buffer per call on Windows (8.0.x backport)ClosedVictor JulienActions

VJ Updated by Victor Julien about 2 months ago Actions #1

  • Status changed from New to In Progress
  • Assignee changed from OISF Dev to Victor Julien

JI Updated by Jason Ish about 1 month ago Actions #2

  • Status changed from In Progress to In Review

MR1382

JI Updated by Jason Ish 27 days ago Actions #3

  • Subtask #9320 added

JI Updated by Jason Ish 27 days ago Actions #4

  • Severity set to LOW

JI Updated by Jason Ish 27 days ago Actions #5

  • GHSA set to GHSA-gr34-c9wj-pvw3

JI Updated by Jason Ish 26 days ago Actions #6

  • Tracker changed from Security to Bug
  • Severity deleted (LOW)
  • GHSA deleted (GHSA-gr34-c9wj-pvw3)

JI Updated by Jason Ish 26 days ago Actions #7

  • Status changed from In Review to Closed

JI Updated by Jason Ish 8 days ago Actions #8

  • Private changed from Yes to No
Actions

Also available in: PDF Atom