nerdexam
CompTIA

PT0-001 · Question #199

A penetration tester is performing a code review against a web application Given the following URL and source code: Which of the following vulnerabilities is present in the code above?

The correct answer is C. Command injection. When a web application passes user-supplied input directly into a system shell command without sanitization, it is vulnerable to command injection.

Vulnerability discovery and analysis

Question

A penetration tester is performing a code review against a web application Given the following URL and source code:

Which of the following vulnerabilities is present in the code above?

Exhibit

PT0-001 question #199 exhibit

Options

  • ASQL injection
  • BCross-site scripting
  • CCommand injection
  • DLDAP injection

How the community answered

(52 responses)
  • A
    6% (3)
  • B
    12% (6)
  • C
    79% (41)
  • D
    4% (2)

Why each option

When a web application passes user-supplied input directly into a system shell command without sanitization, it is vulnerable to command injection.

ASQL injection

SQL injection targets database query interpreters using SQL metacharacters; the URL and code pattern described invoke OS-level execution, not a database layer.

BCross-site scripting

Cross-site scripting involves injecting malicious scripts into output rendered by a browser; the vulnerability here affects server-side command execution, not client-side rendering.

CCommand injectionCorrect

Command injection occurs when user-controlled input is concatenated into an OS-level command call (e.g., via exec(), system(), or shell_exec()) without proper escaping or allowlisting. An attacker can append shell metacharacters such as semicolons, pipes, or backticks to break out of the intended command and execute arbitrary operating system commands. This is distinct from SQL or LDAP injection because the target interpreter is the OS shell, not a query language.

DLDAP injection

LDAP injection manipulates LDAP directory queries; nothing in the described pattern interacts with an LDAP service or query syntax.

Concept tested: OS command injection via unsanitized user input

Source: https://owasp.org/www-community/attacks/Command_Injection

Topics

#command injection#code review#web application#source code analysis

Community Discussion

No community discussion yet for this question.

Full PT0-001 Practice