Linux CIFS filesystem development
 help / color / mirror / Atom feed
* [PATCH 0/4] ksmbd: enforce mandatory signing and encryption on requests
@ 2026-11-19 10:38 RootSys GmbH Research
  2026-11-19 10:38 ` [PATCH 1/4] ksmbd: require signing on sessions that negotiated encryption RootSys GmbH Research
                   ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: RootSys GmbH Research @ 2026-11-19 10:38 UTC (permalink / raw)
  To: Namjae Jeon
  Cc: Steve French, Sergey Senozhatsky, Tom Talpey, ChenXiaoSong,
	mike.michalo, linux-cifs

ksmbd does not enforce "server signing = mandatory" or "smb3 encryption =
mandatory" on requests once a client has offered a cipher in NEGOTIATE,
which the Linux and current Windows clients always do. sess->sign is
cleared for such sessions, and the gate added by 2bebf2470af1 ("ksmbd:
enforce signing required by the session") only looks at sess->sign, so
an unsigned plaintext request is executed on a session that requires
signing, and a plaintext request on a session that was told
SMB2_SESSION_FLAG_ENCRYPT_DATA. A client that offers no cipher at all
gets a plaintext session even with mandatory encryption. On SMB 3.0 and
3.0.2, one client's SMB2_GLOBAL_CAP_ENCRYPTION is ORed into the static
per-dialect table and changes how every later session of that dialect
is set up, until the module is reloaded.

The consequence is that a man-in-the-middle between a client and ksmbd
can inject requests into an authenticated session and have them run
with the victim's credentials, and that an NTLM relay to ksmbd is not
stopped by either setting, which is what the two settings exist for.

The session handling goes back to e2f34481b24d ("cifsd: add server-side
procedures for SMB3"); the signing part is what is left after
2bebf2470af1 (v7.2-rc5). We reproduced it on mainline 4405c18c95d2
(v7.4-rc3-230), on v7.3 and on ksmbd-for-next 267029b35ad1. A
reproducer is available to the maintainers on request.

The series is based on ksmbd-for-next 267029b35ad1, because patch 1
uses sess->sign_required from the session setup signing series queued
there. On mainline it applies on top of that series' first three
commits, 16ab0adace8f ("ksmbd: verify the signature of session binding
requests"), 42a1d80e64a3 ("ksmbd: sign with the negotiated SMB 3.1.1
signing algorithm") and ea472ddf7a9a ("ksmbd: use the channel signing
key for session setup on a bound channel").

Patch 1 makes the request gate honour sess->sign_required. Patch 2
refuses plaintext requests on sessions that were told to encrypt. Patch
3 applies the existing per-share "needs a negotiated cipher" check to
tree connects when encryption is mandatory for the whole server, so an
SMB 2.1 client can no longer connect in that configuration, as
ksmbd.conf(5) documents. Patch 4 gives each connection its own copy of
its dialect's capability table.

Testing: built with W=1 for CONFIG_SMB_SERVER=y and =m without
warnings, each patch on its own, and checkpatch --strict clean. On
KASAN kernels built from ksmbd-for-next 267029b35ad1 and from mainline
4405c18c95d2 (with the three commits above), each with this series,
every unsigned or plaintext TREE_CONNECT that gets through on the
unpatched trees is refused with STATUS_ACCESS_DENIED, and the next
NEGOTIATE no longer advertises a capability another client offered. The
in-kernel cifs client still mounts, writes and reads with sign and with
seal under mandatory signing (vers=2.1, 3.0, 3.0.2 and 3.1.1; seal with
3.0 and 3.1.1), and with seal under mandatory encryption. Not tested:
Kerberos sessions (krb5_authenticate() gets the same change), SMB
Direct and multichannel binding.

We found this with AI-assisted code review and testing; the reproducer
and the fix were tested by us on current mainline.

RootSys GmbH Research (4):
  ksmbd: require signing on sessions that negotiated encryption
  ksmbd: reject plaintext requests on sessions that must be encrypted
  ksmbd: refuse tree connect without a cipher when encryption is
    mandatory
  ksmbd: keep negotiated capabilities per connection

 fs/smb/server/connection.h        |  2 ++
 fs/smb/server/mgmt/user_session.h |  2 ++
 fs/smb/server/server.c            | 14 ++++++++++++--
 fs/smb/server/smb2ops.c           | 19 +++++++++++++++----
 fs/smb/server/smb2pdu.c           | 16 ++++++++++++----
 5 files changed, 43 insertions(+), 10 deletions(-)


base-commit: 267029b35ad1245a36d069cafe93b4ea654e0f81
-- 
2.43.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2026-11-26 15:08 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 10:38 [PATCH 0/4] ksmbd: enforce mandatory signing and encryption on requests RootSys GmbH Research
2026-11-19 10:38 ` [PATCH 1/4] ksmbd: require signing on sessions that negotiated encryption RootSys GmbH Research
2026-11-19 10:38 ` [PATCH 2/4] ksmbd: reject plaintext requests on sessions that must be encrypted RootSys GmbH Research
2026-11-19 10:38 ` [PATCH 3/4] ksmbd: refuse tree connect without a cipher when encryption is mandatory RootSys GmbH Research
2026-11-19 10:38 ` [PATCH 4/4] ksmbd: keep negotiated capabilities per connection RootSys GmbH Research
2026-11-19 12:51 ` [PATCH 0/4] ksmbd: enforce mandatory signing and encryption on requests mixalhs
2026-11-19 13:44   ` RootSys GmbH Research
2026-11-19 17:29 ` Ian Bridges
2026-11-26 15:08 ` [PATCH v2 " RootSys GmbH Research
2026-11-26 15:08   ` [PATCH v2 1/4] ksmbd: keep negotiated capabilities per connection RootSys GmbH Research
2026-11-26 15:08   ` [PATCH v2 2/4] ksmbd: require signing on sessions that negotiated encryption RootSys GmbH Research
2026-11-26 15:08   ` [PATCH v2 3/4] ksmbd: reject plaintext requests on sessions that must be encrypted RootSys GmbH Research
2026-11-26 15:08   ` [PATCH v2 4/4] ksmbd: refuse session setup without encryption when it is mandatory RootSys GmbH Research

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox