Input Validation Mechanisms
What this topic covers
Choose finite allowlists that reflect valid business data, rather than trying to block every dangerous character. Apply validation to the actual value the application will use.
Why is an allowlist better than a blacklist for input validation?
An allowlist accepts only values you have defined as valid, so anything unexpected is rejected. A blacklist tries to list dangerous characters, and attackers find encodings or characters you forgot. For a field like country code or order status, a finite list of the real business values is the safest choice.