Safari is hot-linking images to semi-random websites
Safari's OCR feature parses text inside images and turns it into clickable links, so any uploaded image can embed a URL that Safari offers to open. The researcher also found a way to make Safari strip the http protocol from a crafted URL, leaving a javascript URL that executes on refresh in the safari-resource context.
Published on portswigger.net
Every image is potentially a URL on Safari, thanks to over-enthusiastic OCR (Optical Character Recognition). This means you can link any image to an external website - and Safari might already be sending your users to unintended destinations.
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 Safari's OCR-based link detection trusts text found in images and does not properly validate the resulting URL scheme, allowing a crafted URL to be reduced to a javascript scheme.
Impact
Any image uploaded to any website could make Safari offer a link to an attacker-chosen site, and with a refresh the crafted link could run JavaScript in the safari-resource context, though this required enabling JavaScript in the Smart search field.
What the attacker needed
Safari browser; image uploaded to a website; victim hovers and clicks the image; JavaScript enabled in Smart search field
How it was found
- Create an image containing a URL as text.
- Load the image in Safari and hover over it to see the quick look menu offer the link.
- Craft a URL that begins with http followed by a javascript scheme so Safari strips the http part.
- Click the offered link, which shows a server error, then refresh the page to run the JavaScript.
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.
Safari tries to read text inside pictures and, if it looks like a web address, offers to open it when you hover over the image. The researcher showed that a picture can therefore contain a link to any site, and with a trick the leftover link can run JavaScript code instead. JavaScript is the language web pages use to make things happen, so running it in a trusted browser page is risky.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.