CWE-915: Improperly Controlled Modification of Dynamically-Determined Object Attributes
The product receives input from an upstream component that specifies multiple attributes, properties, or fields that are to be initialized or updated in an object, but it does not properly control which attributes can be modified.
How it's found
Improperly Controlled Modification of Dynamically-Determined Object Attributes 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.
If the object contains attributes that were only intended for internal use, then their unexpected modification could lead to a vulnerability. This weakness is sometimes known by the language-specific mechanisms that make it possible, such as mass assignment, autobinding, or object injection.
Vulnerable vs. safe
objectToModify[attr] = {};}if (typeof objectToModify[attr] !== 'object') {objectToModify = objectToModify[attr];}const pathArray = path.split(".");const attributeToSet = pathArray.pop();let objectToModify = object;for (const attr of pathArray) {objectToModify[attributeToSet] = value;return object;}function setValueByPath (object, path, value) {// Ignore attributes which resolve to object prototype
continue;}
objectToModify[attr] = {};}if (attr === "__proto__" || attr === "constructor" || attr === "prototype") {if (typeof objectToModify[attr] !== "object") {objectToModify = objectToModify[attr];}const pathArray = path.split(".");const attributeToSet = pathArray.pop();let objectToModify = object;for (const attr of pathArray) {objectToModify[attributeToSet] = value;return object;}function setValueByPath (object, path, value) {Consequences
- Modify Application Data: An attacker could modify sensitive data or program variables.
- Execute Unauthorized Code or Commands
- Varies by Context, Alter Execution Logic
Mitigations
- Implementation: If available, use features of the language or framework that allow specification of allowlists of attributes or fields that are allowed to be modified. If possible, prefer allowlists over denylists. For applications written with Ruby on Rails, use the attr_accessible (allowlist) or attr_protected (denylist) macros in each class that may be used in mass assignment.
- Architecture and Design/Implementation: If available, use the signing/sealing features of the programming language to assure that deserialized data has not been tainted. For example, a hash-based message authentication code (HMAC) could be used to ensure that data has not been modified.
- Implementation: For any externally-influenced input, check the input against an allowlist of internal object attributes or fields that are allowed to be modified.
- Implementation/Architecture and Design: Refactor the code so that object attributes or fields do not need to be dynamically identified, and only expose getter/setter functionality for the intended attributes.
How TurboPentest tests for this (white-box)
This weakness (Improperly Controlled Modification of Dynamically-Determined Object Attributes) is caught by white-box static analysis when you connect a GitHub repo: IntegSec's Opengrep SAST rule pack carries 3 rules for it, flagging the issue directly in your source code as part of the pentest.
Frequently asked questions
What is CWE-915?
The product receives input from an upstream component that specifies multiple attributes, properties, or fields that are to be initialized or updated in an object, but it does not properly control which attributes can be modified.
How do you find Improperly Controlled Modification of Dynamically-Determined Object Attributes?
Improperly Controlled Modification of Dynamically-Determined Object Attributes 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-915?
Modify Application Data: An attacker could modify sensitive data or program variables. Execute Unauthorized Code or Commands Varies by Context, Alter Execution Logic
Does TurboPentest test for Improperly Controlled Modification of Dynamically-Determined Object Attributes?
This weakness (Improperly Controlled Modification of Dynamically-Determined Object Attributes) is caught by white-box static analysis when you connect a GitHub repo: IntegSec's Opengrep SAST rule pack carries 3 rules for it, flagging the issue directly in your source code as part of the pentest.
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