nerdexam
CompTIA

CAS-001 · Question #417

A developer is determining the best way to improve security within the code being developed. The developer is focusing on input fields where customers enter their credit card details. Which of the…

The correct answer is D. Regular expression matching. Regular expression (regex) matching performs server-side input validation by checking that the data entered matches a precisely defined pattern before it is processed. For credit card fields, a regex can enforce exact length, digit-only characters, valid IIN/BIN prefixes, and…

Enterprise Security

Question

A developer is determining the best way to improve security within the code being developed. The developer is focusing on input fields where customers enter their credit card details. Which of the following techniques, if implemented in the code, would be the MOST effective in protecting the fields from malformed input?

Options

  • AClient side input validation
  • BStored procedure
  • CEncrypting credit card details
  • DRegular expression matching

How the community answered

(54 responses)
  • A
    4% (2)
  • B
    13% (7)
  • C
    2% (1)
  • D
    81% (44)

Explanation

Regular expression (regex) matching performs server-side input validation by checking that the data entered matches a precisely defined pattern before it is processed. For credit card fields, a regex can enforce exact length, digit-only characters, valid IIN/BIN prefixes, and format-rejecting any malformed, unexpected, or malicious input before it reaches application logic or the database. This directly addresses the problem of malformed input. Client-side input validation (A) runs in the browser and can be trivially bypassed by an attacker using a proxy or curl-it provides no real security and must never be used as the sole defense. Stored procedures (B) protect against SQL injection by parameterizing queries but do not validate whether the input value itself is well-formed. Encrypting credit card details (C) protects data confidentiality at rest and in transit but does nothing to reject malformed input before it is processed. Regex is the most direct and effective technical control specifically targeting input validation at the field level.

Topics

#input validation#regular expressions#secure coding#credit card security

Community Discussion

No community discussion yet for this question.

Full CAS-001 Practice