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
| Where | Example |
|---|---|
| Code cells | A token pasted to test an API call |
| Output cells | A printed environment variable, or a dataframe of real records |
| Comments | An error message with a connection string |
| Text cells | A note with an internal URL |
| Revision history | A 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
- Search the notebook for words like key, token, secret, password and the names of your own services.
- Clear all outputs, or turn off saving output in the notebook settings, per the FAQ.
- Replace any real data in outputs with a small synthetic sample.
- Check the sharing setting and who has edit rights. Edit access lets someone change the code that other people run.
- Check earlier versions for anything you removed.
- 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.