Unsafe Object Deserialization Affecting org.webjars.bower:angular package, versions [1.2.19,1.2.24)
Threat Intelligence
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 SNYK-JAVA-ORGWEBJARSBOWER-479442
- published 23 Jan 2017
- disclosed 8 Sep 2014
- credit Chirayu Krishnappa
How to fix?
Upgrade org.webjars.bower:angular
to version 1.2.24 or higher.
Overview
org.webjars.bower:angular is a bower WebJar for angular.
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:
Array.sort
takes a comparison function and passes it 2 parameters to compare.- 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 onFunction.prototype
was set toFunction.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.