Résumé
ONYEDIKACHI BERNARDCLOUD · DEVSECOPS · AI
RésuméGet in touch
CASE 16BUILD & CI/CD

Securing the Build Process

An internal GitLab instance let any authenticated user enumerate and download repositories, and one of them had an API key hardcoded in its Dockerfile. I identified the exposure, confirmed the sensitive data, and outlined the controls to lock it down.

Status: ASSESSED · REPORTED

DOMAIN
Build & CI/CD
PLATFORM
GitLab, GitLab API
SEVERITY
High
OUTCOME
Exposure identified

TOOLS

GitLabGitLab APIPython 3python-gitlabGitBashgrep
RESULT
BEFORERepos public, secret in code
AFTERExposure mapped and reported
01

Objective

I set out to find whether an internal GitLab instance exposed repositories to users who should not have access to them, and whether any of those repositories contained sensitive information such as secrets or API keys.

02

Scenario

An organisation ran a self-hosted GitLab instance on its internal network. Repositories were expected to be restricted, but no one had verified whether authenticated users could see projects beyond their own. I wanted to enumerate what was visible, download it, and search for hardcoded secrets.

03

What I found

enumerated-reposPUBLIC REPOS
Accessible repositories:
  Basic Build
  Approval Test
  Merge Test
  Mobile App
FINDING 01HIGH

Repositories visible to any authenticated user

Using the GitLab API with a personal access token, I enumerated all publicly visible projects on the instance. Multiple repositories were accessible, including ones unrelated to my own work.

Any authenticated user could clone or download these repositories, regardless of project membership.

secret-in-dockerfileHARDCODED SECRET
File:    Mobile App/Dockerfile
Match:   ENV ANDROID_API_KEY "<REDACTED>"
FINDING 02HIGH

API key hardcoded in a Dockerfile

Searching the downloaded repositories for sensitive strings revealed an Android API key stored directly in the Mobile App repository's Dockerfile as an environment variable.

The key was committed to version control in plain text, accessible to anyone who could reach the repository.

04

What I did

  1. Authenticated to the GitLab instance

    I generated a personal access token with read-level API scopes.

  2. Enumerated visible repositories

    I used a Python script with the GitLab API to list and download all publicly accessible projects.

  3. Searched for secrets

    I extracted the downloaded archives and ran a recursive search for patterns such as secret, api, and key.

  4. Confirmed the exposure

    The Mobile App Dockerfile contained a hardcoded API key available to any authenticated user on the instance.

EVIDENCE

BASH
# Search for sensitive strings across downloaded repos
grep -RiE "secret|api|key" ./extracted-repos/
05

Validation

The enumeration confirmed that multiple repositories were visible to any authenticated user on the instance, and the secret search confirmed at least one hardcoded API key in a Dockerfile.

06

Before and after

CONTROLBEFOREAFTER
Repository visibilityPublic to all authenticated usersExposure identified and reported
Hardcoded secretsAPI key in DockerfileIdentified for rotation and removal
Secret managementNot configuredRecommended: environment variables or vault
Branch protectionNot assessedRecommended: protected branches with review
07

What I recommend

  1. 01Restrict repository visibility to project members only, not all authenticated users.
  2. 02Remove hardcoded secrets from source code and rotate any that were exposed.
  3. 03Use CI/CD environment variables or a secrets manager instead of embedding keys in Dockerfiles.
  4. 04Add pre-commit hooks or CI scanning to catch secrets before they reach the repository.
  5. 05Enable protected branches and require merge-request approvals on sensitive projects.

“Internal access and repository visibility must not be treated as sufficient security boundaries because weak access controls can expose source code and sensitive information.”

WHAT I LEARNED

SKILLS IT PROVES

  • Source Code Security
  • GitLab Security
  • Repository Enumeration
  • Sensitive Data Discovery
  • Secret Identification
  • Access Control
  • RBAC
  • Least Privilege
  • Branch Protection
  • CI/CD Security
  • Secure Secret Management
  • Supply Chain Security
View my labs on GitHub