From: Solar Designer <solar@openwall.com>
To: Willy Tarreau <w@1wt.eu>
Cc: Ernie Petrides <petrides@redhat.com>, linux-kernel@vger.kernel.org
Subject: Re: printk()s of user-supplied strings (Re: [PATCH] binfmt_elf.c : the BAD_ADDR macro again)
Date: Sun, 27 Aug 2006 03:13:14 +0400 [thread overview]
Message-ID: <20060826231314.GA24109@openwall.com> (raw)
In-Reply-To: <20060826082236.GA29736@1wt.eu>
On Sat, Aug 26, 2006 at 10:22:36AM +0200, Willy Tarreau wrote:
> I think that we are trying to protect against :
> 1) local users faking kernel messages. (eg: disk errors, oopses, ...)
> 2) local users changing console settings (eg: black on black)
> 3) local users corrupting the log reader's terminal
>
> 1) is relatively easy to do, basically if we escape \b, \r and \n, it will
> become hard to produce fake logs.
I think it's just '\n'; other characters that you've mentioned achieve
(1) by exploiting (2).
> 2) should be as easy. I'm not aware of any way to change a local console
> setting with non-control chars (>= 0x20)
...except that there are control chars above 0x20:
http://archives.neohapsis.com/archives/linux/lsap/2000-q2/0151.html
(scroll down to the end). One thing that I did not mention in that older
posting is that, IIRC, according to my vt420 manual, macro recording and
playback may be invoked via the 8-bit controls (in some terminal modes).
This is not limited to real (hardware) terminals; of the 8-bit controls,
at least CSI (0x9b) is typically supported by terminal emulators. Even
our linux/drivers/char/console.c supports it.
Although most terminal emulators don't appear to allow for macro
recording/playback to be requested with control chars, they do support
status requests - to which they respond with certain easy-to-guess
strings (an attack would be to create a script in PATH under that name -
yes, this has multiple prerequisites).
So I think that we should escape chars in the 0x7f to 0x9f range as well.
> 3) is a problem of interpretation between the program storing the logs on
> disk and the one retrieving them and showing them to the user. It's by no
> way a kernel problem.
I'd agree, but what about dmesg? It reads directly from the kernel and
it is commonly run with output to a tty. OK, maybe dmesg (the userspace
program) should be fixed.
> Thus, 1 and 2 could be merged by escaping ...
Yes.
In fact, if you do the escaping right when substituting values for "%s",
then you'll cover (3) as well.
You probably don't want to modify the behavior of vsnprintf() for all of
the kernel; you only want to affect its behavior when called from
printk(). So you might need to be calling a private function instead,
which would accept an additional argument, and make vsnprintf() a
wrapper around that function. Yes, that would be a hack.
Alternatively, you can do the escaping right after the vsnprintf() call,
but then it will affect more than just "%s". I am not sure whether this
is acceptable.
> I don't think we will have to escape the escape char itself. I know that
> this is dirty and will not make it reliable to reverse the string, but
> we need to keep in mind that what we are trying to do is not preventing
> users from hiding their programs' exact names, but preventing them from
> faking logs. Moreover, sysklogd does not escape the escape char either,
> so we are not introducing a new weakness by doing this.
I agree.
Thanks,
Alexander
next prev parent reply other threads:[~2006-08-26 23:17 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-20 2:04 [PATCH x7] misc fixes from 2.4.33-ow1 Solar Designer
2006-08-20 9:15 ` [PATCH] binfmt_elf.c : the BAD_ADDR macro again Willy Tarreau
2006-08-20 15:51 ` Solar Designer
2006-08-20 16:23 ` Willy Tarreau
2006-08-21 20:35 ` Ernie Petrides
2006-08-21 21:11 ` Willy Tarreau
2006-08-21 23:36 ` Ernie Petrides
2006-08-22 3:07 ` printk()s of user-supplied strings (Re: [PATCH] binfmt_elf.c : the BAD_ADDR macro again) Solar Designer
2006-08-22 20:23 ` Ernie Petrides
2006-08-22 20:34 ` printk()s of user-supplied strings Willy Tarreau
2006-08-24 16:44 ` printk()s of user-supplied strings (Re: [PATCH] binfmt_elf.c : the BAD_ADDR macro again) Solar Designer
2006-08-24 16:46 ` Willy Tarreau
2006-08-26 2:29 ` Solar Designer
2006-08-26 8:22 ` Willy Tarreau
2006-08-26 23:13 ` Solar Designer [this message]
2006-08-27 20:04 ` printk()s of user-supplied strings Willy Tarreau
2006-08-28 1:52 ` Solar Designer
1970-01-01 0:16 ` Pavel Machek
2006-08-28 8:02 ` Willy Tarreau
2006-08-28 11:17 ` Krzysztof Halasa
2006-08-30 6:15 ` Willy Tarreau
2006-08-28 17:35 ` Valdis.Kletnieks
2006-08-22 4:36 ` [PATCH] binfmt_elf.c : the BAD_ADDR macro again Willy Tarreau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060826231314.GA24109@openwall.com \
--to=solar@openwall.com \
--cc=linux-kernel@vger.kernel.org \
--cc=petrides@redhat.com \
--cc=w@1wt.eu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome