system: set_hostname interpolates the hostname unquoted into a root shell command #43

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.

vlan_mixin.set_hostname() runs uci set system.@system[0].hostname='{new_hostname}' && uci commit system && /etc/init.d/system reload. The name stands between single quotes of its own, so 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.

Fix: hand the name to uci as one shell word with the repo's uci_steps.uci() helper (shlex.join).

Prio: P4 Found in netOrk's security sweep of 2026-11-12; the netOrk side is NetOrk/netork#2456. `vlan_mixin.set_hostname()` runs `uci set system.@system[0].hostname='{new_hostname}' && uci commit system && /etc/init.d/system reload`. The name stands between single quotes of its own, so 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. **Fix:** hand the name to `uci` as one shell word with the repo's `uci_steps.uci()` helper (`shlex.join`).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: NAPALM/napalm-openwrt#43