Monday, 2024-09-09

*** bauzas_ is now known as bauzas00:08
*** bauzas_ is now known as bauzas00:21
*** bauzas_ is now known as bauzas01:01
*** bauzas_ is now known as bauzas01:26
*** mhen_ is now known as mhen01:32
*** bauzas_ is now known as bauzas01:34
*** bauzas_ is now known as bauzas02:24
*** bauzas_ is now known as bauzas02:40
*** bauzas_ is now known as bauzas02:48
*** bauzas_ is now known as bauzas02:56
*** bauzas_ is now known as bauzas04:05
*** bauzas_ is now known as bauzas04:26
*** bauzas_ is now known as bauzas04:58
*** bauzas_ is now known as bauzas06:20
*** bauzas- is now known as bauzas09:54
Luzi#startmeeting image_encryption13:00
opendevmeetMeeting started Mon Sep  9 13:00:34 2024 UTC and is due to finish in 60 minutes.  The chair is Luzi. Information about MeetBot at http://wiki.debian.org/MeetBot.13:00
opendevmeetUseful Commands: #action #agreed #help #info #idea #link #topic #startvote.13:00
opendevmeetThe meeting name has been set to 'image_encryption'13:00
Luzi#topic Roll Call13:00
mheno/13:00
fungiahoy!13:01
Luzidansmith, pdeore and anyone from Cinder, are you around?13:01
Luzihit fungi 13:01
Luzihi13:02
Luziwell mhen asked for people from Cinder and Glance to come around today, because we need to discuss the disk-format problem13:03
fungii recall rosmaita had some input during the last meeting13:03
mhenwe have a cross-project session planned for the PTG now, see last entry here: https://etherpad.opendev.org/p/2025.1-ptg-glance-planning13:04
fungii suppose the issue you're alluding to is the recent realization that we need to check images for safety before exposing qemu to them means there's a need for additional inspection after decryption?13:05
Luzicorrect13:06
Luzidan is working on a spec for this: https://review.opendev.org/c/openstack/glance-specs/+/92511113:06
mhenquoting dansmith here: "I think we need a new disk_format for luks-encrypted images. So much of the complexity of handling that CVE came from all the side vectors by which you can fool nova, glance, and cinder into doing something bad by saying an image is in one format, but actually sending another."13:07
mhen"Having to probe raw images to see if they smell like a LUKS disk, and if not, assume it's a regular raw is inviting more possibility for issue here I think."13:07
mhen"I've got a spec proposed to make glance inspect and reject uploads that do not conform to the stated disk_format"13:07
fungiyep, that matches my understanding from our recent security advisories and the related qemu-img cve13:08
Luziso we need to discuss, what kind of images we want to allow and what the properties of this images should be, so an inspection will notice that 1. the image is encrypted, and maybe 2. it is LUKS encrypted qcow or so13:08
mhenwe effectively have two possible encrypted formats right now: 1. raw luks (as created by Cinder from volumes for example) and 2. qcow2+luks13:09
fungiso i guess the idea is that there would be a specific luks-encrypted variant of each basic image type that we support? or would luks be an image type and then you'd have a property stating what kind of payload is encapsulated inside it?13:09
mhenthat's the question13:10
mhenhow to map this to container_format and disk_format valeus13:10
Luziany other encrypted images than those mentioned by mhen shouldn't be allowed13:10
Luziyeah13:10
mhen... in a way that pleases Glance, Cinder and Nova13:10
fungiso you could have luks-raw and luks-qcow2 as image types i guess, which wouldn't require additional fields13:11
mhenthe can of worms here is: what is considered container and what is disk format when we talk about qcow2+luks for example13:11
mhenwe had a similar discussion in the beginning of the image encryption contribution iirc13:12
mhenthere was some discussion around this and Glance ended up preferring we leave disk_format and container_format alone and put this into metadata (os_encrypt_*)13:13
fungiah, like a qcow2 format image that contains an encrypted block payload? rather than a qcow2 image file the entirety of which is an opaque encrypted blob?13:13
fungioh, i see, just from the metadata perspective then13:14
mhenhttps://docs.openstack.org/glance/latest/user/formats.html13:14
mhenqcow2 is classified as a disk_format here13:14
fungiaha, i was blithely unaware of the distinction in glance13:15
fungiso "encrypted" container similar to the existing "compressed" container?13:15
mhenI dunno, that's up to Glance (and by extension Cinder and Nova) and we need to discuss exactly this.13:16
fungimakes sense13:16
mhencould imagine a "raw+luks" and "qcow2+luks" disk_format for example13:17
mhenmaking luks a container_format like "compressed" currently is, is questionable13:17
Luzior we can add a os_decrypt_disk_format which contains the format after decryption: allowed values would be raw or qcow213:18
mhensince with qcow2+luks, qcow2 is outer and luks is inner format afaik13:18
fungiyeah, that's what i was wondering, so given encryption is an existing option for the qcow2 format already, it technically is still a qcow2 image file just with a different block encoding13:19
fungiwhereas with raw, encryption is at the outer layer13:20
mhen"format after decryption" <- I don't think this is applicable here; this would suggest that qcow2 is the inner format but I think it is the other way around13:20
fungiso maybe the real problem is considering qcow2 and raw image encryption as similar, when they're fairly distinct underlying representations that simply need some similar logistics for handling key material and such13:21
Luziwhatever we will do, we need to be able to get around with both kind of encrypted images: luks encrypted raw blocks and qcow2 with encrypted payload13:22
mhenyes, and we need appropriate format metadata values to represent those13:23
Luziwell we did not wanted to wait until PTG to discuss this, but already have considered some options at least13:24
fungiso for qcow2 there's a crypt_method field which contains values indicating none or aes13:24
mhenor luks13:25
mhenhttps://github.com/qemu/qemu/blob/master/docs/interop/qcow2.txt#L62-L6513:25
fungigot it13:25
fungibut really if the encryption can be determined by inspecting the header of a qcow2 encrypted image, then that's clearly distinct (and auditable) when compared to an encrypted blob the user claims is hiding a raw format image inside13:26
fungier, rather, auditable without access to the decryption key i mean13:27
Luzithat would be another thing, we may need to discuss13:27
LuziGlance will have access to the encryption keys13:27
Luziencryption/decryption13:28
rosmaitahere's what the output looks like from qemu-img info for a qcow2-luks image: https://etherpad.opendev.org/p/image-formats13:28
fungiokay, so that does at least mean it can theoretically validate both, and it's more a matter of the time and storage required to do the decryption13:28
mhenboth qcow2+luks as well as raw luks have a header13:30
fungioh, right, because raw luks has a luks header13:30
mhenusing `qemu-img info` on a raw luks disk will print "file format: luks"13:30
fungithe kernel needs to know the various parameters it was created with, etc13:30
mhenyou can identify both pretty easily by looking at the first chunks I guess13:31
mhenand if I understand dansmith correctly, he wants to have disk_format values that represent those specifically so that he can check exactly that13:31
fungipresumably we "just" need the format inspector to be able to check those header details without relying on calls to qemu-img then13:31
fungiso the luks+raw image isn't really a "could be anything" sort of raw image, it's a file with a luks header13:35
mhenpretty much13:35
fungiand we can tell qemu to treat it as luks rather than raw13:35
mhenI guess we could simplify this as "luks" disk_format rather than "raw+luks"13:35
mhenthen we'd have "luks" and "qcow2+luks" as new disk_formats, which we can differentiate13:36
mhenboth in the inspector and the actual handling13:36
fungiand technically speaking, qcow2+luks isn't really a new image type (though i suppose openstack services could treat it as such if that's the desire), merely a set of supported options for the existing qcow2 image type13:37
rosmaitawould probably be better to just stick with qcow2 as the disk_format13:38
mhenhow do we mark it as encrypted then?13:39
mhenjust based on whether it has a "os_encrypt_key_id" metadata?13:39
rosmaitawell, it will have the other metadata13:39
rosmaitawon't be usable without it13:39
fungiyeah, so this goes back to my earlier assertion that trying to treat the two cases similarly may be the problem. one is essentially a new type of image, while the other is a new set of options for a type of image openstack already recognizes13:39
mhenfair point13:40
rosmaitai am coming around to your way of thinking13:40
fungithere are some similar logistics for both since you do need to track key material13:40
mhenrightz13:41
rosmaitawhat happens if someone creates a luks image and writes a vmdk or something into it?13:41
fungican luks encapsulate random other image types?13:41
mhenit encrypts block data, so yes, anything effectively13:42
rosmaitawell, with luks you create a "container" that holds stuff13:42
mhenbut the vulns were based on qemu-img handling it before writing it to the target (e.g. for conversion)13:42
mhenI believe it would only look at the first layer here (luks) because it is not called recursively13:42
fungimmm, right, thinking about how i use it on physical machines, i generally make a disk partition, luks encrypt that, then set the luks device as an lvm physical volume13:43
rosmaitaso i've always thought of our cinder volumes-uploaded-as-images to be container_format==luks, disk_format=raw13:43
rosmaitathough 'luks' is not a defined value for glance container_format13:44
mhenhttps://docs.openstack.org/glance/latest/user/formats.html13:44
mhen"The container format refers to whether the virtual machine image is in a file format that also contains metadata about the actual virtual machine."13:44
mhenI first thought so too, but container_format means something different in Glance.13:44
fungimhen: the risks of passing untrusted image types to qemu-img extend to qemu itself as well. basically we need to make sure that qemu's format guesser doesn't come into play and that it only uses the precise drivers we want because it also includes drivers with unsafe side effects13:45
rosmaitayeah, so i've been thinking about it incorrectly13:45
fungithe qemu-img risk is merely an extension of a larger risk inherent to qemu as a whole13:45
mhenyea right, qemu is also handling the attachment to libvirt iirc13:45
fungii guess the question is whether, when qemu boots a luks encrypted image, does it decrypt the luks wrapper and use its own (vmdk or whatever) driver on what's inside the luks encryption in order to present that unencrypted to the guest kernel? or does it pass the luks encrypted device to the guest kernel and let the kernel's own block device drivers handle what's inside?13:48
fungithe risk we're trying to mitigate is not knowing what disk drivers qemu will decide to use on an image13:49
mhenthe guest kernel sees an unencrypted block device afaik, encryption/decryption is handled by the host somewhere around KVM and qemu13:49
fungiokay, so in this case qemu's luks driver would decrypt the image and then present a block device with vmdk headers to the guest kernel, rather than qemu also iteratively calling into its vmdk driver and presenting whatever's inside that vmdk to the guest kernel?13:50
fungithe former behavior should be safe, the latter unsafe13:51
mhenfungi: I believe that the former is the case, however I'm no expert of qemu13:52
croelandtAnything sounds funny about adimm's answer? :)  https://bugs.launchpad.net/glance/+bug/207902713:52
fungicroelandt: wrong channel?13:53
fungicroelandt: and yes, that's clearly something pasted from an llm chatbot13:54
croelandtoops sorry, wrong channel indeed 13:55
Luziokay so we definitely need to discuss this with Nova and Glance13:56
fungiLuzi: and possibly also with someone from qemu who has deeper knowledge about whether it's "safe" to let qemu directly handle untrusted luks format images13:57
fungithough the cinder/glance/nova folks probably know who from qemu to loop in13:58
mhenI'll see if I can attempt to try the vmdk-within-luks case in one of my dev setups13:59
fungithanks!14:01
Luziokay, thank you for the discussion today14:02
Luzihave a nice week14:02
rosmaitathanks!14:02
Luzi#endmeeting image_encryption14:02
opendevmeetMeeting ended Mon Sep  9 14:02:49 2024 UTC.  Information about MeetBot at http://wiki.debian.org/MeetBot . (v 0.1.4)14:02
opendevmeetMinutes:        https://meetings.opendev.org/meetings/image_encryption/2024/image_encryption.2024-09-09-13.00.html14:02
opendevmeetMinutes (text): https://meetings.opendev.org/meetings/image_encryption/2024/image_encryption.2024-09-09-13.00.txt14:02
opendevmeetLog:            https://meetings.opendev.org/meetings/image_encryption/2024/image_encryption.2024-09-09-13.00.log.html14:02
mhenthanks fungi and rosmaita for joining and the valuable input!14:03
*** bauzas_ is now known as bauzas21:15
*** bauzas_ is now known as bauzas21:56
*** bauzas_ is now known as bauzas22:37
*** bauzas_ is now known as bauzas23:10

Generated by irclog2html.py 2.17.3 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!