From: Mike Kazantsev <mike_kazantsev@fraggod.net>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] Restricting Firefox website access
Date: Wed, 14 Jan 2009 06:52:57 +0500 [thread overview]
Message-ID: <20090114065257.3c11748f@coercion> (raw)
In-Reply-To: <200901131933.29930.michaelkintzios@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3054 bytes --]
On Tue, 13 Jan 2009 19:33:14 +0000
Mick <michaelkintzios@gmail.com> wrote:
> On Sunday 11 January 2009, Mike Kazantsev wrote:
>
> > If blocking every possible user is too much trouble or you wish to
> > block just firefox, but not wget to http port for _all_ users (not the
> > same case as emerge from root) you can write a simple SUID wrapper for
> > firefox binary, which changes group to restricted one (but leaves uid
> > and home unchanged),
>
> Is this like creating a symlink to the original FF binary which you have moved
> somewhere else? Can you please explain?
>
> > then launches true firefox binary, to which only
> > that group has access.
No, it's not.
Symlinks aren't made for that purpose, and should be treated just linke
the object they point to, without messing with anything on the way.
As a rule, symlink permissions should not be changed, and in most cases
it's not supported by OS anyway.
What I mean is a wrapper binary. It can be either a native binary file
(like C compiled into ELF) or a script with SUID interpreter (like suid
perl).
I haven't tried this trick with firefox myself, but I don't see why it
shouldn't work here.
For example:
--- ff_wrapper.c
int main(int argc, char **argv)
{
/* Set group to 'ff-users' (gid = 400, for this example) */
setegid(400);
setgid(400);
/* Drop root privileges */
seteuid(getuid());
/* Start real firefox */
execv("/usr/bin/_firefox", argv);
}
--- ff_wrapper.c
You can compile it with 'gcc ff_wrapper.c -o ff_wrapper'.
Then do:
mv /usr/bin/{,_}firefox \
&& chown root:nogroup /usr/bin/_firefox \
&& chmod 0750 /usr/bin/_firefox \
&& mv ff_wrapper /usr/bin/firefox \
&& chown root:root /usr/bin/firefox \
&& chmod 6555 /usr/bin/firefox
So firefox can only be launched directly by specific group (with gid=400
in this example, which should be created for this purpose), and the
wrapper ensures that when typing 'firefox' every user will be launching
it as a member of that group.
After that you can limit this group as you like.
Note that for all this to make sense, no user (firefox user, anyway)
should belong to the aforementioned group, or they'll be able to run
'/usr/bin/_firefox' directly, having effective gid that's written in
passwd (like 'someuser', usually the same as login name with linux).
It's a bit more complicated with the scripts (bash, for example),
because in that case it's an interpreter binary that gets launched
(i.e. /bin/bash, which then just reads the script), so the interpreter
should have suid flag, and that's a huge security gap, since every user
having access to it will be able to abuse root privileges.
There are, however, interpreters like perl, which, granted suid bit,
will shed all the privileges if the script they're trying to execute
doesn't have suid bit set on it, but even then there are whole lot of
things to check, so no one'll be able to abuse the script itself.
--
Mike Kazantsev // fraggod.net
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
next prev parent reply other threads:[~2009-01-14 1:55 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-07 21:44 [gentoo-user] Restricting Firefox website access Grant
2009-01-07 21:54 ` Paul Hartman
2009-01-08 20:57 ` Kyle Bader
2009-01-09 18:40 ` Grant
2009-01-09 19:05 ` Alan McKinnon
2009-01-09 19:32 ` Grant
2009-01-09 20:58 ` Kyle Bader
2009-01-09 21:07 ` Nick Cunningham
2009-01-09 21:23 ` Alan McKinnon
2009-01-10 10:14 ` Peter Humphrey
2009-01-10 14:35 ` Matt Causey
2009-01-10 17:50 ` Grant
2009-01-10 19:35 ` Matt Causey
2009-01-10 5:18 ` Mike Kazantsev
2009-01-10 17:48 ` Grant
2009-01-11 2:05 ` Mike Kazantsev
2009-01-11 2:27 ` Grant
2009-01-13 19:33 ` Mick
2009-01-14 1:52 ` Mike Kazantsev [this message]
2009-01-17 5:34 ` Grant
2009-01-17 6:30 ` Mike Kazantsev
2009-01-17 9:50 ` Peter Humphrey
2009-01-17 8:47 ` Alan McKinnon
2009-01-17 18:12 ` Grant
2009-01-17 18:21 ` Alan McKinnon
2009-01-17 18:53 ` Matt Harrison
2009-01-17 18:24 ` Grant
2009-01-17 15:43 ` Stroller
2009-01-17 16:32 ` [gentoo-user] " Harry Putnam
2009-01-17 17:40 ` Grant
2009-01-17 19:02 ` Harry Putnam
2009-01-17 17:32 ` [gentoo-user] " Grant
2009-01-23 11:04 ` Matt Causey
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=20090114065257.3c11748f@coercion \
--to=mike_kazantsev@fraggod.net \
--cc=gentoo-user@lists.gentoo.org \
/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