Exploiting Laravel based applications with leaked APP_KEYs and Queues
A leaked Laravel APP_KEY allows attackers to forge encrypted payloads that are deserialised by vulnerable code, and access to a Laravel queue (such as AWS SQS) allows injecting a malicious serialised command that is unserialised before its signature is checked, leading to remote code execution.
Published on mogwailabs.de
Laravel is a widespread open-source PHP web framework. It can be used to create complex web applications with relative ease and is used within many popular projects.
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
Laravel unserialises attacker-controlled data (either via a decrypt call that deserialises by default, or a queue command object) before verifying its integrity, enabling PHP object injection.
Impact
An attacker with a leaked APP_KEY or queue access could achieve remote code execution on the Laravel application.
What the attacker needed
Leaked APP_KEY or queue access; a vulnerable Laravel endpoint or queue
How it was found
- Obtain the APP_KEY, for example by reading the .env file through an arbitrary file read vulnerability.
- Create a malicious serialised PHP object using a known gadget chain.
- Encrypt the object with the leaked APP_KEY.
- Send the encrypted payload to a vulnerable endpoint that decrypts with deserialisation enabled.
- Alternatively, if queue access is available, replace the command object in a queue job with a malicious serialised object.
- Wait for the queue worker to process the job, which triggers the gadget chain.
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.
Laravel is a tool for building websites in PHP. It uses a secret key (APP_KEY) to protect things like cookies and queued tasks. If that key leaks, or if an attacker can write directly into the queue that holds tasks, the attacker can slip in a harmful object that the site later unpacks and runs, which can let them run commands on the server.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.