Input Validation / Cordova Cross-Site Scripting (XSS)

AndroidiOSMobile App


Cordova Cross-site Scripting (XSS) is a type of vulnerability classified by CWE-79, Cross-site Scripting, which occurs in Android, iOS, and Mobile App platforms. XSS vulnerabilities occur when an application or webpage does not sanitize user input properly, allowing malicious code to be executed as part of the application. This type of vulnerability is especially dangerous as it allows attackers to access sensitive information and even modify the application’s behavior. According to the OWASP Testing Guide v4, the risk of this vulnerability is high, as it can be used to execute malicious code and bypass the same-origin policy.


This vulnerability is considered a high risk, as it allows malicious code to be executed as part of an application or webpage. It can also be used to bypass the same-origin policy, allowing attackers to access sensitive data and even modify the application’s behavior.


The solution is to ensure that user input is properly sanitized and validated before being used. This can be done by using input validation techniques such as whitelisting and blacklisting. Additionally, the application should not trust any user-supplied data, and should always check for malicious code before it is executed.


The following example code is taken from CVE-2015-1835, which demonstrates a Cross-site Scripting vulnerability in the Cordova framework.

  function onDeviceReady() {
    var url = getQueryParam('url');
    document.write('<iframe src="' + url + '"></iframe>');
  document.addEventListener('deviceready', onDeviceReady, false);

In this example, the application is vulnerable to Cross-site Scripting due to the lack of input validation. The application is allowing user-supplied data to be used in the iframe URL, which could be used to inject malicious code.

Curious? Convinced? Interested?

Arrange a no-obligation consultation with one of our product experts today.