COMMON WEAKNESS ENUMERATIONIncomplete

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.

Abstraction

Base

Structure

Simple

Likelihood of Exploit

Medium

Understand the problem

What is the problem?

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.

Terminology

Alternate terms and usages

Mass Assignment

"Mass assignment" is the name of a feature in Ruby on Rails that allows simultaneous modification of multiple object attributes.

AutoBinding

The "Autobinding" term is used in frameworks such as Spring MVC and ASP.NET MVC.

PHP Object Injection

Some PHP application researchers use this term for attacking unsafe use of the unserialize() function, but it is also used for CWE-502.

Root cause

How and when does the problem arise?

Lifecycle phase

Architecture and Design

Lifecycle phase

Implementation

Risk

What does successful exploitation lead to?

Modify Application Data

Affected security scopes: Integrity

An attacker could modify sensitive data or program variables.
Execute Unauthorized Code or Commands

Affected security scopes: Integrity

Varies by ContextAlter Execution Logic

Affected security scopes: Other, Integrity

Defence

How is it prevented and fixed?

Implementation

Implementation-phase defence

Detail
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

Defence to apply across several lifecycle phases

Detail
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

Input Validation

Detail
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

Refactoring

Detail
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.

Verification

How is it detected?

Automated Static Analysis

High
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.)
CWE-915: Common Weakness Enumeration Entry CWE-915 · DayBreach Sözlük · DayBreach