Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upPrevent shared random seed across VMs #1311
Comments
marmarek
added
bug
C: core
C: templates
P: major
labels
Oct 9, 2015
marmarek
added this to the Release 3.0 updates milestone
Oct 9, 2015
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
qubesuser
Oct 9, 2015
Reading 256 bits from dom0 /dev/urandom at VM startup and passing the value to the VM by writing it to a part of the first sector of volatile.img that isn't the partition table seems the simplest solution, and should work with disposable VMs too (might need to blockdev --flushbufs the device before reading it).
qubesuser
commented
Oct 9, 2015
|
Reading 256 bits from dom0 /dev/urandom at VM startup and passing the value to the VM by writing it to a part of the first sector of volatile.img that isn't the partition table seems the simplest solution, and should work with disposable VMs too (might need to blockdev --flushbufs the device before reading it). |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
marmarek
Oct 9, 2015
Member
Linked thread already contains patches prepared by HW42, which
implements very similar approach, but use QubesDB for that. I'm going to
apply them.
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
|
Linked thread already contains patches prepared by HW42, which Best Regards, |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
adrelanos
Oct 10, 2015
Member
Same issue reported against a different project:
grml/grml-debootstrap#91
The problem is, that no big mainstream distribution such as Debian or Fedora officially ships raw / VM images. They all ship installer dvd. Distributing images is relatively new.
Shipping public known random seeds by default is the worst situation. They should of course not be shipped. But not shipping the file at all and leaving it to the system may also be an issue. Perhaps that's off-topic here and deserves it's own ticket.
So when one installs using a mainstream installer dvd, how are the random seeds created on the disk? Can we re-use the same mechanism?
What happens if an image is started, that does not have the random seeds? Will the system safely create them at boot time then?
Tails has a similar issue. See https://labs.riseup.net/code/issues/7642. It implies that the seed file may be seeded by date +%s.%N only. Then this may also be not much more secure than shipping public known random seed files. I haven't fully wrapped my head around this yet. Might be upstream issues, but these need to be found and reported. Not sure it's a Tails specific or general issue.
|
Same issue reported against a different project: The problem is, that no big mainstream distribution such as Debian or Fedora officially ships raw / VM images. They all ship installer dvd. Distributing images is relatively new. Shipping public known random seeds by default is the worst situation. They should of course not be shipped. But not shipping the file at all and leaving it to the system may also be an issue. Perhaps that's off-topic here and deserves it's own ticket. So when one installs using a mainstream installer dvd, how are the random seeds created on the disk? Can we re-use the same mechanism? What happens if an image is started, that does not have the random seeds? Will the system safely create them at boot time then? Tails has a similar issue. See https://labs.riseup.net/code/issues/7642. It implies that the seed file may be seeded by |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
marmarek
Oct 10, 2015
Member
So when one installs using a mainstream installer dvd, how are the random seeds created on the disk? Can we re-use the same mechanism?
In some cases, using post installation scripts, in other - on first startup. I don't think there is generic way to reuse any of those techniques. At least we need to ensure that distributed images are free from random-seeds. Building image twice and comparing the results should reveal that.
What happens if an image is started, that does not have the random seeds? Will the system safely create them at boot time then?
Most likely. And exceptions (hopefully rare) needs to be fixed some other way - for example creating them manually (copy&paste from post-installation script? re-running that script dpkg-reconfigure?)
Tails has a similar issue. See https://labs.riseup.net/code/issues/7642. It implies that the seed file may be seeded by
date +%s.%Nonly.
This is already handled by patches for this very ticket.
In some cases, using post installation scripts, in other - on first startup. I don't think there is generic way to reuse any of those techniques. At least we need to ensure that distributed images are free from random-seeds. Building image twice and comparing the results should reveal that.
Most likely. And exceptions (hopefully rare) needs to be fixed some other way - for example creating them manually (copy&paste from post-installation script? re-running that script
This is already handled by patches for this very ticket. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
adrelanos
Oct 10, 2015
Member
Marek Marczykowski-Górecki:
Tails has a similar issue. See https://labs.riseup.net/code/issues/7642. It implies that the seed file may be seeded by
date +%s.%Nonly.
This is already handled by patches for this very ticket.
Isn't that something that should be upstreamed to Debian/Fedora? Or at
least reported upstream? Sounds like an upstream bug to me?
|
Marek Marczykowski-Górecki:
Isn't that something that should be upstreamed to Debian/Fedora? Or at |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
marmarek
Oct 10, 2015
Member
On Sat, Oct 10, 2015 at 07:44:59AM -0700, Patrick Schleizer wrote:
Marek Marczykowski-Górecki:
Tails has a similar issue. See https://labs.riseup.net/code/issues/7642. It implies that the seed file may be seeded by
date +%s.%Nonly.
This is already handled by patches for this very ticket.Isn't that something that should be upstreamed to Debian/Fedora? Or at
least reported upstream? Sounds like an upstream bug to me?
I think there are two issues:
- Having random seeds distributed in template packages
- Having random seeds (and other unique identifiers) shared among VMs
The first one is a security issue, because it may affect quality of PRNG.
This also apply to other data like host keys etc (checked the obvious
locations and currently none are included). But it doesn't apply to just
"unique identifiers" (like machine-id). It's even better for anonymity
reasons. This apply only to software preinstalled in the templates.
The second one apply to all the files above - where it is also a
security issue. But in case of Whonix, it additionally apply to unique
identifiers, because it may be used to correlate different VMs on the
same physical system. Note that only unique identifiers not included in
the original template image are a threat here, because only those are
identifying the user (not just the fact that Whonix on Qubes is used).
The first issue probably worth reporting upstream. The second is quite
Qubes specific.
BTW Just checked that Debian Live image doesn't contain
/var/lib/urandom/random-seed. Is it removed somewhere during image
build (and we can reuse that code), or it isn't created at all - in
which case it's interesting why we had it created.
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
|
On Sat, Oct 10, 2015 at 07:44:59AM -0700, Patrick Schleizer wrote:
I think there are two issues:
The first one is a security issue, because it may affect quality of PRNG. The second one apply to all the files above - where it is also a The first issue probably worth reporting upstream. The second is quite BTW Just checked that Debian Live image doesn't contain Best Regards, |
added a commit
to marmarek/old-qubes-core-agent-linux
that referenced
this issue
Oct 11, 2015
added a commit
to marmarek/old-qubes-core-agent-linux
that referenced
this issue
Oct 11, 2015
added a commit
to marmarek/old-qubes-core-agent-linux
that referenced
this issue
Oct 11, 2015
added a commit
to marmarek/old-qubes-core-agent-linux
that referenced
this issue
Oct 11, 2015
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Update already in current-testing repository. |
marmarek commentedOct 9, 2015
Reported by @v6ak:
I've examined what is shared between AppVMs that use the same template with
focus on security and discussed that with the Qubes team. I've found that
/var/lib/systemd/random-seed is stored on /, which means:
However, it is not as bad as it might look:
Even better, this means that haveged reaches low water mark immediatelly
and starts gathering new entropy (if haveged is present), which minimizes
the issue.
Impact:
Bitcoin wallets where was a transaction signed by an Android client with flawed RNG, so such attacks might be practical.) Again, mostly users of fedora-minimal without haveged installed should be worried about this.
Note that users of non-systemd OSes (Debian 7?) may be affected more, because the random seed scripts may behave differently. If entropy_avail is increased by the random seed script, such issue would also affect /dev/random. Moreover, haveged would probably not reach low water mark so quickly, so the impact would be greater in such case. However, not using systemd does not imply this behavior. Not using systemd just means I don't know how it behaves.
How to fix?
Moving random seed to /rw does not fully solve this issue at the moment. The /rw is cloned from the TemplateVM, which is somehow suboptimal.
We've also discussed distributing some entropy from dom0 to AppVMs. Some related discussion: #673 . While it solves these issues, it makes dom0 potentially more vulnerable to its RNG flaws. I remember a keyboard timing side-channel vulnerability on /dev/random. Maybe dom0 should only provide an one-time random seed in order to lower impact of such vulnerabilities. If an AppVM asks for new random seed second time within one boot, the user should be at least notified.
How to prevent similar issues?
This and similar issues could have been found by:
Note that 1) does not uncover issues with packages that are not preinstalled. But such testing can be used on any package. It can uncover issues like shared SSH keys (I remember such issue at one VPS provider that provides VPS templates…) and so on.
Public discussion
We have decided to start a public discussion in order to find the best
solution.
The discussion:
https://groups.google.com/d/msgid/qubes-devel/8f3553f3-cf7e-41ce-959f-d81a6285a0f5%40googlegroups.com