# C.S.R.F. & "Resource Linking"

Nous avons évoqué [précédemment](/api-rest/h.a.t.e.o.a.s.-et-resource-linking.md) le problème de confiance lié au *resource linking* en général.

Un client *(browser ou autre)* **communique** généralement avec **plusieurs APIs**.

Une réponse malicieuse ou simplement maladroite d’une API pourrait pousser le client à forger une requête vers une autre API en envoyer le token d’authentification ou encore d’autres informations confidentielles.

```javascript
{
    "firstName": "Foo",
    "address": {
        "href": "https://api.attacker.com/"
    }
}
```

Il est possible de se protéger partiellement avec des règles C.S.P. *(Content Security Policy)* `connect-src`\
<https://w3c.github.io/webappsec-csp/>

Autrement, il est recommandé d’implémenter ou d’utiliser une librairie HTTP robuste avec des *whitelists* strictes ou le rejet d’URLs absolues bien qu’une URL relative puisse être également malicieuse.


---

# Agent Instructions: 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:

```
GET https://guide-api-rest.marmicode.fr/securite-des-apis-rest/c.s.r.f.-and-resource-linking.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
