Home / Learn Secure SQL / Canonicalization Pitfalls
Canonicalization Pitfalls
Why the same-looking value can have more than one representation.
Breaking it down
What it is
Canonicalization means converting a value to one single, standard form before validating or comparing it; without it, equivalent-looking values (different Unicode normalizations, different cases, extra whitespace) can slip past a check that only looked for one specific representation.
Why it matters
A validation check written against one representation of a value (say, a lowercase email) can be silently bypassed by an equivalent but differently-encoded value, if the comparison does not first normalize both sides.
Mechanically speaking
Normalize case, Unicode form, and whitespace consistently before validating or comparing (e.g. store and compare emails lowercased and trimmed), and do this normalization once, in one shared place.
Shows up in
- Web application code review
- Backend development
- Database administration
Normalizing both sides (here, with LOWER()) before comparing avoids missing a match purely due to case differences — the same idea applies to any canonicalization need.
Check yourself
1. Canonicalization pitfalls arise because...
Multiple representations, one true value.