question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android native bridge security concerns

See original GitHub issue

Quoting the Iframes and the Callback Id Mechanism section of the Security Guide

If content is served in an iframe from a whitelisted domain, that domain will have access to the native Cordova bridge. This means that if you whitelist a third-party advertising network and serve those ads through an iframe, it is possible that a malicious ad will be able to break out of the iframe and perform malicious actions. Because of this, you should generally not use iframes unless you control the server that hosts the iframe content. Also note that there are third party plugins available to support advertising networks. Note that this statement is not true for iOS, which intercepts everything including iframe connections.

We are in a situation where we have iframes that can serve content from a third party source not controlled by us (integrations/plugins in our app). Our own app data is secured, the only way to communicate with our app is via window.postMessage. We even have 2 levels of iframe — it’s an iframe inside an iframe — where the first level is controlled by us (for CSP reasons).

When inspecting from the uncontrolled iframe, you can indeed have access to the _cordovaNative object which has the exec method. As you can see from the method signature, it expects a bridgeSecret as the first parameter. Said secret seems to be generated from the native side and any attempt at using the method with the wrong secret will completely disable the bridge.

My question is: Since the secret isn’t exposed to JavaScript and it’s a different one for everyone and change every time you reload the app, how can this bridge exposure be exploited? I’d be also curious to know how plugins can still use cordova.exec without the bridge secret.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
vbrauncommented, Oct 9, 2020

If the cross-origin iframe can access window.frameElement then it is unsafe in the browser, too. Without cordova you may not be able to run native code but you can still steal authentication tokens, overlay malicious login screens, etc. So I don’t understand why you shouldn’t assume that frameElement is null, if it isn’t then you have so many other problems before you even get to the cordova native bridge.

1reaction
EtienneLemcommented, Sep 15, 2020

Sure thing! Thanks again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Security Aspects to consider for a React Native Application
What are the common Security Issues while dealing with React Native applications? - Storing Sensitive Information - Selection of Local Storage ...
Read more >
Implementing Security | Android Open Source Project
Native code should be analyzed using an automated tool that can detect memory management issues such as buffer overflows and off-by-one errors.
Read more >
Iframes/Popups Are Dangerous in Mobile WebView - USENIX
We conduct the first security study in Android WebView. => Differential Context Vulnerabilities (DCVs). • We assess the security impacts on real-world apps ......
Read more >
React Native security: things to keep in mind | Cossack Labs
React Native security: what developers and team leads need to know. Handle risks and threats, prevent typical security mistakes, ...
Read more >
Getting started with React Native security - Snyk
Explore React Native security challenges that developers ... as a React Native bridge for AppAuth for iOS and AppAuth for Android SDKs, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found