Timedora
Free Practice Quiz Question List

Injection Risks and Defenses Online Quiz Questions

Use this free practice quiz with 10 questions to review Injection Risks and Defenses, test your knowledge, and prepare for your next test or exam.

10 questions
01
Choose one
1 point

Which situation best describes injection?

  1. A

    Untrusted data is checked against an expected format before being stored.

  2. B

    Untrusted data is interpreted as part of a command or structured language.

  3. C

    A system records technical details in a protected server-side log.

  4. D

    A user is denied access to a record they are not authorized to view.

02
Choose one
1 point

What is the central defense against injection?

  1. A

    Reject every input containing punctuation so it cannot affect a command.

  2. B

    Use detailed error messages to reveal when an input is suspicious.

  3. C

    Keep untrusted data separate from instructions using controls suited to the context.

  4. D

    Rely on one security filter to replace other protective controls.

03
Choose one
1 point

Which set contains only examples of injection?

  1. A

    SQL injection, operating-system command injection, and cross-site scripting

  2. B

    Input validation, least privilege, and secure error handling

  3. C

    Prepared statements, protected logs, and authorization checks

  4. D

    HTML text, HTML attributes, and CSS

04
Choose one
1 point

A program displays untrusted data in different contexts. Which approach follows the principle of separating data from instructions?

  1. A

    Validate all input and then output it without encoding.

  2. B

    Encode all stored input once, before knowing how it will later be used.

  3. C

    Use the same generic escape operation for every output destination.

  4. D

    Encode untrusted data for the exact context in which it will be interpreted.

05
Choose one
1 point

An application retrieves a record using a user-supplied ID. Which method best prevents the ID from being interpreted as SQL syntax?

  1. A

    Concatenate the supplied ID into the SQL text after checking its length.

  2. B

    Bind the supplied ID as a value in a parameterized query.

  3. C

    Manually escape the supplied ID before joining it to the SQL text.

  4. D

    Allow the supplied ID to determine the query structure, then filter results.

06
Choose one
1 point

A user can choose which column to sort by. How should the application handle this structural choice?

  1. A

    Pass the requested table name as a parameter and assume the database will treat it as a value.

  2. B

    Concatenate the requested sort direction into the query after manually escaping it.

  3. C

    Map the requested structural choice to a small allowlist of fixed options.

  4. D

    Let the user supply a complete SQL fragment and validate its length.

07
Choose one
1 point

A database lookup safely binds a user-supplied record ID as a parameter. What must the application still do?

  1. A

    Check separately whether the user is allowed to access the requested record.

  2. B

    Assume parameter binding authorizes access to every requested record.

  3. C

    Remove the authorization check because the ID is safely bound.

  4. D

    Use a more restrictive input format as a replacement for authorization.

08
Choose one
1 point

A program needs to create a directory named by a user. Which approach best avoids command injection?

  1. A

    Build a shell command using the directory name, then escape the name manually.

  2. B

    Put the directory name into a command string and reject it only if an error occurs.

  3. C

    Use a generic input filter as a substitute for changing how the command is built.

  4. D

    Use a filesystem library to create the directory without constructing a shell command.

09
Choose one
1 point

An application must launch an operating-system process using a user-supplied argument. Which approach best reduces command injection risk?

  1. A

    Construct one shell command from the executable and all user-supplied arguments.

  2. B

    Pass a trusted executable and each argument separately through a process API, and validate the arguments.

  3. C

    Pass the full command as one argument and assume this also authorizes it.

  4. D

    Rely on a generic escape function to make any shell command safe.

10
Choose one
1 point

How does input validation relate to parameterization and context-aware output encoding?

  1. A

    Validation alone safely separates user data from every command and output context.

  2. B

    Validation replaces parameterization as long as malformed inputs are rejected.

  3. C

    Validation complements parameterization and output encoding but does not replace them.

  4. D

    Validation is useful only after an injection has already occurred.