CWE-1041: Use of Redundant Code
The product has multiple functions, methods, procedures, macros, etc. that contain the same code.
How it's found
Use of Redundant Code is typically found by tracing untrusted input from where it enters the system to the point where it is used without the check or neutralization this weakness describes, combining manual code review with dynamic testing.
Vulnerable vs. safe
// complex math equationssurface_area = pi * r * s + pi * Math.pow(r, 2);
// a complex set of mathsurface_area = pi * r * s + pi * Math.pow(r, 2);double s = 10.0;double r = 1.0;double pi = 3.14159;double surface_area;if(r > 0.0) {}if(r > 1.0) {}
public static void main(String[] args) {}public class Main {}//complex math equationsdouble pi = Math.PI;double surface_area = pi * r * s + pi * Math.pow(r, 2);return surface_area;
private double ComplexMath(double r, double s) {}
surface_area = ComplexMath(r, s);
surface_area = ComplexMath(r, s);double s = 10.0;double r = 1.0;double surface_area;if(r > 0.0) {}if(r > 1.0) {}
public static void main(String[] args) {}public class Main {}Consequences
- Reduce Maintainability: This issue makes it more difficult to maintain the product, which indirectly affects security by making it more difficult or time-consuming to find and/or fix vulnerabilities. For example, if there are two copies of the same code, the programmer might fix a weakness in one copy while forgetting to fix the same weakness in another copy.
Mitigations
- Implementation: Merge common functionality into a single function and then call that function from across the entire code base.
Where this fits in a TurboPentest engagement
This weakness is not covered by the automated black-box pentest. IntegSec pentesters cover it in a manual engagement.
Frequently asked questions
What is CWE-1041?
The product has multiple functions, methods, procedures, macros, etc. that contain the same code.
How do you find Use of Redundant Code?
Use of Redundant Code is typically found by tracing untrusted input from where it enters the system to the point where it is used without the check or neutralization this weakness describes, combining manual code review with dynamic testing.
What is the impact of CWE-1041?
Reduce Maintainability: This issue makes it more difficult to maintain the product, which indirectly affects security by making it more difficult or time-consuming to find and/or fix vulnerabilities. For example, if there are two copies of the same code, the programmer might fix a weakness in one copy while forgetting to fix the same weakness in another copy.
Does TurboPentest test for Use of Redundant Code?
This weakness is not covered by the automated black-box pentest. IntegSec pentesters cover it in a manual engagement.
Related CWEs
Written and reviewed by
Michel Chamberland - Founder & CEO, IntegSec
CISSP, OSCP, OSCE, CEH, GIAC, CCSK · 20+ years in offensive security
Michel has spent 20+ years on offensive security teams including IBM X-Force Red and Trustwave SpiderLabs, leading penetration tests, red team engagements, and breach response for Fortune 500 customers. He is the founder of IntegSec and the architect of TurboPentest.
Find these issues before an attacker does
TurboPentest runs an agentic AI pentest against your target and reports findings with proof, from $99 per target.
Start a pentest