Finding A Pop Chain On A Common Symfony Bundle: Part 1
The article analyses the Symfony doctrine-bundle and its dependencies to find a PHP object injection (POP) chain, starting from the __destruct method of the CacheAdapter class. It shows how an attacker who can supply a serialised object could reach file write and arbitrary file include sinks, though the full working chain is deferred to part two.
Published on synacktiv.com
Written by Rémi Matasse - 12/09/2023 - in Pentest - Download
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
Likely the library relies on loosely typed, docblock-only property types, so an attacker-controlled serialised object can substitute arbitrary classes for the cache and deferred item properties and hijack the method calls made during destruction.
Impact
An attacker able to trigger unserialisation could reach a file write and an arbitrary file include, but the article notes the written file's extension cannot be controlled, limiting that path, and the full working chain is left to part two.
What the attacker needed
Ability to supply a serialised object; vulnerable app uses doctrine-bundle
How it was found
- Install the doctrine-bundle and its dependencies with composer.
- Grep the vendor directory for __destruct, __wakeup and __unserialize methods to find entrypoints.
- Filter out classes whose __wakeup throws an exception, leaving reachable __destruct methods.
- Follow the commit call from CacheAdapter's __destruct into the save and delete calls on the controlled cache property.
- Identify MockFileSessionStorage save as a file write sink and PhpArrayAdapter delete as an arbitrary include sink.
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.
When PHP stores an object as text and later turns it back into an object, it automatically runs certain built-in methods on that object. If an attacker can control the text, they can pick which classes those methods run on, and chain them so one class's method calls another's, eventually reaching something dangerous like writing or including a file. This article maps out such a chain step by step in a widely used library.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.