Content deleted Content added
→Techniques: Intelligent source code reuse | ch Reusing code is not ''always'' good practice... to remove clarification request Dec 2017 |
→Other techniques: MAJOR Rebuilt the section, expanded sections, clarified information and formatting. Tag: Disambiguation links added |
||
Line 142:
Assume that code constructs that appear to be problem prone (similar to known vulnerabilities, etc.) are bugs and potential security flaws. The basic rule of thumb is: "I'm not aware of all types of [[security exploit]]s. I must protect against those I ''do'' know of and then I must be proactive!".
===Other
* One of the most common problems is unchecked use of constant-size
* Encrypt/authenticate all important data transmitted over networks. Do not attempt to implement your own encryption scheme,
▲* One of the most common problems is unchecked use of constant-size structures and functions for dynamic-size data (the [[buffer overflow]] problem). This is especially common for [[string (computer programming)|string]] data in [[C (programming language)|C]]. C library functions like <code>gets</code> should never be used since the maximum size of the input buffer is not passed as an argument. C library functions like <code>scanf</code> can be used safely, but require the programmer to take care with the selection of safe format strings, by sanitizing it before using it.
▲* Encrypt/authenticate all important data transmitted over networks. Do not attempt to implement your own encryption scheme, but use a proven one instead.
====The 3 Rules of Data Security====
* All [[data]] is
* All
* All code is insecure until proven otherwise.
** You cannot prove the security of any code in [[userland (computing)|userland]], or, more These three rules about data security describe how to handle any data, internally or externally sourced:
* If data is to be checked for correctness, verify that it is correct, not that it is incorrect.▼
'''All data is important until proven otherwise''' means that all data must be verified as garbage before being destroyed.
'''All data is tainted until proven otherwise''' means that all data must be handled in a way that does not expose the rest of the runtime environment without verifying integrity.
'''All code is insecure until proven otherwise''' while a slight misnomer, does a good job reminding us to never assume our code is secure as bugs or [[Undefined Behavior]] may expose the project or system to attacks such as common [[SQL injection]] attacks.
====More Information====
▲* If data is to be checked for correctness, verify that it is correct, not that it is incorrect.
* [[Design by contract]]
* [[Assertion (computing)|Assertions]] (also called '''assertive programming''')
* Prefer [[Exception handling|exceptions]] to return codes
** Generally speaking, it is preferable to throw
==See also==
|