PTY DOS vulnerability?
Has someone considered PTYs as a possible attack vector for DOS attacks? Correct me if I'm wrong, but cannot someone just open all available PTYs on a console-less server and make everyone unable to log in?
I mean, what if eg. apache is hacked, and the first thing the attacker does is to tie up all PTYs, so that noone can log in to correct the situation while the attacker can go about his business? Then the only possible solution would be to reboot the server, which might very well not be desirable.
If you want proof of concept code, look at
http://www.dolda2000.cjb.net/~fredrik/ptmx.c
I successfully ran this on one of my servers which effectively disabled anyone from logging in via SSH.
Shouldn't PTYs be a per-user resource limit?
Someone must have thought of this before me, right? How am I wrong?
Fredrik Tolf
Quoted 1 line · Fredrik Tolf
Shouldn't PTYs be a per-user resource limit?
It depends to what degree you consider your users hostile. But yes its possibly one of the things to do per user counting on.
I'll summarize some of the answers:
Quoted 5 lines · Alan Cox
Quoted 1 line · Fredrik Tolf
Shouldn't PTYs be a per-user resource limit?
It depends to what degree you consider your users hostile. But yes its possibly one of the things to do per user counting on.
It isn't necessarily an entitled user; see below. But even if it is, I think it should be able to limit it, just as it is possible to put a limit on processes.
Quoted 9 lines · Marcelo Bezerra
Quoted 1 line · Fredrik Tolf
Shouldn't PTYs be a per-user resource limit?
This would help, but not solve.
Once he roots your box, he can easly change the script to setuid each uid possible and request all ptys it can.
Or he could run it as root, without the limit.
That is provided that he is able to root the system. Take for example Apache, a program that is relatively often cracked. It, as many other programs, doesn't run as root. If the attacker could tie up all PTYs, though, he could go on his business (extracting confidential information, subnet scanning, etc.) without root being able to log in to stop him. Instead, the admimistrator might have to call the datacenter to get them to reboot the box.
Of course, if the attacker is able to root the box, it doesn't help very with a resource limit, but that's more of an issue for the grsecurity project, isn't it?
Quoted 2 lines · Mark Hahn
pty's are not required for ssh activity, though they would make it tricker.
That is true, though, of course. Stupid me not to think about that. However, that means that an administrator who could find himself being under such an attack might not think about it either. Also, from the outside, the ssh client just does nothing, making it look as if the server is unresponsive. Of course, the exact error is logged to the server's syslog, but if you can't view it, then you won't know about it.
So all in all, do you think I should implement a per-user resource limit on PTYs?
Fredrik Tolf
Quoted 10 lines · Fredrik Tolf
That is true, though, of course. Stupid me not to think about that. However, that means that an administrator who could find himself being under such an attack might not think about it either. Also, from the outside, the ssh client just does nothing, making it look as if the server is unresponsive. Of course, the exact error is logged to the server's syslog, but if you can't view it, then you won't know about it.
So all in all, do you think I should implement a per-user resource limit on PTYs?
There are a whole collection of things that would benefit from that kind of management - go for it but make it possible to add other stuff too
Quoted 9 lines · Alan Cox
Quoted 8 lines · Fredrik Tolf
That is true, though, of course. Stupid me not to think about that. However, that means that an administrator who could find himself being under such an attack might not think about it either. Also, from the outside, the ssh client just does nothing, making it look as if the server is unresponsive. Of course, the exact error is logged to the server's syslog, but if you can't view it, then you won't know about it.
Quoted 5 lines
Quoted 2 lines
So all in all, do you think I should implement a per-user resource limit on PTYs?
There are a whole collection of things that would benefit from that kind of management - go for it but make it possible to add other stuff too
In thinking about that...
I would suggest a "resource allocation daemon", where resource is defined to be non-kernel objects - devices mostly... ptys /dev/tape unmounted disks removable media, specific files (not sure how to explain this one though, but controlling access to specified fifo's, memory mapped files? how about printer queues...)
Anything that gets defined as a system wide resource that users may access, but exist as external (to the kernel) objects. It would need some kind of kernel interface, but the access control would be defined outside the kernel.
The most the kernel would need is a "resource controlled by" and "resource allocated to" identification so that the appropriate daemon could be invoked (I do see a possibility for multiple resource allocation daemons).
How about giving each user his own set of virtual ptys?
Quoted 17 lines · Alan Cox
Quoted 3 lines · Fredrik Tolf
That is true, though, of course. Stupid me not to think about that. However, that means that an administrator who could find himself being under such an attack might not think about it either. Also, from the outside, the ssh client just does nothing, making it look as if the server is unresponsive. Of course, the exact error is logged to the server's syslog, but if you can't view it, then you won't know about it.
So all in all, do you think I should implement a per-user resource limit on PTYs?
There are a whole collection of things that would benefit from that kind of management - go for it but make it possible to add other stuff too
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Hello!
Quoted 4 lines · Fredrik Tolf
Has someone considered PTYs as a possible attack vector for DOS attacks? Correct me if I'm wrong, but cannot someone just open all available PTYs on a console-less server and make everyone unable to log in?
ability to login != availability of free ptys.
Quoted 5 lines
I mean, what if eg. apache is hacked, and the first thing the attacker does is to tie up all PTYs, so that noone can log in to correct the situation while the attacker can go about his business? Then the only possible solution would be to reboot the server, which might very well not be desirable.
Nope.
slogin someuser@someserver "/bin/bash -i"
will let you in even if you do not have a single pty free. Try it. If course job control won't work and other minor things are there, but still this is enough to e.g kill apache and all of its children in your case.
Quoted 1 line
Shouldn't PTYs be a per-user resource limit?
This one is still interesting, though.
Bye,
Oleg
Quoted 16 lines · Fredrik Tolf
Has someone considered PTYs as a possible attack vector for DOS attacks? Correct me if I'm wrong, but cannot someone just open all available PTYs on a console-less server and make everyone unable to log in?
I mean, what if eg. apache is hacked, and the first thing the attacker does is to tie up all PTYs, so that noone can log in to correct the situation while the attacker can go about his business? Then the only possible solution would be to reboot the server, which might very well not be desirable.
If you want proof of concept code, look at
http://www.dolda2000.cjb.net/~fredrik/ptmx.c
I successfully ran this on one of my servers which effectively disabled anyone from logging in via SSH.
Quoted 4 lines
Shouldn't PTYs be a per-user resource limit?
Someone must have thought of this before me, right? How am I wrong?
One problem is that ptys are not just "used by the user". Every terminal window opened uses a pty. As does a network connection.
As does "expect" - which is less visible to the user since it is intended to be invisible.
The real question is "how many PTYs should a single user have?" Which then prompts the question "How many concurrent users should there be?"
second, just providing a user limit doesn't prevent a denial of service.. Just have more connections than ptys and you are in the same situation.
Quoted 4 lines · Jesse Pollard
One problem is that ptys are not just "used by the user". Every terminal window opened uses a pty. As does a network connection.
Quoted 8 lines
As does "expect" - which is less visible to the user since it is intended to be invisible.
The real question is "how many PTYs should a single user have?" Which then prompts the question "How many concurrent users should there be?"
second, just providing a user limit doesn't prevent a denial of service.. Just have more connections than ptys and you are in the same situation.
Isn't this something a improved sshd could do? I.e. if the connection using up the last (or one of the last) pty's logs in as non-root - just kill it.
Hello,
Quoted 8 lines
Quoted 2 lines
second, just providing a user limit doesn't prevent a denial of service.. Just have more connections than ptys and you are
in the same
Quoted 1 line
situation.
Isn't this something a improved sshd could do? I.e. if the connection using up the last (or one of the last) pty's logs in as non-root - just kill it.
Why restricting this to SSH ? I mean, this can occur even if you are not using SSH.
Some per-user limit seems to be good... but if we do that, what about also limiting the number of TCP/UDP ports used on a per-user basis ?
In fact, all the resources that are available should be per-user limited if you want to avoid a single one causing a complete DoS...
- CPU
- Memory
- Network
- Disk
- Pty
- ...
Paul
Quoted 11 lines · Helge Hafting
Quoted 10 lines · Jesse Pollard
One problem is that ptys are not just "used by the user". Every terminal window opened uses a pty. As does a network connection.
As does "expect" - which is less visible to the user since it is intended to be invisible.
The real question is "how many PTYs should a single user have?" Which then prompts the question "How many concurrent users should there be?"
Quoted 6 lines
Quoted 2 lines
second, just providing a user limit doesn't prevent a denial of service.. Just have more connections than ptys and you are in the same situation.
Isn't this something a improved sshd could do? I.e. if the connection using up the last (or one of the last) pty's logs in as non-root - just kill it.
and how is it to determine that it is the last?
try two and die if the second fails???
at least one system just creates more ptys...
Followup to: <03070220143600.04348@tabby> By author: Jesse Pollard <[email protected]> In newsgroup: linux.dev.kernel
Quoted 9 lines
Quoted 4 lines
Isn't this something a improved sshd could do? I.e. if the connection using up the last (or one of the last) pty's logs in as non-root - just kill it.
and how is it to determine that it is the last?
try two and die if the second fails???
at least one system just creates more ptys...
Viro's working on it... but as someone else pointed out, "ssh root@machine bash -i" works great without any ptys. You don't have all features, but enough to nuke whatever it is that's eating them all.
-hpa
Signature · 3 lines
<[email protected]> at work, <[email protected]> in private! "Unix gives you enough rope to shoot yourself in the foot." Architectures needed: ia64 m68k mips64 ppc ppc64 s390 s390x sh v850 x86-64