repositories

daemon-sec-cheatsheet

The cheatsheet vault for operators: AD, enumeration, exploitation, priv-esc, web, DFIR

clonegit clone https://git.daemon-sec.xyz/daemon-sec-cheatsheet.git
cordova-apps.mdMarkdown151 lines9.1 KiBsource raw download

title: "Cordova Apps" section: "Mobile" sectionSlug: "mobile-pentesting" sourcePath: "src/mobile-pentesting/cordova-apps.md" sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/mobile-pentesting/cordova-apps.md" sha: "188de82beb54e70956b2952367a0af91d26758b8" isIndex: false modified: true license: "CC-BY-NC-4.0"#

Cordova Apps#

The cloning workflow below is based on this Cordova application recreation write-up.[4]

Apache Cordova builds hybrid applications with JavaScript, HTML, and CSS rendered in a WebView. Its web assets remain recoverable from an APK or IPA unless the project adds obfuscation or other protection. React Native also normally ships recoverable JavaScript or bytecode artifacts, so its JavaScript VM should not be treated as source-code protection.

Cloning a Cordova Application#

Before cloning a Cordova application, install Node.js and the platform prerequisites, such as the Android SDK, JDK, and Gradle. Consult the Cordova CLI documentation for the versions required by the selected Cordova platform.[5]

Consider an example application named Bank.apk with the package name com.android.bank. To access the source code, unzip bank.apk and navigate to the bank/assets/www folder. This folder contains the complete source code of the application, including HTML and JS files. The application's configuration can be found in bank/res/xml/config.xml.

To clone the application, follow these steps:

npm install -g cordova@latest
cordova create bank-new com.android.bank Bank
cd bank-new

Copy the contents of bank/assets/www to bank-new/www, excluding cordova_plugins.js, cordova.js, cordova-js-src/, and the plugins/ directory.

Specify the platform (Android or iOS) when creating a new Cordova project. For an Android app, add the Android platform. Cordova platform versions and Android API levels are distinct; consult the Cordova Android documentation for supported combinations.[6]

To determine the appropriate Cordova Android platform version, check the PLATFORM_VERSION_BUILD_LABEL in the original application's cordova.js file.

After setting up the platform, install the required plugins. The original application's bank/assets/www/cordova_plugins.js file lists all the plugins and their versions. Install each plugin individually as shown below:

cd bank-new
cordova plugin add cordova-plugin-dialogs@2.0.1

If a plugin is not available on npm, it can be sourced from GitHub:

cd bank-new
cordova plugin add https://github.com/moderna/cordova-plugin-cache.git

Ensure all prerequisites are met before compiling:

cd bank-new
cordova requirements

To build the APK, use the following command:

cd bank-new
cordova build android -- --packageType=apk

This command generates an APK with the debug option enabled, facilitating debugging via Google Chrome. It's crucial to sign the APK before installation, especially if the application includes code tampering detection mechanisms.

Automation Tool#

For those seeking to automate the cloning process, MobSecco is a recommended tool. It streamlines the cloning of Android applications, simplifying the steps outlined above.


Security Risks & Recent Vulnerabilities (2023-2025)#

Cordova’s plugin-based architecture means that most of the attack surface sits inside third-party plugins and the WebView bridge. The following issues have been actively exploited or publicly disclosed in the last few years:

Quick checks during a pentest#

  1. Look for android:debuggable="true" in the decompiled AndroidManifest.xml. Debuggable builds expose the WebView over chrome://inspect allowing full JS injection.
  2. Review config.xml for overly permissive <access origin="*"> tags or missing CSP meta-tags in www/index.html.
  3. Grep www/ for eval(, new Function( or dynamically-constructed HTML that could turn CSP bypasses into XSS.
  4. Identify embedded plugins in plugins/ and run npm audit --production or osv-scanner --lockfile to find known CVEs.

Dynamic Analysis Tips#

Remote WebView Debugging#

If the application has been compiled in debug mode (or explicitly calls WebView.setWebContentsDebuggingEnabled(true)), you can attach Chrome DevTools:

adb forward tcp:9222 localabstract:chrome_devtools_remote
google-chrome --new-window "chrome://inspect/#devices"

This gives you a live JavaScript console, DOM inspector, and the ability to modify JavaScript functions at runtime.[7]

Hooking the JS ⇄ Native bridge with Frida#

The Java-side entry point of most plugins is org.apache.cordova.CordovaPlugin.execute(...). Hooking this method lets you monitor or tamper with calls made from JavaScript:

// frida -U -f com.vulnerable.bank -l hook.js --no-pause
Java.perform(function () {
  var CordovaPlugin = Java.use('org.apache.cordova.CordovaPlugin');
  CordovaPlugin.execute.overload('java.lang.String','org.json.JSONArray','org.apache.cordova.CallbackContext').implementation = function(act, args, ctx) {
    console.log('[Cordova] ' + act + ' => ' + args);
    // Tamper the first argument of a sensitive action
    if (act === 'encrypt') {
      args.put(0, '1234');
    }
    return this.execute(act, args, ctx);
  };
});

Hardening recommendations#


References#