hilbix / suid

run programs and scripts suid
Other
0 stars 0 forks source link

New flag `A` to pass env-vars unchanged #17

Open hilbix opened 2 years ago

hilbix commented 2 years ago

Currently most environment variables are prefixed with SUID_ to disarm unknown possible future environmental bombs like LD_PRELOAD in the past. But it is a PITA to move all necessary variables back, just in case we need them as-is (and the program is secure like statically compiled).

Hence proposal for a new way to handle environment:

Alternatives:

Rationale:

hilbix commented 2 years ago

To be more specific:

Additionally AB should NOT work by default, such that if you add this, the command is disabled until explicitly enabled.

Hence we need to invent some way to silence this warning. The idea here is:

I am currently undecided how to archive that. Here is a plan:

Two things are important:

Either it becomes part of the line (like being added to the flags field)
or it must be added to the next line as a comment (looks like #HASH#)

I like the latter approach, as this does not need to change the line (which might be error prone) and can easily be scripted (inserting a line is not a big problem). Calculating the hash code also can be implemented in linereader on the fly (if needed).

The "next line" approach also can support #HASH#HASH#HASH# to enable variants of a line. This is good for testing and development, when you often change the flags (or other aspects) and do not want to be disturbed by the line become disabled.

Alternatively it can be "previous line", such that we just can remember the previous line in some buffer.

This even leaves opportunities like passing that line into the environment, such that the called script is able to verify that it is legit.

hilbix commented 2 years ago

We cannot use C as it is already taken by arg0 given to cmd is first arg given to 'suid'

Free letters are

I vote for V, as this puts something "verbosely" into environment. You can also read this as "verify".

hilbix commented 1 year ago

List of possibly exploitable environment variables:

List of known to be dangerous environment variables:

List of highly dangerous environment variables:

I cannot find information about this in the glibc-doc, instead see LFS: http://www.scratchbox.org/documentation/general/tutorials/glibcenv.html

Lists from glibc (is there a way to automate this?):

Note that suid never will detect presence of files like /etc/suid-debug, because it always must behave 100% predicatble and such settings not only affects the debuged part but everything.

To enable debugging you must alter /etc/suid.conf or /etc/suid.conf.*/*.conf files.

Notes:

hilbix commented 1 year ago

Due to CVE-2023-4911 I changed my mind:

Apparently it is far too dangerous to pass unknown variables to a script. Hence the new plan is twofold:

So this probably better:

Notes:

Hence the updated idea:

Rationale:

For Authentication, suid should pass additional environment variables:

But those should go into another issue ..