Sourcehut account takeover via build logs (XSS in ansi2html)
The ansi2html library failed to properly escape hyperlink URLs, allowing an attacker to inject HTML attributes and JavaScript into build logs. An attacker could execute arbitrary JavaScript in the browser of anyone viewing a malicious build log, potentially leading to account takeover and access to deploy keys.
blog.arusekk.pl
Published on blog.arusekk.pl
I like good stories, so let me describe some background first. I recently had a ‘great’ idea (I know, I know, I should stop having these) to set up a sr.ht instance that would pay people for hosting their projects.
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
Impact
An attacker could execute JavaScript in a victim's browser, potentially steal CSRF tokens, submit build jobs as the victim, and access deploy keys, though the exploit required the victim to have JavaScript enabled.
What the attacker needed
Victim views build log with JS enabled; attacker can inject into build log; no account needed for some vectors
How it was found
- Craft a malicious input string containing an OSC 8 hyperlink with an injected attribute or javascript: URL.
- Make that string appear in a build job log, for example by sending a patch to a public mailing list with CI enabled or by controlling a remote resource printed to the log.
- Submit or trigger the build job so the log is generated.
- Get a victim to view the build log page, which executes the payload in their browser.
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.
Build logs are web pages that show the output of automated software builds. The tool that converts terminal colour codes into HTML did not properly clean up special link sequences, so an attacker could sneak in malicious code. When someone opened the log, that code ran in their browser and could steal their session or perform actions on their behalf.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.