Skip to content
Business logic Write-up Intermediate

Adding a malicious notebook to be treated like a trusted notebook in Google Colab — 1337$

Google Colab treated any notebook hosted in the trusted googlecolab GitHub organisation as Google-authored, so it loaded without the usual untrusted-notebook warning. An attacker who could get a malicious notebook into that repository could have it run silently and, if the victim had previously granted media permissions, access the camera or microphone.

Raushan Raj Follow

Published on medium.com

Bounty$1,337 View original

When we try to execute any Google Colab notebook from GitHub repo like https://colab.research.google.com/github/raushanraj/poclikethat/blob/master/testsimplecamera.ipynb

Raushan Raj, 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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 4 min read.

Context

Google Colab can open notebooks hosted on GitHub directly, by URL, without the user downloading anything first. The entry point is a URL of the form colab.research.google.com/github/<owner>/<repo>/blob/<ref>/<path>.ipynb. For example, the researcher used this notebook from his own repository:

Text
https://colab.research.google.com/github/raushanraj/poc_likethat/blob/master/test_simple_camera.ipynb

When a notebook comes from a third-party GitHub repository, Colab does not run it silently. It shows a warning first:

Warning: This notebook was not authored by Google. This notebook is being loaded from GitHub. It may request access to your data stored with Google, or read data and credentials from other sessions. Please review the source code before executing this notebook.

Notebooks from Google-owned repositories, such as https://github.com/googlecolab, are treated differently: they load and run without that warning. The researcher gives this example:

Text
https://colab.research.google.com/github/googlecolab/colabtools/blob/master/tests/simple.ipynb

Separately, when a notebook is executed from Drive and tries to use a sensitive capability such as the camera or the microphone, Colab shows a permission prompt. The notebook can only use that capability after the user accepts. The warning prompt therefore acts as a control that enables or disables certain attributes, which is what makes it worth bypassing.

Setup

The researcher needed a public GitHub repository and the ability to open a Colab URL pointing at a notebook inside it. The browser and OS used were Chrome and Firefox on Linux. No other accounts, roles or tool versions are described.

Finding it

The observation is a trust decision made on the repository owner rather than on the notebook. Colab decides whether to show the "not authored by Google" warning by looking at where the notebook is hosted. Anything under a Google-controlled repository such as googlecolab is considered trusted and skips the warning. The researcher noticed that this trust is granted to the repository as a whole, not to the specific files that Google authored in it, and that a public repository accepts contributions from anyone through pull requests.

That mismatch is the bug: a file that a third party can add to a trusted repository inherits the trusted status of the repository.

Exploitation

Step 1: add a notebook to the trusted repository

Create a new file in the public repository https://github.com/googlecolab/colabtools and generate a pull request. The file the researcher used is a notebook at this path:

Text
https://github.com/googlecolab/colabtools/blob/[redacted]/notebooks/test_simple_camera.ipynb

The file the researcher used is a notebook at this path, referenced by a specific commit. The notebook content is malicious, but its location is inside the repository that Colab trusts.

Step 2: open the notebook through Colab

Open the public notebook at the Colab URL for that path:

Text
https://colab.research.google.com/github/googlecolab/colabtools/blob/[redacted]/notebooks/test_simple_camera.ipynb

Because the owner is googlecolab, Colab treats the notebook as trusted and does not show the "not authored by Google" warning. The user sees a notebook that appears to come from Google and executes the code. The code is malicious.

Attack scenario

  1. Present a malicious notebook to the victim as a trusted Google notebook, with no warning message.
  2. The code used in the proof of concept can capture the victim's media, such as camera and voice, if permission was previously saved in the browser.

The second point is the condition the report gives: the code can capture media if permission was previously saved in the browser.

Root cause

The trust decision is based on the repository owner. Colab suppresses the third-party warning for notebooks hosted under Google-owned repositories such as googlecolab, but those repositories are public and accept pull requests from anyone. A contributor can therefore place a notebook in a trusted repository and have it treated as if Google had authored it. The warning that normally tells the user to review the source before executing is skipped.

