The vulnerability is a classic stored Cross-Site Scripting (XSS) issue. The root cause is the failure to sanitize user-provided input from an Android APK's manifest file before rendering it in an HTML report. The analysis of the patch commit 2b08dd050e7685ee2a14fdbb454affab94129eae clearly shows the remediation steps.
-
Input Processing: The function manifest_analysis in mobsf/StaticAnalyzer/views/android/manifest_analysis.py is responsible for parsing the AndroidManifest.xml file. The patch shows that this function was modified to add sanitization.
-
Vulnerable Code: Specifically, the code that extracts the android:host attribute was identified as the source of the vulnerability. The line xmlhost = data.getAttribute(f'{ns}:host') reads the potentially malicious data.
-
The Fix: The patch introduces a new helper function, escape_manifest_attribute, which uses Django's escape() utility. This function is then called on the xmlhost variable immediately after it's read: xmlhost = escape_manifest_attribute(xmlhost). This change ensures that any HTML tags within the android:host attribute are escaped and rendered as plain text, preventing script execution.
-
Template Sink: The patch also removes the |safe filter from the Django template (mobsf/templates/static_analysis/android_binary_analysis.html). Previously, {{item|key:"title" | safe}} explicitly told Django to render the content as raw HTML, which is what allowed the XSS payload to execute. Removing |safe enforces Django's default auto-escaping, providing a defense-in-depth mitigation.
Therefore, the manifest_analysis function is the primary vulnerable function as it is responsible for processing the malicious input from the APK and failing to secure it before passing it to the template for rendering.