Securing Databricks cluster init scripts
A low-privileged authenticated user could modify or create init scripts stored on the shared Databricks File System (DBFS), leading to remote code execution on compute clusters. This allowed breaking cluster isolation, accessing secrets, and escalating to workspace administrator privileges.
Published on sec-consult.com
This blog was co-authored by Elia Florio, Sr. Director of Detection & Response at Databricks and Florian Roth and Marius Bartholdy, security researchers with SEC Consult.
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
Impact
An attacker could break cluster isolation, access all files and secrets in the workspace, and escalate privileges to workspace administrator; however, exploitation required a valid account and specific legacy configurations, and Databricks found no evidence of it occurring in practice.
What the attacker needed
Valid authenticated account; legacy global init script enabled or cluster init script on…
The fix
Databricks disabled creation of new workspaces with deprecated init script types, set an end-of-life deadline, provided migration tools, and introduced workspace files as a more secure storage location with ACLs; the issue was fixed.
How it was found
- List the contents of the DBFS directory where init scripts are stored.
- Rename an existing init script and create a new malicious script with the original name.
- Wait for the cluster to restart or trigger the init script, which executes the malicious code with root privileges.
- Use the reverse shell to read secrets from /tmp/custom-spark.conf and /proc/<pid>/environ.
- Capture control-plane traffic to leak API tokens of other users, including administrators.
- Use the leaked token to authenticate to the Databricks REST API and access secret scopes.
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.
In Databricks, init scripts are like setup instructions that run automatically when a cluster starts. These scripts were stored in a shared file system that every user could access, so a regular user could change them to run their own commands with high privileges. This let them take control of the cluster and steal sensitive information.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.