A security analyst identifies that a web application is vulnerable to command injection. The vulnerability allows an attacker to execute arbitrary system commands. What is the BEST remediation approach?

  1. Run the application in a sandboxed environment
  2. Restrict network access to the application
  3. Implement input validation and parameterized queries ✓
  4. Monitor the application for suspicious commands

Correct answer: Implement input validation and parameterized queries

Option C is correct because command injection is fundamentally an input-handling failure; implementing strict input validation to reject or sanitize dangerous characters combined with parameterized queries (where applicable) eliminates the attack vector at its root, which is the most effective and lasting fix. Option A is insufficient as the best remediation because sandboxing limits blast radius but does not prevent injection from occurring; a determined attacker can still execute commands within the sandbox. Option B is wrong as the best fix because restricting network access reduces exposure but does not eliminate the vulnerability itself; internal users or already-compromised systems could still exploit it. Option D is inadequate as a primary remediation because monitoring detects attacks after they occur rather than preventing them; it is a useful compensating control but not a substitute for fixing the underlying flaw.

Topic: · command injection, input validation, application security, remediation

Practice CompTIA CySA+ (CS0-003) Questions Free