SN 8.1

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/28

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 9:58 PM on 4/21/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

29 Terms

1
New cards

What is a web application?

A web application is a program that runs on a server. When your browser sends a request, the server processes it and sends back a response (the webpage).

2
New cards

What is a shell?

A shell is a program that provides a text-based interface to interact with an operating system. It interprets commands and tells the OS to execute them.

3
New cards

What is a command injection vulnerability?

A command injection occurs when an attacker sends malicious data to a web application, and that data is used to construct a command that is executed on the server's shell, allowing the attacker to run unintended commands.

4
New cards

Why is the simple PHP ping example vulnerable?

The developer directly pastes user input into a shell command string without validation. An attacker can add special shell characters to execute additional commands.

5
New cards

What dangerous shell characters can be used for command injection?

; & | $() backticks > \n (newline) and many others.

6
New cards

What is the problem with trying to block dangerous characters (blacklisting)?

There are too many dangerous characters and shell interpretation is complex; an attacker can always find a character or encoding that bypasses the filter.

7
New cards

What is the secure alternative to blacklisting?

Whitelisting: define exactly what input is allowed (e.g., a valid IP format) and reject everything else.

8
New cards

How does a shell’s complexity make command injection difficult to prevent by simple filtering?

The shell interprets quotes, variables, subcommands, and encodings, so a simple string replacement cannot reliably remove all malicious patterns.

9
New cards

What is the principle of whitelisting?

Allow only known-good input patterns; do not try to block bad characters. This ensures only legitimate, expected data is processed.

10
New cards

What is the principle of least privilege?

A process should run with the minimum permissions necessary to perform its function. If compromised, the attacker’s capabilities are limited.

11
New cards

How can you minimise the risk of command injection?

Avoid using system commands (like system(), exec(), shell_exec()) whenever possible; use built-in language functions instead.

12
New cards

What should you do if you must use a system command?

Strictly whitelist the input to ensure it matches an expected format, and run the command with the least possible privilege.

13
New cards

What is an example of strong input validation for an IP address in PHP?

Using filter_var($ip, FILTER_VALIDATE_IP) to check that the input is a valid IP address format.

14
New cards

What does the conceptual equation "Secure Application = Whitelist Validation + Minimized Attack Surface + Least Privilege" represent?

It summarises the three key strategies for preventing command injection: use whitelists, avoid unnecessary system commands, and run with minimal permissions.

15
New cards

What is the difference between blacklisting and whitelisting?

Blacklisting tries to block a list of "bad" characters; whitelisting defines what is "good" and rejects everything else. Whitelisting is more secure.

16
New cards

Why is sanitisation alone insufficient?

Attackers can use many characters (;, &, $(), backticks, >, newlines) and shell complexity (quotes, variables, encodings) to bypass simple sanitisation.

17
New cards

What is the purpose of the principle of least privilege in the context of a web server?

If the web server process has minimal permissions (e.g., no access to /etc/passwd), even a successful command injection cannot read sensitive system files.

18
New cards

What is a subcommand in shell injection?

Using $() or backticks to embed a command that is executed and its output is substituted into the original command.

19
New cards

How can an attacker use a semicolon (;) in a command injection?

The semicolon acts as a command separator, allowing the attacker to run a second command after the intended one.

20
New cards

How can an attacker use a pipe (|) in a command injection?

The pipe takes the output of the first command and feeds it as input to the second command, enabling complex chains of commands.

21
New cards

What does a backtick (`) do in a shell?

Backticks execute the command inside them and substitute the output, similar to $().

22
New cards

What does an ampersand (&) do in a shell?

It runs the preceding command in the background, and then the next command is executed immediately.

23
New cards

What does a newline (\n) character do in a shell command?

It ends the current command and starts a new one, similar to pressing Enter.

24
New cards

What is the main takeaway about user input?

Treat all user input as untrusted; it is attacker-controlled until proven otherwise.

25
New cards

What is the recommended approach to handling user input for shell commands?

Use strict whitelisting (allow only valid formats) and avoid using shell commands when possible.

26
New cards

What is a shell’s role in interpreting commands?

The shell parses and interprets the command string, performing expansions (variables, subcommands, globbing) before executing the actual program.

27
New cards

What does "minimise use of system commands" mean in practice?

Use programming language libraries or built-in functions instead of calling external programs via shell functions like exec() or shell_exec().

28
New cards

What is the benefit of using filter_var() for IP validation?

It ensures that the input matches the strict format of an IP address, automatically rejecting any input that contains shell metacharacters.

29
New cards

What does the conceptual equation "Secure Application = Whitelist Validation + Minimized Attack Surface + Least Privilege" encourage?

It encourages a defense‑in‑depth approach: combine multiple security layers to protect against command injection.