Skip to contentSkip to conversation

Possibility to disable icotl TIOCSTI

DISCUSSION Simon Brand 2 participants 2 messages Oct 6, 2022 – Oct 11, 2022

lore
Share & tools
lore
#0 lore raw

Hello,

in the past there have been attempts to restrict the TIOCSTI ioctl. [0, 1] None of them are present in the current kernel.
Since those tries there have been some security issues (sandbox escapes in flatpak (CVE-2019-10063) [2] and snap (CVE 2019-7303) [3], runuser [4], su [5]).

I ask to merge the patches from linux-hardening [6, 7] so users can opt out of this behavior. These patches provide the SECURITY_TIOCSTI_RESTRICT Kconfig (default no) and a tiocsti_restrict sysctl.

Escapes can be reproduced easiliy (on archlinux) via a python script:

```
import fcntl
import termios
with open("/dev/tty", "w") as fd:
    for c in "id\n":
        fcntl.ioctl(fd, termios.TIOCSTI, c)
```
Now run as root:
# su user
$ python3 /path/to/script.py ; exit
uid=0(root) ...

At least to me, this result was not expected.

I asked it before on kernelnewbies mailing list. [8] Please set me in CC, because I have not subscribed to this list.

Best and thank you,
Simon

[0] https://lkml.kernel.org/lkml/CAG48ez1NBnrsPnHN6D9nbOJP6+Q6zEV9vfx9q7ME4Eti-vRmhQ@mail.gmail.com/T/
[1] https://lkml.kernel.org/lkml/[email protected]/T/
[2] https://github.com/flatpak/flatpak/issues/2782
[3] https://wiki.ubuntu.com/SecurityTeam/KnowledgeBase/SnapIoctlTIOCSTI
[4] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=815922
[5] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=628843
[6] https://github.com/anthraxx/linux-hardened/commit/d0e49deb1a39dc64e7c7db3340579
[7] https://github.com/anthraxx/linux-hardened/commit/ea8f20602a993c90125bf08da3989
[8] https://www.spinics.net/lists/newbies/msg64019.html

#1 lore raw
Quoted 8 lines · Simon Brand

Hello,

in the past there have been attempts to restrict the TIOCSTI ioctl. [0, 1] None of them are present in the current kernel.
Since those tries there have been some security issues (sandbox escapes in flatpak (CVE-2019-10063) [2] and snap (CVE 2019-7303) [3], runuser [4], su [5]).

Quoted 4 lines

I ask to merge the patches from linux-hardening [6, 7] so users can opt out of this behavior. These patches provide the SECURITY_TIOCSTI_RESTRICT Kconfig (default no) and a tiocsti_restrict sysctl.

Please send to the hardening mailing list and/or hardening maintainer.

Quoted 30 lines

Escapes can be reproduced easiliy (on archlinux) via a python script:

```
import fcntl
import termios
with open("/dev/tty", "w") as fd:
    for c in "id\n":
        fcntl.ioctl(fd, termios.TIOCSTI, c)
```
Now run as root:
# su user
$ python3 /path/to/script.py ; exit
uid=0(root) ...

At least to me, this result was not expected.

I asked it before on kernelnewbies mailing list. [8] Please set me in CC, because I have not subscribed to this list.

Best and thank you,
Simon

[0] https://lkml.kernel.org/lkml/CAG48ez1NBnrsPnHN6D9nbOJP6+Q6zEV9vfx9q7ME4Eti-vRmhQ@mail.gmail.com/T/
[1] https://lkml.kernel.org/lkml/[email protected]/T/
[2] https://github.com/flatpak/flatpak/issues/2782
[3] https://wiki.ubuntu.com/SecurityTeam/KnowledgeBase/SnapIoctlTIOCSTI
[4] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=815922
[5] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=628843
[6] https://github.com/anthraxx/linux-hardened/commit/d0e49deb1a39dc64e7c7db3340579
[7] https://github.com/anthraxx/linux-hardened/commit/ea8f20602a993c90125bf08da3989
[8] https://www.spinics.net/lists/newbies/msg64019.html

Signature · 1 line
~Randy