From 5bc272c5565cc24bf700c96f7ccb02050f55bf87 Mon Sep 17 00:00:00 2001 From: des Date: Tue, 13 Dec 2011 13:02:31 +0000 Subject: [PATCH] MFH r228384: validate the service name Approved by: re (kib) Security: some poorly thought out programs allow the user to specify the service name; this patch makes it harder to trick these programs into loading and executing arbitrary code. git-svn-id: svn://svn.freebsd.org/base/releng/9.0@228465 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- contrib/openpam/lib/openpam_configure.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/contrib/openpam/lib/openpam_configure.c b/contrib/openpam/lib/openpam_configure.c index f9197adc..688b2acc 100644 --- a/contrib/openpam/lib/openpam_configure.c +++ b/contrib/openpam/lib/openpam_configure.c @@ -285,6 +285,13 @@ openpam_load_chain(pam_handle_t *pamh, size_t len; int r; + /* don't allow to escape from policy_path */ + if (strchr(service, '/')) { + openpam_log(PAM_LOG_ERROR, "invalid service name: %s", + service); + return (-PAM_SYSTEM_ERR); + } + for (path = openpam_policy_path; *path != NULL; ++path) { len = strlen(*path); if ((*path)[len - 1] == '/') { -- 2.42.0