Skip to content
XSS Write-up Advanced

Github Token Stealing

A Jupyter notebook rendered in a VSCode webview could run JavaScript that simulated keyboard shortcuts, leading to the installation of a malicious extension that stole the user's GitHub token. The token had full access to all repositories the user could access, including private ones.

blog.ammaraskar.com

Published on blog.ammaraskar.com

Just by clicking a link, it’s possible for an attacker to steal a GitHub token that can read and write to your repos, including private ones.

The author, on blog.ammaraskar.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 webview allowed untrusted content to dispatch synthetic keydown events that the main editor treated as real user input, enabling command execution without user interaction.

Impact

An attacker could steal a GitHub token with read and write access to all repositories the victim can access, including private ones; the attack works on github.dev and, with more effort, on desktop VSCode.

What the attacker needed

Victim clicks a link to a malicious repo; victim has used github.dev before (or clicks through dialog); repo contains a Jupyter notebook and local extension

How it was found

  1. Open a repository containing a Jupyter notebook with a malicious markdown cell and a local workspace extension.
  2. The notebook's JavaScript waits for VSCode to show a notification recommending extensions.
  3. It emits a keydown event for Ctrl+Shift+A to accept the notification and install the recommended extension.
  4. It waits for the extension to install and activate, adding a custom keybinding.
  5. It emits a keydown event for Ctrl+F1 to trigger the installation of the attacker's extension.
  6. The installed extension reads the GitHub token and queries the GitHub API for private repositories.

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.

When you open a repository on github.dev, a small code editor runs in your browser and receives a special key (a token) that lets it act as you on GitHub. The bug let a malicious notebook run hidden code that pretended to press keys, which installed a bad extension. That extension then read the token and used it to access all your repositories.

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.