Skip to content
Path traversal Disclosed report Advanced

Bypass of GitLab CI runner slash fix in YAML validation!

The runner's cache key validation could be bypassed by injecting a directory traversal through a CI variable, constructing a malicious cache URL that might bypass access to other projects' caches.

GitLab

Originally disclosed on GitLab

  • Fixed in 15 months
  • Disclosed after 15 months

HackerOne report #537537 by bull on 2019-04-13, assigned to estrike:

Hi,

I have found that after #301432 and #409395 , i can still inject malicious directory traversal in the cache key.

Issue:

directory traversal can still be injected into cache key by using gitlab api to inject in variables.

Screenshot_2019-04-13_at_11.30.29_PM.png
Screenshot_2019-04-13_at_11.30.29_PM.png From the original on GitLab

which is forbidden in web UI and according to your documentation.

However, now there is in place an additional check at the before making request to cache server, if the project is same as the build of project in docker.
So, it doesn't request url if the project id is not of that project.

Screenshot_2019-04-13_at_11.38.42_PM.png
Screenshot_2019-04-13_at_11.38.42_PM.png From the original on GitLab

I thought you might want to fix the injection as someone might find a bypass, as i found some perks.

Double variable manipulation:

i found that double variable manipulation can still be used to make malicious url,

when variable l is set to ../1/cache

and we inject into key:

a:  
  script:  
  - ls -lashR  
  cache:  
    key: "$$l"  
    policy: pull  
    paths:  
      - .  

this gets converted into $l and injected as $l
however this give 403 when the url is request which might be because
Url is signed for
/gitlab-com-runners-cache/project/10982096/$l?signature=nstuff.....
but at the time of requesting
this variable is manipulated:
/gitlab-com-runners-cache/project/1/cache?signature=nstuff....not for after manipulation

while pulling:

Screenshot_2019-04-13_at_11.45.11_PM.png
Screenshot_2019-04-13_at_11.45.11_PM.png From the original on GitLab

while pushing :

Screenshot_2019-04-13_at_11.46.12_PM.png
Screenshot_2019-04-13_at_11.46.12_PM.png From the original on GitLab

if you would like to fix the injection, in the meantime i will let you if i could take it any further.
Thanks
bull

Impact

directory traversal injection might bypass access to cache of other projects

Attachments

Warning: Attachments received through HackerOne, please exercise caution!

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 was validated before variable expansion, so a variable containing a traversal sequence was substituted afterwards and the resulting path was not re-checked.

Impact

Directory traversal injection might bypass access to the cache of other projects, although the attempt described returned a 403 because the URL signature did not match the manipulated path.

What the attacker needed

Ability to create or edit a CI job; ability to set CI variables

How it was found

  1. Set a CI variable named l to a directory traversal value.
  2. Configure a job with a cache key that references that variable.
  3. Run the job so the runner builds a cache URL containing the traversal.
  4. Observe that the request is rejected with 403 because the signature does not match the manipulated URL.

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 CI lets projects store files in a cache to speed up later jobs. The cache key is used to build a storage path, and the runner tried to block keys containing '../' to stop one project reaching another's cache. The researcher found that by setting a CI variable to a traversal string and referencing it in the cache key, the check could be bypassed and a path pointing at another project's cache could be built.

What is Path traversal?

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.

More from GitLab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Path traversal and file inclusion

The lesson behind this report.

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.