Hardening Samba as an AD DC: Difference between revisions

From SambaWiki
No edit summary
Line 48: Line 48:


The default values of these options should not be changed:
The default values of these options should not be changed:
<code>allow nt4 crypto = no</code>
<code>allow nt4 crypto = no</code>,
<code>reject md5 clients = yes</code>
<code>reject md5 clients = yes</code>,
<code>server schannel require seal = yes</code>
<code>server schannel require seal = yes</code>,
<code>server schannel = yes</code>
<code>server schannel = yes</code>


If specific client hosts need to use outdated NETLOGON cryptography, then see the smb.conf documentation for the per-host overrides that are permitted.
If specific client hosts need to use outdated NETLOGON cryptography, then see the smb.conf documentation for the per-host overrides that are permitted.

==GnuTLS TLS option configuration==

Samba can feed the GnuTLS cryptography provider an option string to describe the TLS protocols that should be supported and not supported. See [https://gnutls.org/manual/html_node/Priority-Strings.html|The GnuTLS manual] for valid strings. The <code>tls priority</code> option is is useful to disable a newly-vulnerable TLS protocol. The default in Samba (and in modern GnuTLS) is set to ensure that SSLv3 is disabled.


=Samba Host hardening=
=Samba Host hardening=
These are things to do, on the Samba host, to improve security of Samba and your AD Domain.
The Samba Team does not maintain these hardening methods, but does recommend using packages with them prepared and tested.

The Samba Team does not maintain these hardening methods, but does recommend using (eg) packages with them prepared and tested.


==Apparmor==
==Apparmor==
Line 63: Line 69:
==SeLinux==
==SeLinux==
Samba as packaged on Fedora and RHEL has SELinux rules set to likewise restrict Samba only to the parts of the filesystem that it requires access to. This should not be disabled.
Samba as packaged on Fedora and RHEL has SELinux rules set to likewise restrict Samba only to the parts of the filesystem that it requires access to. This should not be disabled.

==TLS Configuration (LDAP over TLS, ldaps://, StartTLS)==

Samba will autogenerate a TLS certificate for the LDAP service. This should be replaced with a properly signed certificate trusted and verified by the clients in your organisation.

The options <code>tls cafile</code>,<code>tls certfile</code>,<code>tls crlfile</code>,<code>tls dh params file</code>,<code>tls keyfile</code> control the location of these files.

Currently Samba will need to be restarted when these files are updated.


=AD DC configuration options to consider=
=AD DC configuration options to consider=

Revision as of 00:27, 1 June 2023

Samba smb.conf options to set/not set

ldap server require strong auth

This smb.conf option was introduced due to the attacks on LDAP known as NTLM forwarding or 'pass the hash' attacks. If ldap server require storong auth it set to no or allow_sasl_over_tls then the authentication to an SMB server by a privileged user or computer can be redirected to our LDAP server, allowing impersonation.

A hardened installation will retain the default value of yes

See also notes on this change.

It is more secure to use Kerberos with Kerberos encryption directly.

Future possible hardening

Microsoft has chosen a different path to addressing this issue, and instead would like AD clients to include a session-specific value in the NTLMv2 response, known a channel binding. Samba doesn't set this as a client nor does it check this as a server, at this time. A future Samba may add a new option here allowing NTLM and Kerberos connections over TLS, when this is sent and checked.

ntlm auth

NTLM authentication is 56-bit encryption at best and compromised badly for well-known word lists.

For a passive attacker, the options no and allow-mschapv2 are at their core equally insecure, as they boil down to the same cryptography, but the latter option is permitted because MSCHAPv2 is harder to eliminate, is not presented on administrative interfaces and may be protected by a TLS tunnel.

A fully hardened installation should set this to disabled, to require Kerberos or simple-bind authentication only, as even NTLMv2 is quite poor security in 2023.

allow store nt hash

Related to the above, Samba 4.17 has an the allow store nt hash option, allowing Samba to avoid storing the NT hash. Well known for being unsalted the NT hash is required for NTLM, NTLMv2, and MSCHAPv2 authentication, as well as for arcfour-hmac-md5 Kerberos authentication. However in 2023 all of these authentication mechanisms are considered as weak, and should not be used on hardened networks.

The purpose of this option is to allow Samba to not store the NT hash that will not be used, as it presents a vulnerability if the DB is exposed.

A hardened installation will set the value never, which avoids this storage.

server min protocol, client min protocol, client ipc min protocol

Modern Samba versions default to SMB2 and above. A hardened Samba installation should not set server min protocol client min protocol or client ipc min protocol to values such as NT1, which enable the old SMB1 support.

Avoiding SMB1 avoids support for NTLMv2 without NTLMSSP, which is not as secure as NTLMv2 as used within NTLMSSP - eg as used in SMB2, as well as a significant body of older C code in Samba. The SMB message signing (integrity protection) protocols are also much better in SMB2.

smb1 unix extensions, unix extensions

This is only relevant if SMB1 is enabled.

The SMB1 unix extensions allow the creation of a server-side symlink to a user-chosen location, and significant work had to be done to avoid Samba following such a link. While this work is now complete, it is still better to never allow the creation of such symbolic links.

A hardened installation will retain the default of no.

NETLOGON Secure channel options

The default values of these options should not be changed: allow nt4 crypto = no, reject md5 clients = yes, server schannel require seal = yes, server schannel = yes

If specific client hosts need to use outdated NETLOGON cryptography, then see the smb.conf documentation for the per-host overrides that are permitted.

GnuTLS TLS option configuration

Samba can feed the GnuTLS cryptography provider an option string to describe the TLS protocols that should be supported and not supported. See GnuTLS manual for valid strings. The tls priority option is is useful to disable a newly-vulnerable TLS protocol. The default in Samba (and in modern GnuTLS) is set to ensure that SSLv3 is disabled.

Samba Host hardening

These are things to do, on the Samba host, to improve security of Samba and your AD Domain.

The Samba Team does not maintain these hardening methods, but does recommend using (eg) packages with them prepared and tested.

Apparmor

Samba as packaged for some distributions (SuSE has been observed) has an extensive AppArmor rule set to restrict Samba only to the parts of the filesystem that it requires access to. This should not be disabled.

SeLinux

Samba as packaged on Fedora and RHEL has SELinux rules set to likewise restrict Samba only to the parts of the filesystem that it requires access to. This should not be disabled.

TLS Configuration (LDAP over TLS, ldaps://, StartTLS)

Samba will autogenerate a TLS certificate for the LDAP service. This should be replaced with a properly signed certificate trusted and verified by the clients in your organisation.

The options tls cafile,tls certfile,tls crlfile,tls dh params file,tls keyfile control the location of these files.

Currently Samba will need to be restarted when these files are updated.

Protected Users

Protected users, implemented in Samba 4.17 and later, are not permitted to use NTLM, are restricted from Kerberos delegations (were one server can act as the user to another) and have shorter ticket lifetimes. Windows clients also detect protected users and implement local protections for these accounts.