Project

General

Profile

Actions

Bug #9069

closed
VJ VJ

lua: NTP/JA3 FFI getters take Rust references without C-side pointer revalidation (hardening)

Bug #9069: lua: NTP/JA3 FFI getters take Rust references without C-side pointer revalidation (hardening)

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); hardening
  • Class: FFI pointer-contract hardening (latent UB, depends on already-filed stale/forged-pointer classes)
  • Component: src/util-lua-ntp.c:58-88, src/util-lua-ja3.c:83/112/137/166 and the Rust getters

Description

The Rust getters take references, which assert non-NULL/dereferenceable to the optimizer:

  • SCNtpLuaGetVersion/Mode/Stratum/ReferenceId(&mut NTPTransaction) (rust/src/ntp/lua.rs:24/31/38/45);
  • SCQuicTxGetJa3(&QuicTransaction) (rust/src/quic/detect.rs:64-67).

The C libs validate the tx pointer only once, at get_tx() time (util-lua-ntp.c:35-38, util-lua-ja3.c:47-51). Any stale, forged or wrong-protocol pointer reaching the getters becomes instant UB instead of a checked nil.

Fix direction

Take *const c_void in these FFI functions and validate/re-cast on each call (cast_pointer! + explicit NULL check), as quic_tx_get_version already does.

Test

lua-txlibs-ffi-null: unit test passing a forged/wrong-type userdata under ASAN; must fail cleanly.


Subtasks 1 (0 open — 1 closed)

Bug #9319: lua: NTP/JA3 FFI getters take Rust references without C-side pointer revalidation (hardening) (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 #9319 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

  • Tracker changed from Security to Bug
  • Severity deleted (LOW)

JI Updated by Jason Ish 26 days ago Actions #6

  • Status changed from In Review to Closed

JI Updated by Jason Ish 8 days ago Actions #7

  • Private changed from Yes to No
Actions

Also available in: PDF Atom