Dear LTS maintainers,

See attached patch for CVE-2019-3880 in samba. Don't know if it applies cleanly.

Regards

Mathieu Parent

---------- Forwarded message ---------
De : Sebastien Delafond <s...@debian.org>
Date: lun. 8 avr. 2019 à 10:27
Subject: [SECURITY] [DSA 4427-1] samba security update
To: <debian-security-annou...@lists.debian.org>


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

- -------------------------------------------------------------------------
Debian Security Advisory DSA-4427-1                   secur...@debian.org
https://www.debian.org/security/                       Sebastien Delafond
April 08, 2019                        https://www.debian.org/security/faq
- -------------------------------------------------------------------------

Package        : samba
CVE ID         : CVE-2019-3880

Michael Hanselmann discovered that Samba, a SMB/CIFS file, print, and
login server for Unix, was vulnerable to a symlink traversal
attack. It would allow remote authenticated users with write
permission to either write or detect files outside of Samba shares.

For the stable distribution (stretch), this problem has been fixed in
version 2:4.5.16+dfsg-1+deb9u1.

We recommend that you upgrade your samba packages.

For the detailed security status of samba please refer to
its security tracker page at:
https://security-tracker.debian.org/tracker/samba

Further information about Debian Security Advisories, how to apply
these updates to your system and frequently asked questions can be
found at: https://www.debian.org/security/

Mailing list: debian-security-annou...@lists.debian.org
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCgAdFiEEAqSkbVtrXP4xJMh3EL6Jg/PVnWQFAlyrA9kACgkQEL6Jg/PV
nWSvLQf+Mce+c49AVUGwYVjnVN3TgXbrgVI2lmWDwGIBdh/Kygg9Va3v66nW5pwH
RyjmOOIn9nTgxMFPeO7gdk3ui8mL7lJ+KEKPySAXpGy3BlruB8qBSdpSnNOzjyQA
K0cLbOrARly5q/HYgNx5CM5E/cqX5xFnJidmwbwwccvy/f1cgAmnZfSkCHTAri01
7X0xZRm2nlfFAGWZEOEkyEKRPxNeP5WpCikdC+z6+5H6ezVPr57lO/1IhI8i9de+
KpGGx9LSbEAfKAyuv1BVlSugsQ4mGYB7oEiTCEU6tS46Tyb7kG2gaouRUBXqBjFZ
sG4By7dtaEc+jwQVK3MZriMrePZOeA==
=6GCj
-----END PGP SIGNATURE-----
From 278d169c1078608ef41702bcd5b0dbfed62c3886 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra@samba.org>
Date: Thu, 21 Mar 2019 14:51:30 -0700
Subject: [PATCH] CVE-2019-3880 s3: rpc: winreg: Remove implementations of
 SaveKey/RestoreKey.

The were not using VFS backend calls and could only work
locally, and were unsafe against symlink races and other
security issues.

If the incoming handle is valid, return WERR_BAD_PATHNAME.

[MS-RRP] states "The format of the file name is implementation-specific"
so ensure we don't allow this.

As reported by Michael Hanselmann.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13851

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>

(backported to Samba 4.5 by Andrew Bartlett)
---
 source3/rpc_server/winreg/srv_winreg_nt.c | 96 ++-----------------------------
 1 file changed, 6 insertions(+), 90 deletions(-)

