Secure Coding

Secure coding, also referred to as secure programming, involves writing code in a high-level language that follows strict principles, with the goal of preventing potential vulnerabilities which could expose data or cause harm within a targeted system. Secure coding is more than just writing, compiling, and releasing code into applications. To fully embrace secure programming, you also need to create a secure development environment built on a reliable and secure IT infrastructure using secure hardware, software, services, and providers

Secure Coding Practices

  • Validate input: input from all untrusted data sources should be Validated. Proper input validation can eliminate the majority of software vulnerabilities. External data sources, including command line arguments, network interfaces, environmental variables, and user-controlled files should be handled with caution

  • Heed compiler warnings: Code should be compiled with highest warning level available. Static and dynamic analysis tools should be used to detect and eliminate additional security flaws.

  • Architect and design for security policies: Create a software architecture and design your software to implement and enforce security policies. For example, if your system requires different privileges at different times, consider dividing the system into distinct intercommunicating subsystems, each with an appropriate privilege set.

  • Keep it simple: Keep the design as simple and small as possible. Complex designs increase the likelihood that errors will be made in their implementation, configuration, and use. Also, the effort required to achieve an appropriate level of assurance increases dramatically as security mechanisms become more complex.

  • Default deny: Base access decisions on permission rather than exclusion. This means that, by default, access is denied, and the protection scheme identifies conditions under which access is permitted 

  • Adhere to the principle of least privilege: Every process should execute with the least set of privileges necessary to complete the job. Any elevated permission should only be accessed for the least amount of time required to complete the privileged task. This approach reduces the opportunities an attacker has to execute arbitrary code with elevated privileges.

  • Practice defense in depth: Manage risk with multiple defensive strategies, so that if one layer of defense turns out to be inadequate, another layer of defense can prevent a security flaw from becoming an exploitable vulnerability and/or limit the consequences of a successful exploit. 

  • Use effective quality assurance techniques: Good quality assurance techniques can be effective in identifying and eliminating vulnerabilities. Fuzz testing, penetration testing, and source code audits should all be incorporated as part of an effective quality assurance program.

  • Adopt a secure coding standard: Develop and/or apply a secure coding standard for your target development language and platform.

Comments

Popular posts from this blog