[BUG] Integer overflow in Proxy ownKeys property enumeration causes heap buffer overflow (32-bit)
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 68/100
Línea de trabajo
Start in quickjs.c at js_proxy_get_own_property_names() and inspect the sizeof(tab[0]) * len allocation and the subsequent property-enumeration loop. Reproduce with a 32-bit build using a Proxy ownKeys trap that returns an array with length at least 0x20000000, then verify that enumeration no longer causes an out-of-bounds write.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
js_proxy_get_own_property_names() in quickjs.c contains an integer overflow in the allocation size computation for the property enumeration table. The expression sizeof(tab[0]) * len where sizeof(JSPropertyEnum) = 8 and len is an attacker-controlled uint32_t wraps to zero or a small value on 32-bit platforms when len >= 0x20000000 (536,870,912). The allocator returns a tiny buffer, and the subsequent loop writes len entries past it.
Root Cause
After the Proxy's ownKeys trap returns an array, the function computes:
tab = js_mallocz(ctx, sizeof(tab[0]) * len);
On 32-bit (sizeof(size_t) = 4): 8 * 0x20000000 = 0x100000000 wraps to 0. The js_mallocz(ctx, 0) path returns a singleton pointer. The initialization loop then writes len entries (up to 4 GB) past this allocation.
The Proxy trap only needs to return an array with length >= 0x20000000. The array entries themselves can be lazy getters (a few KB total), making this practical on memory-constrained 32-bit embedded devices -- QuickJS's primary deployment target.
Impact
Heap buffer overflow via crafted JavaScript on 32-bit platforms. QuickJS is widely deployed in embedded/IoT systems (ESP32, smart home, automotive) where 32-bit is the norm.
CWE-190 / CWE-122, CVSS 8.1
- Lenguaje dominante
- C
- Estrellas
- 11.1k
- Forks
- 1.2k
- Merge medio
- 11 h 20 min
- PR fusionados (30 d)
- 1
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de bellard/quickjs
-
Dificultad 4/5 3-5 días Aptitud para principiantes 15/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 22/100
-
Collecting WeakMap keys requires multiple GC passesPosiblemente ocupada @jluxenberg la tomó hace 5 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
-
Dificultad 4/5 1-2 días Aptitud para principiantes 48/100
-
Failed Build/Compile On CygwinAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 58/100
Todos los issues de bellard/quickjs
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
openwrt/openwrt#26385 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 Medio día Aptitud para principiantes 62/100
php/php-src#25137 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
c3lang/c3c#3613 · 2 comentarios ·
Los mantenedores suelen responder en 1 día