diff --git a/source3/rpc_server/winreg/srv_winreg_nt.c b/source3/rpc_server/winreg/srv_winreg_nt.c
index f45c3b9ff9d..cbe7834264d 100644
--- a/source3/rpc_server/winreg/srv_winreg_nt.c
+++ b/source3/rpc_server/winreg/srv_winreg_nt.c
@@ -640,46 +640,6 @@ WERROR _winreg_AbortSystemShutdown(struct pipes_struct *p,
 }
 
 /*******************************************************************
- ********************************************************************/
-
-static int validate_reg_filename(TALLOC_CTX *ctx, char **pp_fname )
-{
-	char *p = NULL;
-	int num_services = lp_numservices();
-	int snum = -1;
-	const char *share_path = NULL;
-	char *fname = *pp_fname;
-
-	/* convert to a unix path, stripping the C:\ along the way */
-
-	if (!(p = valid_share_pathname(ctx, fname))) {
-		return -1;
-	}
-
-	/* has to exist within a valid file share */
-
-	for (snum=0; snum<num_services; snum++) {
-		if (!lp_snum_ok(snum) || lp_printable(snum)) {
-			continue;
-		}
-
-		share_path = lp_path(talloc_tos(), snum);
-
-		/* make sure we have a path (e.g. [homes] ) */
-		if (strlen(share_path) == 0) {
-			continue;
-		}
-
-		if (strncmp(share_path, p, strlen(share_path)) == 0) {
-			break;
-		}
-	}
-
-	*pp_fname = p;
-	return (snum < num_services) ? snum : -1;
-}
-
-/*******************************************************************
  _winreg_RestoreKey
  ********************************************************************/
 
@@ -687,36 +647,11 @@ WERROR _winreg_RestoreKey(struct pipes_struct *p,
 			  struct winreg_RestoreKey *r)
 {
 	struct registry_key *regkey = find_regkey_by_hnd( p, r->in.handle );
-	char *fname = NULL;
-	int snum = -1;
 
-	if ( !regkey )
-		return WERR_BADFID;
-
-	if ( !r->in.filename || !r->in.filename->name )
-		return WERR_INVALID_PARAM;
-
-	fname = talloc_strdup(p->mem_ctx, r->in.filename->name);
-	if (!fname) {
-		return WERR_NOMEM;
-	}
-
-	DEBUG(8,("_winreg_RestoreKey: verifying restore of key [%s] from "
-		 "\"%s\"\n", regkey->key->name, fname));
-
-	if ((snum = validate_reg_filename(p->mem_ctx, &fname)) == -1)
-		return WERR_OBJECT_PATH_INVALID;
-
-	/* user must posses SeRestorePrivilege for this this proceed */
-
-	if ( !security_token_has_privilege(p->session_info->security_token, SEC_PRIV_RESTORE)) {
-		return WERR_ACCESS_DENIED;
+	if ( !regkey ) {
+		return WERR_INVALID_HANDLE;
 	}
-
-	DEBUG(2,("_winreg_RestoreKey: Restoring [%s] from %s in share %s\n",
-		 regkey->key->name, fname, lp_servicename(talloc_tos(), snum) ));
-
-	return reg_restorekey(regkey, fname);
+	return WERR_BAD_PATHNAME;
 }
 
 /*******************************************************************
@@ -727,30 +662,11 @@ WERROR _winreg_SaveKey(struct pipes_struct *p,
 		       struct winreg_SaveKey *r)
 {
 	struct registry_key *regkey = find_regkey_by_hnd( p, r->in.handle );
-	char *fname = NULL;
-	int snum = -1;
 
-	if ( !regkey )
-		return WERR_BADFID;
-
-	if ( !r->in.filename || !r->in.filename->name )
-		return WERR_INVALID_PARAM;
-
-	fname = talloc_strdup(p->mem_ctx, r->in.filename->name);
-	if (!fname) {
-		return WERR_NOMEM;
+	if ( !regkey ) {
+		return WERR_INVALID_HANDLE;
 	}
-
-	DEBUG(8,("_winreg_SaveKey: verifying backup of key [%s] to \"%s\"\n",
-		 regkey->key->name, fname));
-
-	if ((snum = validate_reg_filename(p->mem_ctx, &fname)) == -1 )
-		return WERR_OBJECT_PATH_INVALID;
-
-	DEBUG(2,("_winreg_SaveKey: Saving [%s] to %s in share %s\n",
-		 regkey->key->name, fname, lp_servicename(talloc_tos(), snum) ));
-
-	return reg_savekey(regkey, fname);
+	return WERR_BAD_PATHNAME;
 }
 
 /*******************************************************************
-- 
2.11.0

Reply via email to