Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change addresses a SOP bypass vulnerability in the ChildBrowser that could result in remote disclosure of local files.
Assume that a Cordova-based application allows users to submit URLs that are redisplayed to other users. The application takes necessary steps to prevent JavaScript injection into the Cordova WebView by escaping single/double quotes. This scenario may occur if users are allowed to create a profile with a link to their website. The iOS application utilizes the ChildBrowser to load the untrusted website.
A malicious user sets their URL to the following URL.
The iOS application validates that the URI scheme is HTTP or HTTPS and then escapes all the double quotes and builds the following JavaScript which is used to invoke the ChildBrowser plugin.
Now the ChildBrowser's loadURL method is invoked on the victim's device.
Since the submitted URL ends with .png, the ChildBrowser plug-in dynamically builds some HTML code without performing output encoding and then loads the HTML into the WebView using the loadHTMLString:baseURL: method. The baseURL argument is set to [NSURL URLWithString:@""], which is equivalent to setting the baseURL argument to nil. Apple's API documentation for NSURL states that "if the URL string was malformed or nil, [the method] returns nil" and an empty string is considered a malformed URL. Unfortunately, the default setting is insecure if the baseURL argument is set to nil. The HTML code will be loaded using the file URI scheme, which means that the HTML/JavaScript code will have access to local files and can send those local files to remote servers.
In this example, the following HTML code is loaded into the ChildBrowser's WebView. Note that I break out of the src attribute value and inject in a JavaScript event handler (onerror), which will execute malicious JavaScript code that reads a local file using AJAX (/etc/passwd) and then sends the contents of the file to a remote server. This is possible since the same origin policy restrictions do not apply in this context. This technique could be used to remotely steal any local file that the target Cordova application has access to which may include SQLite databases or property list files that contain sensitive data such as OAuth access tokens, session identifiers, or credentials.
See the attached screenshots for the outcome.
http://d3adend.org/cordova/ChildBrowserExploit1.PNG
I would recommend the following to address the vulnerability.