JBOH: When an Android Web Page Reached Into the App
In 2014, security researchers described how web content fetched by an Android app could be changed on the way in, then used to run code with the app's permissions. The dangerous connection was between the web page on the screen and the app behind it.
The researchers called the weakness JBOH, short for JavaScript Binding Over HTTP. It involved an Android WebView, a component that displays web content inside an app, and an unsafe way for that content to call the app's own code.
The 2014 Black Hat paper describes a historical attack demonstration.
- Read messages on the train without the person beside you reading along.
- Protect the glass from scratches while you protect what is on it.
- Keep spares on hand: three come in the pack.
The connection an app deliberately creates
A page inside a WebView can run JavaScript, the programming language used to make web pages respond and perform tasks. The Android app may also have code written in Java. Despite their similar names, these are different languages.
A developer can connect them through a native bridge. This exposes some of the app's functions so that JavaScript running in the page can ask the app to perform actions.
That integration can be useful, but it raises a security question: which page gets to ask, and how much can it ask the app to do?
How HTTP supplied the attacker with a page
The researchers' scenario involved an app, or advertising code included in it, fetching content over unencrypted HTTP. HTTP is the Hypertext Transfer Protocol used for web requests and responses.
An attacker able to change that traffic in transit could insert JavaScript into the content delivered to the WebView. The unsafe bridge then gave that script a way to run native code: code running as part of the Android app.
The script could now act with the app's permissions. It did not inherently give the attacker root access, the highest level of administrative control over the device. The app's granted permissions helped determine the damage possible, which is one reason limiting unnecessary privileges matters.
How One Tweet Started Retweeting Itself
Android narrowed the bridge
Android changed the interface rules so that apps targeting newer versions had to mark the public methods they wanted JavaScript to call. A method is a callable function in the app's code. Earlier rules exposed a broader set of public methods, including ones inherited from other code.
The Android interface reference explains the historical boundary: the requirement to mark methods applies to apps targeting API level 17 or later. An API level identifies a version of Android's programming interfaces. The app declares a target level, but the device's own Android version matters too. On devices running versions older than Android 4.2, changing the target alone was not a complete remedy.
More selective exposure still leaves the developer with a decision about what the page may do. A deliberately exposed function can be dangerous if it offers sensitive operations to untrusted content.
The bridge can also be reached from embedded frames—separately loaded portions of a page. The app cannot identify the originating frame simply from the Java call it receives.
Protecting the page and limiting its reach
Android's native-bridge security guidance advises developers to load trusted content and check both the server name and the type of address, such as HTTPS. It calls for HTTPS connections and removing interfaces before loading untrusted content. Developers can also remove JavaScript and exposed operations the app does not need.
HTTPS, the protected form of HTTP, safeguards content during delivery, closing the unprotected-transport opportunity in the historical scenario. It doesn't make a malicious page safe. The page that arrives through a protected connection should still have access only to app functions it is trusted to use.
Malicious Mobile Apps: Why Does a Photo Editor Want Your Contacts?

Active Content: When a Page or Document Runs Instructions

Sandboxing: Deciding What a Program Can Reach

QUOTE:
"Amateurs hack systems, professionals hack people."
