Skip to content
RCE Disclosed report Intermediate

[Twitter Open Source] Releases were & are built/executed/tested/released in the context of insecure/untrusted code

Several Twitter open-source projects resolve build dependencies over HTTP without integrity checks, allowing a man-in-the-middle to replace a downloaded JAR with malicious code. An attacker could then execute arbitrary code during builds or on production servers that use the compromised artifacts.

Jonathan Leitschuh Follow

Originally disclosed on HackerOne

Bounty$280 High 8.1 View original
  • Triaged in 9 days
  • Fixed in 7 months
  • Paid in 11 days
  • Disclosed after 9 months

Summary:

CWE-829: Inclusion of Functionality from Untrusted Control Sphere CWE-494: Download of Code Without Integrity Check

Twitter maintains several Open Source Projects under the Twitter GitHub organization. These projects contain build files that indicate that some of these projects are resolving dependencies over HTTP instead of HTTPS. This allows these artifacts to be potentially MITMed to maliciously compromise them and infect the build artifacts that are produced. Additionally, if any of these JARs or other dependencies were compromised, any developers or production servers using these could continue to be infected past updating to fix this.

Description:

This attack leverages the build infrastructure loading dependencies over HTTP without any other sort of integrity check to allow them to be maliciously compromised.

This isn't just theoretical

POC code has existed since 2014 to maliciously compromise a JAR file inflight. See:

MITM Attacks Increasingly Common

See:

Source Locations

Insecure Download

Scrooge

Tormentia

Scalding

Diffy

Bijection

Algebird

Hdfs-Du

Iago

Ambrose

BookKeeper
Elephant-Bird
JOAuth
Ect...

This list is not exaustive, I just wanted to come up with examples so the Twitter security team could get a general sense of what they are looking for.

Here are the GitHub queries I used to find these:

WARNING! If any of these builds are using a shared or reused ~/.gradle, ~/.m2 or whatever SBT uses as an artifact cache between builds and any of these downloads were maliciously compromised, the compromised jar may remain inside of cache directory and continue to be used in future builds.

Fix and Public Disclosure

At a minimum, all of these code locations where artifacts are downloaded from an untrusted source needs to be fixed. Previous releases should be rebuilt with the fix applied. The checksum of the released artifacts and artifacts built in a trusted environment should be made. If the checksums match, you can be certain that they weren't compromised.

If the checksums don't match, indicating a compromised artifact, CVE numbers need to be issued for the potentially malicious artifacts.

The ability to check if checksums match assume that these projects have reproducible builds.

Steps To Reproduce:

  1. Cone the Impacted Project
  2. Change this line in Dilettante so it is targeting the repository used in the build. https://github.com/mveytsman/dilettante/blob/master/dilettante.py#L143
  3. Start Dilettante on your local machine.
  4. Proxy the HTTP traffic for the build through Dilettante
  5. Execute the Build's tests.
  6. You should be greeted with the image of a cat.

Other Places to Look

Given how widely I'm finding this vulnerablity externally to Twitter, I'd advise that the Twitter Security team take some time to also analize their internal infrastructure for similar vulnerabilities.

This responsible disclosure follows Google's 90-day vulnerability disclosure policy (I'm not an employee of Google, I just like their policy).

Impact

By insecurely downloading code over an untrusted connection HTTP and executing the untrusted code inside of these JAR files as part of the unit/integration tests before a release opens these artifacts up to being maliciously compromised.

Remote code execution on a production server. Malicious compromise of build artifacts.

The original report as published on HackerOne, by jlleitschuh. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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

Build configuration files reference dependency repositories using HTTP instead of HTTPS and do not verify checksums, so downloaded artifacts can be tampered with in transit.

Impact

An attacker could achieve remote code execution on production servers and maliciously compromise build artifacts, and compromised JARs may persist in shared caches even after updates.

What the attacker needed

Attacker can intercept network traffic; build uses HTTP dependency resolution; no integrity checks on downloads

The fix

All insecure download locations should be changed to use HTTPS with integrity checks, previous releases should be rebuilt with the fix, and checksums should be compared to detect compromise.

How it was found

  1. Clone the impacted project.
  2. Modify the Dilettante tool to target the repository used in the build.
  3. Start Dilettante on your local machine.
  4. Proxy the build's HTTP traffic through Dilettante.
  5. Execute the build's tests.
  6. Observe the image of a cat, indicating successful compromise.

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 a project is built, it often downloads other pieces of software (dependencies) from the internet. If those downloads happen over an insecure connection (HTTP), someone on the network can secretly swap the real file for a malicious one. That malicious file then runs as part of the build or on servers, giving the attacker control.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More by Jonathan Leitschuh

View all

4 more disclosed reports, best first.

More from X / xAI

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.