cloud-init snippet: storage_path and filename go unquoted into a root shell command #47

Closed
opened 2026-11-02 08:24:11 +00:00 by christianmanivong · 0 comments
Owner

What happens

_write_snippet (napalm_proxmox/vm_provision_mixin.py ~281-292) writes the cloud-init snippet with a root shell command built by string formatting:

f"mkdir -p {storage_path}/snippets && "
f"echo {encoded} | base64 -d > {storage_path}/snippets/{filename}",

storage_path and filename go into the command unquoted; a space, ; or $(…) in either is interpreted by the node's root shell. #43 quoted the cloud-image download the same way; this path was left.

Expected

Both values go through shlex.quote (and filename is restricted to a safe basename, like _import_volume_name). Test-first: a filename with ;reboot; stays one argument when the command runs through a local sh.

Priority: P3 — root command injection on the hypervisor from values passed to create_vm_from_cloud_init.

Found during the bug sweep of 2026-11-02 (#43).

## What happens `_write_snippet` (`napalm_proxmox/vm_provision_mixin.py` ~281-292) writes the cloud-init snippet with a root shell command built by string formatting: ```python f"mkdir -p {storage_path}/snippets && " f"echo {encoded} | base64 -d > {storage_path}/snippets/{filename}", ``` `storage_path` and `filename` go into the command unquoted; a space, `;` or `$(…)` in either is interpreted by the node's root shell. #43 quoted the cloud-image download the same way; this path was left. ## Expected Both values go through `shlex.quote` (and `filename` is restricted to a safe basename, like `_import_volume_name`). Test-first: a filename with `;reboot;` stays one argument when the command runs through a local `sh`. Priority: P3 — root command injection on the hypervisor from values passed to `create_vm_from_cloud_init`. Found during the bug sweep of 2026-11-02 (#43).
christianmanivong added the
prio
P3
bug
labels 2026-11-02 08:24:11 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: NAPALM/napalm-proxmox#47