From nobody Mon May 25 01:14:40 2026 Received: from mail-qt1-f172.google.com (mail-qt1-f172.google.com [209.85.160.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E7982FE05C for ; Wed, 20 May 2026 03:19:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779247198; cv=none; b=AH/831D5Gbv+LDWQTGuEyyDSf98k2I1DffTD0zyxdGjEMtVEoG4nsLwUexsa3KhcCL+r686LsqNETQlSPoL+CvQeERxZj3AMvXBgEVfXLHAkMBGphP3iRCsP+SssVb9L1bVozBTGYA8zhFndU1V3rB0G9uEZ/Ip+SHRgVXB+d4g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779247198; c=relaxed/simple; bh=17nxfRsu/mmBWYVlL9OzSO4HeHZxjgfU0eC2ctFuVPM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=pPyRSfKixED43vR1CTEY1ZATup9e5mbb7pOUHF2Kwa42qOAQSX/BSB14bmdvhqItG1y/mZsf7NC3Wf8JnfWhUt88XeIQpH8ilbTb6VOzt0HEJBftQGAlplKMgkFhnQUYkTbmQel5Gh5N0HF/HV7MWt+VdJ/i6/6cXeMpyasRdlk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DZb14AXJ; arc=none smtp.client-ip=209.85.160.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DZb14AXJ" Received: by mail-qt1-f172.google.com with SMTP id d75a77b69052e-512f09ecc67so32246621cf.3 for ; Tue, 19 May 2026 20:19:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779247195; x=1779851995; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ExOjUKx730L5h/Y9Isojqzag32vFvnt6fAHuWyYmv/Q=; b=DZb14AXJqszT86bDu9VMgV8k7nfVfjE+J6OGk+Qr2YXZ7udsz0esLIeozpLOPTZy/K 3+/aNFrrglILIKu3FRO+GDoTPBgd9uTq/dFV9xvgmZG4bKLXm5V8G4IEuW2OyDo/cPfR 6clJOzDK58LPl8RBYcaHIPFcUU/ch8FZ9vGQr/8Z0Cj8riJ5HQdkxU365sWmhNQGLqzn O3NT///o25Pm97FU4mEFca5gbBhaXMg7W9v7ypMMpAxVYguJKdcrwn6OtMnEK2ofyBs2 hMjs5h5Cr0dmuF5g2OUs+L54VDAqimGr1IPUdavST6sQ5vKzzKgos5Bxo1YUBu10XFBl YK4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779247195; x=1779851995; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ExOjUKx730L5h/Y9Isojqzag32vFvnt6fAHuWyYmv/Q=; b=aqFSSzTTeshR5gGApZzJ2U6GafHe+GOQV7qze2caGVLWW1wZmBIIPH5xLYsqgf8V9y xwmqwOlPgWe42PyHJoDuWfe+nUpDXo/Fr/DB9FfINQFUbUwvLSIjoYIN7V2RanLrfx4k q9X02YMQxClZVPOgl3DOLQEl4QFaCXWpJB379DJEsJtOa/F3n0RqRdkeyHmH6KK6pUYn OcSTZo0AlO7oi0LXm9BPmx8ly0nRvrp/Z6GM3OB7u/vwv0STp+8anxukHWVC7iRjqcZl ME6YvHCFOoE1G5StsmgmJAdU6XRIEJRJITp3bfvhtJGk4quP+dcLmEn5i2nsn+WNaqYf 66jQ== X-Forwarded-Encrypted: i=1; AFNElJ/xb7JdiTzRTMq3R9X5t8lSJZ+W6xGmG/EfV6eNtYHKBHTYbWfm0W3FoeH+P9lzjKc/j9crysjQZCrcTn0=@vger.kernel.org X-Gm-Message-State: AOJu0YzWzUMdQk/yTmTin3GTPmMFCaIRUxGS8oJydbrWYpIYLluE2wCZ BJaZBB9a1VlJ7IJbp8fwdXEAKnhBLch6WfxK+UXJU+BdCx2r3wsCQ7f/ X-Gm-Gg: Acq92OHHX07TOCkC62r9tsCAp6bWT1YCGNwSsY4NKNEsDFQLdcpPAmAQznrKWM6Xfxe 7WaZi75Xqxj4S0FzMXh3FGyT/lx3UnaxO3PbtYxZbBE/akNGMPN2zc32OulBIK6GOgQ+gbwcwdu gDuHXn7Dc3XxP2sCHHGdMYCO2lNRwdjWJKoaE/rIz5lHwtlc3HVHIXHeflsO/BSaHIEkeHDKVQG 2S/ykl5rG0kMfaVrQTpjWS2HapZDhyGRS3wEuC9JFSvyN4qUiWocj1itc+57N1s8MsI8koS12fQ 5ucRB1+Bg0QZxvnEC7sGUPG+4Gd/giNEGQVDNtrEIXfAoV0kkhHePn1Mar4VUhcW0DMCql7v6Tz RDxUdI9Dj/Uc2uecyS7NSNP+NZbQ3pgRmP9vUCywbh0ytT1ija0qYDEtMYs/Irq17h5nIpRoVXy Op7KYXWBpkpbJZRmcdRviSnSAlrtzPYhIjfJi/IcUfxJvco1LPnQehI0tE5/YvoBJyIy5f4ZeV3 xHTdzO/aG6QYPmiHuTO X-Received: by 2002:a05:622a:8584:b0:50d:a8f5:1bf8 with SMTP id d75a77b69052e-5165a1dc9f7mr251865621cf.37.1779247195399; Tue, 19 May 2026 20:19:55 -0700 (PDT) Received: from server0 (c-68-48-65-54.hsd1.mi.comcast.net. [68.48.65.54]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-516456c0a42sm189710571cf.10.2026.05.19.20.19.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2026 20:19:54 -0700 (PDT) From: Michael Bommarito To: Namjae Jeon , Steve French Cc: Sergey Senozhatsky , Tom Talpey , Hyunchul Lee , Ronnie Sahlberg , Marios Makassikis , linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH] ksmbd: reject unsigned non-exempt requests when session requires signing Date: Tue, 19 May 2026 23:19:23 -0400 Message-ID: <20260520031923.3679744-1-michael.bommarito@gmail.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This is the ksmbd SMB2 sibling of Samba CVE-2023-3347 ("SMB2 packet signing not enforced"): when the server-side policy requires SMB2 signing, unsigned non-exempt requests must be rejected instead of processed. CVE-2016-2114 is the older Samba SMB1 analogue for mandatory server signing not being enforced. When a ksmbd target is configured with "server signing =3D mandatory" and a client completes a signed SESSION_SETUP, an attacker on the network path of that connection can read the cleartext SessionId from the SMB2 header and inject unsigned TREE_CONNECT, CREATE, and WRITE requests on the victim's TCP flow. ksmbd processes the unsigned PDUs and commits attacker-supplied content to the share under the victim session's authority, without the attacker holding the victim's credentials. In fs/smb/server/server.c, __process_request() verifies signatures only when conn->ops->is_sign_req() returns true. The predicate (smb2_is_sign_req() at fs/smb/server/smb2pdu.c:8936-8947) reads only the client-set SMB2_FLAGS_SIGNED and never work->sess->sign -- the per-session "signing required" state set during SESSION_SETUP at smb2pdu.c:1546 and :1645. MS-SMB2 3.3.5.2.4 requires the server to reject any unsigned non-exempt request when Session.SigningRequired is TRUE. Reject directly in __process_request() when work->sess->sign is set and the inbound non-exempt request lacks SMB2_FLAGS_SIGNED, bypassing check_sign_req() to avoid emitting pr_err("bad smb2 signature") at KERN_ERR for each unsigned PDU. The set of commands exempt from signing (NEGOTIATE, SESSION_SETUP, OPLOCK_BREAK) is unchanged. Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3") Cc: stable@vger.kernel.org Signed-off-by: Michael Bommarito Assisted-by: Claude:claude-opus-4-7 --- Reproduction =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Tree: linux-mainline 2f448dd9ef4e, x86_64 QEMU+KVM, CONFIG_SMB_SERVER=3Dy, CONFIG_KASAN=3Dy. Target ksmbd.conf has "server signing =3D mandatory", "map to guest =3D Never", "valid users =3D alice"; SMB user alice was added via ksmbd.adduser. Conditions: ksmbd configured with "server signing =3D mandatory" or a client requesting SMB2_NEGOTIATE_SIGNING_REQUIRED, so work->sess->sign is set to TRUE after SESSION_SETUP completes. Encryption MUST NOT be negotiated on the session (smb2_sess_setup clears sess->sign to FALSE at smb2pdu.c:1558/:1657 when smb3_encryption_negotiated() is TRUE). The PoCs force SMB 2.1 to keep the session in the signing-required state. Harness: a wire-level Python client establishes a normal NTLMv2 SESSION_SETUP on a fresh TCP connection, then on the same connection issues TREE_CONNECT, CREATE, and WRITE with SMB2_FLAGS_SIGNED cleared and the Signature field zeroed. A companion transparent TCP MITM proxy demonstrates the same primitive without holding credentials: it observes SessionId from the cleartext SESSION_SETUP response and injects an unsigned TREE_CONNECT, CREATE, and WRITE into the victim's TCP flow using that SessionId; the victim's own SMB session continues normally and observes the attacker's file appear on the share. Stock kernel: unsigned TREE_CONNECT returns STATUS_SUCCESS with a tree_id; CREATE returns STATUS_SUCCESS with a file id; WRITE returns STATUS_SUCCESS and the attacker payload lands on the share path. The response header carries SMB2_FLAGS_SIGNED with a non-zero MAC, confirming work->sess->sign was TRUE on this session. Patched kernel: same harness, the dispatcher returns STATUS_ACCESS_DENIED on the first unsigned TREE_CONNECT and nothing reaches the share. dmesg shows zero "bad smb2 signature" entries; the rejection bypasses check_sign_req() so the existing pr_err path is not exercised. Regression: a legitimate smbclient session with --client-protection=3Dsign continues to read and write to the share with no observable change. Mitigations: until patched, deployments can leave "server signing =3D mandatory" disabled in ksmbd.conf (the bypass is meaningful only when the session sets work->sess->sign), or configure clients to negotiate SMB3 encryption (sess->enc=3DTRUE clears sess->sign and the session uses TRANSFORM_HEADER encryption for the data path). Selftests: grep over tools/testing/selftests/ on the patched tree returns 0 references to ksmbd or smb2_is_sign_req; there is no in-tree selftest binary that exercises fs/smb/server/server.c's dispatch gate. The trigger Python client and the TCP MITM proxy are available off-list on request. --- fs/smb/server/server.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/smb/server/server.c b/fs/smb/server/server.c index 58ef02c423fce..5755f907f29f4 100644 --- a/fs/smb/server/server.c +++ b/fs/smb/server/server.c @@ -143,6 +143,15 @@ static int __process_request(struct ksmbd_work *work, = struct ksmbd_conn *conn, conn->ops->set_rsp_status(work, STATUS_ACCESS_DENIED); return SERVER_HANDLER_ABORT; } + } else if (work->sess && work->sess->sign && + command !=3D SMB2_NEGOTIATE_HE && + command !=3D SMB2_SESSION_SETUP_HE && + command !=3D SMB2_OPLOCK_BREAK_HE) { + /* MS-SMB2 3.3.5.2.4: Session.SigningRequired=3D=3DTRUE, + * reject unsigned non-exempt request. + */ + conn->ops->set_rsp_status(work, STATUS_ACCESS_DENIED); + return SERVER_HANDLER_ABORT; } =20 ret =3D cmds->proc(work); --=20 2.53.0