virt-aa-helper should resolve symlinks and use only resolved paths
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
libvirt (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
I happened to run into issues with virt-aa-helper.
The behavior is the same since essentially forever, but we could improve on it.
TL;DR
if you use a path like
<interface type='vhostuser'>
<source type='unix' path='/
Then virt-aa-helper will be kind and generate a rule for it to allow access.
But in some cases like in this this isn't sufficient, as there can be symlinks
/var/run -> /run
But to avoid attacks via symlinks apparmor resolves them before matching.
That way the above will be checked against:
/run/
And due to that fail.
virt-aa-helper should on adding a path resolve all symlinks in said path and use the final path for the rules.
Can be tested with symlinks for the image files as well, which should be easier.
Test notes:
test file: symlink- test</name> deadbeef- dead-beef- dead-beefdeadbe ef</uuid> >1048576< /memory> 64'>hvm< /type> var/run/ symlinkdisk' />
<address type='drive' controller='0' bus='0' target='0' unit='0'/> var/run/ symlinknet' mode='server'/>
</interface> var/run/ symlinksocket' /> qemu.guest_ agent.0' />
<domain type='kvm'>
<name>
<uuid>
<memory unit='KiB'
<vcpu>1</vcpu>
<os>
<type arch='x86_
<boot dev='hd'/>
</os>
<devices>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/
<target dev='hda' bus='ide'/>
</disk>
<interface type='vhostuser'>
<model type='virtio'/>
<source type='unix' path='/
<channel type='unix'>
<source mode='bind' path='/
<target type='virtio' name='org.
</channel>
</devices>
</domain>
And /var/run being a symlink to /run (as it is by default in Ubuntu)
$ readlink /var/run
/run
Without fix that creates: aa-helper -u libvirt- deadbeef- dead-beef- dead-beefdeadbe ef -r --dryrun < /tmp/symlink- test.xml d/libvirt/ libvirt- deadbeef- dead-beef- dead-beefdeadbe ef.files run/symlinkdisk " rwk, run/symlinksock et" rw, run/symlinknet" rw,
$ ./src/virt-
/etc/apparmor.
[...]
"/var/
"/var/
"/var/
[...]
None of the rules have any effect due to apparmor checking is vs /run/... (the resolved symlink).