validate() allocates program-declared sizes and loop ranges in check-only mode (resource exhaustion from a small QASM file)
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 43/100
Línea de trabajo
Read src/pyqasm/modules/base.py around QasmModule.validate() and the cited allocation and loop paths in src/pyqasm/visitor.py; inspect src/pyqasm/maps/expressions.py for the array dimension limit. Start by tracing how check-only validation handles declared registers, arrays, and loops, then add bounds or check-only exits with tests for small programs that trigger large allocations or long loops. Done means validation rejects or safely handles these cases without exhausting resources.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Note: your SECURITY.md asks for reports through the private advisory form, but private vulnerability reporting is turned off for this repository, so the form isn't available. That is the only reason we're reporting this publicly. We also emailed [email protected] today asking for a private channel.
Our code review of qBraid/pyqasm at 95747c7bea4b73f6065249e708071fc5b3bdc461 (current main; pyproject version 1.4.0, three commits after the v1.4.0 tag) found that QasmModule.validate() still materialises program-declared sizes and loop ranges in check-only mode, so a short OpenQASM program can force a large allocation or a long loop.
validate() (src/pyqasm/modules/base.py:709–727) builds a QasmVisitor with check_only=True (line 715) and walks the program. A classical bit register is initialised with np.full of the declared length (src/pyqasm/visitor.py:2067–2069) and then one dict entry and one ClbitDepthNode per bit (lines 2212–2214) before the check-only return at line 2236. An array is similarly allocated with np.full (line 2097) after only the number of dimensions is capped (MAX_ARRAY_DIMENSIONS = 7 in src/pyqasm/maps/expressions.py:185), not the product of their sizes. A qubit register adds one label and one QubitDepthNode per qubit (visitor.py:309–312) with no size cap; validate()'s later device_qubits check (base.py:718) applies only if the caller set that option, which defaults to None (base.py:206). A for-loop range is turned into a list (visitor.py:2586) before the existing iteration-limit check (line 2601, default 1e9). A while loop has no check-only exit (unlike the for loop at line 2646) and runs until that same counter (lines 2841–2904, counter at 2895); a continue in the body jumps back without incrementing the counter (lines 2881–2887). The bundled CLI pyqasm validate <file> calls load() then validate() (src/pyqasm/cli/validate.py:74–75). This is a source review only, nothing was run or compiled.
This is an availability issue only: a caller that validates QASM it did not write (a service, a CI job, or the CLI) can be stalled or run out of memory by a small file. We have not claimed a particular hosted service. A suggested untested fix (caps on register and array sizes before allocation, a lazy for-loop range, and a check-only exit for while, plus tests) is available on request. The numeric caps in that patch are a policy choice for you to set.
Credit: Ugur Celik (ucsurf), @ucsurf
— ucsurf / https://uc.surf
If you'd like to support our work, even a coffee helps: https://buymeacoffee.com/ucsurf
- Lenguaje dominante
- Python
- Estrellas
- 29
- Forks
- 33
- Merge medio
- 1 d 20 h
- PR fusionados (30 d)
- 8
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
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 qBraid/pyqasm
-
dumps() prints the original program when unroll() leaves at most one statementPosiblemente ocupada @ShiveshDragon la tomó hace 9 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
qBraid/pyqasm#493 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 63/100
Los mantenedores suelen responder en 1 día
-
enhancement error-handling program-validation
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
dependencies enhancement
Dificultad 3/5 1-2 días Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
-
Integer division for casts, int array elements, bitwise results, ** and int-returning subroutinesAbierto
Dificultad 3/5 1-2 días Aptitud para principiantes 52/100
qBraid/pyqasm#480 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de qBraid/pyqasm
Issues similares
-
available documentation good first issue
Dificultad 1/5 1-3 horas Aptitud para principiantes 95/100
Nixitov/Riptide-Native#944 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
JTHCode/secretguard#24 ·
Los mantenedores suelen responder en 1 día
-
area: middleware documentation good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
-
enhancement good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
good first issue
Dificultad 1/5 Menos de una hora Aptitud para principiantes 95/100
omarelshamy25x/shamy-hijri#63 ·
Los mantenedores suelen responder en 1 día