Skip to content
Info disclosure Disclosed report Intermediate

Access the cache of protected branches from non-protected branches on Windows Gitlab Runner

GitLab blocks non-protected pipelines from reading protected-branch caches by rejecting fallback keys ending in '-protected', but a trailing dot bypasses this on Windows runners because Windows silently strips the dot from file and directory names. A developer on an unprotected branch could therefore read cached files belonging to a protected branch.

GitLab

Originally disclosed on GitLab

  • Fixed in 2 months
  • Disclosed after 2 months

⚠️ Please read the process on how to fix security issues before starting to work on the issue. Vulnerabilities must be fixed in a security mirror.

HackerOne report #3407875 by shells3c on 2025-11-01, assigned to @fvpotvin:

Report | How To Reproduce

HackerOne Analyst Summary

Summary of the issue

The researcher found when the project runner is hosted on a Windows machine, unauthorized Developer can modify .gitlab-ci.yml using cache key with trailing . in CACHE_FALLBACK_KEY variable in an unprotected branch, to disclose cached file content from a protected branch.

The researcher mentioned this finding is a bypass of previous fix in #2855623.

Steps to reproduce

  1. As the victim, sign in victim's GitLab account -> Create a private project -> Go to CI/CD Settings -> Expand Runners -> Disable Instance runners -> Click Create project runner -> Add a new project runner hosted on ==Windows== machine:
3407875-Step1-victim-add-win-runner.png
3407875-Step1-victim-add-win-runner.png From the original on GitLab
  1. As the victim, in project, add .gitlab-ci.yml file with following content in main branch:
YML
my-job:
  script:
    - echo "This is stored in the protected cache" > file.txt
  cache:
    key: "mycache"
    paths:
      - file.txt
3407875-Step2-victim-add-gitlab-ci-yml.png
3407875-Step2-victim-add-gitlab-ci-yml.png From the original on GitLab
  1. As the victim, wait for pipeline job finished, check job log. You can see cache created, as expected:
3407875-Step3-victim-view-cache-created.png
3407875-Step3-victim-view-cache-created.png From the original on GitLab
  1. As the victim, in Project members setting, add attacker as Developer:
3407875-Step4-victim-add-attacker.png
3407875-Step4-victim-add-attacker.png From the original on GitLab
  1. As the attacker, sign in attacker's GitLab account -> Go to victim's project -> Create a new branch -> Edit .gitlab-ci.yml with following content:
YML
variables:
  CACHE_FALLBACK_KEY: mycache-protected.

my-job:
  script:
    - cat file.txt
  cache:
    key: "random-string-to-trigger-fallback-key"
    paths:
      - file.txt
  1. As the attacker, check pipeline job. You can see the content of cached file.txt:
3407875-Step6-attacker-view-cached-file.png
3407875-Step6-attacker-view-cached-file.png From the original on GitLab

Impact statement

If the project runner is hosted on Windows machine, unauthorized "Developer" can disclose cached file from a projected branch.

If you have any questions or concerns about this report, feel free to assign it to H1 Triage via the action picker with a comment indicating your request.

Original Report

Summary

GitLab sanitizes the cache fallback key to disallow it ending with -protected, doing this to prevent non-protected pipelines from abusing the fallback key to access the cache of protected branches. However, it can be bypassed with -protected.. This works with Gitlab Runners that run on Windows OS because on Windows, files and directories aren't allowed to end with ., but an error isn't returned when you perform read/write operations on such files/directories, instead the . is stripped.

A simple test to check this behavior on Windows:

CMD
C:\Users\Me> echo hello > file.txt  
C:\Users\Me> type file.txt  
hello  
C:\Users\Me> type file.txt.  
hello  
Steps to reproduce
Setup
  1. Create a GitLab project.
  2. Install, register and run GitLab Runner on your Windows machine, by following the documentation. You can register the runner for the project you just created or for your entire instance. I registered it for my entire instance.
  3. If you registered for your project, make sure you have disabled instance runners for your project by visiting Settings > CI/CD > Runners and disable Turn on instance runners for this project. If you registered for your instance then make sure you don't have any other runner registered on your instance running, to make sure that the project will pick up this runner.
PoC
  1. Add this CI configuration to your project main branch:

.gitlab-ci.yml

YAML
my-job:    
  script:    
    - echo "This is stored in the protected cache" > file.txt  
  cache:    
    key: "mycache"  
    paths:  
      - file.txt  
  1. After the pipeline is finished, file.txt will be saved in a cache with the cache key mycache-protected. The -protected suffix was added to your cache key by Gitlab as a protection for the cache of protected branches.
  2. This step is not necessary, it just shows a real-life scenario: Invite the attacker as a developer to the project, note that he has no permission to merge or push to the main branch because it's a protected branch
  3. Create a new branch (non-protected), with the following CI configuration:

.gitlab-ci.yml

YAML
variables:    
  CACHE_FALLBACK_KEY: mycache-protected.

my-job:    
  script:    
    - cat file.txt  
  cache:    
    key: "random-string-to-trigger-fallback-key"  
    paths:  
      - file.txt  
  1. Wait until the job for that new branch finish, go to the job log and you will see This is stored in the protected cache in the log. This is the output of cat file.txt, which means the pipeline of this branch was able to fetch the cache of the main branch (protected)
Proposal fix

A simple fix might be improving sanitizeCacheKey in shells/abstract.go to sanitize ., however GitLab needs to consider the case where normal users want their CACHE_FALLBACK_KEY to ends with . as well.

Impact

Bypass https://gitlab.com/gitlab-org/gitlab/-/issues/409111 and https://gitlab.com/gitlab-org/gitlab/-/issues/506381: Malicious developers can read cache of protected branches which they don't have access to.

How To Reproduce

Please add reproducibility information to this section:

The original report as published on GitLab. Images and videos are our own copies; raw HTML is shown as text. View it on GitLab.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the cache key sanitiser only rejects keys ending in '-protected' and does not account for Windows stripping a trailing dot, so '-protected.' resolves to the same cache directory.

Impact

A developer without access to a protected branch could read cached files from that branch, but only when the project's runner runs on Windows.

What the attacker needed

Runner hosted on Windows; attacker is a project Developer; protected branch cache already populated

How it was found

  1. Set up a project with a Windows-hosted runner and a protected main branch whose job writes a file into the cache.
  2. Run the pipeline so the file is stored under the protected cache key.
  3. Add an attacker as a Developer who cannot push to the protected branch.
  4. On a new unprotected branch, set the fallback cache key to the protected key with a trailing dot and run a job that reads the file.
  5. Read the job log to see the contents of the protected branch's cached file.

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 report has not been written yet. The Original tab links to the source.

GitLab lets projects save files between pipeline runs in a cache, and caches for protected branches are meant to be off-limits to people who cannot push to those branches. The check that enforces this only looks at the exact ending of a name, and Windows quietly ignores a trailing dot in file names, so a name that looks different is treated as the protected one. The result is that a lower-privileged developer can read files they should not see.

What is Info disclosure?

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.

More from GitLab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.