Skip to content

security(AcceptInput): sanitize player names to prevent server command injection#18

Merged
Rushaway merged 1 commit intomainfrom
Rushaway-patch-1
Feb 26, 2026
Merged

security(AcceptInput): sanitize player names to prevent server command injection#18
Rushaway merged 1 commit intomainfrom
Rushaway-patch-1

Conversation

@Rushaway
Copy link
Member

Description

This PR addresses a critical security vulnerability where players could execute arbitrary server commands by including control characters (like ;, ", or newlines) in their Steam names.

The Issue

#17

Impact

This fix is global. It protects all maps on the server, including those that inject names directly via VScript string concatenation and those using the plugin's built-in placeholders.


Testing Performed

  • Verified that normal names (e.g., Player123) still display correctly in chat.
  • Verified that malicious names (e.g., Lardy;kill a) are sanitized to Lardy kill a and do not trigger secondary commands.
  • Verified that names with quotes (e.g., Name" say hi) do not break the say command structure.
  • Confirmed that !activator.name placeholders are correctly sanitized before execution.

Checklist

  • Code follows the project's style guidelines.
  • Security implications have been considered and addressed.
  • No redundant checks (optimized logic for !activator tags).

Special thanks to Lardy from NiDE Z.Escape server for reporting this RCE.

…names

- Added SanitizePlayerName to strip ';', '"' and newlines from commands.
- This prevents players from executing arbitrary server commands by changing their Steam name (e.g., "name; quit").
- Applied sanitization to both !activator.name and direct VScript strings.
Copilot AI review requested due to automatic review settings February 26, 2026 16:14
@Rushaway Rushaway merged commit 61d8a9f into main Feb 26, 2026
5 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a critical RCE vulnerability (issue #17) where players could execute arbitrary server commands by including control characters (semicolons, quotes, newlines) in their Steam names. The fix implements sanitization at two levels: global sanitization of all say/say_team commands and targeted sanitization when replacing !activator.name placeholders.

Changes:

  • Added SanitizeSayCommand and SanitizePlayerName functions to strip dangerous characters (;, ", \n, \r) from player names
  • Optimized placeholder replacement to only retrieve client data when placeholders are present in commands
  • Fixed format string vulnerability by using ServerCommand("%s", sCommand) instead of ServerCommand(sCommand)

Comment on lines +261 to +268
bool SanitizeSayCommand(char[] sCommand, int maxlen)
{
// Only sanitize chat commands
if (strncmp(sCommand, "say ", 4, false) != 0 && strncmp(sCommand, "say_team ", 9, false) != 0)
return false;

return SanitizePlayerName(sCommand, maxlen);
}
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SanitizeSayCommand function is only called in AcceptInput (line 199), but not in the Detour_SendToServerConsole or Detour_SetValue functions. This means that if VScript uses SendToConsole("say " + playerName + " message"), the command will not be sanitized for command injection. While the PR description claims "global protection" for VScript string concatenation, this only applies to commands going through point_servercommand, not through SendToConsole. Consider adding the same sanitization to Detour_SendToServerConsole to ensure consistent protection across all command sources.

Copilot uses AI. Check for mistakes.
@Rushaway Rushaway deleted the Rushaway-patch-1 branch February 27, 2026 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants