Windows Setup

Secure a Windows Game Server Against DDoS and Resource Abuse

Tech Setup6 min read
TS

Tech Setup

Published September 15, 2026 · Editorial policy

Secure a Windows Game Server Against DDoS and Resource Abuse

Running a Windows dedicated game server on a cloud provider like Hetzner, OVH, or AWS exposes you to constant scanning, volumetric DDoS attacks targeting game ports like UDP 27015, and rogue players exhausting your CPU and RAM. Game server engines often run with elevated privileges or poor input validation, meaning a compromised process can quickly pivot to a full system takeover. You are a systems administrator or developer managing a community game server on Windows Server 2022, and you need to lock down the network stack and enforce strict resource ceilings without breaking the game's netcode. By the end of this guide, you will have a hardened Windows Server instance that drops malicious traffic at the kernel level and strictly sandboxes your game processes.

Quick TL;DR Fix: The Baseline Hardening Script

If you need to secure a fresh Windows Server deployment right now, run this PowerShell script as Administrator. It disables unnecessary remote management surfaces, configures the Windows Firewall to drop incoming traffic by default, and sets up process containment basics.

# Disable WinRM HTTP, enforce HTTPS only (optional for remote mgmt)
Set-Item WSMan:\localhost\Service\Auth\Basic $false

# Set Windows Firewall to block all inbound by default, allow outbound
Set-NetFirewallProfile -Profile Domain,Public,Private -DefaultInboundAction Block -DefaultOutboundAction Allow

# Enable Windows Defender real-time protection and cloud-delivered protection
Set-MpPreference -DisableRealtimeMonitoring $false
Set-MpPreference -CloudBlockLevel High
Set-MpPreference -SubmitSamplesConsent 3

Write-Host "Baseline security applied. Configure specific game ports next." -ForegroundColor Green

Expected Output:

Baseline security applied. Configure specific game ports next.

Do not stop here. The default Windows firewall blocks everything, but your game server needs specific ports poked through that wall. Furthermore, game netcode relies heavily on UDP, which is the primary vector for reflection and amplification attacks.

Network Perimeter Defense: Windows Firewall and UDP Hardening

Game servers run primarily on UDP to minimize latency. Attackers know this and will flood your server ports with garbage UDP payloads, causing CPU saturation via packet processing overhead. You must restrict inbound traffic strictly to the required ports and drop invalid states.

Restricting Inbound Game Ports

Never open a broad port range (like 1-65535 or 27000-27050) unless the game engine explicitly demands it for dynamic host allocation.

Open an elevated PowerShell prompt and create explicit rules for your game. For example, if you are running a Source engine game (Counter-Strike 2, Garry's Mod) on standard ports:

# Create rule for game client UDP traffic
New-NetFirewallRule -DisplayName "GameServer-Inbound-UDP" `
    -Direction Inbound `
    -Protocol UDP `
    -LocalPort 27015 `
    -Action Allow `
    -Profile Public,Private

# Create rule for Remote Administration (RDP) - RESTRICT THIS TO YOUR IP
New-NetFirewallRule -DisplayName "Admin-RDP-Strict" `
    -Direction Inbound `
    -Protocol TCP `
    -LocalPort 3389 `
    -RemoteAddress "YOUR_HOME_OR_MGMT_IP_HERE" `
    -Action Allow `
    -Profile Public,Private

Mitigating UDP Amplification and Floods

Windows Server includes built-in IPsec and advanced filtering, but for rapid volumetric mitigation, you should tune the TCP/IP stack registry keys to drop malformed packets and handle SYN-floods (relevant if your game uses TCP for handshakes or you run a web-based control panel).

Run these commands to harden the network stack against basic denial-of-service vectors:

# Enable SYN attack protection
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" -Name "SynAttackProtect" -Value 1

# Enable Dead Gateway Detection
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" -Name "EnableDeadGWDetect" -Value 1

# Disable IP source routing (prevents spoofed packets)
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" -Name "DisableIPSourceRouting" -Value 2

Reboot your server after applying these registry changes.

Enforcing Resource Limits via Windows Job Objects

Most game server binaries (e.g., srcds.exe, RustDedicated.exe) do not have built-in resource throttling. If a memory leak occurs or a malicious player triggers an infinite loop via custom scripts (like SourceMod or Ue4SS), the process will consume 100% of your CPU cores and swap to disk, taking down the entire machine.

Windows uses Job Objects to manage groups of processes collectively. You can limit a game server process and all its child processes to a specific CPU percentage and hard memory ceiling.

Creating a Job Object via PowerShell Task

Windows Task Scheduler allows you to apply Job Object limits natively without third-party tools, but for a running service, using a scheduled task wrapper or a dedicated containerization approach is safer.

Alternatively, use Windows Server Resource Manager (WSRM) if available, or configure Win32 priorities and affinity masks directly. For a lightweight, scriptable approach, use a PowerShell wrapper script to launch your game server with restricted CPU affinity and priority.

Create a file named Launch-SecureServer.ps1 in your server root directory:

param(
    [string]$ExecutablePath = "C:\GameServers\Rust\RustDedicated.exe",
    [string]$Arguments = "-batchmode +server.port 28015",
    [int]$MaxMemoryMB = 8192
)

# Start the process in suspended state or normal and grab the ID
$ProcessInfo = New-Object System.Diagnostics.ProcessStartInfo
$ProcessInfo.FileName = $ExecutablePath
$ProcessInfo.Arguments = $Arguments
$ProcessInfo.WorkingDirectory = [System.IO.Path]::GetDirectoryName($ExecutablePath)

$Process = [System.Diagnostics.Process]::Start($ProcessInfo)

# Set Process Priority to BelowNormal to prevent starving system services
$Process.PriorityClass = [System.Diagnostics.ProcessPriorityClass]::BelowNormal

# Set CPU Affinity (e.g., restrict to cores 0 through 3 on an 8-core machine)
# Bitmask: Cores 0,1,2,3 -> Binary 1111 = Decimal 15
$Process.ProcessorAffinity = 15

Write-Host "Game server launched with PID: $($Process.Id). Priority: BelowNormal. Affinity restricted." -ForegroundColor Cyan

Setting Hard Memory Limits with PowerShell

To prevent memory leaks from crashing the host, set up a background monitoring script that watches the game server's working set and terminates it gracefully (or restarts it) if it exceeds your threshold.

Create Monitor-Memory.ps1:

$ProcessName = "RustDedicated"
$MaxMemoryBytes = 8GB

while ($true) {
    $procs = Get-Process -Name $ProcessName -ErrorAction SilentlyContinue
    foreach ($p in $procs) {
        if ($p.WorkingSet64 -gt $MaxMemoryBytes) {
            Write-Warning "Process $($p.Id) exceeded memory limit ($($p.WorkingSet64 / 1MB) MB). Killing process."
            Stop-Process -Id $p.Id -Force
            # Add logic here to restart your server wrapper
        }
    }
    Start-Sleep -Seconds 30
}

Run this monitor as a background job or install it as a persistent Windows Service using NSSM (Non-Sucking Service Manager).

Sandboxing and Filesystem Permissions

Game servers frequently load third-party plugins, DLLs, and mods written by anonymous community developers. If a mod contains malicious code, it executes with the permissions of the user account running the game server.

Least Privilege Service Accounts

Never run your game server as NT AUTHORITY\SYSTEM or your primary Administrator account. Create a restricted, unprivileged local user account specifically for game execution.

Run these commands to create a dedicated service user and strip it of interactive logon rights:

# Create a local user for the game server
$Password = Read-Host -AsSecureString "Enter secure password for game user"
New-LocalUser -Name "GameServiceAccount" -Password $Password -FullName "Game Server Restricted Account" -Description "Runs dedicated game processes with minimal privileges"

# Remove user from Users group if you want strict isolation, or leave in standard Users
# Ensure they do NOT belong to Administrators or Remote Management Users
Remove-LocalGroupMember -Group "Administrators" -Member "GameServiceAccount" -ErrorAction SilentlyContinue

Next, apply explicit Access Control Lists (ACLs) to your game installation directory so GameServiceAccount can only write to necessary folders (like logs, save, cfg), while the game binary files remain read-only.

$GameDir = "C:\GameServers\Rust"

# Reset inheritance and set baseline
icacls $GameDir /inheritance:r
icacls $GameDir /grant "Administrators:(OI)(CI)F"
icacls $GameDir /grant "SYSTEM:(OI)(CI)F"

# Grant read-only to game account for the root, modify only for data folders
icacls $GameDir /grant "GameServiceAccount:(OI)(CI)R"
icacls "$GameDir\server\my_server_identity\oxide\data" /grant "GameServiceAccount:(OI)(CI)M"
icacls "$GameDir\server\my_server_identity\logs" /grant "GameServiceAccount:(OI)(CI)M"

If This Doesn't Work: Common Failure Points

Even with strict hardening, game servers often misbehave due to Windows security defaults or netcode quirks. Check these three points if your setup fails:

  1. Clients Cannot Connect Despite Firewall Rules Open:

    • The Cause: Many game servers use Steamworks or Epic Online Services, which require outbound connections to master servers on ports TCP 27010-27031 and UDP 27000-27031. If your outbound firewall policy blocks these, the server will fail to list in the master browser.
    • The Fix: Ensure outbound rules allow destination ports required by your specific game engine documentation.
  2. Server Crashes Immediately When Launched via Restricted User:

    • The Cause: The game engine or a native C++ plugin attempts to write configuration files or logs to C:\Windows\System32 or the game installation root, which is now read-only.
    • The Fix: Check Event Viewer (eventvwr.msc) under Windows Logs > Application for .NET Runtime or Application Error events pointing to Access Denied (Error Code 0x80070005). Grant modify permissions to the specific folder throwing the error.
  3. High CPU Spike and Lag Despite Affinity Masks:

    • The Cause: Windows Defender real-time scanning hooks into file read/write operations. When a game server constantly streams write operations to save files or logs, Defender scans every single write, causing massive thread contention.
    • The Fix: Add an exclusion in Windows Defender for your entire game server directory path:
      Add-MpPreference -ExclusionPath "C:\GameServers\"
      

Maintaining Your Hardened Posture

Hardening a Windows game server is not a one-time script execution. Game server updates often overwrite file permissions, and engine patches can introduce new listening ports. Implement a monthly audit routine: review your active firewall rules (Get-NetFirewallRule), check for unauthorized local user accounts (Get-LocalUser), and ensure your game server binaries are updated to patch remote code execution (RCE) vulnerabilities inherent in older engine builds. For production-grade volumetric DDoS protection that exceeds Windows software firewall capabilities, terminate your game traffic through an upstream TCP/UDP proxy service provided by your hosting provider or a specialized DDoS mitigation vendor like Path.net or Cloudflare Spectrum.