Skip to content
DoS Disclosed report Intermediate

DoS - Debian Packages - dpkg-deb leaves temporary files (feature flag)

The Debian Packages API uses dpkg-deb to extract package metadata, but if the package contains a non-writable directory, dpkg-deb cannot delete the extracted files, leaving them in /tmp. An attacker could upload a large package to gradually exhaust disk space, causing a denial of service.

GitLab

Originally disclosed on GitLab

  • Fixed in 2.2 years
  • Disclosed after 2.2 years

⚠️ 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 #1970716 by zhutyra on 2023-05-03, assigned to @nmalcolm:

Report | Attachments | How To Reproduce

Report

The vulnerability is in the Debian Packages API which is gated behind a feature flag that's disabled by default.

When uploading a Debian package, information about this package is obtained using the dpkg-deb --field command.

A Debian package is an ar archive containing two tar archives. dpkg-deb must unpack these archives to get the required information.

If the archive contains a non-writable directory, then dpkg-deb cannot delete the extracted files at the end.

This can gradually exhaust the free disk space. Attached is a package containing two 5GB files.

Possible workaround

dpkg-deb extracts the data to the directory specified in the TMPDIR environment variable, so you can set it yourself and then delete the directory afterwards.

Steps to reproduce

Quick test

  • Download the attached package dangling.deb
  • Run the following command (on Debian system):
    Bash
    dpkg-deb --field dangling.deb  
    ## output:  
    ## dpkg-deb: 'dangling.deb' contains no control component 'control'  
    ## dpkg-deb: error: 1 requested control component is missing  
    ## rm: cannot remove '/tmp/dpkg-deb.1wy1zI/dir/file1': Permission denied  
    ## rm: cannot remove '/tmp/dpkg-deb.1wy1zI/dir/file2': Permission denied  
    ## dpkg-deb: error while cleaning up:  
    ## rm command for cleanup subprocess returned error exit status 1  
    

Full test on your GitLab instance

  • Enable Debian Packages in your GitLab instance (Debian Linux)

    • On the server run gitlab-rails console and enter following commands:
      Ruby
      Feature.enable(:debian_packages)  
      Feature.enable(:debian_group_packages)  # i'm not sure if this one is needed  
      
  • Log in to your GitLab instance and go to any project page:

    • Save the Project ID number for later use
  • Generate your personal token:

    • In the upper-right corner, select your avatar.
    • Select Edit profile.
    • On the left sidebar, select Access Tokens.
    • Enter a name and optional expiry date for the token.
    • Select the desired scopes.
      • read_repository and write_repository
      • or just all :)
    • Select Create personal access token.
    • Save the token for later use
  • Download the attached package dangling.deb

  • In the directory with the package, run the following commands in a bash shell (change the marked values):

    Bash
    GLHOST=http://yourinstance.com  # change  
    GLUSER=username                 # change  
    GLPTOKEN=personal-token         # change  
    GLPROJID=project-id             # change  
    GLDISTRO=dist01  
    GLDEB=dangling.deb
    
    curl --request POST \  
         --header "PRIVATE-TOKEN: $GLPTOKEN" \  
         "$GLHOST/api/v4/projects/$GLPROJID/debian_distributions?codename=$GLDISTRO"  
    ## output: {"id":...}
    
    curl --request PUT \  
         --user "$GLUSER:$GLPTOKEN" \  
         --upload-file $GLDEB \  
         "$GLHOST/api/v4/projects/$GLPROJID/packages/debian/$GLDEB?component=main&distribution=$GLDISTRO"  
    ## output: {"message":"201 Created"}  
    
  • On the server check the /tmp/dpkg-deb... directory

    • Extrated files should still be there (two 5GB files)
  • Wait

  • Visit yourgitlabserver.com and see a 500 error

Impact

Denial of service due to running out of disk/temp space.

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

Likely, dpkg-deb fails to clean up extracted files when the package contains a non-writable directory, leaving them in the temporary directory.

Impact

An attacker could cause a denial of service by exhausting disk space, but the vulnerable feature is behind a feature flag that is disabled by default.

What the attacker needed

Debian Packages feature flag enabled; Valid personal access token with write scope; Ability to upload a Debian package

How it was found

  1. Enable the Debian Packages feature flag on the GitLab instance.
  2. Log in and obtain a personal access token with repository write scope.
  3. Create a Debian distribution using the API.
  4. Upload the crafted Debian package to the Debian package endpoint.
  5. Check that the extracted files remain in /tmp/dpkg-deb...
  6. Wait until the disk fills and the GitLab instance returns a 500 error.

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.

When you upload a Debian package, the system uses a tool called dpkg-deb to read information from it. This tool unpacks the package into a temporary folder and then tries to delete the files. If the package contains a folder that cannot be written to, the deletion fails and the files stay on disk. By uploading a very large package, an attacker can fill up the disk and make the service unavailable.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More from GitLab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.