oss-sec mailing list archives

Re: s/party/hack like it's 1999


From: David Holland <dholland-oss-security () netbsd org>
Date: Sat, 26 Sep 2015 22:26:09 +0000

On Mon, Sep 21, 2015 at 09:02:27PM +0200, Florian Weimer wrote:
I have been arguing for years (but without success) that vt bomb
injection needs to be blocked in the tty driver. This problem
(corruption of concurrent UTF-8 streams) needs to be too, as a matter
of correctness and not even security.

How exactly would a tty driver "block" anything like this?

Avoiding in-band signaling in the first place. :-/

Yes, that.

A tty driver never looks at the data stream in the kernel, as that
way lies madness...

Surely there is a way to prevent two writes from interleaving?  For
writes to files in O_APPEND mode, this already happens, doesn't it?

Theoretically each write() call is supposed to be atomic; there are
presumably some limits to that in practice, especially on ptys (like
PIPE_BUF is the limit for pipes) but this doesn't help if programs
emit partial characters, as is (in general) likely. Programs that use
stdio to write to stdout are ok because stdio line-buffers stdout when
it's a tty; but that doesn't help with stderr, or with programs that
ship text around in arbitrary-sized blocks, or programs in cbreak
mode, or if you're logged in across a network that hiccups
occasionally. (Or can be made to hiccup on purpose.)

ISTM that for safety the tty driver is going to have to know about
multibyte encodings and not let through partial characters; this is an
enormous can of worms.

(but, let's not overreact; it's always been possible to blat out
sequences beginning with [ and hope that they'll be inserted right
after someone else's ESC.)

-- 
David A. Holland
dholland () netbsd org


Current thread: