Resources

100 MUD Security resources for MUD players

Securing a Multi-User Dungeon requires a multi-layered approach that addresses the vulnerabilities of legacy C codebases, the exposure of the Telnet protocol, and the risks associated with long-term player data storage. This guide provides actionable technical steps for administrators to harden their servers and code against common exploits and infrastructure attacks.

100 MUD Security resources for MUD players illustration
Placeholder illustration shown while custom artwork is being produced.

Infrastructure and Network Hardening

  1. 1

    Fail2Ban Telnet Protection

    beginnerhigh

    Configure Fail2Ban to monitor MUD log files for failed login attempts or rapid connection cycling to automatically drop IP addresses via iptables.

  2. 2

    Non-Root Execution

    beginnerhigh

    Never run the MUD binary as the root user. Create a dedicated service account with restricted shell access and limited filesystem permissions to the 'lib' and 'src' directories.

  3. 3

    SSH Key-Only Authentication

    intermediatestandard

    Disable password authentication in /etc/ssh/sshd_config and require SSH keys for all administrative access to the hosting environment.

  4. 4

    Docker Containerization

    intermediatemedium

    Wrap the MUD process in a Docker container to isolate the game environment from the host OS, preventing directory traversal attacks from reaching system files.

  5. 5

    Iptables Rate Limiting

    intermediatehigh

    Implement 'recent' module rules in iptables to limit new connections to the MUD port (typically 4000) to 5 per minute per IP to mitigate low-level DDoS and botting.

  6. 6

    Automated Remote Backups

    beginnermedium

    Use rsync or rclone to push encrypted copies of player files (pfiles) and the world database to a secondary cloud provider or off-site server every 6 hours.

  7. 7

    Log Rotation and Auditing

    beginnerstandard

    Configure logrotate for game logs and implement a script to scan for keywords like 'segmentation fault' or 'SIGSEGV' to identify potential exploit attempts.

  8. 8

    Kernel Hardening via sysctl

    advancedmedium

    Modify /etc/sysctl.conf to enable TCP SYN cookies and disable ICMP redirects to harden the network stack against common spoofing and exhaustion attacks.

  9. 9

    VPN-Only Admin Port

    intermediatehigh

    If using a separate port for administrative tools or web-based control panels, restrict access to a specific VPN subnet or IP whitelist.

  10. 10

    System Resource Limits

    intermediatestandard

    Use ulimit or systemd service limits to restrict the maximum memory and CPU usage the MUD process can consume, preventing a crash from locking the entire server.

Codebase Security and Exploit Prevention

  1. 1

    Buffer Overflow Audit

    advancedhigh

    Search for all instances of 'strcpy', 'strcat', and 'gets' in the C source. Replace them with 'strncpy', 'strncat', and 'fgets' to enforce explicit buffer length limits.

  2. 2

    Format String Sanitization

    advancedhigh

    Ensure that 'send_to_char' or 'sprintf' calls do not pass user-provided strings directly as the format argument; always use a static format string like '%s'.

  3. 3

    Integer Overflow Protection

    intermediatemedium

    Audit currency and XP addition functions. Implement checks to ensure that adding a value does not cause a variable to wrap around to a negative or zero value.

  4. 4

    Item Duplication Logic Fixes

    intermediatehigh

    Verify that 'get' and 'drop' commands are atomic. Ensure that an item is removed from the source container before being added to the destination to prevent race conditions.

  5. 5

    Static Analysis with Cppcheck

    beginnermedium

    Run Cppcheck against the entire source directory to identify uninitialized variables, memory leaks, and out-of-bounds array accesses before compiling.

  6. 6

    Valgrind Memory Testing

    advancedmedium

    Run the MUD binary through Valgrind in a test environment to identify memory leaks and invalid writes that could be leveraged for remote code execution.

  7. 7

    Stack Smashing Protection

    beginnerhigh

    Compile the MUD with the '-fstack-protector-all' GCC flag to add canary values to the stack, causing the program to abort if a buffer overflow is detected.

  8. 8

    Input Sanitization for ANSI

    intermediatestandard

    Filter player input to remove or escape ANSI escape sequences that could be used to spoof system messages or clear the screens of other players.

  9. 9

    Command Rate Limiting

    intermediatemedium

    Implement a 'wait state' or 'pulse' check on all player commands to prevent macro-based spamming and brute-force guessing of hidden command names.

  10. 10

    Address Space Layout Randomization

    beginnerstandard

    Ensure the host OS has ASLR enabled (echo 2 > /proc/sys/kernel/randomize_va_space) to make it harder for attackers to predict memory addresses for exploits.

Player Data and Access Control

  1. 1

    Bcrypt Password Hashing

    advancedhigh

    Replace legacy plaintext or DES-based password storage with a modern library like libxcrypt using the Blowfish (bcrypt) algorithm with a high cost factor.

  2. 2

    PII Minimization

    beginnermedium

    Audit player files (pfiles) and remove unnecessary personally identifiable information such as real names or exact birthdates to reduce liability in case of a breach.

  3. 3

    Admin Command Logging

    beginnerhigh

    Force-enable 'snoop' or 'log' on all characters with administrative flags to create a permanent audit trail of all staff actions and world changes.

  4. 4

    Role-Based Access Control

    intermediatemedium

    Refactor 'trust' levels to use a granular permission system. An 'area builder' should not have the permission to 'shutdown' the server or 'set' player stats.

  5. 5

    Secure File Permissions

    beginnerstandard

    Set pfile directory permissions to 700 (drwx------) so only the MUD service user can read player data, preventing other local users from seeing passwords.

  6. 6

    Session Timeout for Staff

    beginnerstandard

    Implement an idle-timeout for characters with administrative privileges to prevent hijacked sessions if a staff member leaves their terminal unattended.

  7. 7

    Email Obfuscation

    beginnerstandard

    If player emails are displayed in 'whois' or 'finger' commands, ensure they are only visible to administrators or are masked to prevent scraping by spambots.

  8. 8

    Multi-Factor Authentication

    advancedhigh

    Implement a basic TOTP (Google Authenticator) check for 'Imp' or 'God' level logins, requiring a 6-digit code before granting access to high-level commands.

  9. 9

    IP-Locked Admin Accounts

    intermediatemedium

    Hard-code or config-lock specific administrative characters to only be accessible from known, static IP addresses or CIDR ranges.

  10. 10

    Database Encryption at Rest

    intermediatestandard

    If using MySQL or PostgreSQL for player data, enable transparent data encryption (TDE) to protect the data files on the physical disk.