Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add security.level for php-fpm #65935 #516

Closed
wants to merge 11 commits into from
Closed

add security.level for php-fpm #65935 #516

wants to merge 11 commits into from

Conversation

krakjoe
Copy link
Member

@krakjoe krakjoe commented Oct 31, 2013

https://bugs.php.net/bug.php?id=65935

It went something like this:

Someone asked for suexec like functionality, a gid/uid check, which I implemented.
Some other people said can we do more.
Remi pointed out that suexec is much more

http://httpd.apache.org/docs/2.2/suexec.html

suexec is loads, and restrictive, all the time.

So for php-fpm only I implemented a security level to give a bit of power to the user in configuring their security.

Lastly ... SECURE ALL THE THINGS !!!

wp->limit_guid = wp->config->security_limit_guid;
}



Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's with the extra new lines?

return 0;
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And there is more broken whitespace/indentation.

@remicollet
Copy link
Contributor

Do you really think that script uid matching proccess uid increase security ?

I mostly think the opposite.
If the user running the process is also the owner of the script, it will have "write" access to it (so making exploit possible).

I usually think that the process "must not" own the script and have only "read" right.

@remicollet
Copy link
Contributor

I think another check could make sense:

"webserver" user can only excute script from a "webauthor" (with webserver != webauthor), thus is any file is added by some exploit, it won't be executable.

P.S. which I think is mostly what suExec do.

@krakjoe
Copy link
Member Author

krakjoe commented Oct 31, 2013

http://httpd.apache.org/docs/2.2/suexec.html

  1. ...
  2. ...
  3. Is this valid user allowed to run the wrapper?
    Is this user the user allowed to run this wrapper? Only one user (the Apache user) is allowed to execute this program.

Seems quite similar to suexec to me ??

I'm up for implementing varied modes of security while we are at it all the same ...

@krakjoe
Copy link
Member Author

krakjoe commented Nov 1, 2013

This has been totally done over ...

; Set the security level for FPM
; Security level is on the scale of 0-8, where 0 means no security checks are performed
; Setting the number to, for example 5, means level 5 and below security requirements are 
; enforced for each request
;
; Default Value: 0
; Values:
;   1: do not allow any script to execute as root user
;   2: do not allow any script to execute as root group
;   3: do not allow access to paths with backreferences ".."
;   4: do not allow access to anything not a regular file
;   5: do not allow access to executable files
;   6: do not allow access to paths that are readable or writable by any other group
;   7: do not allow access to paths that are writable by the current user or group
;   8: do not allow access to paths where the group and user do not match the current group and user *exactly*
;
; At level 8, only files owned by the current user and group, with permissions 400 may be executed.
security.level = 8

Delicious now, right ??

@remicollet
Copy link
Contributor

From http://httpd.apache.org/docs/2.2/suexec.html

3. Is this valid user allowed to run the wrapper? Is this user the user allowed to run this wrapper? Only one user (the Apache user) is allowed to execute this program.

This means that the wrapper can only be called by apache. The wrapper, not the script.
But:

8. Is the target userid ABOVE the minimum ID number?

This means the script will run under an unprivileged account which is obviously not apache. But suExec is something special.

So definitively, having process uid = script owner doesn't make sense, from security POV.

@krakjoe
Copy link
Member Author

krakjoe commented Nov 2, 2013

Coming back to this later ...

@krakjoe krakjoe closed this Nov 2, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants