|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +comments: false |
| 4 | +title: "Introducing the conan audit Command for Scanning C++ CVEs" |
| 5 | +meta_title: "Secure Your C++ Builds with the New conan audit Command - Conan Blog" |
| 6 | +description: "Learn how the new conan audit command helps you detect CVEs in your C++ dependencies, ensuring a more secure development workflow." |
| 7 | +permalink: /introducing-conan-audit-command/ |
| 8 | +--- |
| 9 | + |
| 10 | +Maintaining a secure dependency graph and responding swiftly to security threats is |
| 11 | +critical in modern software development. A recent example that underscores this need is |
| 12 | +[the vulnerability discovered in XZ |
| 13 | +Utils](https://en.wikipedia.org/wiki/XZ_Utils_backdoor) (CVE-2024-3094). While this |
| 14 | +vulnerability had the potential to affect many systems, it was detected before widespread |
| 15 | +deployment, limiting its actual impact. This incident highlights the importance of |
| 16 | +proactive security tools to help identify and mitigate vulnerabilities in dependencies. |
| 17 | + |
| 18 | +At Conan, we have long considered security a priority, continuously implementing |
| 19 | +features to enhance it. Some examples include native support for [generating SBOMs with |
| 20 | +CycloneDX](https://blog.conan.io/2025/02/05/What-is-your-code-made-of-sboms.html) and |
| 21 | +[package signing](https://docs.conan.io/2/reference/extensions/package_signing.html). |
| 22 | + |
| 23 | +Building on this security-focused approach, we are excited to introduce a new experimental |
| 24 | +command in Conan: `conan audit`. Starting with Conan 2.14, this command allows you to |
| 25 | +check for potential CVEs (Common Vulnerabilities and Exposures) within your dependency |
| 26 | +graph. |
| 27 | + |
| 28 | +## Scanning for Vulnerabilities with `conan audit` |
| 29 | + |
| 30 | +The `conan audit` command enables users to scan for potential vulnerabilities in any Conan |
| 31 | +package available in Conan Center. This command connects to a free service powered by |
| 32 | +[JFrog Advanced Security](https://jfrog.com/devops-native-security), which provides |
| 33 | +detailed vulnerability analysis reports. |
| 34 | + |
| 35 | +> **Note:** If you are using packages from Conan Center, some vulnerabilities may have already |
| 36 | +> been mitigated through patches applied in the recipe. To verify if a patch has been |
| 37 | +> applied, check the recipe in Conan Center. |
| 38 | +
|
| 39 | +To use the command, users must register and obtain a token that grants access to a limited |
| 40 | +number of scans per day. |
| 41 | + |
| 42 | +### Registering for the Service |
| 43 | + |
| 44 | +Before using `conan audit`, you need to sign up for the free service. Upon registration, you |
| 45 | +will receive a token that must be validated via email. |
| 46 | + |
| 47 | +To register, go to [https://audit.conan.io/register](https://audit.conan.io/register) and |
| 48 | +fill in your details. |
| 49 | + |
| 50 | +<p class="centered"> |
| 51 | + <img src="{{ site.baseurl }}/assets/post_images/2025-03-19/conan-audit-register.png" alt="Conan Audit Registration"/> |
| 52 | +</p> |
| 53 | + |
| 54 | +> **Notes:** |
| 55 | +> - The `conan audit` service is currently in an experimental phase and may undergo |
| 56 | +> breaking changes in its APIs, results, and functionality. |
| 57 | +> - To ensure fair usage and prevent abuse, there is a limit of **100 queries per day**, |
| 58 | +> which resets every 24 hours. |
| 59 | +
|
| 60 | +After registration, you will receive a token. Please make sure to store it securely as it |
| 61 | +will only be displayed once. |
| 62 | + |
| 63 | +<p class="centered"> |
| 64 | + <img src="{{ site.baseurl }}/assets/post_images/2025-03-19/conan-audit-token.png" alt="Conan Audit Token"/> |
| 65 | +</p> |
| 66 | + |
| 67 | +Next, you will receive an email to validate your token. Once validated, you can start |
| 68 | +using `conan audit`. |
| 69 | + |
| 70 | +<p class="centered"> |
| 71 | + <img src="{{ site.baseurl }}/assets/post_images/2025-03-19/conan-audit-validation.png" alt="Conan Validate Token"/> |
| 72 | +</p> |
| 73 | + |
| 74 | +### Using the `conan audit` Command |
| 75 | + |
| 76 | +The first thing you need to do is update the security provider token for Conan Center. Do |
| 77 | +this by running: |
| 78 | + |
| 79 | +```shell |
| 80 | +$ conan audit provider auth conancenter --token=<your_token> |
| 81 | +Provider authentication added. |
| 82 | +``` |
| 83 | + |
| 84 | +> **Note:** We use `--token` for simplicity, but this may expose your token in shell |
| 85 | +> history. To avoid this, set it as an environment variable matching the provider name in |
| 86 | +> uppercase, e.g., `CONAN_AUDIT_PROVIDER_TOKEN_CONANCENTER`. |
| 87 | +
|
| 88 | +Once this is done, you're ready to scan for vulnerabilities in your Conan packages. The |
| 89 | +simplest way to check a specific package reference is by using `conan audit list` like |
| 90 | +this: |
| 91 | + |
| 92 | +```shell |
| 93 | +$ conan audit list openssl/1.1.1w |
| 94 | +Requesting vulnerability info for: openssl/1.1.1w |
| 95 | + |
| 96 | +****************** |
| 97 | +* openssl/1.1.1w * |
| 98 | +****************** |
| 99 | + |
| 100 | +2 vulnerabilities found: |
| 101 | + |
| 102 | +- CVE-2023-5678 (Severity: Medium, CVSS: 5.3) |
| 103 | + |
| 104 | + Issue summary: Generating excessively long X9.42 DH keys or checking |
| 105 | + excessively long X9.42 DH keys or parameters may be very slow. Impact summary: |
| 106 | + Applications that use the functions DH_generate_key() to generate an X9.42 DH |
| 107 | + key may exper... |
| 108 | + url: https://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff;h=db925ae2e65d0d925adef429afc37f75bd1c2017 |
| 109 | + |
| 110 | +- CVE-2024-0727 (Severity: Medium, CVSS: 5.5) |
| 111 | + |
| 112 | + Issue summary: Processing a maliciously formatted PKCS12 file may lead OpenSSL |
| 113 | + to crash leading to a potential Denial of Service attack Impact summary: |
| 114 | + Applications loading files in the PKCS12 format from untrusted sources might |
| 115 | + terminate ... |
| 116 | + url: https://github.com/alexcrichton/openssl-src-rs/commit/add20f73b6b42be7451af2e1044d4e0e778992b2 |
| 117 | + |
| 118 | +Total vulnerabilities found: 2 |
| 119 | + |
| 120 | + |
| 121 | +Summary: |
| 122 | + |
| 123 | +- openssl/1.1.1w 2 vulnerabilities found |
| 124 | + |
| 125 | +Vulnerability information provided by JFrog. Please check https://jfrog.com/advanced-security/ for more information. |
| 126 | + |
| 127 | +You can send questions and report issues about the returned vulnerabilities to conan-research@jfrog.com. |
| 128 | +``` |
| 129 | + |
| 130 | +To scan the entire dependency graph of a Conan recipe, use the `conan audit scan` command |
| 131 | +and provide the path to the `conanfile`, just as you would with other Conan commands. This |
| 132 | +command calculates the graph based on the specified profiles, taking all transitive |
| 133 | +dependencies into account. For instance, if a Conan recipe depends on `libpng/1.5.30` and |
| 134 | +`openssl/1.1.1w`, running an audit on the recipe would produce a result similar to this: |
| 135 | + |
| 136 | + |
| 137 | +```shell |
| 138 | +$ conan audit scan . |
| 139 | +``` |
| 140 | + |
| 141 | +You will see something similar to this: |
| 142 | + |
| 143 | +<p class="centered"> |
| 144 | + <img src="{{ site.baseurl }}/assets/post_images/2025-03-19/conan-audit-scan-cli.gif" align="center" alt="conan audit scan results"/> |
| 145 | +</p> |
| 146 | + |
| 147 | +The `conan audit scan` command supports different output formats, allowing you to generate |
| 148 | +results in JSON for programmatic analysis or in HTML for a more detailed visual report. |
| 149 | + |
| 150 | +```shell |
| 151 | +$ conan audit scan . --format=html > report.html |
| 152 | +``` |
| 153 | + |
| 154 | +Now open `report.html` to view the detailed results of the vulnerabilities found, |
| 155 | +presented in a searchable table. |
| 156 | + |
| 157 | +<p class="centered"> |
| 158 | + <img src="{{ site.baseurl }}/assets/post_images/2025-03-19/cona-audit-scan-html.gif" align="center" alt="conan audit scan html render"/> |
| 159 | +</p> |
| 160 | + |
| 161 | +## Troubleshooting |
| 162 | + |
| 163 | +If you run into any issues using `conan audit`, please don’t hesitate to reach out for |
| 164 | +support—we're here to help! |
| 165 | + |
| 166 | +🛠️ **Service Support:** For issues related to the usage of the `conan audit` command, |
| 167 | +please open an issue on our [GitHub issue |
| 168 | +tracker](https://github.com/conan-io/conan/issues). |
| 169 | + |
| 170 | +🔒 **CVE-related Issues:** If you encounter problems with the CVE data returned by the |
| 171 | +command, please report them to the JFrog Security team at |
| 172 | +[conan-research@jfrog.com](mailto:conan-research@jfrog.com). |
| 173 | + |
| 174 | +## Conclusion |
| 175 | + |
| 176 | +Proactive vulnerability scanning is essential in today's fast-paced development |
| 177 | +environment. By integrating `conan audit` into your workflow, you can detect and mitigate |
| 178 | +potential security issues early, ensuring a more secure dependency graph for your |
| 179 | +projects. We encourage you to try out this experimental tool and share your feedback with |
| 180 | +the community. |
| 181 | + |
| 182 | +Stay secure, and happy coding! |
0 commit comments