Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)
Critical Data Element Declared Public
This vulnerability occurs when a critical piece of data—like a variable, field, or class member—is mistakenly declared as public when it should be kept private according to the application's…
What is CWE-766?
Real-world CVEs caused by CWE-766
-
variables declared public allow remote read of system properties such as user name and home directory.
Parcours de l'attaquant étape par étape
- 1
The following example declares a critical variable public, making it accessible to anyone with access to the object in which it is contained.
- 2
Instead, the critical data should be declared private.
- 3
Even though this example declares the password to be private, there are other possible issues with this implementation, such as the possibility of recovering the password from process memory (CWE-257).
- 4
The following example shows a basic user account class that includes member variables for the username and password as well as a public constructor for the class and a public method to authorize access to the user account.
- 5
However, the member variables username and password are declared public and therefore will allow access and changes to the member variables to anyone with access to the object. These member variables should be declared private as shown below to prevent unauthorized access and changes.
Vulnerable C++
The following example declares a critical variable public, making it accessible to anyone with access to the object in which it is contained.
public: char* password; Secure C++
Instead, the critical data should be declared private.
private: char* password; How to prevent CWE-766
- Implementation Data should be private, static, and final whenever possible. This will assure that your code is protected by instantiating early, preventing access, and preventing tampering.
How to detect CWE-766
Plexicus détecte automatiquement CWE-766 et ouvre une PR de correction en moins de 60 secondes.
Codex Remedium analyse chaque commit, identifie cette faiblesse précise et livre une pull request prête à être relue avec le correctif. Pas de tickets. Pas de transferts.
Frequently asked questions
Qu'est-ce que CWE-766 ?
This vulnerability occurs when a critical piece of data—like a variable, field, or class member—is mistakenly declared as public when it should be kept private according to the application's security design.
Quelle est la gravité de CWE-766 ?
MITRE n'a pas publié de note de probabilité d'exploitation pour cette faiblesse. Traitez-la comme un impact moyen jusqu'à ce que votre modèle de menace prouve le contraire.
Quels langages ou plateformes sont affectés par CWE-766 ?
MITRE lists the following affected platforms: C++, C#, Java.
Comment puis-je prévenir CWE-766 ?
Data should be private, static, and final whenever possible. This will assure that your code is protected by instantiating early, preventing access, and preventing tampering.
Comment Plexicus détecte et corrige CWE-766 ?
Le moteur SAST de Plexicus reconnaît la signature de flux de données de CWE-766 à chaque commit. Lorsqu'une correspondance est trouvée, notre agent Codex Remedium ouvre une PR de correction avec le code corrigé, les tests et un résumé d'une ligne pour le relecteur.
Où puis-je en savoir plus sur CWE-766 ?
MITRE publie la définition canonique à https://cwe.mitre.org/data/definitions/766.html. Vous pouvez également consulter la documentation OWASP et NIST pour des conseils adjacents.
Weaknesses related to CWE-766
Incorrect Permission Assignment for Critical Resource
This vulnerability occurs when a system grants overly permissive access to a sensitive resource, allowing unauthorized users or processes…
Sensitive Cookie Without 'HttpOnly' Flag
This vulnerability occurs when an application stores sensitive data in a cookie but fails to set the 'HttpOnly' flag, leaving the cookie…
Incorrect Default Permissions
This vulnerability occurs when software installation scripts set overly permissive file or directory access rights by default. Instead of…
Insecure Inherited Permissions
This vulnerability occurs when an application sets default file or directory permissions that are too permissive, and these insecure…
Insecure Preserved Inherited Permissions
This vulnerability occurs when a software product copies or extracts files while unintentionally preserving insecure permissions from…
Incorrect Execution-Assigned Permissions
This vulnerability occurs when a running application incorrectly changes an object's access permissions, overriding the security settings…
Improper Preservation of Permissions
This vulnerability occurs when a system fails to correctly maintain file or object permissions during operations like copying, sharing, or…
Arrêtez de payer par développeur.
Commencez à fermer la boucle.
Plexicus est l'ASPM natif IA qui scanne, filtre, corrige, penteste et explique — de façon autonome. Développeurs illimités, dépôts illimités, actions IA à usage équitable. Vrai niveau gratuit, €269/mo annuel quand vous êtes prêt.