Chapter 8: OS Hardening
Foundations of Operating System Hardening
Definition and Core Role of System Hardening:
Operating system (OS) hardening is the methodical process of securely configuring an operating system and its associated application software to minimize vulnerabilities and reduce the overall attack surface.
While boundary defense mechanisms—such as hardware firewalls, network perimeters, and proxy servers—are foundational, perimeter security alone is insufficient.
Internal hosts, workstations, and servers house critical institutional applications and sensitive databases; hardening internal machines ensures that defense-in-depth is maintained should the perimeter be compromised.
Securing operating systems and underlying software configurations represents one of the most critical steps in modern computer security, yet it remains one of the most frequently neglected operational tasks.
Windows Target Scope and Essential Hardening Tasks:
Applicable Windows client environments cover Windows 7 and later desktop editions, specifically including Windows 7, Windows 8, Windows 8.1, and Windows 10.
Key foundational tasks for properly configuring and securing Windows systems include:
Disabling unnecessary background services.
Configuring security-relevant keys and settings within the Windows Registry.
Enabling and enforcing host-based firewall profiles.
Hardening web browser security and privacy settings.
Windows User Accounts and Identity Management
Management of Default Accounts and Groups:
Default user accounts and administrative groups are prime targets for automated reconnaissance and password spraying attacks.
Disabling the default built-in
Administratoraccount provides superior security compared to simply renaming it, as security identifiers (SIDs) can still reveal renamed administrative accounts.Unneeded or extraneous built-in service and application accounts must be disabled when not actively required. Notable accounts include:
IUSR_MachineName: The built-in account used by Internet Information Services (IIS) for anonymous web access.ASP.NET: The local user account automatically created to run ASP.NET worker processes.Database Accounts: Dedicated accounts provisioned for database servers; where active, strict access rules must be enforced (noting that cryptographic mechanisms such as database encryption can negatively impact operational processing performance).
Principle of Least Privilege and User Hygiene:
Every account provisioned on the operating system must strictly be assigned only the minimal privileges and access rights essential to fulfill its operational function.
Administrative accounts must never be utilized for regular daily operational activities such as web browsing or standard email access.
Organizational policies must enforce strict credential hygiene:
Users must never write down credentials on paper or insecure physical media.
Users must never share account passwords or authenticate on behalf of another entity.
Windows Password and Account Lockout Policies
Default Windows Password Policies:
Out-of-the-box Windows client installations maintain minimal native password protections, requiring proactive administrative hardening.
Enforce password history: Default setting remembers password.
Maximum password age: Default lifetime is days.
Minimum password age: Default threshold is days (permitting immediate successive password changes).
Minimum password length: Default requirement is characters (permits blank passwords).
Passwords must meet complexity requirements: Disabled by default.
Store password using reversible encryption for all users in the domain: Disabled by default.
Comparative Password Setting Recommendations:
Password History (number of passwords remembered before reuse):
Microsoft baseline recommendation: passwords.
National Security Agency (NSA) recommendation: passwords.
Expert recommendation: passwords.
Maximum Password Age (validity duration before mandatory expiration):
Microsoft recommendation: days.
NSA recommendation: days.
Expert recommendation: days. The value of is arbitrary and non-intuitive; excessively frequent password changes lead end users to select weaker passwords or write them down due to cognitive fatigue.
Minimum Password Age (duration a user must wait before changing a newly established password):
Microsoft recommendation: days.
NSA recommendation: days.
Expert recommendation: days (prevents users from immediately cycling through the history threshold to reuse an old password).
Minimum Password Length:
Microsoft recommendation: characters.
NSA recommendation: characters.
Expert recommendation: characters for standard corporate operations; the -character NSA threshold should be strictly mandated in heightened-security, high-threat environments.
Complexity Requirements (forcing combinations of uppercase, lowercase, numbers, and symbols):
Microsoft recommendation: Left to user/administrator discretion.
NSA recommendation: Enforced (Yes).
Expert recommendation: Enforced (Yes).
Store Password Using Reversible Encryption:
Microsoft recommendation: Left to discretion (Disabled standardly).
NSA recommendation: No recommendation.
Expert recommendation: Left to user/administrator discretion (should remain disabled unless an application strictly demands legacy authentication protocols).
Default Windows Account Lockout Policies:
Default settings leave systems highly vulnerable to automated brute-force attacks:
Account lockout duration: Not defined.
Account lockout threshold: invalid logon attempts (meaning accounts are never automatically locked).
Reset account lockout counter after: Not defined.
Comparative Account Lockout Policy Recommendations:
Account Lockout Duration (time an account remains inaccessible post-lockout):
Microsoft recommendation: (indefinite duration; requires explicit unlock by an administrator).
NSA recommendation: hours.
Expert recommendation: hours. Long windows prevent brute-force attacks over weekends or holiday periods, guaranteeing the account remains locked until an administrator reviews the security event.
Account Lockout Threshold (permitted failed logon attempts before locking):
Microsoft recommendation: invalid attempts.
NSA recommendation: invalid attempts.
Expert recommendation: invalid attempts.
Reset Account Lockout Counter After (elapsed time before failed attempt tally resets to zero):
Microsoft recommendation: minutes.
NSA recommendation: minutes.
Expert recommendation: minutes.
Windows Registry Hardening and Architecture
Registry Architectural Fundamentals:
The Windows Registry is a centralized, hierarchical database used by the operating system to store critical configuration parameters, drivers, services, installed software, and user preferences.
Subtrees within the database are organized into major root branches termed hives.
Manual and administrative inspection/modification is conducted using the native graphical utility
regedit(orregedt32).The five primary top-level hives include:
HKEY_CLASSES_ROOT(HKCR): Contains file association linkages and Component Object Model (COM) class registration details.HKEY_CURRENT_USER(HKCU): Stores environment settings, configurations, and profile data specific to the user currently logged on.HKEY_LOCAL_MACHINE(HKLM): Holds software, hardware, and operating system configuration settings generic to the local machine.HKEY_USERS(HKU): Contains individual configuration hives for all actively loaded user profiles on the host.HKEY_CURRENT_CONFIG(HKCC): Stores temporary hardware profile information gathered at system runtime boot.
Registry Editing Precautions and Hazards:
Inappropriate or flawed edits within the Registry can corrupt kernel settings, destabilize applications, or render the operating system unbootable.
Unsupervised configuration modifications—such as adjusting write protections via parameters like
WriteProtect(toggling ON/OFF states)—can cause catastrophic system failures.Novice administrators must never test or practice registry modifications directly on production machines housing valuable operational data.
Securing the Registry Environment:
To harden the Registry and block network reconnaissance, the following countermeasures must be applied:
Restrict Null session access across the network.
Restrict Null session access via named pipes.
Restrict anonymous network access.
Disable default administrative file shares (e.g.,
C).Disable remote network access to the Registry service.
Strictly restrict anonymous access directly to Registry keys.
LanmanServer Service Key Hardening:
Target Key Path:
HKLM\SYSTEM\CurrentControlSet\Services\LanmanServerPrescribed Hardening Action: Delete all configured values within this key path to strip away default sharing behaviors that permit unauthorized lateral visibility.
TCP/IP Stack and Network Registry Optimization
TCP/IP Registry Hardening Parameters:
The default Windows TCP/IP network stack parameters are optimized for broad compatibility rather than high security, exposing machines to network spoofing, denial of service (DoS), and resource starvation.
Hardening values must be placed in the TCP/IP stack configuration parameters within the Registry (
HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters):DisableIPSourceRouting=2Setting the value to
2completely disables IP source routing, preventing external attackers from specifying network routing hops to bypass firewalls or spoof IP addresses.
EnableDeadGWDetect=0Setting the value to
0disables dead-gateway detection, preventing malicious redirection of system network traffic to an attacker-controlled rogue gateway.
EnableICMPRedirect=0Setting the value to
0blocks the host from accepting ICMP redirect packets, neutralizing Man-in-the-Middle (MitM) route poisoning attempts.
EnablePMTUDiscovery=0Disables automatic Path Maximum Transmission Unit discovery to counter fragmentation-based DoS vulnerabilities.
EnableSecurityFilters=1Activates native TCP/IP security filtering mechanisms to restrict permitted inbound IP protocols and ports.
KeepAliveTime=300,000Configures the TCP keep-alive probe transmission frequency to (), accelerating the reclamation of half-open and abandoned connections.
NoNameReleaseOnDemand=1Setting the value to
1ensures the host does not release its NetBIOS machine name upon receiving unauthorized release requests over the network.
PerformRouterDiscovery=0Setting the value to
0halts automatic RFC 1256 router discovery protocols, protecting the machine from illegitimate router advertisements.
SynAttackProtect=2A setting of
2provides the highest tier of SYN flood protection, reducing connection memory footprints and expediting SYN-ACK timeouts during high connection load.
TcpMaxConnectResponseRetransmissions=2Limits TCP connection response retransmissions to attempts before dropping the pending socket, reducing SYN flood impact.
TcpMaxConnectRetransmissions=3Restricts outbound TCP connection initialization retransmissions to a maximum of cycles.
TCPMaxPortsExhausted=5Sets the threshold limit of exhausted TCP ports to , triggering protective system countermeasures when inbound port flooding occurs.
Windows Services Management and EFS Encryption
Managing Windows Background Services:
Services are continuous background executables running independently of interactive user logons, operating analogously to daemons in Unix and Linux environments.
Every running service introduces an attack vector; terminating and disabling unused services immediately minimizes host attack surfaces.
Services are administratively managed using the native Microsoft Management Console snap-in
services.msc.Service Dependency Verification: Administrators must inspect the Dependencies tab within a service's properties dialog prior to modifying or disabling it to ensure that critical operating system features or secondary services do not fail unexpectedly.
Encrypting File System (EFS):
EFS is a native Windows security mechanism engineered to provide file-level and directory-level cryptographic protection directly on NTFS file systems.
Cryptographic Implementation: Operates via an asymmetric public key cryptographic architecture, encrypting files with a symmetric key that is subsequently encrypted using the user's public key certificate.
User Transparency: Once activated, EFS operations remain completely transparent to the logged-in authorized credential holder, enabling uninterrupted read/write access while denying unauthorized offline extraction.
Deployment Simplicity: Integrated natively within the Windows desktop and server operating systems, requiring no external third-party software installation.
Windows Security Templates and Group Policy Deployment
Architecture of Windows Security Templates:
A security template is an administrative text file (bearing an
.inffile extension) comprising hundreds of preconfigured security definitions, parameters, and defensive baselines.Templates standardize the application of user rights assignments, object-level access controls, system auditing configurations, registry permissions, and password/account lockout limits.
Rather than manually editing distinct nodes on local machines, administrators import templates into Active Directory Group Policy Objects (GPOs) for scalable, automated deployment across enterprise estates.
Standard Security Templates:
Hisecdc.inf: High-security hardening template engineered exclusively for Active Directory Domain Controllers.Securedc.inf: Moderate/standard security baseline template designated for Domain Controllers.Hisecws.inf: High-security hardening template configured for enterprise client workstations and non-controller member servers.Securews.inf: Baseline security template established for enterprise client workstations and member servers.Setup security.inf: Rollback template designed to reapply the out-of-the-box factory default security parameters of a newly installed operating system.
Linux Operating System Hardening
Commonalities Between Windows and Linux Hardening:
Both operating systems necessitate strict management, renaming, or disabling of default users, along with rigid access policy enforcement (differing only in platform terminology and syntax).
All unneeded services, daemons, and background daemons must be terminated and prevented from launching at boot.
Installed web browsers must undergo stringent privacy and execution hardening.
Operating system distributions require routine, scheduled security patch cycles.
Linux-Specific Hardening Requirements:
Root Account Restrictions: Applications, public services, and web servers must never be executed under the identity of the superuser (
root); they must run within dedicated, non-privileged service user accounts.Root Password Management: The
rootadministrative password must maintain exceptionally high complexity and undergo regular, aggressive rotation.Console Access Lockdown: All console-equivalent access rights (such as virtual consoles or privileged local shells) must be completely disabled for standard, non-administrative accounts.
Information Concealment: All system-revealing banners, kernel version outputs, and OS identification files (such as
/etc/issueor/etc/issue.net) must be stripped or masked to deny remote attackers intelligence during network scanning.
Operating System and Application Patch Management
Windows Patching Workflows:
Windows systems must be configured to run the native Windows Update service automatically to download and install security bulletins, critical patches, and driver updates.
Automatic installation prevents vulnerabilities from lingering unpatched between manual administrative reviews.
Linux Package and Kernel Updates:
In Debian- and Ubuntu-derived Linux operating systems, terminal package managers oversee security patching.
The standard administrative command string used to update all currently installed system packages and vulnerabilities is:
sudo apt-get upgrade
Web Browser Security and Privacy Configuration
The Browser as an Attack Vector:
Web browsers serve as the primary interface between internal users and external internet threats, making them frequent vectors for drive-by downloads, exploit kits, and malicious scripts.
Proper browser hardening mitigates hostile code execution and thwarts tracking mechanisms.
Browser Privacy Hardening:
Third-Party Cookies: Completely block all third-party cookies to prevent behavioral tracking and profiling by external ad networks.
First-Party Cookies: Configure the browser to prompt the end user prior to storing persistent first-party cookies.
Session Cookies: Always permit temporary session cookies, which remain strictly in volatile memory and are purged automatically upon terminating the browser application.
Browser Execution and Security Controls:
Unsigned Components: Prohibit the download and execution of all unsigned software components, drivers, or browser controls.
ActiveX Controls: Prevent ActiveX components from executing automatically without explicit user authorization.
Java Runtime Integration: Strictly restrict or disable Java applets and plugins within the browser interface due to historical exploitation vectors.
Script Execution Governance: Prevent all client-side scripts from executing invisibly; enforce settings or utilize extensions requiring explicit awareness or approval prior to script parsing.