nerdexam
CompTIA

CAS-003 · Question #353

A penetration tester noticed special characters in a database table. The penetration tester configured the browser to use an HTTP interceptor to verify that the front-end user registration web form…

The correct answer is B. IF $AGE == [1234567890] {1,3} THEN CONTINUE. Using a positive (whitelist) validation pattern that only permits numeric digits of a valid age length is the most secure input validation approach for an age field.

Technical Integration of Enterprise Security

Question

A penetration tester noticed special characters in a database table. The penetration tester configured the browser to use an HTTP interceptor to verify that the front-end user registration web form accepts invalid input in the user's age field. The developer was notified and asked to fix the issue. Which of the following is the MOST secure solution for the developer to implement?

Options

  • AIF $AGE == "!@#%^&*()_+<>?":{}[]" THEN ERROR
  • BIF $AGE == [1234567890] {1,3} THEN CONTINUE
  • CIF $AGE != "a-bA-Z!@#$%^&*()_+<>?"{}[]"THEN CONTINUE
  • DIF $AGE == [1-0] {0,2} THEN CONTINUE

How the community answered

(28 responses)
  • A
    11% (3)
  • B
    82% (23)
  • C
    4% (1)
  • D
    4% (1)

Why each option

Using a positive (whitelist) validation pattern that only permits numeric digits of a valid age length is the most secure input validation approach for an age field.

AIF $AGE == "!@#%^&*()_+<>?":{}[]" THEN ERROR

This uses negative (blacklist) validation that checks for specific bad characters; blacklists are inherently incomplete and can be bypassed with unlisted special characters or encoding tricks.

BIF $AGE == [1234567890] {1,3} THEN CONTINUECorrect

The expression IF $AGE == [1234567890]{1,3} THEN CONTINUE implements positive (allowlist) input validation by specifying exactly which characters are permitted (digits 0-9) and constraining input length (1 to 3 characters). This approach rejects all non-numeric and out-of-range input by default, directly preventing SQL injection and special character injection without relying on a blacklist of known-bad characters.

CIF $AGE != "a-bA-Z!@#$%^&*()_+<>?"{}[]"THEN CONTINUE

This is a negative check (!=) against a blacklist of bad characters, which is inferior to allowlist validation and still susceptible to bypass via omitted characters.

DIF $AGE == [1-0] {0,2} THEN CONTINUE

The pattern [1-0] is an invalid regex range (1 to 0 is empty) and {0,2} would allow zero-length input, making this both logically incorrect and insecure.

Concept tested: Allowlist input validation to prevent injection attacks

Source: https://owasp.org/www-project-proactive-controls/v3/en/c5-validate-inputs

Topics

#input validation#web application security#SQL injection prevention#secure coding

Community Discussion

No community discussion yet for this question.

Full CAS-003 Practice