pyk: arbitrary Python module import from untrusted `kbuild.toml`

Abierto
#4,969 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
15/100
Tipo de issue
Error
Claridad
Necesita aclaración
Estado de actividad
Activo
Stack tecnológico
python

Línea de trabajo

Start at Source.from_dict in pyk/src/pyk/kbuild/project.py (around line 27), which builds PackageSource from the [dependencies] table, then read PackageSource.resolve (around line 49), which calls importlib.resources.files on the package name. Done means the untrusted package string is validated or restricted to installed or locked distributions, with tests covering a malicious kbuild.toml. The suggested fix also touches the _NODES/_PROOF_TYPES allow-lists, which needs maintainer input.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Summary

PackageSource.resolve imports a Python package named by an untrusted kbuild.toml (kbuild.toml is data fetched/build-time config from the project being processed), giving arbitrary code execution in the pyk process when resolving that package.

1 finding(s) (1 LOW) — line-anchor verified at commit 4a46d1231473.

Findings
Severity ID Location Summary
LOW pyk-tools-004 pyk/src/pyk/kbuild/project.py:49 PackageSource.resolve imports an arbitrary Python module from untrusted kbuild.toml
Details
pyk-tools-004 — `PackageSource.resolve` imports an arbitrary Python module from untrusted `kbuild.toml` (pyk/src/pyk/kbuild/project.py:49)

Trigger (as reviewed): Source.from_dict (pyk/src/pyk/kbuild/project.py:27) builds PackageSource(dct['package']) from the [dependencies] table of a kbuild.toml with no allow-list or format validation. importlib.resources.files(name) imports the named module (and can import submodules) to locate it, executing its top-level code.

Impact (as reviewed): Cloning an untrusted K project and running kbuild kompile / kbuild which (or any pyk caller of Project.load) triggers import of an attacker-chosen module name, giving arbitrary code execution under the caller's privileges via import side effects. The dependency 'package' is treated as a plain string but is actually an import directive.

Deep review: reachability=REACHABLE-FROM-UNTRUSTED; exploitability=EXPLOITABLE; red-team=VERIFIABLE-UNKNOWN.

Suggested fix

Enforce the declared _NODES/_PROOF_TYPES allow-lists before globals()/locals() dispatch, restrict PackageSource.resolve to installed/locked distributions, and shlex-quote generated bug-report scripts.


From a static audit of this repository at commit 4a46d1231473b599c699160132fd6e76a5c46406 (master). Every location above was verified against the source at that revision; no exploit code was run against this repository or its infrastructure.

Lenguaje dominante
Python
Estrellas
605
Forks
165
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

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 runtimeverification/k

Todos los issues de runtimeverification/k

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.