Remote Code Execution Found in CocoaPods
The CocoaPods server passed user-controlled package source fields to a git command without sanitisation, allowing an attacker to inject shell commands. An attacker could execute arbitrary code on the server and poison any package download.
justi.cz
Published on justi.cz
tl;dr CocoaPods is a popular package manager used by lots of iOS apps (among other Swift and Objective-C Cocoa applications). I found a remote code execution bug in the central CocoaPods server holding keys for the Specs repo (https://trunk.cocoapods.org/).
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 write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The server passed user-controlled values directly as arguments to a git command, and one of those arguments could be abused to execute shell commands.
What the attacker needed
An authentication token for the CocoaPods API
The fix
The bug was fixed by the CocoaPods maintainers.
How it was found
- Upload a package spec with a crafted git source field that includes a git flag which evaluates a shell command.
- The server runs git ls-remote with the attacker's flag, causing the command to execute on the server.
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 write-up has not been written yet. The Original tab links to the source.
CocoaPods is a tool that helps developers download and manage code libraries for iOS apps. The server that stores these libraries ran a command using untrusted input from the package uploader, so an attacker could sneak in extra commands that the server would run. This let the attacker take control of the server and tamper with the libraries that other people download.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.