From 14928b7492abec82afa4c2b778fc03f78cd419b6 Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Tue, 1 Apr 2014 14:38:07 +1100 Subject: - (djm) On platforms that support it, use prctl() to prevent sftp-server from accessing /proc/self/{mem,maps}; patch from jann AT thejh.net --- sftp-server.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'sftp-server.c') diff --git a/sftp-server.c b/sftp-server.c index b8eb59c36..77834117c 100644 --- a/sftp-server.c +++ b/sftp-server.c @@ -29,6 +29,9 @@ #ifdef HAVE_SYS_STATVFS_H #include #endif +#ifdef HAVE_SYS_PRCTL_H +#include +#endif #include #include @@ -1523,6 +1526,17 @@ sftp_server_main(int argc, char **argv, struct passwd *user_pw) log_init(__progname, log_level, log_facility, log_stderr); +#ifdef HAVE_PRCTL + /* + * On Linux, we should try to avoid making /proc/self/{mem,maps} + * available to the user so that sftp access doesn't automatically + * imply arbitrary code execution access that will break + * restricted configurations. + */ + if (prctl(PR_SET_DUMPABLE, 0) != 0) + fatal("unable to make the process undumpable"); +#endif + if ((cp = getenv("SSH_CONNECTION")) != NULL) { client_addr = xstrdup(cp); if ((cp = strchr(client_addr, ' ')) == NULL) { -- cgit v1.2.3