> For the complete documentation index, see [llms.txt](https://simon-6.gitbook.io/simoncyber/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://simon-6.gitbook.io/simoncyber/portswigger-web-academy/xss/xss-contexts/lab-3.md).

# Lab 3

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

## `<a>` HTML anchor element

The **`<a>`** [HTML](https://developer.mozilla.org/en-US/docs/Web/HTML) element (or *anchor* element), with [its `href` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/a#href), creates a hyperlink to web pages, files, email addresses, locations in the same page, or anything else a URL can address.

Content within each `<a>` *should* indicate the link's destination. If the `href` attribute is present, pressing the enter key while focused on the `<a>` element will activate it.

A **canonical tag** is a `<link>` element in the page's `<head>` that tells search engines "the official URL for this page is X."

#### What it looks like

```html
<head>
  <link rel="canonical" href="https://example.com/product/123">
</head>
```

That's it. Sits in the `<head>`, invisible to users, only relevant to search engine crawlers.

<figure><img src="/files/50xkCx7Nh1txT96c3X58" alt=""><figcaption></figcaption></figure>

We don't see any input fields for the website, which means the only way to inject anything is through the URL.&#x20;

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

Let's try escaping the href quotes - try putting in a alert(1)<br>

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

The quotes seem to be a little messed up&#x20;

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

We added a " ' " right before alert and that seem to fixed it, but it doesn't work why? We need an access key. (plus the description said we needed to activate it using one of the commands)&#x20;

#### `accesskey` — the keyboard shortcut attribute

`accesskey` is an HTML attribute that assigns a **keyboard shortcut** to an element. When the user presses that shortcut, the browser treats it as if the element was clicked.

#### Basic example

```html
<button accesskey="s" onclick="save()">Save</button>
```

Pressing the shortcut (`Alt+S` on Chrome Windows) triggers the button's `onclick`, running `save()`. Same as clicking it.

So instead of doing onload, we do onclick and create a access key:

?'accesskey='X'onclick='alert(1)
