Skip to content
XSS Write-up Intermediate

javascript:name in href attribute

A page copied a URL parameter into the window name and then used a second parameter as the href of a link, so a javascript: href could write attacker HTML into the page body. An attacker could get script to run in the target origin when a victim clicked the link.

medium.com

Published on medium.com

The javascript: pseudo-protocol is a mechanism in web development that can execute JavaScript code directly from an href attribute. This behavior has some interesting nuances, particularly when it comes to security implications.

Thiagofca, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the application assigned an untrusted URL parameter directly to an anchor's href and also copied another parameter into window.name, allowing a javascript: URL to inject HTML into the page.

Impact

Script could run in the target site's origin when a victim clicked the link, though the text notes that a javascript: URL pointing at a window property holding code does not execute it directly.

What the attacker needed

Victim opens a crafted link; victim submits the form and clicks Continue

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

A link can start with javascript: instead of https:, which tells the browser to run code rather than open a page. Here the site let a visitor choose that link and also stored text from the address bar in a browser variable called window.name. When the link was clicked, the browser put that stored text into the page as HTML, so a tag with an error handler ran script.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.