Skip to content
Advisory Advanced CVE-2024-42370

GHSL-2024-177: Environment Variable injection in an Actions workflow of Litestar - CVE-2024-42370

The docs-preview workflow read an unvalidated .pr_number file from an artifact into GITHUB_ENV, allowing newline injection of environment variables such as LD_PRELOAD. An attacker could then execute arbitrary code when a later step ran node, exposing the DOCS_PREVIEW_DEPLOY_TOKEN secret and granting write permissions to issues and pull requests.

Alvaro Muñoz Follow

Originally disclosed on GitHub Security Lab

Litestar docs-preview.yml workflow is vulnerable to Environment Variable injection which may lead to secret exfiltration and repository manipulation.

pwntester, on GitHub Security Lab

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

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 workflow wrote the contents of an untrusted artifact file directly into $GITHUB_ENV without validating or sanitising newlines, allowing environment variable injection.

Impact

The attacker could execute arbitrary code, expose the DOCS_PREVIEW_DEPLOY_TOKEN secret, and gain write permissions to issues and pull requests.

What the attacker needed

Ability to create a pull request; attacker-controlled server for payload

How it was found

  1. Clone the repository and edit the ci.yml workflow to create a payload directory containing a malicious .pr_number file and a shared library.
  2. Upload the payload directory as an artifact named docs-preview using actions/upload-artifact.
  3. Create a pull request with the modified workflow, which triggers the Tests And Linting workflow.
  4. When that workflow completes, the docs-preview workflow downloads the artifact and reads .pr_number into GITHUB_ENV, injecting LD_PRELOAD.
  5. A later step runs node, causing the malicious shared library to execute and expose the secret token.

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.

A GitHub Actions workflow is an automated script that runs on GitHub's servers. It can read files produced by earlier runs, called artifacts. Here, the workflow trusted a file from an artifact and copied its contents into environment variables without checking for extra lines. By adding a line that sets a special variable, an attacker could make the system load their own code and steal a secret token.

More by Alvaro Muñoz

View all

132 more disclosed reports, best first.

More from GitHub Security Lab

View all

The newest disclosed reports for this program.

Similar reports

Same bug class and techniques, clearest first.