
"Commonly exploited software vulnerabilities are usually caused by avoidable software defects. Having analyzed nearly 18,000 vulnerability reports over the past ten years, the CERT/Coordination Center (CERT/CC) has determined that a relatively small number of root causes account for most of them. This book identifies and explains these causes and shows the steps that can be taken to prevent exploitation. Moreover, this book encourages programmers to adopt security best practices and develop a security mindset that can help protect software from tomorrow's attacks, not just today's."--BOOK JACKET.
"Secure Coding in C and C++"
https://www.oreilly.com/library/view/secure-coding-in/978013...
"The CERT C Secure Coding Standard"
https://www.oreilly.com/library/view/the-cert-c/978032160319...
MISRA-C
Frama-C
Also have a look at the static analysis and warnings available across all major C compilers.
The classic for C++ is Seacord's "Secure coding in C and C++". As for techniques, you'll want a mix of:
* design (using smart pointers, taking advantage of array, vector and string, using optionals, atomics, etc)
* compiler flags (gcc can for example make integer overflows which are normally undefined behaviour defined by wrapping)
* static analysis (e.g. clang static analyser, clang-tidy, many commercial products)
* dynamic analysis (e.g. the clang/gcc sanitizers or whatever VC++ is offering nowadays). They work well together with automated tests.
* code review. It's extremely helpful to have an experienced engineer review your code.
* fuzzing combined with sanitizers
You'll probably want to read about threat modelling (e.g. Adam Shostack's book), to understand common attacks and how to think about them in relation to your projects.
There are others for C++, but this would be a good start.
As for C, "Extreme C" has nice up to day content.
And in both cases, "Secure Coding in C and C++",
https://www.amazon.com/Secure-Coding-2nd-Software-Engineerin...
"Secure Coding in C and C++, Second Edition"
https://www.oreilly.com/library/view/secure-coding-in/978013...
"Extreme C"
If you're serious about writing safer C code, certainly check up the following two resources from Robert Seacord:
- SEI CERT C Coding Standard: https://wiki.sei.cmu.edu/confluence/display/c/SEI+CERT+C+Cod...
- Secure Coding in C and C++: https://resources.sei.cmu.edu/library/asset-view.cfm?assetid...