Description
The source code contains comments that do not accurately describe or explain aspects of the portion of the code with which the comment is associated.
Potential Impact
Other
Reduce Maintainability
Other
Increase Analytical Complexity
Demonstrative Examples
public class Main {
public static void main(String[] args) {
int pt_weight = 83;
int mg_per_kg = 3;
int daily_dose = 0;
// Add the patient weight and Mg/Kg to calculate the correct daily dose
daily_dose = pt_weight * mg_per_kg;
return dosage;
}
}public class Main {
public static void main(String[] args) {
int pt_weight = 83;
int mg_per_kg = 3;
int daily_dose = 0;
// Multiply the patient weight and Mg/Kg to calculate the correct daily dose
daily_dose = pt_weight * mg_per_kg;
return dosage;
}
}Mitigations & Prevention
Verify that each comment accurately reflects what is intended to happen during execution of the code.
Related Weaknesses
Frequently Asked Questions
What is CWE-1116?
CWE-1116 (Inaccurate Source Code Comments) is a software weakness identified by MITRE's Common Weakness Enumeration. It is classified as a Base-level weakness. The source code contains comments that do not accurately describe or explain aspects of the portion of the code with which the comment is associated.
How can CWE-1116 be exploited?
Attackers can exploit CWE-1116 (Inaccurate Source Code Comments) to reduce maintainability. This weakness is typically introduced during the Implementation phase of software development.
How do I prevent CWE-1116?
Key mitigations include: Verify that each comment accurately reflects what is intended to happen during execution of the code.
What is the severity of CWE-1116?
CWE-1116 is classified as a Base-level weakness (Medium abstraction). Its actual severity depends on the specific context and how the weakness manifests in your application.