Impact

An attacker who can get a notebook into a trusted Google repository can have victims run it without the "not authored by Google" warning. In the researcher's proof of concept the notebook captures media such as camera and voice, provided the victim's browser already has the permission saved. The attack scenario is presenting the malicious notebook to a victim as a trusted Google notebook. The report does not describe other capabilities or other preconditions.

Fix

Google fixed the issue on 16 January 2020, after the report on 2 January 2020. The bounty of 1337 USD was awarded on 17 January 2020. The report does not describe the change that was made.

Variants to test

  • Other trusted-owner lists. Find other products that grant trust by repository or organisation owner (for example, a documentation site, a package registry or a notebook viewer that skips warnings for a vendor's own repositories). A positive result is a file you can add to that owner's public repository being loaded with the trusted treatment and no warning.
  • Pinned commit references. Try loading the same path at a specific commit rather than a branch, as in the URL above. A positive result is the trusted treatment persisting for a revision that contains your file.
  • Saved browser permissions. On any feature that gates sensitive capabilities behind a prompt, check whether a previously granted permission removes the prompt for a notebook or page loaded from a trusted source. A positive result is access to the camera or microphone with no prompt at load time.
  • Trust inherited by forks or mirrors. Check whether a fork or mirror of a trusted repository, or a repository whose name resembles the trusted one, is also treated as trusted. A positive result is the warning being skipped for content the vendor did not author.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 10 min read.

What happened, in plain words

Google Colab is a free service from Google where you can open and run a "notebook": a document that mixes text with small pieces of code, and that runs the code on Google's computers when you press play. People often keep notebooks on GitHub, a website where anyone can store and share code. Colab can open a notebook straight from GitHub if you give it a link, so you do not have to download anything first.

When a notebook comes from a stranger's GitHub account, Colab is careful. Before running it, Colab shows a warning saying the notebook was not written by Google and that you should read the code before executing it. But when the notebook sits in a GitHub repository owned by Google, Colab skips that warning and runs the notebook as if Google itself had written it.

The researcher noticed a gap in that logic. The Google-owned repository used here is public, and anyone on the internet can propose adding a file to it through a "pull request" (a request to change a repository, which the owner can accept). So a stranger could put their own notebook inside a repository that Colab trusts, and Colab would then treat that stranger's notebook as a trusted Google notebook, with no warning at all.

That is the whole bug: trust is given to the repository as a whole, not to the individual files Google actually wrote. The researcher demonstrated it with a notebook that can capture the victim's media, such as camera and voice, if permission was previously saved in the browser, and Google paid a bounty of 1337 USD after fixing it.

Background: the pieces involved

Before the steps make sense, here are the moving parts, explained from zero.

  • Notebook: a file, usually ending in .ipynb, that contains text cells and code cells. You read it like a document and run the code cells one by one. It is popular for data work and for quick experiments.
  • Google Colab: Google's online place to open and run notebooks. The code runs on Google's servers, not on your own machine, but the notebook page in your browser can still ask your browser for things like your camera.
  • GitHub: a website that hosts code and documents in "repositories" (project folders). A repository can be public, meaning anyone can read it, and anyone can propose changes to it.
  • Repository owner: the account or organisation that owns a repository. Here the owner is googlecolab, a Google organisation.
  • Pull request: a proposal to add or change files in someone else's repository. The owner reviews it and can accept or reject it. This is how outsiders contribute to public projects.
  • Commit reference: a long string of letters and numbers that identifies one exact saved state of a repository. Using it in a link means the link always points at that same version, even if the files change later.
  • Warning prompt: a message shown before something risky happens, asking you to confirm or to read first. In a browser it is the little pop-up asking whether a site may use your camera or microphone.
  • Saved permission: when you allow a site to use your camera once, the browser can remember that choice. Next time, the site may get access without asking again.
  • Broken authorization / logic flaw: a category of bug where the software makes a wrong decision about who or what should be trusted, rather than crashing or leaking data directly. Here the software decides "this notebook is from Google, so it is safe" based on the wrong thing.

The normal behaviour, and the warning

Colab can open a notebook hosted on GitHub directly by URL. The address has a fixed shape:

Read it piece by piece:

  • colab.research.google.com is the Colab website.
  • /github/ tells Colab the notebook lives on GitHub.
  • <owner> is the GitHub account or organisation that owns the repository.
  • <repo> is the repository name.
  • /blob/<ref>/ points at a particular version: <ref> can be a branch name such as master, or an exact commit reference.
  • <path>.ipynb is the location and name of the notebook file inside the repository.

For example, the researcher used this notebook from his own repository:

Text
https://colab.research.google.com/github/raushanraj/poc_likethat/blob/master/test_simple_camera.ipynb

Here the owner is raushanraj, the repository is poc_likethat, the version is the master branch, and the file is test_simple_camera.ipynb at the top of the repository.

When a notebook comes from a third-party GitHub repository like that one, Colab does not run it silently. It shows a warning first:

Warning: This notebook was not authored by Google. This notebook is being loaded from GitHub. It may request access to your data stored with Google, or read data and credentials from other sessions. Please review the source code before executing this notebook.

The warning is telling you two things: Google did not write this notebook, and the notebook might ask for access to your Google data or read data and credentials from other sessions. In plain terms, it is a "look before you leap" sign.

Notebooks from Google-owned repositories, such as https://github.com/googlecolab, are treated differently: they load and run without that warning. The researcher gives this example:

Text
https://colab.research.google.com/github/googlecolab/colabtools/blob/master/tests/simple.ipynb

Same URL shape, but now the owner is googlecolab, so Colab considers the notebook trusted and skips the warning.

There is a second safety net as well. When a notebook is executed from Drive and tries to use a sensitive capability such as the camera or the microphone, Colab shows a permission prompt. The notebook can only use that capability after the user accepts. So the warning prompt acts as a control that enables or disables certain attributes, which is exactly why it is worth bypassing: if you can skip the warning, you remove one of the barriers between a stranger's code and the victim's device.

Setup

The researcher needed a public GitHub repository and the ability to open a Colab URL pointing at a notebook inside it. The browser and OS used were Chrome and Firefox on Linux. No other accounts, roles or tool versions are described.

Finding it

The observation is a trust decision made on the repository owner rather than on the notebook. Colab decides whether to show the "not authored by Google" warning by looking at where the notebook is hosted. Anything under a Google-controlled repository such as googlecolab is considered trusted and skips the warning. The researcher noticed that this trust is granted to the repository as a whole, not to the specific files that Google authored in it, and that a public repository accepts contributions from anyone through pull requests.

A simple comparison: imagine a building where the front desk lets anyone in who says they work for a certain company, without checking the person's badge against the company's staff list. If the company's office is open to visitors who can leave papers on the desks, a visitor can leave a document that later looks official. The building trusted the company name, not the document.

That mismatch is the bug: a file that a third party can add to a trusted repository inherits the trusted status of the repository.

Exploitation

Step 1: add a notebook to the trusted repository

Create a new file in the public repository https://github.com/googlecolab/colabtools and generate a pull request. The file the researcher used is a notebook at this path:

Text
https://github.com/googlecolab/colabtools/blob/[redacted]/notebooks/test_simple_camera.ipynb

Why this step: the goal is to get a malicious notebook inside a repository that Colab already trusts. The repository googlecolab/colabtools is public, so a pull request is the normal way to propose a new file in it. The file the researcher used is a notebook at this path, referenced by a specific commit. The notebook content is malicious, but its location is inside the repository that Colab trusts.

Step 2: open the notebook through Colab

Open the public notebook at the Colab URL for that path:

Text
https://colab.research.google.com/github/googlecolab/colabtools/blob/[redacted]/notebooks/test_simple_camera.ipynb

Why this step: this is the link a victim would click. Because the owner is googlecolab, Colab treats the notebook as trusted and does not show the "not authored by Google" warning. The user sees a notebook that appears to come from Google and executes the code. The code is malicious.

Attack scenario

  1. Present a malicious notebook to the victim as a trusted Google notebook, with no warning message.
  2. The code used in the proof of concept can capture the victim's media, such as camera and voice, if permission was previously saved in the browser.

The second point is the condition the report gives: the code can capture media if permission was previously saved in the browser. In everyday terms, if the victim once told the browser "yes, this site may use my camera", the browser remembers that answer, and the notebook can use the camera without asking again.

Root cause

The trust decision is based on the repository owner. Colab suppresses the third-party warning for notebooks hosted under Google-owned repositories such as googlecolab, but those repositories are public and accept pull requests from anyone. A contributor can therefore place a notebook in a trusted repository and have it treated as if Google had authored it. The warning that normally tells the user to review the source before executing is skipped.

Impact

An attacker who can get a notebook into a trusted Google repository can have victims run it without the "not authored by Google" warning. In the researcher's proof of concept the notebook captures media such as camera and voice, provided the victim's browser already has the permission saved. The attack scenario is presenting the malicious notebook to a victim as a trusted Google notebook. The report does not describe other capabilities or other preconditions.

Fix

Google fixed the issue on 16 January 2020, after the report on 2 January 2020. The bounty of 1337 USD was awarded on 17 January 2020. The report does not describe the change that was made.

Variants to test

These are ideas for looking for the same kind of mistake elsewhere. Each one is a way to check whether a product trusts a name or a location instead of the actual content.

  • Other trusted-owner lists. Find other products that grant trust by repository or organisation owner (for example, a documentation site, a package registry or a notebook viewer that skips warnings for a vendor's own repositories). A positive result is a file you can add to that owner's public repository being loaded with the trusted treatment and no warning.
  • Pinned commit references. Try loading the same path at a specific commit rather than a branch, as in the URL above. A positive result is the trusted treatment persisting for a revision that contains your file.
  • Saved browser permissions. On any feature that gates sensitive capabilities behind a prompt, check whether a previously granted permission removes the prompt for a notebook or page loaded from a trusted source. A positive result is access to the camera or microphone with no prompt at load time.
  • Trust inherited by forks or mirrors. Check whether a fork or mirror of a trusted repository, or a repository whose name resembles the trusted one, is also treated as trusted. A positive result is the warning being skipped for content the vendor did not author.

Glossary

  • Notebook: a document, usually ending in .ipynb, that mixes text and runnable code cells.
  • Google Colab: Google's online service for opening and running notebooks on Google's computers.
  • GitHub: a website that hosts code and documents in repositories that others can read and contribute to.
  • Repository: a project folder on GitHub, containing files and their history.
  • Pull request: a proposal to add or change files in a repository, which the owner can accept or reject.
  • Commit reference: a long identifier for one exact saved state of a repository.
  • Branch: a named line of development in a repository, such as master.
  • URL: the address of a page or file on the web.
  • Warning prompt: a message shown before a risky action, asking the user to read or confirm first.
  • Permission prompt: a browser pop-up asking whether a site may use something sensitive, such as the camera or microphone.
  • Saved permission: a browser's memory of a previous allow or deny choice, so the prompt may not appear again.
  • Broken authorization: a bug where software makes a wrong decision about who or what is allowed or trusted.
  • Logic flaw: a bug in the reasoning of the software rather than in a single line of code, such as trusting the wrong thing.
  • Bypass: getting past a safety check without satisfying it.
  • Proof of concept (POC): a small demonstration that a bug is real and can be exploited.
  • Bounty: money paid by a company to someone who reports a valid security bug.
  • Fork: a personal copy of someone else's repository on GitHub.
  • Mirror: a copy of a repository hosted somewhere else.
  • Vendor: the company that makes the product.

More by Raushan Raj

View all

4 more disclosed reports, best first.

More from Google

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.