Bug Description

Hello Calibre,

There are 5 separate vulnerabilities with the calibre SUID mount helper:

These vulnerabilities concern /src/calibre/ devices/ linux_mount_ helper. c.

1. Ability to create root owned directory anywhere. The mount helper calls mkdir(argv[3], ...) on line 48.

2. Ability to remove any empty directory on the system. For example, line 172.

3. Ability to create and delete user_controlled _dir/.created_ by_calibre_ mount_helper anywhere on the filesystem, lines 55 and 165.

4. Ability to inject arguments into 'mount' being exec'd. On lines 78, 81, and 83, the final two arguments to mount are user controlled. On lines 1033, 106, 108, 139, and 141, the last argument to unmount/eject is user controlled. The "exists()" check can be subverted via race condition or by creating an existing file in the working directory with a filename equal to the desired injected argument.

5. Ability to execute any program as root. The mount helper makes use of execlp on lines 78, 81, 83, 103, 106, 108, 139, and 141, and the first argument does not start with a / character. Because of this, execlp will search PATH for the executable to run. PATH is user controlled, and thus it is trivial to write a program that spawns a shell and give it "mount" as a filename, and direct PATH to its directory. A proof of concept of this is attached.

Thanks,

Jason Donenfeld