Summary
A stored cross-site scripting (XSS) issue in MobSF prior to version 4.4.5 allows arbitrary JavaScript execution in the browser of anyone viewing generated analysis reports.
By uploading a malicious APK with crafted android:host values in <data android:scheme="android_secret_code"> elements, an attacker can inject script code into the HTML report, potentially leading to session hijacking and account takeover within the MobSF web interface.
Affected context
This vulnerability occurs in MobSF's web-based reporting interface when analyzing Android applications.
Specifically, values from the android:host attribute in <data android:scheme="android_secret_code"> elements within an APK's AndroidManifest.xml are reflected into HTML reports without proper sanitization or encoding.
The risk is present in multi-user or shared MobSF instances where users upload APKs and others view the corresponding analysis reports through a browser.
Exploit preconditions
- Attack surface: MobSF web UI that displays HTML analysis reports for uploaded Android APKs.
- Required access: Ability to upload an APK to a MobSF instance (e.g., authenticated user, CI pipeline integration, or exposed upload endpoint).
- Trigger point: A victim user with access to the MobSF interface opens the HTML report for the malicious APK in their browser.
- Why exploitation is possible: The
android:hostattribute from<data android:scheme="android_secret_code">entries is embedded into the report HTML without output encoding or sanitization, allowing attacker-controlled JavaScript to execute in the victim's browser context.
Why this happens
The core issue is untrusted data from an analyzed APK being inserted into an HTML report without appropriate context-aware escaping or sanitization.
MobSF treats the contents of the android:host attribute as display-only data but renders it directly into the DOM, which maps to CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting).
Because the report template does not encode characters with special meaning in HTML/JavaScript contexts, an attacker can smuggle script fragments or event handlers that execute when the report is viewed.
Potential impact
- Execution of arbitrary JavaScript in the browser of users viewing MobSF reports
- Theft of MobSF session cookies and potential session hijacking
- Account takeover within the MobSF interface, depending on session handling and roles
- Unauthorized actions performed on behalf of a victim (e.g., modifying settings, viewing or deleting analysis data)
- Injection of malicious content that could further pivot to other internal tools or browser-based resources
General mitigation guidance
Effective mitigation focuses on treating all analysis-derived content as untrusted and enforcing robust output encoding:
- Apply context-aware HTML encoding to all dynamic values, including
android:host, before inserting them into report templates. - Use templating engines or helper functions that escape output by default, only allowing explicit safe HTML for tightly controlled, vetted content.
- Normalize and validate manifest fields, rejecting or neutralizing values that contain HTML/JavaScript control characters where they are not semantically required.
- Isolate report rendering components with strict Content Security Policy (CSP) rules to limit script execution and reduce XSS blast radius.
- Follow a least-privilege model in the web interface so that a compromised user session has minimal impact on other users and system configuration.
How teams detect issues like this
Organizations can identify similar vulnerabilities by combining static and manual review techniques:
- Perform static analysis or grep-based scans for places where data derived from APKs, manifests, or other user-controlled artifacts are interpolated directly into HTML.
- During code review, flag any report templates or views that render unescaped variables from analysis results, especially those originating in XML/manifest parsing.
- Add automated tests that include payload-like test values in manifest attributes and verify that generated reports display them as text rather than executing them.
- Integrate security-focused linters or SAST tools configured with rules for CWE-79, focusing on server-side templating contexts used by MobSF or similar tools.

