Colab shared notebook roles do not separate code execution from viewing
0 reputation · 20 Jun 2024, 12:12 UTC
0 reputation · 20 Jun 2024, 12:12 UTC
Google Colab notebooks inherit Google Drive sharing permissions, and the Colab Share dialog offers link access levels such as Restricted, Anyone with the link, and Public on the web. When a notebook is shared with specific accounts, the UI assigns Viewer or Editor roles. However, Colab does not expose a distinct permission that allows a collaborator to view the notebook source and outputs while preventing them from running or modifying code cells.
This limitation means that any account granted Editor access can execute arbitrary code in the shared runtime environment, potentially accessing attached secrets, mounted Drive files, or outbound network calls. Conversely, there is no built-in way to grant read-only access that still permits interactive exploration of outputs without execution rights. Drive-level permissions apply to the file as a whole and cannot scope execution rights independently.
Organizations that need to share notebooks for review or demonstration purposes must either accept full execution capability for editors or restrict sharing to view-only Drive permissions, which also blocks output rendering in the Colab UI.
37775 reputation · 20 Jun 2024, 23:35 UTC
Google Colab inherits Drive sharing roles but provides no distinct permission to view outputs while blocking code execution. Both Viewer and Editor roles in the Colab Share dialog grant the ability to run cells in the collaborator's own ephemeral runtime.
Any account with run capability can insert code that accesses their own mounted Drive files, environment variables, or outbound network calls. The runtime is per-user, so an editor cannot directly access your secrets, but they can write code that exfiltrates data when you subsequently run that notebook.
File > Download .html or File > Print then save as PDF. Share the exported file via Drive or email..ipynb to a private repository and use GitHub's notebook viewer for read-only access.Google Apps Script can manage Drive file sharing programmatically (e.g., Drive.Permissions.insert()), but there is no Colab-specific service or API method to disable cell execution at runtime. Apps Script cannot sandbox or restrict what code runs when a collaborator presses the play button.
To confirm current behavior:
1. Share a notebook with a second Google account as Viewer. 2. Log in as that account, open the notebook in Colab. 3. Check: are run buttons active? Can you execute cells? 4. Repeat as Editor and verify save/modify capabilities.
Assumption: These behaviors reflect Colab as of late 2026. Google may introduce execution-scoped roles or a read-only mode in future updates. Always verify against the current Colab Help documentation before implementing controls.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.