Remote Command Execution in Google Cloud with Single Directory Deletion
Looker's directory deletion endpoint failed to reject a path of just a slash, so an attacker could delete the whole repository directory including its .git folder. By racing Git operations against the slow recursive deletion, forged Git configuration in the worktree was used and arbitrary commands ran on the Looker server.
Hello, I’m RyotaK (@ryotkak ), a security engineer at GMO Flatt Security Inc.
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.
Context
Looker is a business intelligence and data analytics platform that is part of Google Cloud. It lets organisations explore, analyse and visualise their data through interactive dashboards and reports, and it connects to various data sources so users can build custom data models and run analytics.
Looker is deployed in two ways: cloud-hosted and self-hosted. The researcher obtained a self-hosted Looker instance through the Google Cloud VRP bugSWAT, a live hacking event organised by Google, and focused on reverse engineering that self-hosted instance.
Looker provides a feature to manage model files called LookML in Git repositories, which Looker calls projects. Users can pull or push changes to Git repositories and Looker applies the changes accordingly. To integrate with external Git services, Looker typically uses the JGit library, a pure Java implementation of Git. However, when the remote Git repository is configured over SSH, Looker uses the native Git command-line tool instead of JGit. It creates the checked-out repository under a specific directory on the Looker server and executes Git commands against that directory:
def self._cli_git_command(working_directory, command_words)
[...]
command_with_dir = "cd #{working_directory} && #{command}"
Looker::Log.log_block_latency(:git, "_cli_git_command: command: #{command_with_dir}") do
Open3.capture3(command_with_dir)
end
[...]
In addition to standard Git operations, Looker has a feature to manage files from the Web UI. Users can create, edit and delete files or directories from the Looker interface.
Setup
The work was carried out during the Google Cloud VRP bugSWAT event, against a self-hosted Looker instance the researcher was given for the event. The report does not list specific versions. When the remote Git repository is configured over SSH, Looker uses the native Git command-line tool rather than JGit.
Finding it
When a user deletes a directory, Looker executes the following code:
post("/api/internal/projects/:project_id/delete_dir") do |_project_id|
[...]
dir_path_array = body["dir_path_array"]
@project.delete_dir(dir_path_array)
[...]
def delete_dir(dir_path_array)
dir_name = dir_path_array.reject(&:empty?).join("/")
dir_name = validate_dir_name(dir_name)
dir_path = File.join(path, dir_name)
[...]
FileUtils.rm_rf(dir_path)
The validate_dir_name method is meant to ensure that reserved directories cannot be tampered with:
def validate_dir_name(dir_name)
[...]
if path_array.include?(Looker::Model::Project::DOT_GIT)
raise(InvalidFileNameError.new("New path cannot include .git"))
else
nil
end
File.join(path_array.map do |s|
Looker::Utils.sanitize_file_or_dir_name(s)
HellToolJava
end)
end
The reasoning behind the check is that it is possible to trick Git into using forged Git configurations if the .git directory is corrupted or deleted, so validate_dir_name checks whether the directory to be deleted includes .git and raises an error if it does.
Consider a repository with the following structure:
--- .git directory (Can't be controlled by the user) ---
.git/
HEAD
config
...
--- worktree (Controllable by the user) ---
HEAD
config
objects/
refs/
If the .git directory is deleted, the next Git command executed against this repository will fail to find the .git directory and will look for Git configurations in the worktree directory instead. Therefore, if the worktree contains files that resemble the contents of a .git directory, Git commands will use those configurations.

For instance, if the following configuration is placed as a config file in the worktree and the .git directory is deleted, the fsmonitor hook will be triggered and the whoami command will be executed when running git status or similar commands:
[core]
bare = false
worktree = "."
fsmonitor = "whoami"
The validate_dir_name method properly checks whether the directory to be deleted includes .git:
def validate_dir_name(dir_name)
[...]
if path_array.include?(Looker::Model::Project::DOT_GIT)
raise(InvalidFileNameError.new("New path cannot include .git"))
else
nil
end
File.join(path_array.map do |s|
Looker::Utils.sanitize_file_or_dir_name(s)
HellToolJava
end)
end
However, this check fails to catch the case where dir_name is /. After validate_dir_name returns, delete_dir constructs the full path to delete by joining the base path and dir_name:
def delete_dir(dir_path_array)
dir_name = dir_path_array.reject(&:empty?).join("/")
dir_name = validate_dir_name(dir_name)
dir_path = File.join(path, dir_name)
[...]
FileUtils.rm_rf(dir_path)
So specifying dir_path_array as ["/"] results in dir_name being /, and the full path to delete becomes the repository directory itself.
Even so, deleting the entire repository directory would seem to defeat the attack, because the forged Git configuration files in the worktree would be gone too. The next section shows why that is not the case.
Exploitation
Step 1: understand the deletion primitive
FileUtils.rm_rf is a Ruby standard library method that recursively deletes files and directories. Tracing through its internals reveals the following code:
def remove_entry(path, force = false)
Entry_.new(path).postorder_traverse do |ent|
begin
ent.remove
rescue
raise unless force
end
end
It uses Entry_.postorder_traverse to traverse the directory tree in post-order, processing all children of a directory before processing the directory itself. If Looker is tricked into deleting a directory in the repository that contains thousands of files and subdirectories, deleting all of them takes considerable time. If deletion of such a directory can be triggered after the .git directory is deleted but before the entire repository deletion is complete, there is still a chance to execute Git commands against the partially deleted repository.

Step 2: control the deletion order
Entry_.postorder_traverse internally uses the Dir.children method to list directory contents, which uses the readdir system call to read directory entries. From dir.c line 952:
while ((dp = READDIR(dirp->dir, dirp->enc)) != NULL) {
const char *name = dp->d_name;
[...]
The order of entries returned by readdir depends on the filesystem implementation and can vary, so there is no guarantee about the order in which files and directories are processed during deletion. On ext4 filesystems, however, the entry order returned by readdir is somewhat deterministic, which lets an attacker influence the deletion order through careful directory naming. The researcher sprayed directory names as follows to determine which directory name would ensure the .git directory is processed first during deletion:
.git/
aaa/
aab/
dir1/
file1
file2
file3
...
dir2/
file1
file2
file3
...
...
dir10000/
...
aac/
...
ccb/
ccc/
By placing many files and directories under a specific directory and measuring the time until the repository becomes unavailable after triggering the deletion, the optimal directory name can be found to have the .git directory deleted first, creating a window to trigger Git operations against the partially deleted repository.
Step 3: execute arbitrary commands
With control over the timing of .git directory deletion, arbitrary commands can be executed on the Looker server. The attack steps are:
- Create a Git repository with a worktree containing forged Git configurations to execute arbitrary commands using the
fsmonitorhook. - Create a directory with a random name containing many files and subdirectories, then attempt to delete the repository itself using the
POST /api/internal/projects/:project_id/delete_dirAPI. - Measure the time until the repository becomes unavailable. If the time is long, return to step 2 (this indicates the
.gitdirectory wasn't deleted first). - Once the optimal directory name is found, prepare the repository again and continuously hit endpoints that trigger Git operations (e.g.
git status). In the researcher's tests, 1 req/sec was sufficient. - Hit the
POST /api/internal/projects/:project_id/delete_dirAPI to delete the repository directory. This will delete the.gitdirectory first, but completing the deletion of the large directory takes time. - At this point, Git operations triggered in step 4 will attempt to use the partially deleted repository, causing the Git configuration from the worktree to be used and executing arbitrary commands.
The following Git configuration was used to test command execution:
[core]
bare = false
worktree = "."
fsmonitor = "echo \"$(whoami) $(uname -a)\" > ../output/pwned.model.lkml"
Once git status is executed during repository deletion, the whoami and uname -a commands are executed, and the output is written to ../output/pwned.model.lkml, which is another repository the researcher could access normally.

Step 4: privilege escalation against other Looker instances
At this point the researcher asked the Google Cloud team for permission to investigate the vulnerability's impact further, and it was granted. Shortly after gaining a reverse shell on the Looker instance, the researcher noticed the instance was isolated in Kubernetes pods, limiting the impact on other Looker instances.
Inspecting the Kubernetes service account credentials mounted at /var/run/secrets/kubernetes.io/serviceaccount revealed excessive permissions:
{
"kind": "SelfSubjectAccessReview",
"apiVersion": "authorization.k8s.io/v1",
[...],
"spec": {
"resourceAttributes": {
"namespace": "looker",
"verb": "update",
"resource": "secrets"
}
},
"status": {
"allowed": true,
"reason": "RBAC: allowed by RoleBinding..."
}
}
The Looker service account had permission to update secrets in the looker namespace, which was shared across multiple Looker instances. Read permission for secrets was not granted, so existing secrets could not be read directly, making safe testing difficult: without read access there was no way to back up existing secrets before modification, so any update would be irreversible and could potentially break other Looker instances. That limitation prevented a full demonstration without risking production systems, so the finding was shared with the Google Cloud team for further investigation. After investigation, they confirmed it was possible to escalate privileges to access other instances in the same Kubernetes cluster by abusing this permission, and classified the vulnerability as S0.
Root cause
The mistake is in the directory deletion path. delete_dir joins the user-supplied dir_path_array into a single dir_name and passes it to validate_dir_name, which rejects any path array that includes .git. The check fails to catch the case where dir_name is /. When dir_path_array is ["/"], dir_name becomes /, the check does not match .git, and File.join(path, "/") resolves to the repository directory itself. The reserved-directory defence therefore protects the .git component but not the repository root.
The second half of the root cause is the deletion mechanism. FileUtils.rm_rf traverses in post-order and lists entries with readdir, whose order on ext4 is somewhat deterministic and can be influenced by naming. Because deletion of a large tree takes time, the .git directory can be removed first while the rest of the repository still exists, and concurrent Git operations then fall back to reading Git configuration from the worktree. The forged config with an fsmonitor hook is then honoured, giving command execution. The .git check did not stop this.
Impact
An attacker who can use the project file management features and the directory deletion API could execute arbitrary commands on the Looker server. In the researcher's test, 1 req/sec of Git-triggering requests was sufficient to hit the window. Instances were isolated in Kubernetes pods, which limited the impact on other Looker instances. However, the Looker service account's permission to update secrets in the shared looker namespace could allow privilege escalation to access other instances within the same Kubernetes cluster; Google confirmed this was possible and classified it as S0.
Fix
After the vulnerability was reported to Google, both the remote command execution vulnerability and the privilege escalation vulnerability were fixed. As of the time of publishing the article, both have been fixed by the Google Cloud team. The report does not describe the specific code changes made.
Variants to test
- Directory deletion endpoints that validate path components rather than the joined path: try a component that resolves to the base directory (for example
["/"]or equivalent) and observe whether the repository root is deleted. - Recursive delete implementations that traverse in post-order with
readdir: create a large tree and measure whether a sensitive directory (such as.git) is removed before the rest, which would open a race window. - Git integrations that fall back to the native CLI over SSH: place a forged
configwith anfsmonitorhook in the worktree and check whether Git operations honour it after the real.gitis removed. - Kubernetes service accounts mounted into application pods: inspect
/var/run/secrets/kubernetes.io/serviceaccountand run aSelfSubjectAccessReviewforupdateonsecretsin a shared namespace; a positive result is"allowed": true. - Concurrent Git operations during deletion: keep hitting endpoints that trigger
git statusat a low rate (1 req/sec was enough here) while a large directory is being deleted, and watch for command output appearing in a location the attacker can read.
What happened, in plain words
A security researcher found a way to run his own commands on a Google Cloud server, using nothing more than a feature that lets you delete a folder. The product involved is Looker, a tool that companies use to build dashboards and reports from their data. Looker can store its model files in Git repositories, and it lets users manage those files from a web page, including deleting folders.
The researcher discovered that the folder deletion feature did not check its input properly. By asking Looker to delete a folder called /, he could make it delete the whole repository folder, including the hidden .git folder that Git relies on. Deleting that folder normally would destroy the attack, because the trick depends on files the attacker placed in the repository. But deleting a folder with thousands of files takes time, and during that time Git commands still run against the half-deleted repository. If the .git folder disappears first, Git falls back to reading its settings from the attacker's files, and one of those settings can run a command. That is how the researcher got his commands executed on the server.
He then looked at how the server was set up. It ran inside Kubernetes, a system that keeps each application in its own isolated box (a pod). That isolation limited the damage. But the account the Looker application used inside Kubernetes had more permissions than it needed: it could update secrets in a namespace shared by several Looker instances. Google confirmed this could be used to reach other instances and classified it as S0. Both problems were fixed.
This article walks through the whole story from zero. You only need to know how to use a browser and a computer. Every technical word is explained the first time it appears, and there is a glossary at the end.
Background: what Looker is and how it stores files
Looker is a business intelligence and data analytics platform that is part of Google Cloud. In everyday terms, it is a website where a company's staff can explore, analyse and visualise their data through interactive dashboards and reports. It connects to various data sources, so users can build custom data models and run analytics on top of them.
Looker is deployed in two ways: cloud-hosted (Google runs it for you) and self-hosted (you run it on your own machines). The researcher obtained a self-hosted Looker instance through the Google Cloud VRP bugSWAT, a live hacking event organised by Google. At such an event, companies invite researchers to attack their systems in a controlled way, with permission, so problems can be found and fixed before criminals find them. He focused on reverse engineering that self-hosted instance. Reverse engineering means taking a program apart to understand how it works inside, rather than reading its source code.
Looker provides a feature to manage model files called LookML in Git repositories, which Looker calls projects. Two ideas need unpacking here.
- LookML is Looker's own file format for describing data models: which tables exist, how they relate, and what the dashboards should show.
- Git is a version control system. Think of it as a very careful filing cabinet that remembers every change ever made to a set of files, so you can see history and undo mistakes. A repository (often shortened to repo) is one such tracked folder.
Users can pull or push changes to Git repositories, and Looker applies the changes accordingly. Pull means fetching the latest version from a shared server; push means sending your changes there.
To integrate with external Git services, Looker typically uses the JGit library, a pure Java implementation of Git. A library is a bundle of ready-made code a program can call instead of writing everything itself. However, when the remote Git repository is configured over SSH, Looker uses the native Git command-line tool instead of JGit. SSH is a secure way for one computer to connect to another and run commands on it. The native Git command-line tool is the ordinary git program you would type into a terminal.
When it uses the native tool, Looker creates the checked-out repository under a specific directory on the Looker server and executes Git commands against that directory:
def self._cli_git_command(working_directory, command_words)
[...]
command_with_dir = "cd #{working_directory} && #{command}"
Looker::Log.log_block_latency(:git, "_cli_git_command: command: #{command_with_dir}") do
Open3.capture3(command_with_dir)
end
[...]
Line by line, in plain words:
def self._cli_git_command(working_directory, command_words)defines a function (a named block of code) that takes two inputs: the folder to work in, and the command to run.[...]marks code the report leaves out.command_with_dir = "cd #{working_directory} && #{command}"builds a text string.cdmeans change directory, so the string says: go into this folder, and then run this command. The#{...}parts are placeholders that get filled in with the actual values.Looker::Log.log_block_latency(...)wraps the next step in logging, so the time taken is recorded.Open3.capture3(command_with_dir)is the important line: it hands that string to the operating system to run as a shell command, and captures its output. A shell is the program that reads typed commands and runs them.
In addition to standard Git operations, Looker has a feature to manage files from the Web UI. Web UI means the web interface you see in a browser. Users can create, edit and delete files or directories from the Looker interface. A directory is just a folder.
The setup for the research
The work was carried out during the Google Cloud VRP bugSWAT event, against a self-hosted Looker instance the researcher was given for the event. The report does not list specific versions, accounts or roles beyond the ability to use the project file management features and the directory deletion API.
An API (application programming interface) is the set of web addresses a website offers so that programs, not just people clicking buttons, can ask it to do things. When you click delete in a web page, the page quietly sends a request to an API address behind the scenes. The relevant precondition for the attack is a project whose remote Git repository is configured over SSH, so that Looker falls back to the native Git command-line tool rather than JGit. In other words, the attack only works in the setup where Looker runs real git commands on its own server.
Finding the flaw: deleting a folder
When a user deletes a directory, Looker executes the following code:
post("/api/internal/projects/:project_id/delete_dir") do |_project_id|
[...]
dir_path_array = body["dir_path_array"]
@project.delete_dir(dir_path_array)
[...]
Line by line:
post("/api/internal/projects/:project_id/delete_dir")registers a handler for a web request.postis one of the standard request types a browser or program can send; it is normally used when you are submitting something to be changed. The address contains:project_id, a placeholder for which project you mean.dir_path_array = body["dir_path_array"]reads a value out of the request body. The request body is the data sent along with the request, like the contents of a form. Here it is expected to be a list (an array) of folder names.@project.delete_dir(dir_path_array)passes that list to the deletion function.
So a user can send a list of folder names to this address, and Looker will delete that folder. The next piece of code shows what happens inside:
def delete_dir(dir_path_array)
dir_name = dir_path_array.reject(&:empty?).join("/")
dir_name = validate_dir_name(dir_name)
dir_path = File.join(path, dir_name)
[...]
FileUtils.rm_rf(dir_path)
Line by line:
def delete_dir(dir_path_array)defines the deletion function, taking the list of folder names.dir_path_array.reject(&:empty?).join("/")throws away any empty entries in the list and glues the rest together with slashes. So["reports", "old"]becomesreports/old.dir_name = validate_dir_name(dir_name)runs a safety check on the result.dir_path = File.join(path, dir_name)sticks the checked name onto the base folder where the project lives, producing the full path to delete.FileUtils.rm_rf(dir_path)deletes it.rm_rfis a standard Ruby function that removes a folder and everything inside it, recursively. Ruby is the programming language Looker is partly written in.
The validate_dir_name method is meant to ensure that reserved directories cannot be tampered with:
def validate_dir_name(dir_name)
[...]
if path_array.include?(Looker::Model::Project::DOT_GIT)
raise(InvalidFileNameError.new("New path cannot include .git"))
else
nil
end
File.join(path_array.map do |s|
Looker::Utils.sanitize_file_or_dir_name(s)
HellToolJava
end)
end
Line by line:
def validate_dir_name(dir_name)defines the safety check.if path_array.include?(Looker::Model::Project::DOT_GIT)asks: does the list of path pieces contain the special name.git?raise(InvalidFileNameError.new("New path cannot include .git"))stops everything with an error if it does.else nilmeans do nothing otherwise.- The
File.join(...)block rebuilds a path from the pieces, cleaning each one withsanitize_file_or_dir_name.
The reasoning behind the check is that it is possible to trick Git into using forged Git configurations if the .git directory is corrupted or deleted, so validate_dir_name checks whether the directory to be deleted includes .git and raises an error if it does. Forged here means written by the attacker to look like something Git trusts.
Why does .git matter so much? Consider a repository with the following structure:
--- .git directory (Can't be controlled by the user) ---
.git/
HEAD
config
...
--- worktree (Controllable by the user) ---
HEAD
config
objects/
refs/
Two terms appear here. The .git directory is Git's own private storage inside a repository: it holds the history, the settings and the bookkeeping. The worktree is the visible set of files you actually edit. Normally the .git directory is off limits to users, while the worktree is fully under their control.
If the .git directory is deleted, the next Git command executed against this repository will fail to find the .git directory and will look for Git configurations in the worktree directory instead. Therefore, if the worktree contains files that resemble the contents of a .git directory, Git commands will use those configurations.

The diagram shows how Git recognises the worktree directory as the .git directory when the actual .git directory is deleted.
For instance, if the following configuration is placed as a config file in the worktree and the .git directory is deleted, the fsmonitor hook will be triggered and the whoami command will be executed when running git status or similar commands:
[core]
bare = false
worktree = "."
fsmonitor = "whoami"
Line by line:
[core]starts a section of Git settings called core.bare = falsesays this is a normal repository with a worktree, not a bare one (a bare repository has no visible files, only history).worktree = "."says the worktree is the current folder.fsmonitor = "whoami"is the dangerous line. A hook is a command Git runs automatically at a certain moment.fsmonitoris a setting that tells Git to run a helper program to watch for file changes. Here the helper iswhoami, a standard command that prints the name of the user the program is running as. So every time Git checks the repository status, it would runwhoami.
The validate_dir_name method properly checks whether the directory to be deleted includes .git:
def validate_dir_name(dir_name)
[...]
if path_array.include?(Looker::Model::Project::DOT_GIT)
raise(InvalidFileNameError.new("New path cannot include .git"))
else
nil
end
File.join(path_array.map do |s|
Looker::Utils.sanitize_file_or_dir_name(s)
HellToolJava
end)
end
This is the same check as before, shown again to make the next point clear. However, this check fails to catch the case where dir_name is /. After validate_dir_name returns, delete_dir constructs the full path to delete by joining the base path and dir_name:
def delete_dir(dir_path_array)
dir_name = dir_path_array.reject(&:empty?).join("/")
dir_name = validate_dir_name(dir_name)
dir_path = File.join(path, dir_name)
[...]
FileUtils.rm_rf(dir_path)
Again line by line, focusing on the flaw:
- The list is cleaned and joined into
dir_name. - The check looks at the pieces of the path for the word
.git. A single/is not.git, so it passes. File.join(path, dir_name)combines the base folder with/. The full path to delete becomes the repository directory itself.FileUtils.rm_rf(dir_path)then deletes the whole repository.
So specifying dir_path_array as ["/"] results in dir_name being /, and the full path to delete becomes the repository directory itself. This is a classic input validation mistake: the check inspects the list of pieces, but the value actually used afterwards is the joined string, and the two do not always agree.
Even so, deleting the entire repository directory would seem to defeat the attack, because the forged Git configuration files in the worktree would be gone too. The next section shows why that is not the case.
Exploitation
Step 1: understand the deletion primitive
A primitive in security means a small, reliable capability you have obtained, which you can then build bigger attacks on. Here the primitive is: delete any folder inside the project, including the repository root.
FileUtils.rm_rf is a Ruby standard library method that recursively deletes files and directories. Tracing through its internals reveals the following code:
def remove_entry(path, force = false)
Entry_.new(path).postorder_traverse do |ent|
begin
ent.remove
rescue
raise unless force
end
end
end
Line by line:
def remove_entry(path, force = false)defines a function to remove one entry, with an optional force flag.Entry_.new(path).postorder_traverse do |ent|walks through the folder tree. Post-order means it handles everything inside a folder before the folder itself, like emptying a box completely before throwing the box away.ent.removedeletes the current item.rescuecatches errors, andraise unless forcere-raises them unless force was set, meaning errors are ignored when force is on.
It uses Entry_.postorder_traverse to traverse the directory tree in post-order, processing all children of a directory before processing the directory itself. If Looker is tricked into deleting a directory in the repository that contains thousands of files and subdirectories, deleting all of them takes considerable time. If deletion of such a directory can be triggered after the .git directory is deleted but before the entire repository deletion is complete, there is still a chance to execute Git commands against the partially deleted repository.

The diagram shows the order of directory deletion.
This is a race condition: a situation where the outcome depends on exact timing, and an attacker who can influence the timing can slip something in between two events that were assumed to happen together.
Step 2: control the deletion order
Entry_.postorder_traverse internally uses the Dir.children method to list directory contents, which uses the readdir system call to read directory entries. A system call is a request from a program to the operating system, here asking it to list what is inside a folder. From dir.c line 952:
while ((dp = READDIR(dirp->dir, dirp->enc)) != NULL) {
const char *name = dp->d_name;
[...]
Line by line:
while ((dp = READDIR(dirp->dir, dirp->enc)) != NULL) {keeps asking the operating system for the next entry in the folder until there are none left.READDIRis the C name for the readdir call.const char *name = dp->d_name;takes the name of that entry.[...]marks omitted code.
The order of entries returned by readdir depends on the filesystem implementation and can vary, so there is no guarantee about the order in which files and directories are processed during deletion. A filesystem is the part of the operating system that organises how files are stored on disk. On ext4 filesystems, however, the entry order returned by readdir is somewhat deterministic, which lets an attacker influence the deletion order through careful directory naming. ext4 is a common filesystem on Linux servers. Deterministic means predictable: the same input tends to give the same order.
The researcher sprayed directory names as follows to determine which directory name would ensure the .git directory is processed first during deletion:
.git/
aaa/
aab/
dir1/
file1
file2
file3
...
dir2/
file1
file2
file3
...
...
dir10000/
...
aac/
...
ccb/
ccc/
What this shows: many folders with names chosen to sort in particular ways (aaa, aab, aac, and so on), and inside one of them a huge number of subfolders each holding many files. Spraying means creating lots of variations at once and seeing which one behaves as you want. By placing many files and directories under a specific directory and measuring the time until the repository becomes unavailable after triggering the deletion, the optimal directory name can be found to have the .git directory deleted first, creating a window to trigger Git operations against the partially deleted repository.
Step 3: execute arbitrary commands
With control over the timing of .git directory deletion, arbitrary commands can be executed on the Looker server. Arbitrary command execution means the attacker can run any program on the victim's machine, as the user the application runs as. The attack steps are:
- Create a Git repository with a worktree containing forged Git configurations to execute arbitrary commands using the
fsmonitorhook. - Create a directory with a random name containing many files and subdirectories, then attempt to delete the repository itself using the
POST /api/internal/projects/:project_id/delete_dirAPI. - Measure the time until the repository becomes unavailable. If the time is long, return to step 2 (this indicates the
.gitdirectory wasn't deleted first). - Once the optimal directory name is found, prepare the repository again and continuously hit endpoints that trigger Git operations (e.g.
git status). In the researcher's tests, 1 req/sec was sufficient. - Hit the
POST /api/internal/projects/:project_id/delete_dirAPI to delete the repository directory. This will delete the.gitdirectory first, but completing the deletion of the large directory takes time. - At this point, Git operations triggered in step 4 will attempt to use the partially deleted repository, causing the Git configuration from the worktree to be used and executing arbitrary commands.
Why each step: step 1 plants the trap. Step 2 tests whether the timing works out. Step 3 is the measurement that tells you whether .git went first. Step 4 keeps Git busy so that a command runs the moment the trap is exposed. Step 5 starts the slow deletion. Step 6 is the payoff. An endpoint is one specific web address the API offers. git status is the everyday Git command that reports what has changed in a repository, and it is the command that triggers the hook.
The following Git configuration was used to test command execution:
[core]
bare = false
worktree = "."
fsmonitor = "echo \"$(whoami) $(uname -a)\" > ../output/pwned.model.lkml"
Line by line:
[core]opens the core settings section.bare = falsemarks it as a normal repository.worktree = "."points the worktree at the current folder.fsmonitor = "echo \"$(whoami) $(uname -a)\" > ../output/pwned.model.lkml"is the payload.whoamiprints the current user name.uname -aprints details about the operating system and machine.$(...)runs a command and substitutes its output into the surrounding text.echoprints text.>redirects that printed text into a file. The file is../output/pwned.model.lkml, one folder up and intooutput. A payload is the part of an attack that actually does the damage.
Once git status is executed during repository deletion, the whoami and uname -a commands are executed, and the output is written to ../output/pwned.model.lkml, which is another repository the researcher could access normally.

The screenshot shows the Looker web interface displaying the result of the whoami and uname -a commands. Seeing your own command output come back is the proof that code ran on the server.
Step 4: privilege escalation against other Looker instances
At this point the researcher asked the Google Cloud team for permission to investigate the vulnerability's impact further, and it was granted. Shortly after gaining a reverse shell on the Looker instance, the researcher noticed the instance was isolated in Kubernetes pods, limiting the impact on other Looker instances.
A reverse shell is a connection from the victim machine back to the attacker, giving the attacker a command prompt on the victim. Kubernetes is a system for running many applications in containers, each in its own isolated unit called a pod. Think of pods as separate locked rooms in one building: breaking into one room does not automatically open the others.
Inspecting the Kubernetes service account credentials mounted at /var/run/secrets/kubernetes.io/serviceaccount revealed excessive permissions:
{
"kind": "SelfSubjectAccessReview",
"apiVersion": "authorization.k8s.io/v1",
[...],
"spec": {
"resourceAttributes": {
"namespace": "looker",
"verb": "update",
"resource": "secrets"
}
},
"status": {
"allowed": true,
"reason": "RBAC: allowed by RoleBinding..."
}
}
Line by line:
- A service account is an identity for a program rather than a person, like a badge issued to a robot. Credentials are the files that prove that identity, here mounted (made available) inside the pod at that path.
"kind": "SelfSubjectAccessReview"says this is a request asking Kubernetes: am I allowed to do something?"apiVersion": "authorization.k8s.io/v1"names the version of that Kubernetes feature."namespace": "looker"is the shared area, called a namespace, where the question applies. A namespace is a labelled section of a cluster used to group things."verb": "update"is the action being asked about."resource": "secrets"is the kind of object. A secret in Kubernetes is a stored piece of sensitive data such as a password or key."allowed": trueis the answer: yes, this account may update secrets."reason": "RBAC: allowed by RoleBinding..."explains why. RBAC stands for role-based access control: permissions are granted by assigning roles. A RoleBinding is the link that attaches a role to an account.
The Looker service account had permission to update secrets in the looker namespace, which was shared across multiple Looker instances. Read permission for secrets was not granted, so existing secrets could not be read directly, making safe testing difficult: without read access there was no way to back up existing secrets before modification, so any update would be irreversible and could potentially break other Looker instances. That limitation prevented a full demonstration without risking production systems, so the finding was shared with the Google Cloud team for further investigation. After investigation, they confirmed it was possible to escalate privileges to access other instances in the same Kubernetes cluster by abusing this permission, and classified the vulnerability as S0. Privilege escalation means using a small amount of access to gain more. S0 is the severity classification Google assigned to the privilege escalation issue.
Root cause
The mistake is in the directory deletion path. delete_dir joins the user-supplied dir_path_array into a single dir_name and passes it to validate_dir_name, which rejects any path array that includes .git. The check is written against the array of path components, but the value that is finally joined onto the base path is the string dir_name. When dir_path_array is ["/"], dir_name becomes /, the check does not match .git, and File.join(path, "/") resolves to the repository directory itself. The reserved-directory defence therefore protects the .git component but not the repository root.
The second half of the root cause is the deletion mechanism. FileUtils.rm_rf traverses in post-order and lists entries with readdir, whose order on ext4 is somewhat deterministic and can be influenced by naming. Because deletion of a large tree takes time, the .git directory can be removed first while the rest of the repository still exists, and concurrent Git operations then fall back to reading Git configuration from the worktree. The forged config with an fsmonitor hook is then honoured, giving command execution. The existing defence, the .git check, did not stop this because it only looked at the path components being deleted, not at the resulting path or at the timing of the recursive delete.
Impact
An attacker who can use the project file management features and the directory deletion API on a Looker instance with an SSH-configured Git remote could execute arbitrary commands on the Looker server. In the researcher's test, 1 req/sec of Git-triggering requests was sufficient to hit the window. Instances were isolated in Kubernetes pods, which limited the impact on other Looker instances. However, the Looker service account's permission to update secrets in the shared looker namespace could allow privilege escalation to access other instances within the same Kubernetes cluster; Google confirmed this was possible and classified it as S0. The report does not state a bounty amount or a CVSS score. CVSS is a standard scoring system for how severe a vulnerability is.
Fix
After the vulnerability was reported to Google, both the remote command execution vulnerability and the privilege escalation vulnerability were fixed. As of the time of publishing the article, both have been fixed by the Google Cloud team. The report does not describe the specific code changes made.
Variants to test
If you are testing similar systems, these are the angles worth trying, each explained in plain terms:
- Directory deletion endpoints that validate path components rather than the joined path: try a component that resolves to the base directory (for example
["/"]or equivalent) and observe whether the repository root is deleted. The lesson is to check the final value, not just the pieces. - Recursive delete implementations that traverse in post-order with
readdir: create a large tree and measure whether a sensitive directory (such as.git) is removed before the rest, which would open a race window. - Git integrations that fall back to the native CLI over SSH: place a forged
configwith anfsmonitorhook in the worktree and check whether Git operations honour it after the real.gitis removed. - Kubernetes service accounts mounted into application pods: inspect
/var/run/secrets/kubernetes.io/serviceaccountand run aSelfSubjectAccessReviewforupdateonsecretsin a shared namespace; a positive result is"allowed": true. - Concurrent Git operations during deletion: keep hitting endpoints that trigger
git statusat a low rate (1 req/sec was enough here) while a large directory is being deleted, and watch for command output appearing in a location the attacker can read.
Glossary
- API: the set of web addresses a service offers so programs can ask it to do things.
- Arbitrary command execution: the ability to run any program on someone else's machine.
- Array: an ordered list of values in programming.
- Credentials: files or data that prove an identity, such as a password or a token.
- CVSS: a standard scoring system for the severity of a vulnerability.
- Deterministic: predictable, giving the same result for the same input.
- Directory: a folder.
- Endpoint: one specific web address offered by an API.
- ext4: a common Linux filesystem.
- Filesystem: the part of an operating system that organises files on disk.
- Forged: written by an attacker to imitate something trusted.
- fsmonitor: a Git setting that names a helper program Git runs to watch for file changes.
- Git: a version control system that records every change to a set of files.
.gitdirectory: Git's private storage inside a repository, holding history and settings.- Hook: a command a program runs automatically at a certain moment.
- JGit: a pure Java implementation of Git used as a library.
- Kubernetes: a system for running applications in isolated containers called pods.
- Library: a bundle of ready-made code a program can call.
- Looker: a Google Cloud business intelligence and data analytics platform.
- LookML: Looker's file format for describing data models.
- Namespace: a labelled section of a Kubernetes cluster used to group objects.
- Native Git command-line tool: the ordinary
gitprogram run from a terminal. - Payload: the part of an attack that does the damage.
- Pod: an isolated unit in which Kubernetes runs an application.
- Post-order: processing all children of a folder before the folder itself.
- Primitive: a small, reliable capability used as a building block for an attack.
- Privilege escalation: using a small amount of access to gain more.
- Race condition: a flaw where the outcome depends on exact timing.
- RBAC: role-based access control, where permissions come from assigned roles.
- readdir: the system call that lists the entries in a folder.
- Repository: a folder tracked by Git, with its history.
- Reverse engineering: taking a program apart to understand how it works.
- Reverse shell: a connection from the victim machine back to the attacker giving a command prompt.
- RoleBinding: the Kubernetes link that attaches a role to an account.
- Ruby: a programming language, used in parts of Looker.
- S0: Google's most severe rating for a security issue.
- Secret: a stored piece of sensitive data such as a password or key.
- Service account: an identity for a program rather than a person.
- Shell: the program that reads typed commands and runs them.
- Spraying: creating many variations at once to see which one works.
- SSH: a secure way to connect to another computer and run commands on it.
- System call: a request from a program to the operating system.
- Web UI: the web interface you see in a browser.
- Worktree: the visible files of a repository that users edit.