[BUG] Integer overflow in Proxy ownKeys property enumeration causes heap buffer overflow (32-bit)

Abierto
#535 0 comentarios 0 reacciones 0 asignados Ver en GitHub

@Sn0wyDay ya está trabajando en esto.

Desde el 1/10/2026.

  • #566 de @Sn0wyDay — abierto

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
68/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Tranquilo
Stack tecnológico
c
Área
security

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

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de bellard/quickjs

Todos los issues de bellard/quickjs

Issues similares

Más issues de C

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.