Skip to content

Comments

Strict access checks for scripts, secrets files and call option files#577

Open
paulusmack wants to merge 3 commits intomasterfrom
strict
Open

Strict access checks for scripts, secrets files and call option files#577
paulusmack wants to merge 3 commits intomasterfrom
strict

Conversation

@paulusmack
Copy link
Collaborator

This is a reworking and extension of @jkroonza's work in PR #561 to pull out the checking code into a separate function and use it for secrets files and call option files as well as scripts. I moved the checking code into a new function called ppp_check_access() and I used lstat() instead of fstatat(..., AT_SYMLINK_NOFOLLOW), updated the error messages, and reworked the main loop, but apart from that, the body of ppp_check_access() is basically @jkroonza's code.

I would appreciate review and testing - in particular, are there things being checked here that shouldn't be, or things that aren't and should be?

As a security measure, check that scripts that are run as root by pppd
using run_program() could not have been changed by a non-root process.
First, the path to the script file is converted to an absolute path
without symlinks using realpath().  Then each component of the path
from the root directory down, as well as the file itself, are checked
to verify that they are owned by root and not writable by group or
other.  This ensures that some other file couldn't be substituted for
the file that has been checked, and the file itself can't be changed.
(Clearly a process running as root could modify the path or the file
itself, but if that is being done maliciously, then the system must
already be compromised.)

The process of checking the path and the file is in a new function
called ppp_check_access().

Most of the code added here was originally written by Jaco Kroon
<jaco@uls.co.za>.  I moved the code into a separate function,
changed the error messages, changed fstatat(..., AT_SYMLINK_NOFOLLOW)
to lstat(), and otherwise tweaked it a little.

Originally-by: Jaco Kroon <jaco@uls.co.za>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
…cesses

Check that files containing secrets used by a remote system to
authenticate itself to this system could not be changed by a non-root
process, that is, that the file and all directories in the real path
to it are owned by root and not writable by group or other.
The files that are checked in this way are:

/etc/ppp/pap-secrets (or alternate location set by pap-secrets option)
/etc/ppp/chap-secrets (ditto for chap-secrets option)
/etc/ppp/srp-secrets
/etc/ppp/eaptls-server
/etc/ppp/eaptls-client
Files specified using @/file syntax in a secrets file

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
This checks, using ppp_check_access(), that files invoked using the
"call" option can't be tampered with by non-root processes.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant