IFrame can access mashlibs window causing XSS
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):
- open yourpod.solidcommunity.net
- login (required precondition for the exploit to work)
- create a file
test.htmlat any location (in a real exploit the attacker with append/write permissions would create this) - Write the html below into the file. Change the url with a private file
- Display the html with mashlib (click on the "d" symbol)
- 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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