CWE-915: Improperly Controlled Modification of Dynamically-Determined Object Attributes (Base)

Description: 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.

Extended Description: 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.


Alternate Terms: ::TERM:Mass Assignment:DESCRIPTION:Mass assignment is the name of a feature in Ruby on Rails that allows simultaneous modification of multiple object attributes.::TERM:AutoBinding:DESCRIPTION:The Autobinding term is used in frameworks such as Spring MVC and ASP.NET MVC.::TERM:PHP Object Injection:DESCRIPTION:Some PHP application researchers use this term for attacking unsafe use of the unserialize() function, but it is also used for CWE-502.::

Applicable Platforms: ::LANGUAGE NAME:Ruby:LANGUAGE PREVALENCE:Undetermined::LANGUAGE NAME:ASP.NET:LANGUAGE PREVALENCE:Undetermined::LANGUAGE NAME:PHP:LANGUAGE PREVALENCE:Undetermined::LANGUAGE NAME:Python:LANGUAGE PREVALENCE:Undetermined::LANGUAGE CLASS:Not Language-Specific:LANGUAGE PREVALENCE:Undetermined::

Modes of Introduction: ::PHASE:Architecture and Design::PHASE:Implementation::



Common Consequences: ::SCOPE:Integrity:IMPACT:Modify Application Data:NOTE:An attacker could modify sensitive data or program variables.::SCOPE:Integrity:IMPACT:Execute Unauthorized Code or Commands::SCOPE:Other:SCOPE:Integrity:IMPACT:Varies by Context:IMPACT:Alter Execution Logic::

Detection Methods: ::METHOD:Automated Static Analysis:DESCRIPTION: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.):EFFECTIVENESS:High::

Potential Mitigations: ::PHASE:Implementation:DESCRIPTION: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.::PHASE:Architecture and Design Implementation:DESCRIPTION: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.::PHASE:Implementation:STRATEGY:Input Validation:DESCRIPTION:For any externally-influenced input, check the input against an allowlist of internal object attributes or fields that are allowed to be modified.::PHASE:Implementation Architecture and Design:STRATEGY:Refactoring:DESCRIPTION: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.::

Observed Examples: ::REFERENCE:CVE-2012-2054:DESCRIPTION:Mass assignment allows modification of arbitrary attributes using modified URL.:LINK:https://www.cve.org/CVERecord?id=CVE-2012-2054::REFERENCE:CVE-2012-2055:DESCRIPTION:Source version control product allows modification of trusted key using mass assignment.:LINK:https://www.cve.org/CVERecord?id=CVE-2012-2055::REFERENCE:CVE-2008-7310:DESCRIPTION:Attackers can bypass payment step in e-commerce product.:LINK:https://www.cve.org/CVERecord?id=CVE-2008-7310::REFERENCE:CVE-2013-1465:DESCRIPTION:Use of PHP unserialize function on untrusted input allows attacker to modify application configuration.:LINK:https://www.cve.org/CVERecord?id=CVE-2013-1465::REFERENCE:CVE-2012-3527:DESCRIPTION:Use of PHP unserialize function on untrusted input in content management system might allow code execution.:LINK:https://www.cve.org/CVERecord?id=CVE-2012-3527::REFERENCE:CVE-2012-0911:DESCRIPTION:Use of PHP unserialize function on untrusted input in content management system allows code execution using a crafted cookie value.:LINK:https://www.cve.org/CVERecord?id=CVE-2012-0911::REFERENCE:CVE-2012-0911:DESCRIPTION:Content management system written in PHP allows unserialize of arbitrary objects, possibly allowing code execution.:LINK:https://www.cve.org/CVERecord?id=CVE-2012-0911::REFERENCE:CVE-2011-4962:DESCRIPTION:Content management system written in PHP allows code execution through page comments.:LINK:https://www.cve.org/CVERecord?id=CVE-2011-4962::REFERENCE:CVE-2009-4137:DESCRIPTION:Use of PHP unserialize function on cookie value allows remote code execution or upload of arbitrary files.:LINK:https://www.cve.org/CVERecord?id=CVE-2009-4137::REFERENCE:CVE-2007-5741:DESCRIPTION:Content management system written in Python interprets untrusted data as pickles, allowing code execution.:LINK:https://www.cve.org/CVERecord?id=CVE-2007-5741::REFERENCE:CVE-2011-2520:DESCRIPTION:Python script allows local users to execute code via pickled data.:LINK:https://www.cve.org/CVERecord?id=CVE-2011-2520::REFERENCE:CVE-2005-2875:DESCRIPTION:Python script allows remote attackers to execute arbitrary code using pickled objects.:LINK:https://www.cve.org/CVERecord?id=CVE-2005-2875::REFERENCE:CVE-2013-0277:DESCRIPTION:Ruby on Rails allows deserialization of untrusted YAML to execute arbitrary code.:LINK:https://www.cve.org/CVERecord?id=CVE-2013-0277::REFERENCE:CVE-2011-2894:DESCRIPTION:Spring framework allows deserialization of objects from untrusted sources to execute arbitrary code.:LINK:https://www.cve.org/CVERecord?id=CVE-2011-2894::REFERENCE:CVE-2012-1833:DESCRIPTION:Grails allows binding of arbitrary parameters to modify arbitrary object properties.:LINK:https://www.cve.org/CVERecord?id=CVE-2012-1833::REFERENCE:CVE-2010-3258:DESCRIPTION:Incorrect deserialization in web browser allows escaping the sandbox.:LINK:https://www.cve.org/CVERecord?id=CVE-2010-3258::REFERENCE:CVE-2008-1013:DESCRIPTION:Media library allows deserialization of objects by untrusted Java applets, leading to arbitrary code execution.:LINK:https://www.cve.org/CVERecord?id=CVE-2008-1013::



Notes: ::TYPE:Maintenance:NOTE:The relationships between CWE-502 and CWE-915 need further exploration. CWE-915 is more narrowly scoped to object modification, and is not necessarily used for deserialization.::