]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virt-aa-helper: apparmor wildcards to forbidden chars
authorChristian Ehrhardt <christian.ehrhardt@canonical.com>
Thu, 26 Oct 2017 13:22:10 +0000 (15:22 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 27 Oct 2017 08:32:02 +0000 (10:32 +0200)
Some globbing chars in the domain name could be used to break out of
apparmor rules, so lets forbid these when in virt-aa-helper.

Also adding a test to ensure all those cases were detected as bad char.

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
src/security/virt-aa-helper.c
tests/virt-aa-helper-test

index ee3913d66ac3a867bae6af71609ebcd25dd25ae2..07ece730e27d2be4be92adcabb54d788825659f0 100644 (file)
@@ -449,7 +449,7 @@ valid_name(const char *name)
 {
     /* just try to filter out any dangerous characters in the name that can be
      * used to subvert the profile */
-    const char *bad = "/[]*";
+    const char *bad = "/[]{}?^,\"*";
 
     if (strlen(name) == 0)
         return -1;
index 0599046408c3a5492bb873917a3eaa44fb1dd695..e8376687e71bb8b34e87f56a6167796a773fd41a 100755 (executable)
@@ -211,6 +211,26 @@ testme "1" "-c with no os.type" "-c -u $valid_uuid" "$test_xml"
 sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,hvm</type>,hvm_invalid</type>,g" "$template_xml" > "$test_xml"
 testme "1" "-c with invalid hvm" "-c -u $valid_uuid" "$test_xml"
 
+sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,virt-aa-helper-test,virt-aa-helper-test-/,g" "$template_xml" > "$test_xml"
+testme "1" "-c with invalid domain name char /" "-c -u $valid_uuid" "$test_xml"
+sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,virt-aa-helper-test,virt-aa-helper-test-[,g" "$template_xml" > "$test_xml"
+testme "1" "-c with invalid domain name char [" "-c -u $valid_uuid" "$test_xml"
+sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,virt-aa-helper-test,virt-aa-helper-test-],g" "$template_xml" > "$test_xml"
+testme "1" "-c with invalid domain name char ]" "-c -u $valid_uuid" "$test_xml"
+sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,virt-aa-helper-test,virt-aa-helper-test-{,g" "$template_xml" > "$test_xml"
+testme "1" "-c with invalid domain name char {" "-c -u $valid_uuid" "$test_xml"
+sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,virt-aa-helper-test,virt-aa-helper-test-},g" "$template_xml" > "$test_xml"
+testme "1" "-c with invalid domain name char }" "-c -u $valid_uuid" "$test_xml"
+sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,virt-aa-helper-test,virt-aa-helper-test-?,g" "$template_xml" > "$test_xml"
+testme "1" "-c with invalid domain name char ?" "-c -u $valid_uuid" "$test_xml"
+sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,virt-aa-helper-test,virt-aa-helper-test-^,g" "$template_xml" > "$test_xml"
+testme "1" "-c with invalid domain name char ^" "-c -u $valid_uuid" "$test_xml"
+sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,virt-aa-helper-test,virt-aa-helper-test-\,,g" "$template_xml" > "$test_xml"
+testme "1" "-c with invalid domain name char ," "-c -u $valid_uuid" "$test_xml"
+sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,virt-aa-helper-test,virt-aa-helper-test-\",g" "$template_xml" > "$test_xml"
+testme "1" "-c with invalid domain name char \"" "-c -u $valid_uuid" "$test_xml"
+sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" -e "s,virt-aa-helper-test,virt-aa-helper-test-*,g" "$template_xml" > "$test_xml"
+testme "1" "-c with invalid domain name char *" "-c -u $valid_uuid" "$test_xml"
 
 echo "Expected pass:" >$output
 sed -e "s,###UUID###,$uuid,g" -e "s,###DISK###,$disk1,g" "$template_xml" > "$test_xml"