Snap seccomp bblacklist for tiocsti can be circumvented Vulnerability / Exploit
/
/
/
Exploits / Vulnerability Discovered : 2019-03-22 |
Type : dos |
Platform : linux
This exploit / vulnerability Snap seccomp bblacklist for tiocsti can be circumvented is for educational purposes only and if it is used you will do on your own risk!
[+] Code ...
/*
snap uses a seccomp filter to prevent the use of the TIOCSTI ioctl; in the
source code, this filter is expressed as follows:
# TIOCSTI allows for faking input (man tty_ioctl)
# TODO: this should be scaled back even more
ioctl - !TIOCSTI
In the X86-64 version of the compiled seccomp filter, this results in the
following BPF bytecode:
[...]
0139 if nr == 0x00000010: [true +0, false +3]
013b if args[1].high != 0x00000000: [true +205, false +0] -> ret ALLOW (syscalls: ioctl)
0299 if args[1].low == 0x00005412: [true +111, false +112] -> ret ERRNO
030a ret ALLOW (syscalls: ioctl)
[...]
This bytecode performs a 64-bit comparison; however, the syscall entry point for
ioctl() is defined with a 32-bit command argument in the kernel:
This means that setting a bit in the high half of the command parameter will
circumvent the seccomp filter while being ignored by the kernel.
This can be tested as follows on Ubuntu 18.04. You might have to launch the
GNOME calculator once first to create the snap directory hierarchy, I'm not
sure.