SonarSource Rules
  • Products

    In-IDE

    Code Quality and Security in your IDE with SonarQube Ide

    IDE extension that lets you fix coding issues before they exist!

    Discover SonarQube for IDE

    SaaS

    Code Quality and Security in the cloud with SonarQube Cloud

    Setup is effortless and analysis is automatic for most languages

    Discover SonarQube Cloud

    Self-Hosted

    Code Quality and Security Self-Hosted with SonarQube Server

    Fast, accurate analysis; enterprise scalability

    Discover SonarQube Server
  • SecretsSecrets
  • ABAPABAP
  • AnsibleAnsible
  • ApexApex
  • AzureResourceManagerAzureResourceManager
  • CC
  • C#C#
  • C++C++
  • CloudFormationCloudFormation
  • COBOLCOBOL
  • CSSCSS
  • DartDart
  • DockerDocker
  • FlexFlex
  • GitHub ActionsGitHub Actions
  • GoGo
  • HTMLHTML
  • JavaJava
  • JavaScriptJavaScript
  • JSONJSON
  • JCLJCL
  • KotlinKotlin
  • KubernetesKubernetes
  • Objective CObjective C
  • PHPPHP
  • PL/IPL/I
  • PL/SQLPL/SQL
  • PythonPython
  • RPGRPG
  • RubyRuby
  • RustRust
  • ScalaScala
  • SwiftSwift
  • TerraformTerraform
  • TextText
  • TypeScriptTypeScript
  • T-SQLT-SQL
  • VB.NETVB.NET
  • VB6VB6
  • XMLXML
  • YAMLYAML
C

C static code analysis

Unique rules to find Bugs, Vulnerabilities, Security Hotspots, and Code Smells in your C code

  • All rules 315
  • Vulnerability13
  • Bug76
  • Security Hotspot19
  • Code Smell207

  • Quick Fix 19
 
Tags
    Impact
      Clean code attribute
        1. Accessing files should not introduce TOCTOU vulnerabilities

           Vulnerability
        2. Account validity should be verified when authenticating users with PAM

           Vulnerability
        3. "memset" should not be used to delete sensitive data

           Vulnerability
        4. POSIX functions should not be called with arguments that trigger buffer overflows

           Vulnerability
        5. Cipher algorithms should be robust

           Vulnerability
        6. Encryption algorithms should be used with secure mode and padding scheme

           Vulnerability
        7. Server hostnames should be verified during SSL/TLS connections

           Vulnerability
        8. Server certificates should be verified during SSL/TLS connections

           Vulnerability
        9. Cryptographic keys should be robust

           Vulnerability
        10. Weak SSL/TLS protocols should not be used

           Vulnerability
        11. XML parsers should not be vulnerable to XXE attacks

           Vulnerability
        12. Insecure functions should not be used

           Vulnerability
        13. "scanf()" and "fscanf()" format strings should specify a field width for the "%s" string placeholder

           Vulnerability

        POSIX functions should not be called with arguments that trigger buffer overflows

        consistency - conventional
        reliability
        security
        Vulnerability
        • cwe
        • symbolic-execution
        • cert

        Some POSIX functions take one argument that is a buffer and another one that represents the size of the buffer. It is up to the developer to make sure the two arguments do match and that the size argument does not exceed the buffer’s size.

        Why is this an issue?

        How can I fix it?

        More Info

        When the size argument exceeds the actual size of the buffer, the memory management functions will either read or write data past the buffer memory boundary into adjacent memory. Because the memory might be uninitialized or contain other pieces of data, the behavior of the affected function can not be predicted and will likely trigger bugs.

        What is the potential impact?

        Buffer boundaries violations can lead to serious security issues.

        Information disclosure

        In some scenarios, insecure functions can lead to information disclosure. For instance, if an attacker can cause a buffer overread, they might be able to disclose data in memory that they’re not supposed to have access to. This could potentially allow them to access sensitive information, such as passwords or encryption keys. An example of a buffer overread is provided with the Heartbleed vulnerability. ==== Code execution

        In some cases, an attacker can craft input in a way that allows them to gain unauthorized access to your system. For example, they might be able to overwrite a function’s return address in memory, causing your program to execute code of the attacker’s choosing. This could potentially give the attacker full control over your system.

        Denial of service

        If an attacker can trigger a buffer overflow by providing oversized input, it can cause the program to crash. If the attacker repeats this process, it can continually disrupt the service, denying access to other users. This can be particularly damaging for services that require high availability, such as online platforms or databases.

        In some cases, the input might cause the program to enter an infinite loop or consume excessive memory, slowing down the system or even causing it to become unresponsive. This type of attack is known as a resource exhaustion DoS attack.

        Exceptions

        Functions related to sockets using the type socklen_t are not checked. This is because these functions are using a C-style polymorphic pattern using union. It relies on a mismatch between allocated memory and sizes of structures and it creates false positives.

          Available In:
        • SonarQube IdeCatch issues on the fly,
          in your IDE
        • SonarQube CloudDetect issues in your GitHub, Azure DevOps Services, Bitbucket Cloud, GitLab repositories
        • SonarQube ServerAnalyze code in your
          on-premise CI
          Developer Edition
          Available Since
          9.1

        © 2008-2025 SonarSource SA. All rights reserved.

        Privacy Policy | Cookie Policy | Terms of Use