Top 10 Secure Coding Practices from CERT.

  1. Validate input.
  2. Heed compiler warnings.
  3. Architect and design for security policies.
  4. Keep it simple.
  5. Default deny.
  6. Adhere to the principle of least privilege.
  7. Sanitize data sent to other systems.
  8. Practice defense in depth.
  9. Use effective quality assurance techniques.
  10. Adopt a secure coding standard.
You can read more at CERT site.

CERT, the home of the well-known CERT(R) Coordination Center, is located at Carnegie Mellon University's Software Engineering Institute. They study internet security vulnerabilities, research long-term changes in networked systems, and develop information and training to help you improve security.