Actions
Bug #9058
closed
VJ
VJ
lua/bytevar: map() accepts any lightuserdata as Signature pointer (hardening)
Bug #9058:
lua/bytevar: map() accepts any lightuserdata as Signature pointer (hardening)
Affected Versions:
Effort:
Difficulty:
Label:
Description
- Status: present in
main(9b7938aec); hardening (not reachable today) - Class: unchecked pointer from a script argument
- Component:
src/util-lua-bytevarlib.c:41-45(LuaBytevarMap)
Description¶
bytevar.map() validates only that the first argument is a lightuserdata and then treats it as a const Signature *:
if (!lua_islightuserdata(L, -2)) {
return luaL_error(L, "bytevar.map: first argument must be the signature passed to init");
}
const Signature *s = lua_touserdata(L, -2);
...
DetectByteRetrieveSMVar(name, s, -1, &idx);
DetectByteRetrieveSMVar walks s->init_data, so a forged lightuserdata would be an arbitrary-pointer dereference. Today the only lightuserdata a script can obtain is the Signature * passed to init(), so this is not reachable; it should still fail closed.
Fix direction¶
Capture the expected Signature * at init()/thread-init time (registry) and require exact pointer equality; error otherwise. Optionally stop exposing the signature as a lightuserdata and pass an opaque handle.
Test¶
lua-bytevar-map-sig-arg: map(nil, "x") / map(<other lightuserdata>, "x") / extra args → clean Lua error, no deref.
Actions