Windows Server Security Hardening Guide
This guide provides detailed instructions on how to harden a Windows Server installation, focusing on security best practices, tools, and configuration steps to protect your server environment.
Security Assessment Tools
Port Scanning and Vulnerability Assessment
- Nmap: Network mapper for port scanning and service enumeration
- Microsoft Baseline Security Analyzer (MBSA): Identifies common security misconfigurations
- Windows Defender for Endpoint: Microsoft's enterprise security platform
- Qualys: Comprehensive vulnerability management
- Nessus: Industry-standard vulnerability scanner
- OpenVAS: Open-source vulnerability scanner
Security Monitoring Tools
- Windows Event Viewer: Built-in log management
- Microsoft Sentinel: Cloud-native SIEM and SOAR solution
- Sysmon: Enhanced system monitoring and logging
- Splunk: Log collection and analysis platform
- Wazuh: Open-source security monitoring solution
- OSSEC: Host-based intrusion detection system
Server Hardening Steps
1. Update Management
- Configure Windows Server Update Services (WSUS) or Microsoft Endpoint Configuration Manager
- Implement regular patching schedule
- Enable automatic updates for critical security patches
- Run the following PowerShell commands to check for updates:powershell
Get-WindowsUpdate Install-WindowsUpdate -AcceptAll
2. Minimize Attack Surface
Disable Unnecessary Services
- Open Server Manager > Tools > Services
- Identify and disable non-essential services
- Consider disabling services like:
- Print Spooler (if not used)
- Remote Registry
- Secondary Logon
- WebClient
- Windows Remote Management (if not required)
Remove Unnecessary Roles and Features
- Open Server Manager > Manage > Remove Roles and Features
- Remove any roles not specifically required for server function
Disable SMBv1
powershell
Disable-WindowsOptionalFeature -Online -FeatureName SMB1Protocol3. Firewall Management
Configure Windows Defender Firewall
- Open Windows Defender Firewall with Advanced Security
- Set default action for inbound connections to "Block"
- Create specific inbound rules for required services
- Implement firewall logging for denied connections:
- Right-click on each profile (Domain, Private, Public)
- Select Properties > Logging > Customize
- Enable logging for dropped packets and successful connections
Create Strict Firewall Rules
powershell
# Block all inbound connections except those specifically allowed
Set-NetFirewallProfile -Profile Domain,Public,Private -DefaultInboundAction Block -DefaultOutboundAction Allow
# Allow RDP only from specific IP addresses (replace with your management IP range)
New-NetFirewallRule -DisplayName "Allow RDP from Admin IPs" -Direction Inbound -Protocol TCP -LocalPort 3389 -RemoteAddress 10.0.0.0/24 -Action AllowImplement Network Segmentation
- Create separate network segments for different server roles
- Use VLANs to isolate traffic
- Configure Windows Advanced Firewall to restrict traffic between segments
4. User Account and Authentication Security
Implement Strong Password Policies
- Open Group Policy Management Console
- Navigate to Computer Configuration > Windows Settings > Security Settings > Account Policies > Password Policy
- Configure:
- Minimum password length: 14 characters
- Password complexity requirements: Enabled
- Maximum password age: 90 days
- Password history: 24 passwords remembered
Enable Multi-Factor Authentication
- Implement Windows Hello for Business or
- Deploy Azure Multi-Factor Authentication for on-premises systems with:
- Azure AD Connect
- MFA Server
Limit Administrative Access
- Create dedicated administrative accounts
- Implement Just-In-Time (JIT) administration using Privileged Access Management
- Use the principle of least privilege for all accounts
5. Remote Access Security
Secure Remote Desktop Protocol (RDP)
- Enable Network Level Authentication (NLA):
- System Properties > Remote tab > Check "Allow connections only from computers running Remote Desktop with Network Level Authentication"
- Restrict RDP access through firewall rules
- Change default RDP port (3389) to a custom port:Modify the "PortNumber" value
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp
Implement Remote Access Solutions
- Deploy a VPN solution like:
- Windows Server Always On VPN
- DirectAccess
- Configure a Remote Desktop Gateway (RD Gateway)
- Implement an SSL VPN solution
Secure PowerShell Remoting
powershell
# Enable PowerShell remoting with HTTPS
New-SelfSignedCertificate -DnsName "ServerName" -CertStoreLocation Cert:\LocalMachine\My
Enable-PSRemoting -Force
Set-WSManQuickConfig -UseSSL6. DDoS Attack Protection
Windows Server-Level Protection
Enable TCP/IP hardening:
powershell# Increase TCP connection timeout to help with SYN attacks Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" -Name "SynAttackProtect" -Value 2 Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" -Name "TcpMaxPortsExhausted" -Value 5 Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" -Name "TcpMaxConnectResponseRetransmissions" -Value 2Configure connection limits in IIS (if web server role is installed):
- Open IIS Manager
- Select server > Connection Limits
- Set maximum concurrent connections
Network-Level DDoS Protection
- Work with your network team to implement:
- Rate limiting at network edge
- Traffic filtering using dedicated hardware or cloud services
- Consider Azure DDoS Protection for cloud-connected resources
- Configure advanced TCP/IP settings to mitigate SYN floods
7. Malware Protection
Configure Windows Defender Antivirus
- Ensure real-time protection is enabled:powershell
Set-MpPreference -DisableRealtimeMonitoring $false - Configure regular scans:powershell
Set-MpPreference -ScanScheduleDay Everyday - Enable cloud-based protection:powershell
Set-MpPreference -MAPSReporting Advanced Set-MpPreference -SubmitSamplesConsent SendAllSamples
Enable Application Control
- Configure Windows Defender Application Control or AppLocker
- Create policies that only allow trusted applications to run
- Implement code integrity policies:powershell
# Create a new Code Integrity policy New-CIPolicy -Level FilePublisher -Fallback Hash -FilePath "C:\temp\CIPolicy.xml" -UserPEs
8. Security Monitoring and Logging
Configure Windows Event Logging
- Enable enhanced logging through Group Policy:
- Computer Configuration > Windows Settings > Security Settings > Advanced Audit Policy Configuration
- Configure the following audit policies:
- Account Logon Events: Success and Failure
- Account Management: Success and Failure
- Logon Events: Success and Failure
- Object Access: Failure
- Policy Change: Success
- Privilege Use: Success and Failure
- System Events: Success and Failure
Deploy Security Information and Event Management (SIEM)
Configure log forwarding to a central SIEM solution
Set up Windows Event Forwarding:
powershell# Configure event collector server wecutil qc /q # Create a subscription on collector server wecutil cs "C:\temp\subscription.xml"
Implement File Integrity Monitoring
- Enable auditing for critical system files
- Use tools like Windows File Integrity Monitor or Wazuh
9. Regular Security Assessments
Implement Vulnerability Scanning
- Schedule regular scans using tools like Nessus, Qualys, or OpenVAS
- Run Microsoft Baseline Security Analyzer monthly
- Scan for open ports using Nmap:
nmap -sS -sV -T4 <server-ip>
Conduct Security Compliance Scanning
- Use Microsoft Security Compliance Toolkit to assess servers against security baselines
- Run the following PowerShell command to check current security settings:powershell
Get-ComputerInfo | Select-Object OsName, OsVersion, OsBuildNumber, OsHardwareAbstractionLayer
10. Documentation and Incident Response
Document Security Configuration
- Maintain detailed documentation of:
- Network configuration
- Firewall rules
- User accounts and permissions
- Installed software and services
Create an Incident Response Plan
- Define roles and responsibilities
- Document incident response procedures
- Establish communication channels for security incidents
- Test the plan through tabletop exercises
Ongoing Security Management
Maintaining a secure Windows Server environment requires regular attention:
- Schedule monthly security reviews
- Keep up with Microsoft security bulletins
- Regularly test backup and recovery procedures
- Review and rotate credentials
- Update security documentation when changes occur
- Test the network with penetration testing tools periodically
Implementing these hardening measures will significantly improve your Windows Server security posture and help protect against common attack vectors.