Software Development Security

A loosely typed language silently converts a string to a number when an application compares password hashes, so different values compare as equal and authentication is bypassed. Which language property would most directly prevent this flaw class?

Show the answer

Correct answerD. Strong typing with no implicit type coercion

AWhy not this: Garbage collection manages memory lifetime and has no effect on comparison semantics.

BWhy not this: Bounds checking prevents out-of-range memory access, not type-juggling comparisons.

CWhy not this: Compilation changes how code executes; a compiled language can still coerce types loosely.

DWhy this is right: Without implicit coercion, mismatched types are rejected or must be converted explicitly, so the loose comparison cannot occur.

Strong typing without implicit coercion forces explicit conversions, so a string cannot silently be treated as a number in a comparison. Bounds checking addresses memory errors, which are a different flaw class.