SMB-Server 2.1.1

dotnet add package SMB-Server --version 2.1.1
                    
NuGet\Install-Package SMB-Server -Version 2.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SMB-Server" Version="2.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SMB-Server" Version="2.1.1" />
                    
Directory.Packages.props
<PackageReference Include="SMB-Server" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SMB-Server --version 2.1.1
                    
#r "nuget: SMB-Server, 2.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SMB-Server@2.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SMB-Server&version=2.1.1
                    
Install as a Cake Addin
#tool nuget:?package=SMB-Server&version=2.1.1
                    
Install as a Cake Tool

SMB-Server

A SMB 2/3 server library - written in C# (.NET 9)

This is a library specifically build, for implementing / creating your own SMB Fileserver. The library was created based on the official Microsoft Specifications (MS-ERREF, MS-FSCC, MS-NLMP, MS-SMB2, ...)

CI

What it does

  • πŸ“ File shares with full NTFS semantics (read, write, rename, delete, locking).
  • πŸ” Secure by default - signing required, optional per-share encryption, guest/anonymous rejected.
  • πŸ”‘ Real login via NTLMv2; the user source (local, LDAP/AD …) is freely pluggable.
  • :jigsaw: Modular - plug in your own file backend, auth, lock manager or directory watcher.

Installation

The library is available via download of the source files or as nuget package. URL is coming...

Using the library

You will find an example with different usages under /examples.

More background

The rest of this document is a technical reference for contributors and the curious. You don't need it for normal use of the library.

Architecture

Strict Parse ↔ State ↔ Effect layering - each layer its own project, no cycles:

Project Contents
Smb.Protocol Pure wire types: NBSS framing, SMB2 header (sync/async), enums, Negotiate/SessionSetup/TreeConnect/Echo, transform header. Span-based, little-endian. No I/O, no state.
Smb.Crypto Signing (HMAC-SHA256 / AES-CMAC / AES-GMAC), AEAD transform (AES-CCM/GCM 128/256), SP800-108 KDF, SMB 3 key derivation, SHA-512 preauth hash, MD4 + NTLMv2 crypto.
Smb.Auth GSS/SPNEGO abstraction: IGssMechanism, ISpnegoNegotiator, IIdentityBackend. SPNEGO token encoding (ASN.1 DER), OIDs, in-memory backend, dev negotiator.
Smb.FileSystem IShare / IFileStore backend abstraction (NTFS semantics over any backend). Async-first (ValueTask/Memory); purely synchronous backends attach via SyncFileStore (see docs/ASYNC_IO_ROADMAP.md).
Smb.Server State model (Connection/Session/TreeConnect/Open), credit logic, negotiate processor, command dispatcher (receive pipeline).
Smb.Host TCP listener (default 445), per-connection read loop, NBSS/transform handling, fluent builder.

Foundation and fact-check: SMB2-3_Server_Context.md.

Modular authentication

SESSION_SETUP talks only to ISpnegoNegotiator. New mechanisms = register a new IGssMechanism; new identity source (e.g. LDAP/AD) = a new IIdentityBackend - without touching the protocol or server layer.

ISpnegoNegotiator  ──>  IGssMechanism (NTLM today, Kerberos later)
                                β”‚
                                └──>  IIdentityBackend (local today, LDAP/AD later)

Security defaults & audit

  • SMB1 file access off (only the negotiate-upgrade path is provided).
  • Signing required by default; 3.1.1 preferred with preauth integrity (SHA-512).
  • Cipher preference AES-128-GCM > AES-256-GCM > AES-128-CCM > AES-256-CCM.
  • Signing preference AES-GMAC > AES-CMAC > HMAC-SHA256.
  • Guest/anonymous rejected by default.
  • Per-share encryption enforceable (Share.EncryptData): responses are encrypted, and unencrypted access to an encrypted tree is rejected with RejectUnencryptedAccess (on by default); an encrypted share on a connection without a 3.x cipher β†’ ACCESS_DENIED.
  • Crypto exclusively via the .NET BCL (System.Security.Cryptography).

Security audit: status and open items in docs/SECURITY_AUDIT.md (fixed findings are marked in code with [AUDIT-2026-06] and guarded by AuditFixTests). Still open, among others: NTLM MIC verification (O1), 3.1.1 negotiate validation (O3), credit accounting (O6). ⚠️ Cross-check AES-256 key derivation (M3) against a real Windows interop capture before using Kerberos.

Verification

The suite (383 tests) covers, among others:

  • Official crypto vectors: AES-CMAC (RFC 4493 Β§4), MD4 (RFC 1320 A.5), NTOWFv2 (MS-NLMP Β§4.2 example).
  • Wire roundtrips: header (sync/async), NBSS (big-endian length prefix), negotiate contexts (8-byte alignment, offset correctness).
  • Crypto: KDF determinism, key derivation (3.0/3.1.1, AES-128/256, ServerIn label with the trailing space), sign/verify + tamper detection (all 3 algorithms), transform roundtrip
    • AEAD tag check, preauth hash chain.
  • Server end-to-end: NEGOTIATE β†’ SESSION_SETUP β†’ TREE_CONNECT β†’ ECHO; dialect selection; cipher/signing negotiation; signing enforcement (signed accepted, unsigned rejected); guest rejection; TCP integration over real NBSS.
  • Per-share encryption: tree marking + ShareFlags, plaintext request on an encrypted tree rejected (RejectUnencryptedAccess), encrypted-share connect without a cipher rejected, and the host returns the TREE_CONNECT response of an encrypted share as a TRANSFORM frame.
  • Oplocks: grant of the requested level on a solo open (Batch/Exclusive), downgrade to Level II + OPLOCK_BREAK notification on a second open of the same file, acknowledgment, release on CLOSE; lease-break acknowledgment (still) β†’ STATUS_NOT_SUPPORTED.
  • Audit fixes (AuditFixTests): LOGOFF signing enforcement, MessageId sequence window (replay/out-of-window rejected), MaximalAccess enforcement on CREATE, cap on pending async operations.
  • Path sandbox (SymlinkSandboxTests): a symlink/reparse point inside the share that points outside is denied (file and directory); normal in-root access stays allowed (H4).
  • QUERY_DIRECTORY paging + stable FileId (QueryDirectoryPagingTests, O2): large directory across multiple pages, single entry, buffer too small β†’ INFO_LENGTH_MISMATCH.
  • Share modes / persistent handle (ShareModeManagerTests, LocalFileStoreHandleTests, QueryDirectoryPagingTests, O5): sharing violation on an incompatible second open + release after CLOSE; read/write/DeleteOnClose/rename-while-open over a persistent OS handle; stable FileId.

Roadmap

Milestone Status
M1 Transport & parsing βœ…
M2 Negotiate (incl. 3.1.1 contexts, preauth hash) βœ…
M3 Auth (SPNEGO + real NTLMv2 login, key derivation, signing) βœ… (MIC verification still open)
M4 Tree & file access (CREATE/READ/QUERY_DIRECTORY/QUERY_INFO/CLOSE) βœ… via LocalFileStore
M5 Writing (WRITE, SET_INFO/Rename/Delete βœ…; byte-range LOCK βœ… incl. blocking + CANCEL, pluggable ILockManager) βœ…
M6 Encryption & hardening (transform path) βœ… Per-share encryption wired (tree EncryptData, response encryption incl. TREE_CONNECT response) + hardening: RejectUnencryptedAccess (on by default) rejects plaintext access to encrypted trees; encrypted-share connect without a 3.x cipher β†’ ACCESS_DENIED
Share enumeration (srvsvc NetrShareEnum over DCERPC/IPC$, IOCTL FSCTL_PIPE_TRANSCEIVE) βœ…
SMB1β†’SMB2 negotiate upgrade (Β§6.1, for impacket et al.) βœ…
M7 CHANGE_NOTIFY βœ… (pluggable IDirectoryWatcher); oplocks βœ… (pluggable IOplockManager: grant + OPLOCK_BREAK notification + acknowledgment + release); leases & compound polish open 🟑
Native Windows Explorer interop (full FSCC/IOCTL coverage, Secure Negotiate) 🟑 Secure Negotiate βœ… (FSCTL_VALIDATE_NEGOTIATE_INFO, downgrade β†’ connection drop); server-side copy βœ…
Phase 5 Server-side copy & FSCTLs βœ… (FSCTL_SRV_COPYCHUNK + resume keys + CopyRangeAsync offload; SET_SPARSE / SET_ZERO_DATA / QUERY_ALLOCATED_RANGES / GETΒ·SETΒ·DELETE_REPARSE_POINT via opt-in seams; Secure Negotiate) βœ…
Phase 6 Multichannel βœ… (session binding + per-channel signing, FSCTL_QUERY_NETWORK_INTERFACE_INFO via INetworkInterfaceProvider, channel failover) βœ…
Phase 7 DFS referrals βœ… (FSCTL_DFS_GET_REFERRALS / _EX via pluggable IDfsNamespace + StandaloneDfsNamespace; DFS TREE_CONNECT/NEGOTIATE flags; link resolution β†’ STATUS_PATH_NOT_COVERED) βœ…
Phase 8 Operational readiness βœ… (structured audit logging ISmbAuditLogger; idle/auth timeouts; connection admission control ConnectionLimiter; graceful draining shutdown; health/perf metrics SmbServerMetrics) βœ…
Phase 9 Alternate data streams & extended attributes βœ… (named streams file.txt:stream + FileStreamInformation via opt-in INamedStreamStore; FileFullEaInformation via opt-in IExtendedAttributeStore) βœ…
Phase 10 Transport hardening βœ… (M10.1 SMB over TLS β€” SslStream wrapper via SmbServerBuilder.UseTls(cert), mutual TLS; M10.2 SMB over QUIC β€” SmbServerBuilder.UseQuic(cert), TLS 1.3 + ALPN "smb"; M10.3 compression β€” LZ77 + LZNT1 via UseCompression, negotiate context) βœ…
Phase 11 Quota & advanced FS βœ… (M11.1 quota β€” QUERY/SET_QUOTA_INFO via opt-in IQuotaProvider, write enforcement β†’ STATUS_DISK_FULL; M11.2 reparse/symlink β€” STATUS_STOPPED_ON_SYMLINK + SYMLINK_ERROR_RESPONSE via opt-in ISymlinkResolver, dialect-correct SMB2_ERROR_CONTEXT framing; M11.3 WS-Discovery β€” UDP responder via SmbServerBuilder.UseWsDiscovery() for Explorer network browsing) βœ…
M8 Kerberos βœ…, LDAP backend βœ…, durable/persistent handles βœ…, multichannel βœ…, DFS βœ…, operational readiness βœ…, ADS/EA βœ…, TLS/QUIC/compression βœ…, quota βœ…, reparse/symlink βœ…, WS-Discovery βœ…; RDMA 🟑

License note

The underlying Microsoft Open Specifications are covered by the Open Specifications Promise. Structures/constants were reimplemented (no verbatim text was copied).

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net9.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.1.1 92 7/15/2026
2.1.0 94 7/15/2026
2.0.1 101 7/14/2026
2.0.0 116 7/9/2026
1.0.2 102 6/29/2026
1.0.1 111 6/29/2026
1.0.0 105 6/28/2026

Just a quick update for testing and validation.