View My Albums
Category: Web
Description
My RateYourMusic competitor will take off any day now. I just need to add rating... and CSS... and images... and a bunch of other things
Attachments: view-my-albums-dist.zip
Write-up
- Upon accessing the provided URL, we encountered a straightforward web application that allows users to view album details.

- Our attention was drawn to the
prefscookie, which contained serialized user preferences. - Upon analyzing the codebase, our initial approach involved attempting to exploit a Local File Inclusion (LFI) vulnerability. The line
<h1><?php include("greetings/$prefs->language"); ?></h1>inindex.phppiqued our interest. - This could be achieved by manipulating the
languageattribute within the serialized userprefs. - However, our attempts were thwarted by the following check right after
prefsdeserialization: - This check could be bypassed using type juggling, but we were only able to fix the language value as
true, not an arbitrary value. - After investing a considerable amount of time in exploring this potential vulnerability, we decided to explore other attack vectors.
- In the
Albums.phpfile, we discovered that theAlbumsclass implemented the__debugInfo()magic method. This meant that when we usedvar_dump()on anAlbumsobject, we could access all the records in itsstore. - Within the codebase, three types of stores were implemented:
MysqlRecordStore,JsonRecordStore, andCsvRecordStore. TheMysqlRecordStorecan retrieve all records from the specified database, while theJsonRecordStoreandCsvRecordStorecan retrieve records from the specified file. - Therefore, we crafted a serialized cookie that contained an instance of the
Albumsclass initialized with aCsvRecordStorethat read the contents ofdb_creds.php. - Since
prefswas an instance ofAlbumsand notUserPrefs, the following code block would execute when accessingindex.php: - This logic would result in a
var_dump()of our maliciousAlbums(CsvRecordStore)object, leaking the contents ofdb_creds.php.

- With the leaked
db_creds.php, we could then provide a maliciousAlbum(MysqlRecordStore)object, whereMysqlRecordStorewas initialized with the leaked database credentials and theflagtable. - The subsequent
var_dump()would reveal the entire contents of theflagtable, exposing the flag.

- The PHP script to generate both payloads can be found here.
Flag: grey{l4_mu5iCA_DE_haIry_FroG}