C/C++ Secure Coding
Language | Insecure Function | Vulnerability | Scenario | Remediation/Secure Function |
---|---|---|---|---|
C |
| Buffer Overflow | A software application takes user input and stores it in a fixed-size buffer. |
|
C |
| Stack Buffer Overflow | A program reads user input into a stack buffer without bounds checking. |
|
C |
| Heap Buffer Overflow | A program allocates memory for user data but does not check the size of the input. | Ensure loop limits are correct and check allocation size |
C |
| Stack Buffer Overflow leading to Stack Smashing | A web server takes input from a request and copies it into a local stack buffer. |
|
C |
| Command Injection | An application runs system commands based on user input. | Validate input, use |
C | Unchecked arithmetic operations | Integer Overflow | A program performs arithmetic operations without checking for overflow. | Check arithmetic bounds and validate inputs |
C |
| Format String Vulnerability | A program prints user input directly using | Use format specifiers, e.g., |
String Handling Vulnerabilities
Language | Insecure Function | Vulnerability | Scenario | Remediation/Secure Function |
---|---|---|---|---|
C |
| Buffer Overflow | A software application takes user input and stores it in a fixed-size buffer. |
|
C |
| Buffer Overflow | A program uses | Ensure null termination after |
Buffer Overflow
Language | Insecure Function | Vulnerability | Scenario | Remediation/Secure Function |
---|---|---|---|---|
C |
| Stack Buffer Overflow | A program reads user input into a stack buffer without bounds checking. |
|
C | Manual memory management | Heap Buffer Overflow | A program does not properly manage dynamic memory allocation and bounds. | Use safe memory allocation functions and check bounds |
Integer Security
Language | Insecure Function | Vulnerability | Scenario | Remediation/Secure Function |
---|---|---|---|---|
C | Unchecked arithmetic operations | Integer Overflow | A program performs arithmetic operations without checking for overflow. | Check arithmetic bounds and validate inputs |
Code Injection
Language | Insecure Function | Vulnerability | Scenario | Remediation/Secure Function |
---|---|---|---|---|
C |
| Command Injection | An application runs system commands based on user input. | Validate input, use |
Exploiting Formatted Output Functions
Language | Insecure Function | Vulnerability | Scenario | Remediation/Secure Function |
---|---|---|---|---|
C |
| Format String Vulnerability | A program prints user input directly using | Use format specifiers, e.g., |
Last updated