Make sure partition labels are not passed unquoted/unescaped to the shell.
Resolved issues
When a provisioning image contains a partition which has a label that contains special characters interpreted by the shell, these are not properly escaped, leading to issues with mounting and potentially executing unexpected code:
That "label" value is returned by _get_part_labels(), and currently passed unescaped to self._run_control() in remote_mount() (this here assumes self.mount_point == "/foo"):
Example disk image containing an ext4 partition with the label "; echo Hello" (can easily be re-created with gnome-disks by creating a new disk image of 16 MiB, initializing it with a GPT and creating a single ext4 partition with the label "; echo Hello"):
Apart from the special shell characters causing wrong code to be run, even for cases where the partition label contains just spaces (e.g. a partition with the label "My Documents"), this is already an issue.
Description
Make sure partition labels are not passed unquoted/unescaped to the shell.
Resolved issues
When a provisioning image contains a partition which has a label that contains special characters interpreted by the shell, these are not properly escaped, leading to issues with mounting and potentially executing unexpected code:
That "label" value is returned by
_get_part_labels()
, and currently passed unescaped toself._run_control()
inremote_mount()
(this here assumesself.mount_point == "/foo"
):For a label of "; echo Hello", or a
mount
value of"/foo/;echo Hello"
, this would expand to:Which would run on the control host:
Example disk image containing an ext4 partition with the label "; echo Hello" (can easily be re-created with
gnome-disks
by creating a new disk image of 16 MiB, initializing it with a GPT and creating a single ext4 partition with the label "; echo Hello"):Unnamed (2024-08-26 0823).img.zip
Apart from the special shell characters causing wrong code to be run, even for cases where the partition label contains just spaces (e.g. a partition with the label "My Documents"), this is already an issue.
Documentation
No changes.
Web service API changes
No changes.
Tests
Not tested.