Skip to content
Surf Wiki
Save to docs
technology/networking

From Surf Wiki (app.surf) — the open knowledge base

Server Message Block

Network communication protocol for providing shared access to resources

Server Message Block

Network communication protocol for providing shared access to resources

Map Network Drive dialog in Windows 10, connecting to a local SMB network drive

Server Message Block (SMB) is a communication protocol used to share files, printers, serial ports, and miscellaneous communications between nodes on a network. On Windows, the SMB implementation consists of two vaguely named Windows services: "Server" (ID: LanmanServer) and "Workstation" (ID: LanmanWorkstation). It uses NTLM or Kerberos protocols for user authentication. It also provides an authenticated inter-process communication (IPC) mechanism.

SMB was originally developed in 1983 by Barry A. Feigenbaum at IBM to share access to files and printers across a network of systems running IBM PC DOS. In 1987, Microsoft and 3Com implemented SMB in LAN Manager for OS/2, at which time SMB used the NetBIOS service atop the NetBIOS Frames protocol as its underlying transport. Later, Microsoft implemented SMB in Windows NT 3.1 and has been updating it ever since, adapting it to work with newer underlying transports: TCP/IP and NetBT. SMB over QUIC was introduced in Windows Server 2022.

In 1996, Microsoft published a version of SMB 1.0 with minor modifications under the Common Internet File System (CIFS ) moniker. CIFS was compatible with even the earliest incarnation of SMB, including LAN Manager's. It supports symbolic links, hard links, and larger file size, but none of the features of SMB 2.0 and later. Microsoft's proposal, however, remained an Internet Draft and never achieved standard status. Microsoft has since discontinued the CIFS moniker but continues developing SMB and publishing subsequent specifications. Samba is a free software reimplementation of the SMB protocol and the Microsoft extensions to it.

Features

Server Message Block (SMB) enables file sharing, printer sharing, network browsing, and inter-process communication (through named pipes) over a computer network. SMB serves as the basis for Microsoft's Distributed File System implementation.

SMB relies on the TCP and IP protocols for transport. This combination allows file sharing over complex, interconnected networks, including the public Internet. The SMB server component uses TCP port 445. SMB originally operated on NetBIOS over IEEE 802.2 - NetBIOS Frames or NBF - and over IPX/SPX, and later on NetBIOS over TCP/IP (NetBT), but Microsoft has since deprecated these protocols. On NetBT, the server component uses three TCP or UDP ports: 137 (NETBIOS Name Service), 138 (NETBIOS Datagram Service), and 139 (NETBIOS Session Service).

In Microsoft Windows, two Windows services implement SMB. The "Server" service (ID: LanmanServer) is in charge of serving shared resources. The "Workstation" service (ID: LanmanWorkstation) maintains the computer name and helps access shared resources on other computers. SMB uses the Kerberos protocol to authenticate users against Active Directory on Windows domain networks. On simpler, peer-to-peer networks, SMB uses the NTLM protocol.

Windows NT 4.0 SP3 and later can digitally sign SMB messages to prevent some man-in-the-middle attacks. SMB signing may be configured individually for incoming SMB connections (by the "LanmanServer" service) and outgoing SMB connections (by the "LanmanWorkstation" service). The default setting for Windows domain controllers running Windows Server 2003 and later is to not allow unsigned incoming connections. As such, earlier versions of Windows that do not support SMB signing from the get-go (including Windows 9x) cannot connect to a Windows Server 2003 domain controller.

SMB supports opportunistic locking (see below) on files in order to improve performance. Opportunistic locking support has changed with each Windows Server release.

Opportunistic locking

In the SMB protocol, opportunistic locking is a mechanism designed to improve performance by controlling caching of network files by the client. Unlike traditional locks, opportunistic lock (OpLocks) are not strictly file locking or used to provide mutual exclusion.

There are four types of opportunistic locks.

