> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/fr/web/xss/dom-xss-in-href-attribute-with-jquery-location-search.md).

# XSS DOM dans un attribut href avec jQuery et location.search

### XSS DOM dans la cible de l'attribut href d'un lien jQuery utilisant la source location.search

Vulnérabilité XSS DOM sur la page de feedback. Le site utilise la `$` fonction de jQuery pour sélectionner un `<a>` élément (le lien de retour) et remplace son `href` attribut par une valeur extraite de `location.search`. Cette valeur peut être contrôlée via l'URL.

**Étude du laboratoire :**/ Faites déclencher le lien « back » `alert(document.cookie)` lorsque vous cliquez dessus (exécutez une alerte contenant les cookies de la page).

<figure><img src="/files/c61055bc6fe03a55072f8785d8d2676659870b6c" alt=""><figcaption></figcaption></figure>

**Observations :**

* Le bouton « back » renvoie à la racine du site ; il est relié à un `returnPath` paramètre dans l'URL.
* En modifiant `returnPath`, vous pouvez définir la destination du `href` lien.

Utilisez un schéma JavaScript dans `href`:

```javascript
javascript:alert(0)
```

Pour récupérer le cookie de session et l'afficher :

```javascript
javascript:alert(document.cookie)
```

<figure><img src="/files/d39d9302d650d3be505a03f2520f93ad6ef98034" alt=""><figcaption></figcaption></figure>


---

# 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://hacking-notes.jord4n.pro/fr/web/xss/dom-xss-in-href-attribute-with-jquery-location-search.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.
