Skip to content

fix: add input validation to YAML templates, RCON gateway, and match DTOs#7

Open
Flegma wants to merge 2 commits intomainfrom
audit/404-input-validation
Open

fix: add input validation to YAML templates, RCON gateway, and match DTOs#7
Flegma wants to merge 2 commits intomainfrom
audit/404-input-validation

Conversation

@Flegma
Copy link
Copy Markdown
Contributor

@Flegma Flegma commented Apr 2, 2026

Summary

Three input validation improvements:

  1. YAML template sanitizationreplacePlaceholders() now strips newlines from replacement values to prevent YAML structure injection. Uses split/join instead of RegExp for safer string replacement.

  2. RCON command validation — New validateCommand() method rejects commands that are empty, exceed 512 chars, or contain command-chaining characters (;, \n, \r). All commands are logged for audit trail.

  3. Match data DTO validation — Converted MatchData from interface to class with class-validator decorators. Controller now uses @Body() with ValidationPipe({ whitelist: true }) instead of raw req.body cast.

Test plan

  • Create offline match via web UI — YAML generated correctly
  • RCON commands from admin panel work normally
  • Overly long RCON commands (>512 chars) are rejected
  • Invalid match data (missing required fields) returns validation error

Closes 5stackgg/5stack-panel#404
Closes 5stackgg/5stack-panel#405
Closes 5stackgg/5stack-panel#406

…DTOs

- YAML template: sanitize replacement values (strip newlines) and use
  split/join instead of RegExp to prevent injection via special chars
- RCON gateway: validate command length (max 512), reject command
  chaining (semicolons, newlines), log all commands for audit trail
- Offline matches: convert MatchData to class with class-validator
  decorators, use @Body() with ValidationPipe instead of raw req.body cast

Closes 5stackgg/5stack-panel#404
Closes 5stackgg/5stack-panel#405
Closes 5stackgg/5stack-panel#406
These were imported for future nested object validation but are not
currently used. Will be re-added when nested DTOs are converted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant