system: set_hostname interpolates the hostname unquoted into root shell commands #64

Closed
opened 2026-11-12 21:25:38 +00:00 by christianmanivong · 0 comments
Owner

Prio: P4

Found in netOrk's security sweep of 2026-11-12; the netOrk side is NetOrk/netork#2456.

system_mixin.set_hostname() runs postconf -e 'myhostname = {fqdn}', hostname '{short_hostname}' and the /etc/pve/nodes/<old> → <new> move with the paths in single quotes of their own. A name with a single quote ends them: x';reboot;' runs reboot as root. netOrk now validates hostnames as RFC 1123 names before it calls set_hostname, but the driver should not depend on its caller for that. (/etc/hostname, /etc/hosts and /etc/mailname are written through base64 and are not affected.)

Fix: shlex.quote the values in those commands.

Prio: P4 Found in netOrk's security sweep of 2026-11-12; the netOrk side is NetOrk/netork#2456. `system_mixin.set_hostname()` runs `postconf -e 'myhostname = {fqdn}'`, `hostname '{short_hostname}'` and the `/etc/pve/nodes/<old>` → `<new>` move with the paths in single quotes of their own. A name with a single quote ends them: `x';reboot;'` runs `reboot` as root. netOrk now validates hostnames as RFC 1123 names before it calls `set_hostname`, but the driver should not depend on its caller for that. (`/etc/hostname`, `/etc/hosts` and `/etc/mailname` are written through base64 and are not affected.) **Fix:** `shlex.quote` the values in those commands.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: NAPALM/napalm-proxmox#64