Safeguard
Security Guides•

What gets shared when you share a Colab notebook?

Sharing a Colab notebook shares text, code, output and comments, not the VM. What that means for keys and data, and how to check before you send the link.

Safeguard Security Team
3 min read

Sharing a Colab notebook shares its full contents: text, code, output and comments. Google's FAQ says the virtual machine, including custom files and libraries you set up, is not shared. So a key printed in an output cell travels with the link, even though files on the VM stay behind.

What the FAQ says

From the Colaboratory FAQ:

  • If you share a notebook, the full contents of the notebook, meaning text, code, output and comments, are shared.
  • The virtual machine you use, including any custom files and libraries you set up, will not be shared.
  • You can omit code cell output from being saved or shared through the notebook settings.
  • Mounting Google Drive allows any code in your notebook to access any files in your Drive.
  • Notebooks edited by another user do not automatically mount Google Drive.

Taken together: the notebook is a document that carries whatever you typed or printed into it.

What commonly slips out

WhereExample
Code cellsA token pasted to test an API call
Output cellsA printed environment variable, or a dataframe of real records
CommentsAn error message with a connection string
Text cellsA note with an internal URL
Revision historyA token removed later, still in an earlier version

The history item is a general property of shared documents, so check whether the earlier versions are visible to the people you share with.

Drive access is the bigger lever

The FAQ says mounting Drive gives any code in the notebook access to any files in your Drive. That includes code from a notebook you opened from someone else. Before you run a notebook from a stranger or a public repository, read it, and do not mount Drive unless it needs to. Prefer a separate Google account or a folder for experiments rather than your main Drive.

Pre-share checklist

  1. Search the notebook for words like key, token, secret, password and the names of your own services.
  2. Clear all outputs, or turn off saving output in the notebook settings, per the FAQ.
  3. Replace any real data in outputs with a small synthetic sample.
  4. Check the sharing setting and who has edit rights. Edit access lets someone change the code that other people run.
  5. Check earlier versions for anything you removed.
  6. Rotate any credential that was ever visible, then remove it.

Running other people's notebooks

Read the cells first, especially installs, downloads and any call that reads files or secrets. Run it without mounting Drive, in a fresh runtime. Treat a notebook as code, because that is what it is. See is it safe to open an untrusted Jupyter notebook.

For key handling habits, read how to keep API keys out of Jupyter notebooks.

Safeguard's scanning and policy gates can flag secrets in repositories where notebooks end up, and a free scan is at gold.safeguard.sh/scan.

Quick check

Does sharing give people my files on the VM?

Per the FAQ, no. The VM and its custom files are not shared.

Does clearing output remove a key typed into a code cell?

No. Output clearing does not edit code cells. Remove the key and rotate it.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.