GHSA-4V76-RXFX-X42X
Crafted CrewAI agents.py or tasks.py parses in quadratic time and blocks the event loop
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-4V76-RXFX-X42X divulgada | |
| Remediación | Parche 12.9.1 | @cyclonedx/cdxgen · 0 d desde divulgación | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
The parser for CrewAI `agents.py` and `tasks.py` files used regular expressions whose running time grew with the square of the input. A crafted file in a scanned repository kept the Node.js event loop busy for seconds per megabyte, in the CLI and in server mode with `type=ai-skill` or `type=ai`.
Details
`parseCrewAiPython()` in `lib/inventory/communityAiConfigParser.js` (`lib/helpers/communityAiConfigParser.js` in 12.x) ran an unanchored multi-line expression, `def\s+NAME\s*\([^)]*\):[\s\S]*?return\s+Agent\(...`, over the whole file. When no `return Agent(` follows, the engine scans the rest of the file again from every `def`. The helpers that read `role`, `goal` and `tools` from a match had the same shape: `dedent(` without a quote and `tools=[` without a closing bracket each rescanned to the end of the input. The file is read without a size limit and parsing is synchronous.
Proof of concept
node -e 'require("node:fs").writeFileSync("agents.py", "from crewai import Agent\n" + "def x():\n".repeat(128000))'
cdxgen --no-install-deps -t ai-skill -o bom.json .The 1.15 MB file took about 3.5 seconds to parse, and doubling its size roughly quadrupled the time.
Impact
Denial of service. A repository can stall CI scans, and a request to an unauthenticated cdxgen server for a crafted public repository blocks the server's event loop, delaying other requests and health checks. Confidentiality and integrity are not affected.
Patches
Fixed in `@cyclonedx/cdxgen` 12.9.1 (#4758, commit 1a283ce https://github.com/cdxgen/cdxgen/commit/1a283ce1a668e1ceebac78f2e0a5e1bf5a6d8ad2). The fix for `@cdxgen/cdxgen` is in #4759 (commit 51d645e https://github.com/cdxgen/cdxgen/commit/51d645e5d8a889405062ab7d96a8bb0369fad444) and will ship in 13.7.0. The parser now splits the module into logical lines in a single pass that respects strings, comments and brackets, finds each function's body by indentation, and reads the arguments of a returned `Agent` or `Task` call only within that call's own logical line. The proof-of-concept file now parses in about 12 milliseconds, and tests bound the time on four crafted shapes. The rewrite also reports agents under the function that returns them and reads triple-quoted values, which the expressions missed.
Workarounds
Do not run `ai-skill` or `ai` scans of untrusted repositories, and in server mode do not accept those project types from untrusted clients.
Credits
Reported by @andife.
References
- https://github.com/cdxgen/cdxgen/pull/4758
- https://github.com/cdxgen/cdxgen/pull/4759
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
npm@cyclonedx/cdxgen |
Corregida | 12.9.1 | 0 d | 12.9.2 no afectada |
12.9.113.7.0Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/cdxgen/cdxgen/security/advisories/GHSA-4v76-rxfx-x42xLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
