> For the complete documentation index, see [llms.txt](https://docs.snyk.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.snyk.io/scan-fix-and-prevent/scan-with-snyk/snyk-code/snyk-code-security-rules/c-c++-rules.md).

# C/C++ rules

Snyk Code security rules for C and C++

Each rule includes the following information.

* **Rule Name**: The Snyk name of the rule.
* **CWEs**: The [CWE numbers](https://cwe.mitre.org/) the rule covers.
* **Security Categories**: The [OWASP Top 10](https://owasp.org/Top10/2025/) (2025 edition) category the rule maps to, when applicable. This column also notes whether the rule appears in the [CWE Top 25](https://cwe.mitre.org/top25/), and any applicable [OWASP API Security Top 10](https://owasp.org/API-Security/editions/2023/en/0x11-t10/) (2023) or [OWASP Mobile Top 10](https://owasp.org/www-project-mobile-top-10/) (2024) categories.

| Rule Name                                                                | CWEs             | Security Categories                             |
| ------------------------------------------------------------------------ | ---------------- | ----------------------------------------------- |
| Memory Allocation Of String Length                                       | CWE-170          | None                                            |
| Insecure Anonymous LDAP Binding                                          | CWE-287          | OWASP:A07:2025                                  |
| Buffer Overflow                                                          | CWE-122          | CWE Top 25                                      |
| Division By Zero                                                         | CWE-369          | OWASP:A10:2025                                  |
| Missing Release of File Descriptor or Handle after Effective Lifetime    | CWE-775          | None                                            |
| Command Injection                                                        | CWE-78           | CWE Top 25, OWASP:A05:2025                      |
| Dereference of a NULL Pointer                                            | CWE-476          | CWE Top 25, OWASP:A10:2025                      |
| Double Free                                                              | CWE-415          | None                                            |
| Use of Externally-Controlled Format String                               | CWE-134          | None                                            |
| Use of Hardcoded Cryptographic Key                                       | CWE-321          | OWASP:A04:2025                                  |
| Improper Null Termination                                                | CWE-170          | None                                            |
| Use of Password Hash With Insufficient Computational Effort              | CWE-916          | OWASP:A04:2025                                  |
| Integer Overflow                                                         | CWE-190          | None                                            |
| LDAP Injection                                                           | CWE-90           | OWASP:A05:2025                                  |
| Missing Release of Memory after Effective Lifetime                       | CWE-401          | None                                            |
| An optimizing compiler may remove memset non-zero leaving data in memory | CWE-1330         | None                                            |
| Potential Negative Number Used as Index                                  | CWE-125, CWE-787 | CWE Top 25                                      |
| Path Traversal                                                           | CWE-23           | OWASP:A01:2025                                  |
| Exposure of Private Personal Information to an Unauthorized Actor        | CWE-359          | OWASP:A01:2025                                  |
| Size Used as Index                                                       | CWE-125, CWE-787 | CWE Top 25                                      |
| SQL Injection                                                            | CWE-89           | CWE Top 25, OWASP:A05:2025                      |
| Server-Side Request Forgery (SSRF)                                       | CWE-918          | CWE Top 25, OWASP:A01:2025, OWASP-API:API7:2023 |
| Inadequate Encryption Strength                                           | CWE-326          | OWASP:A04:2025                                  |
| Potential buffer overflow from usage of unsafe function                  | CWE-122          | CWE Top 25                                      |
| Use of Expired File Descriptor                                           | CWE-910          | None                                            |
| Use After Free                                                           | CWE-416          | CWE Top 25                                      |
| User Controlled Pointer                                                  | CWE-1285         | None                                            |
| Authentication Bypass by Spoofing                                        | CWE-290          | OWASP:A07:2025                                  |
| Cross-site Scripting (XSS)                                               | CWE-79           | CWE Top 25, OWASP:A05:2025                      |
| XML External Entity (XXE) Injection                                      | CWE-611          | OWASP:A02:2025                                  |
| XPath Injection                                                          | CWE-643          | OWASP:A05:2025                                  |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.snyk.io/scan-fix-and-prevent/scan-with-snyk/snyk-code/snyk-code-security-rules/c-c++-rules.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
