Unsafe Object Deserialization Affecting angular package, versions >=1.2.19 <1.2.27


0.0
high

Snyk CVSS

    Attack Complexity High
    Confidentiality High
    Integrity High

    Threat Intelligence

    Exploit Maturity Proof of concept

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk ID npm:angular:20140909
  • published 23 Jan 2017
  • disclosed 8 Sep 2014
  • credit Chirayu Krishnappa

Introduced: 8 Sep 2014

CVE NOT AVAILABLE CWE-502 Open this link in a new tab

How to fix?

Upgrade angular to version 1.2.27 or higher.

Overview

angular is a package that lets you write client-side web applications as if you had a smarter browser. It also lets you use HTML as your template language and lets you extend HTML’s syntax to express your application’s components clearly and succinctly.

Affected versions of this package are vulnerable to Unsafe Object Deserialization.

POC

The exploitable code:

hasOwnProperty.constructor.prototype.valueOf = valueOf.call;
    ["a", "alert(1)"].sort(hasOwnProperty.constructor);

The exploit:

    1. Array.sort takes a comparison function and passes it 2 parameters to compare.
    2. It then calls .valueOf() if the result is not a primitive.
  • The Function object conveniently accepts two string arguments so so it can be used to construct a function. However, this doesn't do much unless it can be executed.
  • The valueOf function on Function.prototype was set to Function.prototype.call. This causes the function constructed to be executed when sort calls .valueOf() on the result of the comparison.

Details

Serialization is a process of converting an object into a sequence of bytes which can be persisted to a disk or database or can be sent through streams. The reverse process of creating object from sequence of bytes is called deserialization. Serialization is commonly used for communication (sharing objects between multiple hosts) and persistence (store the object state in a file or a database). It is an integral part of popular protocols like Remote Method Invocation (RMI), Java Management Extension (JMX), Java Messaging System (JMS), Action Message Format (AMF), Java Server Faces (JSF) ViewState, etc.

Deserialization of untrusted data (CWE-502) is when the application deserializes untrusted data without sufficiently verifying that the resulting data will be valid, thus allowing the attacker to control the state or the flow of the execution.