Skip to content
Path traversal Disclosed report Intermediate

Arbitrary Local-File Read from Admin - Restore From Backup due to Symlinks

An admin could upload a crafted backup archive containing a symbolic link, and after restoring it, read any file the application user could access, including files outside the application directory. This allowed reading local files such as the system password file.

ziot Follow

Originally disclosed on HackerOne

Bounty$512 High View original
  • Fixed in under an hour
  • Paid in under an hour
  • Disclosed after 60 days

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

  1. Load http://try.discourse.org
  2. Login as an Admin user.
  3. Go to the Backups page:
  1. Create a new backup including files.
  2. Extract the backup files to a folder on your server.
  3. Create a symlink to /etc/passwd In 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
  1. Create a .tar.gz from the extracted files.
  2. Upload the newly crafted tar to the server.
  3. Enable Restore from Backups in settings if it's not enabled.
  4. Restore from the backup that uploaded.
  5. Go to the uploaded file in your browser after it uploads, e.g.
  1. ---> You were able to read file contents of /etc/passwd due to the symlink being extracted from the tar.

Attachments

symlink.png
symlink.png From the original on HackerOne

The original report as published on HackerOne, by ziot. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the backup restore process extracted symbolic links from the uploaded archive without validating or blocking them, allowing the link to point outside the intended upload directory.

What the attacker needed

Admin account; backup restore feature enabled

How it was found

  1. Log in as an admin user and go to the backups page.
  2. Create a new backup that includes files.
  3. Extract the backup files to a folder on your server.
  4. Create a symbolic link to a sensitive file inside the uploads folder of the backup.
  5. Repackage the extracted files into a tar archive and upload it.
  6. Enable restore from backups if needed, restore the uploaded backup, then visit the uploaded file's URL to read the linked file.

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 report has not been written yet. The Original tab links to the source.

A backup is a packaged copy of a website's data. The site let an administrator upload a backup to restore it, but it did not check for special shortcut files called symbolic links inside the package. Those shortcuts can point to sensitive files on the server, so the site ended up serving those files to the browser.

What is Path traversal?

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.

More by ziot

View all

6 more disclosed reports, best first.

More from Discourse

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Path traversal and file inclusion

The lesson behind this report.

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.