# Injection

Web applications are mainly exposed to **HTML and JavaScript code injection**.

There are multiple entry points:

* Some part of the URL,
* Parameters,
* Data coming from an "unsafe" API.

{% hint style="info" %}
Third-party *(user, partner etc...)* data should not be trusted and never executed or used as an HTML template.
{% endhint %}

{% hint style="danger" %}
Never use `eval().`
{% endhint %}

### Encode URI components

When constructing a URL, dynamic parts should be URI encoded.

```javascript
const url = `https://api.wishtack.com/users/${encodeURIComponent(userId)}`;
```


---

# 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://web-dev-guide.wishtack.io/security/injection.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.
