Linux CIFS filesystem development
 help / color / mirror / Atom feed
From: Tom Talpey <tom@talpey.com>
To: Namjae Jeon <linkinjeon@kernel.org>
Cc: Dairui Zhang <zhangdairui@gmail.com>,
	linux-cifs@vger.kernel.org, Steve French <sfrench@samba.org>,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	Paulo Alcantara <pc@manguebit.org>
Subject: Re: [BUG] ksmbd: no check that transform SessionId matches inner one on encrypted requests
Date: Tue, 29 Sep 2026 10:00:40 -0700	[thread overview]
Message-ID: <e4941a3b-e155-4319-b53e-d6e70fe67969@talpey.com> (raw)
In-Reply-To: <CAKYAXd8yTKp5nh7Mc9_Cw9RY323cEZF0EAn6uc72AJS4mOaaKQ@mail.gmail.com>

On 9/26/2026 6:24 PM, Namjae Jeon wrote:
> On Sun, Sep 27, 2026 at 9:25 AM Tom Talpey <tom@talpey.com> wrote:
>>
>> On 9/25/2026 4:45 PM, Namjae Jeon wrote:
>>>> Suggested fix: compare the transform SessionId with the inner one
>>>> after decryption and drop the connection on mismatch. Happy to send
>>>> a patch if that approach sounds right.
>>> Thanks for the detailed report. Please send the patch to the mailing
>>> list and me.
>> I agree that there appears to be an issue, but it may need some more
>> analysis of MS-SMB2 section 3.2.5.1.1.1.
>>
>> This in particular.
>>> As I read MS-SMB2, the server is supposed to verify the two
>>> SessionIds match and treat a mismatch as a protocol error.
>>
>> MS-SMB2 does have explicit requirements that the server MUST check
>> for equality (and drop the connection if unequal), but there is one
>> SHOULD attached to a behavior note stating an exception that doesn't
>> seem appropriate. So there may be a document issue which should be
>> resolved before deciding.
>>
>> Some of us are at the SDC IOLab in Santa Clara this week, I'll bring
>> it up with the Microsoft folks here and report back.
> Thanks for looking into this. I’ll wait for your update!
I did get a chance to look into it and there were some hyperlink issues
with the behavior notes in the document I downloaded, which have been
fixed. MS-SMB2 was updated just yesterday!

The situation is interesting however. On the client side, any difference
in the encryption transform and message sessionid's is basically fatal
and the connection is broken.

On the server, the received sessionid can validly differ if the message
is an encrypted compound, in certain cases.

Section 3.3.5.2.1.1 says:

>  The server MUST verify if any of the following conditions are true and, if so, the server MUST
> disconnect the connection as specified in section 3.3.7.1:
>  For a singleton request and the first operation of a compounded request,
>  The size of the decrypted message is less than the size of the SMB2 Header
>  SMB2_FLAGS_RELATED_OPERATIONS is set in the Flags field of the SMB2 header of
> the request
>  The SessionId field in the SMB2 header of the request is not equal to
> Request.TransformSessionId.
>  In a compounded request, for each operation in the compounded chain except the first
> one, SMB2_FLAGS_RELATED_OPERATIONS is not set in the Flags field of the SMB2
> header of the operation and SessionId in the SMB2 header of the operation is not equal
> to Request.TransformSessionId.

Because I'm not sure what version of MS-SMB2 was referred to in the
fix comments, it would be good to re-verify against this text since it
may have changed.

Bottom line, the server must drop the connection on any mismatch for
singletons, and for the first operation in a compound. But subsequent
operations in the compound may differ if !RELATED, yet must fail if
not!

Tom.

      reply	other threads:[~2026-09-29 17:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-25 17:46 [BUG] ksmbd: no check that transform SessionId matches inner one on encrypted requests Dairui Zhang
2026-09-25 23:45 ` Namjae Jeon
2026-09-27  0:25   ` Tom Talpey
2026-09-27  1:24     ` Namjae Jeon
2026-09-29 17:00       ` Tom Talpey [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e4941a3b-e155-4319-b53e-d6e70fe67969@talpey.com \
    --to=tom@talpey.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=pc@manguebit.org \
    --cc=senozhatsky@chromium.org \
    --cc=sfrench@samba.org \
    --cc=zhangdairui@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox