Defensive programming
Intelligent source code reuse
Secure input and output handling
Canonicalization
Design by contract
Prefer exceptions to return codes
Intelligent source code reuse
Secure input and output handling
Canonicalization
Crackers are likely to invent new kinds of representations of incorrect data.
For example, if you checked if a requested file is not "/etc/passwd", a cracker might pass another variant of this file name, like "/etc/./passwd".
To avoid bugs due to non-canonical input, employ canonicalization libraries.
Low tolerance against "potential" bugsDesign by contract
- Design by contract uses preconditions, postconditions and invariants to ensure that provided data (and the state of the program as a whole) is sanitized. This allows code to document its assumptions and make them safely.
Prefer exceptions to return codes