Discourse · Report #213558
Arbitrary Local-File Read from Admin - Restore From Backup due to Symlinks
Validstatus
highseverity
$512bounty
52upvotes
13 May 2017disclosed
How it was found
As an Admin user on Discourse there is a feature to create, upload, and restore backups. Generating a backup creates a tar file consisting of the database as a SQL file and uploaded files from /public/upload/*. Having the ability to upload these tar files and restore from them, you can add any file that you wish.
Manually modifying the tar archive and adding a symlink, you are able to read any arbitrary file that the user has permission to including files outside of the Discourse application directory.
Steps
- Load http://try.discourse.org
- Login as an Admin user.
- Go to the Backups page:
- Create a new backup including files.
- Extract the backup files to a folder on your server.
- Create a symlink to
/etc/passwdIn the /uploads/ folder of the backup, e.g./uploads/default/original/1X/[file].jpg.
- example:
ln -s /etc/passwd /home/symlink/files/uploads/default/original/1X/7ad2e8f5fe02890f20503044b604e29e6f3718fd.png
- Create a .tar.gz from the extracted files.
- Upload the newly crafted tar to the server.
- Enable
Restore from Backupsin settings if it's not enabled. - Restore from the backup that uploaded.
- Go to the uploaded file in your browser after it uploads, e.g.
- ---> You were able to read file contents of
/etc/passwddue to the symlink being extracted from the tar.