News for hackers. Stuff that matters.
Re:German BSI withholds Truecrypt security report by jmakov on Monday December 16, 2019 @10:19AM (#21803607)
"... in the simplest case a user can mount a Truecrypt volume that contains a file with suid root permission that will open a shell. Golem.de was able to replicate this scenario in a current version of Veracrypt."
Re:German BSI withholds Truecrypt security report by mehrdadn on Monday December 16, 2019 @02:46PM (#21806424)
Can I just point out that this is just one vivid example of why tying setuid permissions to a file is a terrible design to begin with? Permissions should be derived from the execution context at run time. (People might hate me for saying this, but this is one of those design decisions Windows fundamentally gets right.)
Re:German BSI withholds Truecrypt security report by 001spartan on Monday December 16, 2019 @02:58PM (#21806567)
Even Windows gets this wrong at times, with several UAC bypass techniques exposed by auto-elevating binaries. Still, Microsoft has done a great deal of work with the Windows privilege model to prevent things like this, and these issues are steadily being resolved.
Re:German BSI withholds Truecrypt security report by gruez on Monday December 16, 2019 @04:48PM (#21807628)
>with several UAC bypass techniques exposed by auto-elevating binaries

According to Raymond Chen, a MSFT employee:

>There really are only two [UAC] settings.

>* Always notify

>* Meh

https://devblogs.microsoft.com/oldnewthing/20160816-00/?p=94...

Re:German BSI withholds Truecrypt security report by mehrdadn on Monday December 16, 2019 @03:04PM (#21806615)
Re:German BSI withholds Truecrypt security report by orf on Monday December 16, 2019 @03:59PM (#21807131)
Pasting a random article from 2007 with no other comment is not a great rebuttal of what they said.

A _lot_ has changed since 2007.

Re:German BSI withholds Truecrypt security report by mehrdadn on Monday December 16, 2019 @04:06PM (#21807191)
I'm pretty sure the fact that it's not a security boundary has not changed since 2007. They should've probably marketed it better to clarify this, but that's not a technical issue. It was always a horrible idea to run a malicious program under your credentials relying on UAC to enforce any security. That's never changed.
Re:German BSI withholds Truecrypt security report by saagarjha on Monday December 16, 2019 @05:47PM (#21808310)
How do you suggest implementing passwd without setuid?
Re:German BSI withholds Truecrypt security report by JdeBP on Tuesday December 17, 2019 @10:17AM (#21814267)
Using the design of the LSASS is one way, as mentioned. Others include OpenWall's tcb, and Daniel Rench's userdirs.

* https://www.openwall.com/tcb/

* https://web.archive.org/web/20030919191907/http://dren.ch:80...

Re:German BSI withholds Truecrypt security report by mehrdadn on Monday December 16, 2019 @05:50PM (#21808353)
Off the top of my head? Ask a system service that has the privilege to change it for you after authenticating you.
Re:German BSI withholds Truecrypt security report by saagarjha on Monday December 16, 2019 @05:54PM (#21808403)
Isn’t that exactly what passwd is? A system service that has permission to change the passwords file?
Re:German BSI withholds Truecrypt security report by mehrdadn on Monday December 16, 2019 @05:58PM (#21808443)
No, the point is that passwd should obtain its privilege by virtue of being started by a privileged process, not by virtue of being marked as a privileged program when it's run by an unprivileged user.
Re:German BSI withholds Truecrypt security report by saagarjha on Monday December 16, 2019 @06:49PM (#21808891)
How do you start the privileged process as a normal user?
Re:German BSI withholds Truecrypt security report by mehrdadn on Monday December 16, 2019 @06:52PM (#21808913)
You don't. It's already started as part of the system. Or you ask some part of the system that is willing to authenticate you to do it for you.
Re:German BSI withholds Truecrypt security report by exikyut on Monday December 16, 2019 @10:03PM (#21810125)
Shhhhhhhhhh.

Stop giving systemd more ideas.

(/s)

(But seriously, imagine a world where you can't get root because D-Bus crashed.)

Re:German BSI withholds Truecrypt security report by ATsch on Tuesday December 17, 2019 @06:01AM (#21812453)
PolicyKit essentially already does this, and all of the systemd *ctl commands support authentication via polkit
Re:German BSI withholds Truecrypt security report by exikyut on Tuesday December 17, 2019 @08:25PM (#21820907)
TIL (so that's what the whole PolicyKit thing was all about).

Now I'm wondering what its worst case crash behavior is like.

Re:German BSI withholds Truecrypt security report by aasasd on Monday December 16, 2019 @10:44AM (#21803830)
This surprised me the most―never thought about this before. Aren't all permission-supporting filesystems vulnerable to this if mounting by a user is permitted? I presume filesystems don't go through the files and downgrade root ownership.
Re:German BSI withholds Truecrypt security report by unixreply55 on Monday December 16, 2019 @10:56AM (#21803966)
Yes; that is why it is recommended that untrustworthy drives be mounted with the `nosuid` flag.
Re:German BSI withholds Truecrypt security report by aasasd on Monday December 16, 2019 @11:32AM (#21804244)
Ah, so even though filesystems don't go through files, they still can block the operation of suid. This suggests then that Veracrypt can simply enable the nosuid option when mounting a device.
Re:German BSI withholds Truecrypt security report by cyphar on Monday December 16, 2019 @02:57PM (#21806551)
And they should also add nodev, to block a similar attack where you add a bunch of block devices with 777 permissions, in an attempt to make the block device "/" is mounted from be readable to a user and thus able to read (and write) any file on the host.
Re:German BSI withholds Truecrypt security report by unixreply55 on Tuesday December 17, 2019 @01:52PM (#21817154)
I didn't know of this attack, sounds interesting :) can you explain in a bit more detail how it would work?
Re:German BSI withholds Truecrypt security report by aasasd on Tuesday December 17, 2019 @04:05PM (#21818823)
Sounds like it works exactly as described by cyphar. The OS trusts permissions that are set on the files, so if you slip it a device ‘file’ writable by anyone then it will let mere users write to the device even if it points to the root filesystem. Devices are denoted simply by numbers on the file inode in the filesystem, it's not difficult to make one that corresponds to the real disk drive.
Re:German BSI withholds Truecrypt security report by cyphar on Tuesday December 17, 2019 @06:04PM (#21819936)
Right, the attack would be something like:

    # On a machine where you have root, do the following in a Truecrypt volume:
    for maj in {0..4096}; do
      for min in {0..1048576}; do
        mknod block-${maj}.${min} b $maj $min
        mknod char-${maj}.${min} c $maj $min
      done
    done
    chmod a+rwx {block,char}-*
All devices which represent a block device (namely, hard drives and similar media) have some (major, minor) value. There are currently[1] 4096 values for the major number 1048576 for the minor number, so we can just create all of them (or you could just create the first 256 since it's very rare for the number to go above that).

And now when you mount the volume on a machine (with needing root, because that's what TrueCrypt allows you to do), the mounted filesystem contains every possible block and character device with read/write permissions for every user on the system. Therefore, one of the block devices (you can check by doing an ls in /dev) will correspond to the root filesystem and the user can now read or write to it directly.

By adding "nodev", the kernel will not permit any user to access character or block device inodes on the filesystem (even if you would normally have permissions).

[1]: https://elixir.bootlin.com/linux/v5.4.3/source/include/linux...

Re:German BSI withholds Truecrypt security report by gruez on Monday December 16, 2019 @04:52PM (#21807669)
>Aren't all permission-supporting filesystems vulnerable to this if mounting by a user is permitted?

Technically, it's only vulnerable on operating systems that support setuid style permissions. That doesn't exist on windows, for example.

Re:German BSI withholds Truecrypt security report by tinus_hn on Tuesday December 17, 2019 @12:53PM (#21816333)
If you’re mounting a filesystem provided by the user you’re supposed to use the nosuid option which tells the kernel to ignore setuid bits on the filesystem.
Re:German BSI withholds Truecrypt security report by lima on Monday December 16, 2019 @01:01PM (#21805264)
This is also nice for breaking in/out of Docker containers with bind mounts.
Re:German BSI withholds Truecrypt security report by cyphar on Monday December 16, 2019 @02:58PM (#21806563)
Not if you use user namespaces (which you really should).
Re:German BSI withholds Truecrypt security report by lima on Tuesday December 17, 2019 @06:32AM (#21812571)
Which is not the default that Docker uses :(

One more reason to switch to podman, which has sane defaults.

Re:German BSI withholds Truecrypt security report by cyphar on Tuesday December 17, 2019 @08:29AM (#21813215)
Or LXD/LXC which can run containers such that they are isolated from one another in terms of their id mappings.
Re:German BSI withholds Truecrypt security report by zmzrr on Monday December 16, 2019 @11:19AM (#21804131)
Isn't Veracrypt just a container, like a hard disk? Why should Veracrypt care about what filesystem you store inside of a container, and whatever you do with its permissions?
Re:German BSI withholds Truecrypt security report by bonzini on Monday December 16, 2019 @10:38AM (#21803784)
... if you have sudo.
Re:German BSI withholds Truecrypt security report by aasasd on Monday December 16, 2019 @10:47AM (#21803857)
Where does sudo come in with suid executables? Especially since afaik sudo depends on suid in the first place.
Re:German BSI withholds Truecrypt security report by jlgaddis on Monday December 16, 2019 @11:49AM (#21804443)
One might be granted privileges to mount the filesystem using sudo, but not privileges to run other commands.

If the filesystem just mounted has setuid executables, however, the user can then get around their lack of additional sudo privileges by running the setuid executables.

Although most people seem to use sudo to allow a user to run anything, that's really not how it was intended to be used.

Re:German BSI withholds Truecrypt security report by aasasd on Monday December 16, 2019 @12:04PM (#21804600)
That's somewhat different from the Veracrypt case, afaict. And it doesn't seem like this is what bonzini meant by mentioning sudo.
Re:German BSI withholds Truecrypt security report by bonzini on Monday December 16, 2019 @05:54PM (#21808399)
You still need to gain the privilege to mount filesystems in order to exploit the flaw. So it is a privilege escalation in that you can go from "sudo mount" to a root shell, but it is: 1) not exploitable unless you have sudo 2) pointless if you are authorized to "sudo" any command.
Re:German BSI withholds Truecrypt security report by jeroenhd on Monday December 16, 2019 @06:08PM (#21808548)
This depends on the setup really; it's possible to limit sudo access to only some commands, like so:

  %veracryptusers ALL=(root) NOPASSWD:/usr/bin/veracrypt
An inexperienced systems administrator might use this to allow some users access to the mount command so that users can use their encrypted USB drives to carry around sensitive data, not realizing that through the intricacies of the Linux filesystem this can lead to privilege escalation.

Such a config would normally give you sudo, but not a root shell; allowing certain users to use ping floods to test the network by giving them access to the ping command as root, for example, would not expose much security risks other than flooding the network.

Re:German BSI withholds Truecrypt security report by aasasd on Monday December 16, 2019 @07:21PM (#21809164)
I see now that you consider sudo necessary for mounting the filesystem, but

a) it seems the point in the report is that Truecrypt allowed to grant this ability without using sudo (I guess either via a daemon or just a setuid executable)

b) iirc in case of other filesystems you can allow users to mount them without being root—which is how removable devices work in unixes. So this goes around the whole sudo/setuid system and probably might be another option for this feature in Truecrypt too.

Lastly, as jeroenhd noted, even with sudo the root privilege can be granted for a script that mounts a volume, or for one particular command. Sudo, by default, doesn't allow the user to add options to the command specified in `sudoers`.

Re:German BSI withholds Truecrypt security report by kuschku on Monday December 16, 2019 @10:23AM (#21803647)
Ouch.