Public bug reported:

lua-bitop 1.0.2-7 in Ubuntu 24.04 LTS (noble) is affected by
CVE-2024-31449: calling bit.tohex() with INT32_MIN as the number of
digits makes the negation "n = -n" overflow, so n stays negative and
lua_pushlstring() is called with a huge length, reading past the end
of an 8-byte stack buffer. The same code is embedded in Redis, where
it was fixed by commit 1f7c148be2cbacf7d50aa461c58b871e87cc5ed9
(GHSA-whxg-wx83-85p5).

Reproducer (noble, lua-bitop 1.0.2-7):
  $ lua5.1 -e 'local bit=require("bit"); print(bit.tohex(65535,-2147483648))'
  Segmentation fault (core dumped)    # exit status 139

Attached is a debdiff for noble-security (1.0.2-7ubuntu0.24.04.1)
that backports the upstream one-line fix as
debian/patches/CVE-2024-31449.patch.

Testing, done in a clean noble LXD container:
 * package builds; the upstream test suite (runall.lua) passes in
   dh_auto_test
 * reproducer before the update: segfault, exit 139
 * reproducer after the update: prints 0000FFFF, exit 0
 * regression check:
   bit.tohex(65535), bit.tohex(65535,-4), bit.tohex(255,2),
   bit.tohex(-1,-2147483647) -> 0000ffff FFFF ff FFFFFFFF (unchanged)

Later releases are not affected: lua-bitop 1.0.3 and newer
(resolute 1.0.3-2, stonking and tenacious 1.0.4-1) treat n as unsigned
and negate it as ~n+1. Verified on resolute: the same reproducer prints
0000FFFF. The Ubuntu CVE tracker currently lists these releases as
"needed"; they should be "not-affected".

** Affects: lua-bitop (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: noble security

** Patch added: "debdiff for noble-security (1.0.2-7ubuntu0.24.04.1)"
   
https://bugs.launchpad.net/bugs/2173901/+attachment/6016773/+files/lua-bitop_1.0.2-7ubuntu0.24.04.1.debdiff

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2173901

Title:
  CVE-2024-31449: stack buffer over-read in bit.tohex() in noble

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/lua-bitop/+bug/2173901/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to