# C++ analyzer provides a broader coverage of the C++ Core Guidelines and detects broken access control security issues

**URL:** <https://community.sonarsource.com/t/c-analyzer-provides-a-broader-coverage-of-the-c-core-guidelines-and-detects-broken-access-control-security-issues/32556>\
**Category:** Sonar Updates\
**Tags:** security, cfamily\
**Created:** [October 7, 2020, 2:45pm UTC](https://community.sonarsource.com/t/c-analyzer-provides-a-broader-coverage-of-the-c-core-guidelines-and-detects-broken-access-control-security-issues/32556 "2020-10-07T14:45:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexandre\_Gigleux](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/alexandre_gigleux/32/26_2.png) [@Alexandre\_Gigleux](https://community.sonarsource.com/u/Alexandre_Gigleux)\
**Post date:** [October 7, 2020, 2:45pm UTC](https://community.sonarsource.com/t/c-analyzer-provides-a-broader-coverage-of-the-c-core-guidelines-and-detects-broken-access-control-security-issues/32556/1 "2020-10-07T14:45:40Z")

</div>

Hello C++ developers,

We’re proud to announce the following improvements to the C++ analyzer:

- security rules detecting broken authentication and access control issues
- broader coverage of the [C++ Core Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines)

**Security Rules**

We implemented 6 rules related to broken access control (incorrect permission assignments, privilege escalations, unprotected APIs …):

- [S5847](https://rules.sonarsource.com/cpp/RSPEC-5847): Accessing files should not introduce TOCTOU vulnerabilities (Critical)  
 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/8/874abc1229576adc921e430a1a96cae96c5c8598.png)
- [S5832](https://rules.sonarsource.com/cpp/RSPEC-5832): Account validity should be verified when authenticating users with PAM (Major)
- [S5982](https://rules.sonarsource.com/cpp/RSPEC-5982): Changing working directories without verifying the success is security-sensitive
- [S5802](https://rules.sonarsource.com/cpp/RSPEC-5802): Changing directories improperly when using “chroot” is security-sensitive
- [S2612](https://rules.sonarsource.com/cpp/RSPEC-2612): Setting loose POSIX file permissions is security-sensitive
- [S5849](https://rules.sonarsource.com/cpp/RSPEC-5849): Setting capabilities is security-sensitive

**C++ Core Guidelines**

This is still not the end of the journey but we already reached a good coverage of the [C++ Core Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines) with a total of [80+ rules](https://rules.sonarsource.com/cpp?search=%22Core%20Guidelines%22) that help you make sure your C++ code is compliant with these coding guidelines.

Bug Detection rule:

- [S5912](https://rules.sonarsource.com/cpp/RSPEC-5912): Objects should not be sliced (Blocker)

Code Smell Detection rules:

- [S5827](https://rules.sonarsource.com/cpp/RSPEC-5827): “auto” should be used to avoid repetition of types (Major)
- [S5950](https://rules.sonarsource.com/cpp/RSPEC-5950): Use “make\_unique” and “make\_shared” to construct “unique\_ptr” and “shared\_ptr” (Major)
- [S5415](https://rules.sonarsource.com/cpp/RSPEC-5415): “std::move” should only be used where moving can happen (Major)
- [S5945](https://rules.sonarsource.com/cpp/RSPEC-5945): C-style array should not be used (Major)
- [S5965](https://rules.sonarsource.com/cpp/RSPEC-5965): Classes should explicitly specify the access level when specifying base classes (Minor)
- [S5966](https://rules.sonarsource.com/cpp/RSPEC-5966): Struct should explicitly specify the access level when specifying base classes (Minor)
- [S5951](https://rules.sonarsource.com/cpp/RSPEC-5951): Return type of functions shouldn’t be const qualified value (Minor)
- [S5964](https://rules.sonarsource.com/cpp/RSPEC-5964): “std::initializer\_list” constructor should not overlap with other constructors (Minor)
- [S5955](https://rules.sonarsource.com/cpp/RSPEC-5955): Loop variables should be declared in the minimal possible scope (Minor)
- [S5962](https://rules.sonarsource.com/cpp/RSPEC-5962): Threads should not be detached (Minor)
- [S5954](https://rules.sonarsource.com/cpp/RSPEC-5954): “shared\_pointer” should not be taken by rvalue reference (Minor)
- [S1155](https://rules.sonarsource.com/cpp/RSPEC-1155): Do not check emptiness with a size method when a dedicated function exists (Minor)
- [S5946](https://rules.sonarsource.com/cpp/RSPEC-5946): “std::endl” should not be used (Minor)
- [S5952](https://rules.sonarsource.com/cpp/RSPEC-5952): Inheriting constructors should be used (Minor)
- [S5978](https://rules.sonarsource.com/cpp/RSPEC-5978): Multicharacter literals should not be used (Minor)
- [S5981](https://rules.sonarsource.com/cpp/RSPEC-5981): “dynamic\_cast” should be used for downcasting (Minor)

For more information, see the [changelog](https://jira.sonarsource.com/secure/ReleaseNote.jspa?projectId=10090&version=16388).

You can already enjoy these new rules on SonarCloud and you will find them included in SonarQube 8.5 starting from the [Developer Edition](https://www.sonarsource.com/plans-and-pricing/developer/).

Cheers  
Alex

---

<div class="post-metadata">

**Author:** ![Alexandre\_Gigleux](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/alexandre_gigleux/32/26_2.png) [@Alexandre\_Gigleux](https://community.sonarsource.com/u/Alexandre_Gigleux)\
**Post date:** [October 8, 2020, 4:32pm UTC](https://community.sonarsource.com/t/c-analyzer-provides-a-broader-coverage-of-the-c-core-guidelines-and-detects-broken-access-control-security-issues/32556/2 "2020-10-08T16:32:06Z")

</div>

If you want to learn more about TOCTOU vulnerability, you can have a look at this entry added to SonarSource’s blog: [https://blog.sonarsource.com/winning-the-race-against-toctou-vulnerabilities](https://blog.sonarsource.com/winning-the-race-against-toctou-vulnerabilities)
