nerdexam
ExamsCAS-003Questions#448
CompTIA

CAS-003 · Question #448

CAS-003 Question #448: Real Exam Question with Answer & Explanation

The correct answer is C: Use regular expressions. Regular expressions provide a concise, pattern-based method to validate that input conforms to a specific format such as exactly ten numeric digits. They are both precise and computationally efficient, satisfying both the security and performance requirements.

Question

A security engineer is assisting a developer with input validation, and they are studying the following code block: The security engineer wants to ensure strong input validation is in place for customer-provided account identifiers. These identifiers are ten-digit numbers. The developer wants to ensure input validation is fast because a large number of people use the system. Which of the following would be the BEST advice for the security engineer to give to the developer?

Exhibit

CAS-003 question #448 exhibit

Options

  • AReplace code with Java-based type checks
  • BParse input into an array
  • CUse regular expressions
  • DCanonicalize input into string objects before validation

Explanation

Regular expressions provide a concise, pattern-based method to validate that input conforms to a specific format such as exactly ten numeric digits. They are both precise and computationally efficient, satisfying both the security and performance requirements.

Common mistakes.

  • A. Java type checks validate data type such as integer versus string but do not enforce length or character constraints, leaving the format insufficiently validated.
  • B. Parsing input into an array adds processing overhead and does not inherently validate the format or length of the account identifier.
  • D. Canonicalization normalizes input encoding to a standard form as a preprocessing step before validation; it does not perform the actual format validation required for ten-digit identifiers.

Concept tested. Regular expressions for efficient and precise input validation

Reference. https://cheatsheetseries.owasp.org/cheatsheets/Input_Validation_Cheat_Sheet.html

Community Discussion

No community discussion yet for this question.

Full CAS-003 Practice