AttachVolume doesn't validate input

Bug #664572 reported by Jesse Andrews
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
High
Unassigned

Bug Description

user input is sent as a parameter to executed command

Steps:
--------

1) launch instances
2) create volume
3) attach instance to volume with device: "/dev/vda2; reboot"

Expected
-----------

API should throw an exception that device should be of format /dev/vd*

Actual
--------

api is executed and error shows up on compute node that virsh doesn't understand reboot.

Details:
--------

Since nova doesn't validate input (in the aws api), user input can be passed to the command line.

If you attach a volume via:

euca-attach-volume -i i-123123123 -d "/dev/vda; reboot" vol-123123123

the device is stored in the db as: /dev/vda; reboot

Then the attach method is dispatched to the compute node which executes:

nova/virt/libvirt_conn.py

def attach_volume(self, instance_name, device_path, mountpoint):
    yield process.simple_execute("sudo virsh attach-disk %s %s %s" %
                                 (instance_name,
                                  device_path,
                                  mountpoint.rpartition('/dev/')[2]))

Luckily simple_execute is implemented in a way that ; reboot is sent to virsh instead of being ran as a shell command.

I've created a larger blueprint for addressing this in general - https://blueprints.launchpad.net/nova/+spec/aws-api-validation

Related branches

Changed in nova:
status: New → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → 2011.1
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.