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
Actions

Also available in: PDF Atom