SolidOS / SolidOS/solid-panes

IFrame can access mashlibs window causing XSS

Open
#372 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
106
Forks
52
Avg merge
13h 35m
Merged PRs (30d)
10

Description

Summary

When a user opens a html file with mashlib, this file can access the window of mashlib and thus among other things the authenticated fetch at UI.authn.session.fetch.

Reproducing

Steps to reproduce (on NSS):

  1. open yourpod.solidcommunity.net
  2. login (required precondition for the exploit to work)
  3. create a file test.html at any location (in a real exploit the attacker with append/write permissions would create this)
  4. Write the html below into the file. Change the url with a private file
  5. Display the html with mashlib (click on the "d" symbol)
  6. Observe one alert with your webid and one with the file contents
<script>
  const main = async () => {
    mashlibWindow = window.parent;
    alert('Logged in as ' + await mashlibWindow.UI.authn.checkUser())
    res = await mashlibWindow.UI.authn.session.fetch('https://yourpod.solidcommunity.net/private/secret.txt')
    alert('Secret: ' + await res.text())
  }
  main()
</script>

For CSS, the steps are similar, however I think the test.html file would need to be publicly readable to be loaded in the iframe. In NSS this is not necessary because it also uses cookies.

Impact

Opening a malicious html file can result in the attacker gaining control over the whole pod.

Fix

Use an iframe with the sandbox attribute which may not include allow-same-origin. See for instance this article on sandboxing: https://web.dev/sandboxed-iframes/

This would also be fixed, if pods don't serve or sandbox html files (see https://forum.solidproject.org/t/is-it-secure-for-pods-to-serve-html-files/6379/2)
EDIT: after looking at the code, I don't think it matters if pods sandbox the html, as they are not directly included with <iframe src=".../test.html"> but fetched manually and then added as a blob.
EDIT 2: it's more complicated than I thought, SolidOS has 3 different ways of creating iframes. See here for a small discussion)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the exploit on NSS, then trace SolidOS's three iframe-creation paths referenced in the issue. The work is done when an HTML file displayed by mashlib cannot access the parent mashlib window or authenticated fetch session.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.