public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: David Smith <dsmith@redhat.com>
To: Pavel Kankovsky <peak@argo.troja.mff.cuni.cz>
Cc: grundy <grundym@us.ibm.com>,
	fedora-security-list@redhat.com,
	        Systemtap List <systemtap@sources.redhat.com>
Subject: Re: Need some security advice for systemtap
Date: Mon, 11 Jun 2007 18:35:00 -0000	[thread overview]
Message-ID: <466D95D4.2090903@redhat.com> (raw)
In-Reply-To: <466D4979.7010306@redhat.com>

David Smith wrote:
> Thanks for the response.  See stuff below.
> 
> Pavel Kankovsky wrote:
>> On Mon, 4 Jun 2007, David Smith wrote:
>>
>>> One of the complaints we get from users is that we require root access
>>> (using sudo) to install/remove the kernel module.  Large enterprise
>>> customers typically don't give out sudo access to all admins.  So, they
>>> would like a way to designate certain scripts/modules as "blessed", and
>>> allow admins/developers/etc. without root access to run those "blessed"
>>> scripts/modules.
>>
>> The easiest way to designate a certain script as "blessed" (and quite
>> difficult to goof it up) is to let a trusted user take the source of the
>> script, check it, make a kernel module, and install it into a designated
>> directory on the target system (or systems), perhaps under
>> "/lib/modules/$version".
> 
> That's my current thinking.  Seems easier from a user's point of view 
> and less fragile from a security point of view.
> 
>> If you are afraid of allowing "untrusted admins" run "sudo modprobe
>> the_probe" (but not afraid of allowing to run your own setuid root
>> program) you can create something like "sustaprun" that will make it
>> possible to load blessed modules (from the designated directory) only.
> 
> That's also my current thinking.  I'm trying to prototype this now.

After playing around with this a bit, here are my thoughts/plans.  We've 
basically got 2 problems:

(1) we want _certain_ non-privileged users
(2) to be able to run _certain_ compiled scripts

Solving both problems would look like this:

(A) A sysadmin would compile systemtap tap scripts into kernel modules 
and store the module in something like 
/etc/systemtap/authorized_modules/$kernel_version/foo.ko

(B) The sysadmin would add anyone needing to be able to run those 
modules to the new 'systemtap' group.

(C) We'll have a new program, staprun.auth, which would be owned by 
root, group systemtap, and file permission would be 04110.  Here's what 
a 'ls -l' would look like on it:

---s--x--- 1 root systemtap {size} {date} /usr/bin/staprun.auth

This would mean that only people in the systemtap group could run 
staprun.auth and it would give them root privileges.  staprun.auth would 
have similar arguments as staprun (more on that in a sec).  staprun.auth 
would make sure the module is coming from 
/etc/systemtap/authorized_modules/$kernel_version and then just exec 
staprun.

(D) staprun.auth will need to disallow certain staprun.auth command-line 
arguments, such as:

- "-c CMD" (Command CMD will be run and the staprun program will exit 
when CMD does).  We can't allow this since CMD would be run as root 
("staprun.auth -c xterm module" would be a quick way to a root shell).

- "-O FILE" (Send output to FILE).  Since FILE gets created as root, 
that could be used by an user seeking to overwrite a file he couldn't 
normally.


 From a users point of view, it would look something like this:

(as root, installing a new module)
# stap -k -p4 -m stap_foo foo.stp
Keeping temporary directory "/tmp/stapygupi1"
# cp /tmp/stapygupil/stap_foo.ko 
/etc/systemtap/authorized_modules/`uname -r`/stap_foo.ko

(as non-root user, running the new module)
$ groups
users systemtap
(ah, good, this user is in the 'systemtap' group, which means he should 
be able to run staprun.auth)
$ staprun.auth stap_foo.ko
(staprun.auth will make sure /etc/systemtap/authorized_modules/`uname 
-r`/stap_foo.ko exists, then exec staprun with that module)

-- 
David Smith
dsmith@redhat.com
Red Hat
http://www.redhat.com
256.217.0141 (direct)
256.837.0057 (fax)

  reply	other threads:[~2007-06-11 18:35 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-04 19:34 David Smith
2007-06-05  8:47 ` Tomasz Chmielewski
2007-06-05 15:09   ` Frank Ch. Eigler
2007-06-05 20:40   ` David Smith
2007-06-05 17:20 ` grundy
2007-06-05 20:56   ` David Smith
2007-06-08 22:00   ` Pavel Kankovsky
2007-06-11 13:09     ` David Smith
2007-06-11 18:35       ` David Smith [this message]
2007-06-11 21:32         ` Frank Ch. Eigler
2007-06-11 22:00           ` David Smith
2007-06-16 15:35             ` Pavel Kankovsky
2007-06-18 19:45               ` David Smith
2007-06-19  0:02                 ` Martin Hunt
2007-06-19 19:57                   ` David Smith
2007-06-19 20:42                     ` Stone, Joshua I
2007-07-01 16:14                       ` Pavel Kankovsky

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=466D95D4.2090903@redhat.com \
    --to=dsmith@redhat.com \
    --cc=fedora-security-list@redhat.com \
    --cc=grundym@us.ibm.com \
    --cc=peak@argo.troja.mff.cuni.cz \
    --cc=systemtap@sources.redhat.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).