Tag Archives: CVE-2018-3721

CWE-1321 – Improperly Controlled Modification of Object Prototype Attributes (‘Prototype Pollution’)

Read Time:1 Minute, 29 Second

Description

The software receives input from an upstream component that specifies attributes that are to be initialized or updated in an object, but it does not properly control modifications of attributes of the object prototype.

Modes of Introduction:

– Architecture and Design

 

 

Related Weaknesses

CWE-915
CWE-913
CWE-471

 

Consequences

Integrity: Modify Application Data

An attacker can inject attributes that are used in other components.

Availability: DoS: Crash, Exit, or Restart

An attacker can override existing attributes with ones that have incompatible type, which may lead to a crash.

 

Potential Mitigations

Phase: Implementation

Effectiveness: High

Description: 

By freezing the object prototype first (for example, Object.freeze(Object.prototype)), modification of the prototype becomes impossible.

While this can mitigate this weakness completely, other methods are recommended when possible, especially in components used by upstream software (“libraries”).

Phase: Architecture and Design

Effectiveness: High

Description: 

By blocking modifications of attributes that resolve to object prototype, such as proto or prototype, this weakness can be mitigated.

Phase: Implementation

Effectiveness: Limited

Description: 

When handling untrusted objects, validating using a schema can be used.

Phase: Implementation

Effectiveness: High

Description: 

By using an object without prototypes (via Object.create(null) ), adding object prototype attributes by accessing the prototype via the special attributes becomes impossible, mitigating this weakness.

Phase: Implementation

Effectiveness: Moderate

Description: 

Map can be used instead of objects in most cases. If Map methods are used instead of object attributes, it is not possible to access the object prototype or modify it.

CVE References

  • CVE-2019-10744
    • Prototype pollution by setting default values to object attributes recursively.
  • CVE-2020-8203
    • Prototype pollution by setting object attributes based on dot-separated path.