Trusted Hosted App can be hosted by untrusted third-party
The Trusted Hosted Apps (THA) implementation allowed a third-party to host a malicious app by copying a legitimate app's manifest and signature file, because the CSP whitelist permitted the 'self' keyword. An attacker could then host the fake app on their own server and gain the same privileges as the legitimate app.
Originally disclosed on Mozilla
- Fixed in 3.2 years
- Paid in 3 months
- Disclosed after 3.2 years
User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.28 Safari/537.36
Steps to reproduce:
In TrustedHostedAppsUtils.getCSPWhiteList(), THA is allowed to use 'self' keyword for script-src and style-src in it's CSP.
http://dxr.mozilla.org/mozilla-central/source/dom/apps/tests/test_tha_utils.html#125
This spec allows untrusted third-party to host malicious THA, without Mozilla's approval, by cloning legitimate THA manifest and corresponding sig file from trusted application host server.
The neccessary conditions for exploit are as follows:
(a) There is a legitimate THA that has 'self' keyword on CSP directive in it's app-manifest.
ex: "csp" : "script-src 'self' https://www.google.com; style-src https://www.google.com 'self'"
(b) An attacker can download manifest.webapp and manifest.sig of (a) from legitimate app hosting server.
(c) An attacker can host a HPKP protected server, i.e., the server uses https: with sends valid Public-Key-Pins header
Then, the attacker can host fake THA (a) on their server (c) and the untrusted code can gain same privilege as legitimate app.
Here is the easy PoC of exploit:
(0) Due to avoid manifest signature verification, change following code as follows:
http://dxr.mozilla.org/mozilla-central/source/dom/apps/TrustedHostedAppsUtils.jsm#182
+ deferred.resolve(aCert);
- deferred.reject("MANIFEST_SIGNATURE_VERIFICATION_ERROR");
Install patched TrustedHostedAppsUtils.jsm to omni.ja on your device, or if you use simulator save it under \[address removed]\b2g\modules\.
(1) Open https://csrf.jp/installer.html on your device
(2) Click "install" button then malicious THA, named Legitimate Trusted App, is installed
(3) Launch Legitimate Trusted App from home screen and you can see the app access to device storage.
Note: About procedure(0), it's not crutial part of the exploit. The reason why I need (0) is that I don't have any legitimate THA needed for artack.
I tried to use test certificate with "dom.mozApps.use_trustedapp_test_certs", but the test key and certificate is dynamically generated by unit-test code with /dev/urandam so valid test key is changed in every build time.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the CSP whitelist for Trusted Hosted Apps included the 'self' keyword, which allowed any host to be considered trusted if it served the same manifest and signature, without verifying the actual origin.
Impact
An attacker could host a fake Trusted Hosted App that gains the same privileges as the legitimate app, potentially accessing device storage and other sensitive resources.
What the attacker needed
A legitimate THA with 'self' in CSP; Attacker can download manifest and signature; Attacker can host HPKP-protected server
How it was found
- Patch the signature verification to always succeed (for testing only).
- Open the installer page on the device.
- Click the install button to install the malicious THA.
- Launch the app from the home screen and observe access to device storage.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Trusted Hosted Apps are web apps that Firefox OS treats as trusted, giving them extra permissions. The report found that if a trusted app's security policy allowed scripts from its own origin ('self'), an attacker could copy the app's files and host them on their own server, tricking the system into granting the same trust. This means a malicious app could access sensitive device features without approval.
What is Misconfiguration?
Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.