Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚠️DANGER: Vulnerable by design! (on any system supporting TIOCSTI, such as Linux) #23

Open
jpouellet opened this issue Sep 17, 2018 · 6 comments

Comments

@jpouellet
Copy link

jpouellet commented Sep 17, 2018

Hello,

I regret to inform you that any program which crosses privilege boundaries in the manner this program does without also restricting access to the parent TTY (which seems to be the main design (mis-)feature of this program), is fundamentally vulnerable by design on any system allowing the TIOCSTI ioctl on said TTY.

See: https://www.openwall.com/lists/oss-security/2017/06/03/9
See also: https://ruderich.org/simon/notes/su-sudo-from-root-tty-hijacking
See also: tianon/gosu#37

Linux still supports TIOCSTI, and refuses to change due to its unfortunate posture of tying its own hands to keep backwards-compatibility with userspace forever. OpenBSD has removed it, but your users are probably mainly Linux people.

One way to address this is to do exactly as you currently complain about other programs doing (parent staying alive to proxy io), which seems to be the entire reason you wrote this. There are non-portable ways of filtering TIOCSTI without proxying io and otherwise breaking parent TTY manipulation (see util-linux/util-linux@8e49250, for example), but this will not necessarily work on all systems, and IMO manipulation of TTYs across privilege boundaries sounds more like a bug than a feature to begin with as it may allow intended-to-be-deprivileged code from triggering undefined behavior in the parent context.

Consider adding an appropriately scary warning to README.md, and notifying any downstream consumers you are aware of.

Sorry to be the bearer of bad news.

@jpouellet
Copy link
Author

Also, sorry about the clickbaity title. I just wanted to make sure this wouldn't go unnoticed, and hopefully reduce the chance of people continuing to use this without being aware of and considering its limitations. No offense intended.

@jpouellet jpouellet changed the title DANGER: Vulnerable by design! (on any system supporting TIOCSTI, such as Linux) ⚠️DANGER: Vulnerable by design! (on any system supporting TIOCSTI, such as Linux) Sep 17, 2018
@ncopa
Copy link
Owner

ncopa commented Sep 19, 2018

I think we should add a big warning in the README. Care to create a PR?

@jakub-bochenski
Copy link

There is a more detailed discussion and links on the gosu bugreport: tianon/gosu#37

@theAkito
Copy link

theAkito commented Feb 26, 2023

Provide a simple CONFIG and global sysctl to disable this for the system
builders who have wanted this functionality for literally decades now,
much like the ldisc_autoload CONFIG and sysctl.

Can we just add the solution referred to in the section of the comment quoted above to the warning & consider it done?

@kriansa
Copy link

kriansa commented Jun 13, 2023

Provide a simple CONFIG and global sysctl to disable this for the system
builders who have wanted this functionality for literally decades now,
much like the ldisc_autoload CONFIG and sysctl.

Can we just add the solution referred to in the section of the comment quoted above to the warning & consider it done?

For a subset of users, yes, as the new config (dev.tty.legacy_tiocsti) is only available on Kernel >= 6.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants