Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: OpenSSH: Dev

Replace uid==0 tests with capability checks

 

 

OpenSSH dev RSS feed   Index | Next | Previous | View Threaded


vinschen at redhat

Mar 11, 2009, 1:26 AM

Post #1 of 9 (1311 views)
Permalink
Replace uid==0 tests with capability checks

Hi,

This time with it's own subject:

What's still missing in OpenSSH is code which abstracts the idea of the
root user to the idea of a user with certain privileges. At least
Linux/Solaris/Cygwin/Windows allow to specify finer grained user rights,
so that certain types of tasks are not necessarily run by the root user.
In case of Cygwin/Windows there isn't even a root user, just users with
certain privileges. Given that, the hardcoded checks for uid == 0 don't
make sense or rather, are too bulky in a couple of environments. To
reiterate an idea I'm proposing for quite some time now:

Instead of checks as

if (getuid() == 0)
do_foo_bar ();
else
EEEEK!

openssh should have checks along the lines of

if (uid_has_capability (getuid (), CAP_foo_bar))
do_foo_bar ();
else
EEEEK!

The function uid_has_capability() would be quite simple on systems
which don't have fine-grained user rights:

int
uid_has_capability (uid_t uid, int capability)
{
return uid == 0;
}

but could be much more elaborate on other platforms like Linux, Solaris,
or Cygwin. And, again, I'm willing to help with this stuff in terms of
coding.


Corinna

--
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev [at] mindrot
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev


scott_n at xypro

Mar 12, 2009, 9:56 AM

Post #2 of 9 (1260 views)
Permalink
RE: Replace uid==0 tests with capability checks [In reply to]

>
> What's still missing in OpenSSH is code which abstracts the idea of
the
> root user to the idea of a user with certain privileges. At least
> Linux/Solaris/Cygwin/Windows allow to specify finer grained user
> rights,
> so that certain types of tasks are not necessarily run by the root
> user.
> In case of Cygwin/Windows there isn't even a root user, just users
with
> certain privileges. Given that, the hardcoded checks for uid == 0
> don't
> make sense or rather, are too bulky in a couple of environments. To
> reiterate an idea I'm proposing for quite some time now:
>
> Instead of checks as
>
> if (getuid() == 0)
> do_foo_bar ();
> else
> EEEEK!
>
> openssh should have checks along the lines of
>
> if (uid_has_capability (getuid (), CAP_foo_bar))
> do_foo_bar ();
> else
> EEEEK!
>
> The function uid_has_capability() would be quite simple on systems
> which don't have fine-grained user rights:
>
> int
> uid_has_capability (uid_t uid, int capability)
> {
> return uid == 0;
> }
>
> but could be much more elaborate on other platforms like Linux,
> Solaris,
> or Cygwin. And, again, I'm willing to help with this stuff in terms
of
> coding.
>

I'd love to see something like this. I'm on an oddball system
(Tandem/HP NonStop),
where root isn't UID 0, and other stuff has ACL/permissions.


_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev [at] mindrot
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev


vinschen at redhat

Mar 18, 2009, 8:08 AM

Post #3 of 9 (1237 views)
Permalink
Re: Replace uid==0 tests with capability checks [In reply to]

Is there any chance this can be discussed at one point?

On Mar 11 09:26, Corinna Vinschen wrote:
> Hi,
>
> This time with it's own subject:
>
> What's still missing in OpenSSH is code which abstracts the idea of the
> root user to the idea of a user with certain privileges. At least
> Linux/Solaris/Cygwin/Windows allow to specify finer grained user rights,
> so that certain types of tasks are not necessarily run by the root user.
> In case of Cygwin/Windows there isn't even a root user, just users with
> certain privileges. Given that, the hardcoded checks for uid == 0 don't
> make sense or rather, are too bulky in a couple of environments. To
> reiterate an idea I'm proposing for quite some time now:
>
> Instead of checks as
>
> if (getuid() == 0)
> do_foo_bar ();
> else
> EEEEK!
>
> openssh should have checks along the lines of
>
> if (uid_has_capability (getuid (), CAP_foo_bar))
> do_foo_bar ();
> else
> EEEEK!
>
> The function uid_has_capability() would be quite simple on systems
> which don't have fine-grained user rights:
>
> int
> uid_has_capability (uid_t uid, int capability)
> {
> return uid == 0;
> }
>
> but could be much more elaborate on other platforms like Linux, Solaris,
> or Cygwin. And, again, I'm willing to help with this stuff in terms of
> coding.
>
>
> Corinna
>
> --
> Corinna Vinschen
> Cygwin Project Co-Leader
> Red Hat
> _______________________________________________
> openssh-unix-dev mailing list
> openssh-unix-dev [at] mindrot
> https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev

--
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev [at] mindrot
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev


jmknoble at pobox

Mar 18, 2009, 4:27 PM

Post #4 of 9 (1231 views)
Permalink
Re: Replace uid==0 tests with capability checks [In reply to]

On 2009-03-18 10:08, Corinna Vinschen wrote:
: Is there any chance this [the below] can be discussed at one point?

I'm all for it.

: On Mar 11 09:26, Corinna Vinschen wrote:
: > What's still missing in OpenSSH is code which abstracts the idea of the
: > root user to the idea of a user with certain privileges. [...]
: > the hardcoded checks for uid == 0 don't
: > make sense or rather, are too bulky in a couple of environments.

[...]

: > openssh should have checks along the lines of
: >
: > if (uid_has_capability (getuid (), CAP_foo_bar))
: > do_foo_bar ();
: > else
: > EEEEK!

--
jim knoble | jmknoble [at] pobox | http://www.pobox.com/~jmknoble/
(GnuPG key ID: C6F31FFA >>>>>> http://www.pobox.com/~jmknoble/keys/ )
(GnuPG fingerprint: 99D8:1D89:8C66:08B5:5C34::5527:A543:8C33:C6F3:1FFA)
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev [at] mindrot
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev


scott_n at xypro

Mar 18, 2009, 4:42 PM

Post #5 of 9 (1238 views)
Permalink
RE: Replace uid==0 tests with capability checks [In reply to]

> On 2009-03-18 10:08, Corinna Vinschen wrote:
> : Is there any chance this [the below] can be discussed at one point?
>
> I'm all for it.

At the risk of sounding AOL-ish, me too.
I'm working on a non-standard unix-like system (HP/Tandem Nonstop) and
things
are sometimes a bit odd/weird there w.r.t. permissions and uids.

> : On Mar 11 09:26, Corinna Vinschen wrote:
> : > What's still missing in OpenSSH is code which abstracts the idea
of
> the
> : > root user to the idea of a user with certain privileges. [...]
> : > the hardcoded checks for uid == 0 don't
> : > make sense or rather, are too bulky in a couple of environments.
>
> [...]
>
> : > openssh should have checks along the lines of
> : >
> : > if (uid_has_capability (getuid (), CAP_foo_bar))
> : > do_foo_bar ();
> : > else
> : > EEEEK!
>

_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev [at] mindrot
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev


peter at stuge

Mar 18, 2009, 6:08 PM

Post #6 of 9 (1222 views)
Permalink
Re: Replace uid==0 tests with capability checks [In reply to]

Corinna Vinschen wrote:
> Is there any chance this can be discussed at one point?

I approve too, even though I am not really affected.

Maybe it could take advantage of capabilities in Linux though.


//Peter
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev [at] mindrot
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev


vinschen at redhat

Mar 19, 2009, 2:42 AM

Post #7 of 9 (1226 views)
Permalink
Re: Replace uid==0 tests with capability checks [In reply to]

On Mar 19 02:08, Peter Stuge wrote:
> Corinna Vinschen wrote:
> > Is there any chance this can be discussed at one point?
>
> I approve too, even though I am not really affected.
>
> Maybe it could take advantage of capabilities in Linux though.

That's the idea. I'm not asking for Cygwin's benefit alone. A couple
of OSes have finer grained capabilities. And, as far as I'm concerned,
code like this:

if (uid_has_capability(getuid(), CAP_SWITCH_USER))

is much more instructive than

if (getuid() == 0)

Likewise, this:

if (channel_input_port_forward_request(
uid_has_capability(s->pw->pw_uid, CAP_RSVD_PORTS),
options.gateway_ports) < 0) {

is more instructive than this:

if (channel_input_port_forward_request(s->pw->pw_uid == 0,
options.gateway_ports) < 0) {

So, in my eyes this change would make the code clearer even in the
upstream OpenBSD-only code. Given that the uid_has_capability function
would be a no-brainer on BSD and other systems having no capabilities
model

int
uid_has_capability (uid_t uid, int capability __attribute ((unused)))
{
return uid == 0;
}

I only see advantages here.


Corinna

--
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev [at] mindrot
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev


peter at stuge

Mar 19, 2009, 4:32 AM

Post #8 of 9 (1230 views)
Permalink
Re: Replace uid==0 tests with capability checks [In reply to]

Corinna Vinschen wrote:
> > > Is there any chance this can be discussed at one point?
> >
> > I approve too, even though I am not really affected.
>
> So, in my eyes this change would make the code clearer even in the
> upstream OpenBSD-only code.
..
> I only see advantages here.

I agree. I guess produce the patch and push for inclusion..

No real protests yet and the idea has been around for long.


//Peter
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev [at] mindrot
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev


vinschen at redhat

Mar 20, 2009, 1:45 AM

Post #9 of 9 (1213 views)
Permalink
Re: Replace uid==0 tests with capability checks [In reply to]

On Mar 19 12:32, Peter Stuge wrote:
> Corinna Vinschen wrote:
> > > > Is there any chance this can be discussed at one point?
> > >
> > > I approve too, even though I am not really affected.
> >
> > So, in my eyes this change would make the code clearer even in the
> > upstream OpenBSD-only code.
> ..
> > I only see advantages here.
>
> I agree. I guess produce the patch and push for inclusion..
>
> No real protests yet and the idea has been around for long.

Right. The problem is, I already created a patch a couple of years ago
which has just gone stale. Nothing came out of it. If I *knew* it's
not futile work, I'd create another patch happily. That's why I hope
for some definitive answer from the core developers beforehand.


Corinna

--
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev [at] mindrot
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev

OpenSSH dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.