Courseiva
Web App Injection Attacks →mediumMultiple Select

GCIH Practice Question: During a web application penetration test, an assessor discovers an endpoint vulnerable…

During a web application penetration test, an assessor discovers an endpoint vulnerable to OS Command Injection via an improperly sanitized ping utility parameter. Which TWO remediation strategies provide robust defense against command injection vulnerabilities?

⚠ Common exam trap

Test-takers often choose input blacklisting of characters like semicolons or pipes, ignoring the fact that attackers easily find alternative shell delimiters.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

Replace shell execution wrappers with native language libraries or built-in functions designed for the specific task.

Replacing insecure OS command execution functions with native language libraries or APIs completely avoids invoking the underlying operating system shell. When OS execution is strictly necessary, passing arguments as a fixed array rather than a concatenated string prevents shell metacharacter interpretation.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✓

    Replace shell execution wrappers with native language libraries or built-in functions designed for the specific task.

    Why this is correct

    The strongest fix is not to call a shell at all: use a library or built-in function that does the job directly, such as a networking library instead of running the ping binary, or file APIs instead of shell commands. With no shell involved, metacharacters such as semicolons and pipes have no special meaning, so the injection path disappears entirely rather than being filtered.

  • ✗

    Apply strict input validation blacklists to filter out dangerous shell operators such as semicolons, pipes, and ampersands.

    Why it's wrong here

    Blacklists of shell metacharacters are bypassable through encoding, alternate separators, and shell-specific syntax, so they cannot provide robust defence. It is tempting because blocking obvious operators appears to neutralise injection, but blacklisting suits low-risk legacy hardening only; the correct strategies avoid invoking a shell entirely and validate against a strict allowlist.

  • ✓

    Pass command arguments as separate array elements to process execution functions instead of a single string.

    Why this is correct

    When an external program is genuinely needed, call it with the arguments as a list, for example subprocess.run(['ping', '-c', '4', host]) in Python without shell=True, or ProcessBuilder in Java. Each element reaches the program as a single argument, with no shell parsing, so input like '8.8.8.8; cat /etc/passwd' is just an invalid hostname. Add allow-list validation, such as a strict IP address format, as a further layer.

  • ✗

    Configure the web server process to run with elevated root privileges to ensure access to system binaries.

    Why it's wrong here

    Running the web server as root makes things much worse: any command injection then runs with full administrative control of the host. Least privilege says the application should run as a dedicated low-privilege account with only the access it needs, so a successful attack is contained. Elevated privileges are never a remediation for injection; they amplify its impact.

  • ✗

    Encode all user inputs using URL encoding standards before passing parameters into system shell execution functions.

    Why it's wrong here

    URL encoding is for safely transporting data in URLs, and web frameworks decode it automatically before the application sees the parameter, so the original metacharacters reach the command unchanged. Even encoded input would be decoded before use. Command injection is prevented by avoiding the shell, passing arguments as lists, and validating input against an allow-list, not by encoding schemes meant for another context.

About these practice questions

This GCIH question is part of Courseiva's 322-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

You might also like

Similar GCIH questions

Written and reviewed by Johnson Ajibi, MSc IT Security

Security Systems Architect · founder of Courseiva

Last reviewed September 2026 · checked against the official GIAC exam blueprint

This GCIH practice question is part of Courseiva's free GIAC certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the GCIH exam.