; Batch Locks: Batch OpLocks were created originally to support a particular behavior of DOS batch file execution operation in which the file is opened and closed many times in a short period, which is a performance problem. To solve this, a client may ask for an OpLock of type "batch". In this case, the client delays sending the close request and if a subsequent open request is given, the two requests cancel each other. ; Level-1 OpLocks / Exclusive Locks: When an application opens in "shared mode" a file hosted on an SMB server which is not opened by any other process (or other clients) the client receives an exclusive OpLock from the server. This means that the client may now assume that it is the only process with access to this particular file, and the client may now cache all changes to the file before committing it to the server. This is a performance improvement, since fewer round-trips are required in order to read and write to the file. If another client/process tries to open the same file, the server sends a message to the client (called a break or revocation) which invalidates the exclusive lock previously given to the client. The client then flushes all changes to the file. ; Level-2 OpLocks: If an exclusive OpLock is held by a client and a locked file is opened by a third party, the client has to relinquish its exclusive OpLock to allow the other client's write/read access. A client may then receive a "Level 2 OpLock" from the server. A Level 2 OpLock allows the caching of read requests but excludes write caching. ; Filter OpLocks: Added in Windows NT 4.0, Filter Oplocks are similar to Level 2 OpLocks but prevent sharing-mode violations between file open and lock reception. Microsoft advises use of Filter OpLocks only where it is important to allow multiple readers and Level 2 OpLocks in other circumstances. Clients holding an OpLock do not really hold a lock on the file, instead they are notified via a break when another client wants to access the file in a way inconsistent with their lock. The other client's request is held up while the break is being processed. ; Breaks: In contrast with the SMB protocol's "standard" behavior, a break request may be sent from server to client. It informs the client that an OpLock is no longer valid. This happens, for example, when another client wishes to open a file in a way that invalidates the OpLock. The first client is then sent an OpLock break and required to send all its local changes (in case of batch or exclusive OpLocks), if any, and acknowledge the OpLock break. Upon this acknowledgment the server can reply to the second client in a consistent manner.

Performance

The use of the SMB protocol has often correlated with a significant increase in broadcast traffic on a network. However the SMB itself does not use broadcasts—the broadcast problems commonly associated with SMB actually originate with the NetBIOS service location protocol. By default, a Microsoft Windows NT 4.0 server used NetBIOS to advertise and locate services. NetBIOS functions by broadcasting services available on a particular host at regular intervals. While this usually makes for an acceptable default in a network with a smaller number of hosts, increased broadcast traffic can cause problems as the number of hosts on the network increases. The implementation of name resolution infrastructure in the form of Windows Internet Naming Service (WINS) or Domain Name System (DNS) resolves this problem. WINS was a proprietary implementation used with Windows NT 4.0 networks, but brought about its own issues and complexities in the design and maintenance of a Microsoft network.

Since the release of Windows 2000, the use of WINS for name resolution has been deprecated by Microsoft, with hierarchical Dynamic DNS now configured as the default name resolution protocol for all Windows operating systems. Resolution of (short) NetBIOS names by DNS requires that a DNS client expand short names, usually by appending a connection-specific DNS suffix to its DNS lookup queries. WINS can still be configured on clients as a secondary name resolution protocol for interoperability with legacy Windows environments and applications. Further, Microsoft DNS servers can forward name resolution requests to legacy WINS servers in order to support name resolution integration with legacy (pre-Windows 2000) environments that do not support DNS.

Network designers have found that latency has a significant impact on the performance of the SMB 1.0 protocol, that it performs more poorly than other protocols like FTP. Monitoring reveals a high degree of "chattiness" and a disregard of network latency between hosts. For example, a VPN connection over the Internet will often introduce network latency. Microsoft has explained that performance issues come about primarily because SMB 1.0 is a block-level rather than a streaming protocol, that was originally designed for small LANs; it has a block size that is limited to 64K, SMB signing creates an additional overhead and the TCP window size is not optimized for WAN links. Solutions to this problem include the updated SMB 2.0 protocol, Offline Files, TCP window scaling and WAN optimization devices from various network vendors that cache and optimize SMB 1.0 and 2.0.

History

SMB 1.0

Barry Feigenbaum originally designed SMB at IBM in early 1983 with the aim of turning DOS INT 21h local file access into a networked file system. Microsoft made considerable modifications to the most commonly used version and included SMB support in the LAN Manager operating system it had started developing for OS/2 with 3Com around 1990. Microsoft continued to add features to the protocol in Windows for Workgroups () and in later versions of Windows. LAN Manager authentication was implemented based on the original legacy SMB specification's requirement to use IBM "LAN Manager" passwords, but implemented DES in a flawed manner that allowed passwords to be cracked. Later, Kerberos authentication was also added. The Windows domain logon protocols initially used 40-bit encryption outside of the United States, because of export restrictions on stronger 128-bit encryption (subsequently lifted in 1996 when President Bill Clinton signed ).

SMB 1.0 (or SMB1) was originally designed to run on NetBIOS Frames (NetBIOS over IEEE 802.2). Since then, it has been adapted to NetBIOS over IPX/SPX (NBX), and NetBIOS over TCP/IP (NetBT). Also, since Windows 2000, SMB runs on TCP using TCP port 445, a feature known as "direct host SMB". There is still a thin layer (similar to the Session Message packet of NetBT's Session Service) between SMB and TCP. Windows Server 2003, and legacy NAS devices use SMB1 natively.

SMB1 is an extremely chatty protocol, which is not such an issue on a local area network (LAN) with low latency. It becomes very slow on wide area networks (WAN) as the back and forth handshake of the protocol magnifies the inherent high latency of such a network. Later versions of the protocol reduced the high number of handshake exchanges. One approach to mitigating the inefficiencies in the protocol is to use WAN optimization products such as those provided by Riverbed, Silver Peak, or Cisco. A better approach is to upgrade to a later version of SMB. This includes upgrading both NAS devices as well as Windows Server 2003. The most effective method to identify SMB1 traffic is with a network analyzer tool, such as Wireshark. Microsoft also provides an auditing tool in Windows Server 2016 to track down devices that use SMB1.

Microsoft marked SMB1 as deprecated in June 2013. Windows Server 2016 and Windows 10 version 1709 do not have SMB1 installed by default.

CIFS

Specifications

The specifications for the SMB are proprietary and were initially closed, thereby forcing other vendors and projects to reverse-engineer the protocol to interoperate with it. The SMB 1.0 protocol was eventually published some time after it was reverse engineered, whereas the SMB 2.0 protocol was made available from Microsoft's Open Specifications Developer Center from the outset.

Third-party implementations

Samba

Main article: Samba (software)

In 1991, Andrew Tridgell started the development of Samba, a free-software re-implementation (using reverse engineering) of the SMB/CIFS networking protocol for Unix-like systems, initially to implement an SMB server to allow PC clients running the DEC Pathworks client to access files on SunOS machines. Because of the importance of the SMB protocol in interacting with the widespread Microsoft Windows platform, Samba became a popular free software implementation of a compatible SMB client and server to allow non-Windows operating systems, such as Unix-like operating systems, to interoperate with Windows.

As of version 3 (2003), Samba provides file and print services for Microsoft Windows clients and can integrate with a Windows NT 4.0 server domain, either as a Primary Domain Controller (PDC) or as a domain member. Samba4 installations can act as an Active Directory domain controller or member server, at Windows 2008 domain and forest functional levels.

Package managers in Linux distributions can search for the cifs-utils package. The package is from the Samba maintainers.

Netsmb

NSMB (Netsmb and SMBFS) is a family of in-kernel SMB client implementations in BSD operating systems. It was first contributed to FreeBSD 4.4 by Boris Popov, and is now found in a wide range of other BSD systems including NetBSD and macOS. The implementations have diverged significantly ever since.

The macOS version of NSMB is notable for its now-common scheme of representing symlinks. This "Minshall-French" format shows symlinks as textual files with a extension and a magic number, always 1067 bytes long. This format is also used for storing symlinks on native SMB servers or unsupported filesystems. Samba supports this format with an option. Docker on Windows also seems to use it.

NQ

NQ is a family of portable SMB client and server implementations developed by Visuality Systems, an Israel-based company established in 1998 by Sam Widerman, formerly the CEO of Siemens Data Communications. The NQ family comprises an embedded SMB stack (written in C), a Pure Java SMB Client, and a storage SMB Server implementation. All solutions support the latest SMB 3.1.1 dialect. NQ for Linux, NQ for WinCE, iOS, Android, VxWorks and other real-time operating systems are all supported by the configurable NQ solution.

MoSMB

MoSMB is a user space SMB implementation for Linux. It supports SMB 2.x and SMB 3.x. Key features include Cloud-scale Active-Active Scale-out Clusters, SMB Direct (RDMA), SMB Multichannel, Transparent Failover and Continuous Availability. MoSMB also supports Amazon S3 object storage as storage backend in addition to POSIX file systems such as ext4, ZFS, Lustre, Ceph, etc.

Fusion File Share by Tuxera

Fusion File Share by Tuxera is a proprietary SMB server implementation developed by Tuxera that can be run either in kernel or user space. It supports SMB 3.1.1 and all previous versions, additionally advanced SMB features like continuous availability (persistent handles) scale-out, RDMA (SMB Direct), SMB multichannel, transparent compression, shadow copy.

Likewise

Likewise developed a CIFS/SMB implementation (versions 1.0, 2.0, 2.1 and SMB 3.0) in 2009 that provided a multiprotocol, identity-aware platform for network access to files used in OEM storage products built on Linux/Unix based devices. The platform could be used for traditional NAS, Cloud Gateway, and Cloud Caching devices for providing secure access to files across a network. Likewise was purchased by EMC Isilon in 2012.

KSMBD

KSMBD is an open source in-kernel CIFS/SMB server implementation for the Linux kernel. Compared to user-space implementations, it provides better performance and makes it easier to implement some features such as SMB Direct. It supports SMB 3.1.1 and previous versions.

Security

Over the years, there have been many security vulnerabilities in Microsoft's implementation of the protocol or components on which it directly relies. Other vendors' security vulnerabilities lie primarily in a lack of support for newer authentication protocols like NTLMv2 and Kerberos in favor of protocols like NTLMv1, LanMan, or plaintext passwords. Real-time attack tracking shows that SMB is one of the primary attack vectors for intrusion attempts, for example the 2014 Sony Pictures attack, and the WannaCry ransomware attack of 2017. In 2020, two SMB high-severity vulnerabilities were disclosed and dubbed as SMBGhost (CVE-2020-0796) and SMBleed (CVE-2020-1206), which when chained together can provide RCE (Remote Code Execution) privilege to the attacker.

References

References

  1. (October 22, 2009). "Microsoft SMB Protocol and CIFS Protocol Overview". [[Microsoft]].
  2. "Lan Manager Networking Concepts". Microsoft.
  3. (18 July 2012). "Common Internet File System". Microsoft.
  4. (8 January 2021). "Microsoft SMB Protocol and CIFS Protocol Overview". [[Microsoft]].
  5. (24 November 2021). "Overview of Server Message Block signing". [[Microsoft]].
  6. Johansson. (20 May 2005). "How to Shoot Yourself in the Foot with Security, Part 1". [[Microsoft]].
  7. Barreto. (1 December 2010). "The Basics of SMB Signing (covering both SMB1 and SMB2)". [[Microsoft]].
  8. (November 30, 2007). "MSKB887429: Overview of Server Message Block signing". [[Microsoft]].
  9. (May 31, 2018). "Opportunistic Locks". Microsoft.
  10. (2014). "All About Opportunistic Locking".
  11. Jose Barreto. (December 9, 2008). "SMB2, a Complete Redesign of the Main Remote File Protocol for Windows". [[Microsoft]] Server & Management Blogs.
  12. Neil Carpenter. (October 26, 2004). "SMB/CIFS Performance Over WAN Links". [[Microsoft]].
  13. (31 August 2016). "What's New in SMB in Windows Server".
  14. Mark Rabinovich, Igor Gokhman. "CIFS Acceleration Techniques". Storage Developer Conference, SNIA, Santa Clara 2009.
  15. Mark Rabinovich. "Accelerating SMB2". Storage Developer Conference, SNIA, Santa Clara 2011.
  16. Tridgell, Andrew. "Myths About Samba".
  17. "Have to use SMB 1.0? Windows 10 April 2018 Update says NO". [[theregister.com]].
  18. (15 June 2017). "Microsoft plans to deactivate SMBv1 in Windows 10 V1709". Born's Tech and Windows World.
  19. (20 April 2022). "Microsoft Gets Ready to Disable SMB1 Protocol on Windows 11". Thurrott.com.
  20. Christopher Hertel. (1999). "SMB: The Server Message Block Protocol".
  21. (November 1, 2006). "Description of Microsoft Windows Encryption Pack 1". [[Microsoft]].
  22. (1996). "US Executive Order 13026". [[United States Government]].
  23. (October 11, 2007). "Direct hosting of SMB over TCP/IP". [[Microsoft]].
  24. (13 May 2017). "SMB1 – Audit Active Usage using Message Analyzer". Microsoft.
  25. (21 April 2015). "The Deprecation of SMB1 – You should be planning to get rid of this old SMB dialect – Jose Barreto's Blog".
  26. "SMBv1 is not installed by default in Windows 10 Fall Creators Update and Windows Server, version 1709 and later versions".
  27. "WebNFS - Technical Overview".
  28. Navjot Virk and Prashanth Prahalad. (March 10, 2006). "What's new in SMB in Windows Vista". [[Microsoft]].
  29. "Server Message Block (SMB) Protocol Versions 2 and 3". Open Specifications.
  30. "Samba 3.5.0 Available for Download".
  31. "Samba 3.6.0 Available for Download".
  32. (December 2000). "NFS version 4 Protocol".
  33. Eran, Daniel. (June 11, 2013). "Apple shifts from AFP file sharing to SMB2 in OS X 10.9 Mavericks". Appleinsider.com.
  34. Vaughan, Steven J.. (October 28, 2013). "Mavericks' SMB2 problem and fixes". ZDNet.
  35. MacParc. "10.9: Switch the SMB stack to use SMB1 as default". macworld.com.
  36. Topher Kessler. (March 23, 2011). "Say adios to Samba in OS X". CNET.
  37. Thom Holwerda. (March 26, 2011). "Apple Ditches SAMBA in Favour of Homegrown Replacement".
  38. "Linux 3.7 - Linux Kernel Newbies".
  39. (October 21, 2009). "Implementing an End-User Data Centralization Solution". [[Microsoft]].
  40. Jeffrey Snover. (April 19, 2012). "SMB 2.2 is now SMB 3.0". Windows Server Blog.
  41. Chelsio Communications. (2 April 2013). "40G SMB Direct".
  42. Jose Barreto. (October 19, 2012). "SNIA Tutorial on the SMB Protocol". [[Storage Networking Industry Association]].
  43. Thomas Pfenning. "The Future of File Protocols: SMB 2.2 in the Datacenter".
  44. Joergensen, Claus. (2012-06-07). "SMB Transparent Failover – making file shares continuously available". Microsoft TechNet.
  45. Savill, John. (2012-08-21). "New Ways to Enable High Availability for File Shares". Windows IT Pro.
  46. (January 15, 2014). "SMB Security Enhancements". Microsoft Technet.
  47. Jose Barreto. (May 5, 2013). "Updated Links on Windows Server 2012 File Server and SMB 3.0". [[Microsoft TechNet]] Server & Management Blogs.
  48. Jose Barreto. (July 7, 2014). "Updated Links on Windows Server 2012 R2 File Server and SMB 3.02". [[Microsoft TechNet]] Server & Management Blogs.
  49. Jose Barreto. (December 12, 2013). "Storage Developer Conference – SDC 2013 slides now publicly available. Here are the links to Microsoft slides…". [[Microsoft TechNet]] Server & Management Blogs.
  50. Eric Geier. (December 5, 2013). "WindowsNetworking.com: Improvements in the SMB 3.0 and 3.02 Protocol Updates".
  51. Jose Barreto. (April 30, 2015). "SMB3 Networking Links for Windows Server 2012 R2". [[Microsoft TechNet]] Server & Management Blogs.
  52. Jose Barreto. (May 5, 2015). "What's new in SMB 3.1.1 in the Windows Server 2016 Technical Preview 2". [[Microsoft TechNet]] Server & Management Blogs.
  53. "SMB security enhancements". Microsoft Learn.
  54. "Windows Protocols".
  55. Tridgell, Andrew. (June 27, 1997). "A bit of history and a bit of fun".
  56. (February 25, 2011). ["Samba 4 functional levels *.
  57. "netsmb(4)".
  58. {{man. 5. nsmb.conf. FreeBSD.
  59. "UNIX Extensions".
  60. Sunu Engineer. "Building a Highly Scalable and Performant SMB Protocol Server".
  61. (14 September 2016). "Microsoft and Tuxera strengthen partnership through Tuxera SMB Server". Microsoft News Center.
  62. (December 1, 2007). "MS02-070: Flaw in SMB Signing May Permit Group Policy to Be Modified". [[Microsoft]].
  63. (January 13, 2009). "MS09-001: Vulnerabilities in SMB could allow remote code execution". [[Microsoft]].
  64. (March 7, 2013). "Sicherheitstacho.eu". [[Deutsche Telekom]].
  65. "Alert (TA14-353A) Targeted Destructive Malware". [[US-CERT]].
  66. (19 December 2014). "Sony Hackers Used Server Message Block (SMB) Worm Tool".
  67. "WannaCry Ransomware Attack Hits Victims With Microsoft SMB Exploit". [[eWeek]].
  68. (2020-06-09). "SMBleedingGhost Writeup: Chaining SMBleed (CVE-2020-1206) with SMBGhost".
Info: Wikipedia Source

This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page.

Want to explore this topic further?

Ask Mako anything about Server Message Block — get instant answers, deeper analysis, and related topics.

Research with Mako

Free with your Surf account

Content sourced from Wikipedia, available under CC BY-SA 4.0.

This content may have been generated or modified by AI. CloudSurf Software LLC is not responsible for the accuracy, completeness, or reliability of AI-generated content. Always verify important information from primary sources.

Report