> For the complete documentation index, see [llms.txt](https://blog.s1rn3tz.ovh/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://blog.s1rn3tz.ovh/pentest-mobile/android/deeplinks-vulns/webview-hijacking-via-deeplink.md).

# WebView hijacking (via deeplink)

Si une application se base sur une URL forgé via un deeplink pour ouvrir une WebView, il est parfois possible à la manière d'une open redirect de manipuler l'url afin de contourner la vérification de celle-ci.

&#x20;Il y a plusieurs possibilités pour cela,

## Via un domain takeover

Imaginons qu'une application se base sur une whitelist de domaines et qu'elle oublie de supprimer le domaine de pré production lors de sa mise en production dans l'application. SI le domaine de pré production expire ou est disponible par la suite, il sera alors possible pour un attaquant de l'acheter afin de pouvoir prendre le contrôle des WebView.

Exemple:

```java
private boolean isAuthorisedURL(String url)
    {
        String [] allowedHosts = {"example.com", "test.com", "staging.site"};
        for(String str: allowedHosts)
            if (url.equals(str)) 
                return true;
        
        return false;
    }
```

L'application est publié avec le domaine `staging.site` d'autorisé (domaine qui n'appartient potentiellement plus à l'entreprise)

## Via contournement de validation de l'URL

Pour cela, plusieurs possibilités:

### Absence de validation du schéma

Si le schéma n'est pas correctement validé, il peut être possible d'utiliser des schéma sensibles tels que `javascript:` ou `file:`

```
javascript://target.com/%0aalert(1)//

file://target.com/sdcard/payload.html
```

## Ressources

* <https://ash-king.co.uk/blog/facebook-bug-bounty-09-18>
* <https://valsamaras.medium.com/when-equal-is-not-another-webview-takeover-story-730be8d6e202>


---

# 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://blog.s1rn3tz.ovh/pentest-mobile/android/deeplinks-vulns/webview-hijacking-via-deeplink.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.
