Modify the Cordova whitelist
One of the security fixes involves creating a new whitelist for non http/s
protocols. If your application uses other protocols besides http://
and https://
, such as sms:
, mailto:
, geo:
,tel:
etc., then you will need to make some configuration changes to add these protocols to the whitelist.
This is easy to do:
- Open up the Cordova config.xml file, located at: yourProject --> apps --> yourProject --> android --> native --> res --> xml --> config.xml. Note: If you have a file located at yourProject --> apps --> yourProject --> android --> nativeResources --> res --> xml, you will have to make the changes to this file (under the nativeResources folder) instead, since if this file exists, it will overwrite the config.xml in /native/ folder when the app is rebuilt.
Scroll to your whitelist entries. You should see items listed like this:
<access origin="https://my.company.com/resources" />
<access origin="http://*.othersupplier.com" />
For every non http/https protocol that you use, you will have to add a whitelist entry like this:
<access origin="sms://*" launch-external="true" />
<access origin="mailto://*" launch-external="true" />
The launch-external attribute will tell Cordova to allow this URL to be handled by other applications in Android system - not by the currently running Cordova/Worklight application.
This will mean that when a user clicks on a <a href="sms:555...">
link, Android will let whatever application is registered to sms:
handle the request.
If the only entry that is in your whitelist looks like this:
<access origin="*" />
then your application will allow resource requests to any internet resource, which could open your application to certain kinds of attacks.
You should list specific domains in this tag that you want to be able to access.
If your whitelist looks like this:
<access origin="https://www.ibm.com" />
<access origin="https://my-worklight-server.company.com" />
and inside your application you utilize the mailto:
protocol to open a user's email client, and the geo:
protocol to display a map, then you should modify the whitelist to look like:
<access origin="https://www.ibm.com" />
<access origin="https://my-worklight-server.company.com" />
<access origin="mailto://*" launch-external="true" />
<access origin="geo://*" launch-external="true" />
HTML :
<a href="tel:+212x-xx-xx-xx-xx">Call</a>
Add to file "config.xml" :
<access origin="tel:*" launch-external="yes"/>
source :
https://www.ibm.com/developerworks/community/blogs/worklight/entry/action_required_cordova_android_security_update?lang=en`