Skip to content

Fix issue 91 - #106

Closed
mmndaniel wants to merge 4 commits into
LavaMoat:mainfrom
mmndaniel:fix-issue-91
Closed

mmndaniel wants to merge 4 commits into
LavaMoat:mainfrom
mmndaniel:fix-issue-91

Conversation

@mmndaniel

Copy link
Copy Markdown
Contributor

An attempt to fix 91, using approach c which I mentioned here...

@weizman

weizman commented Jun 21, 2023

Copy link
Copy Markdown
Member

Thanks for the PR @mmndaniel ! Highly appreciated 🙏

I'm not sure what the intent here is, but I'm pretty sure something is missing.

According to MDN, the API expects a node rather than a string. Also, the variable you use inside the try-catch block does not exist.

Without the try-catch you'd see this solution doesn't work currently, do you mind explaining again the logic you had in your mind behind this attempt please?

@mmndaniel

Copy link
Copy Markdown
Contributor Author

Ah shit, sorry, was coding in a rush! Anyway, the idea is to use XMLSerializer to normalize the HTML and prevent namespace confusion (that leads to the mXSS bug). See section 5.2 here.

@weizman weizman mentioned this pull request Jun 21, 2023
@weizman

weizman commented Jun 21, 2023

Copy link
Copy Markdown
Member

yo @mmndaniel check out #108

@mmndaniel

Copy link
Copy Markdown
Contributor Author

from the paper linked above:

attacks can be upgraded
to allow recursive mutation – making double-, triple- and
further multiply-encoded escapes and entities useful in the
attack scenario, immediately when multiple innerHTMLaccess to the same element takes place.

So I'm afraid single innerHTML assignment isn't enough (I will try to implement this type of attack soon). It MIGHT be possible to re-assign until two consecutive assignments result the same childNodes.length, but this approach a. have performance drawbacks and b. possibly vulnerable, if an attacker could craft a payload that mutates only after 3 consecutive assignments (not sure if that's possible, but the with complexity of (X/Math/HT)ML and SVG ser/de, who knows).

@weizman

weizman commented Jun 21, 2023

Copy link
Copy Markdown
Member

Here's another idea.
Unlike DOMPurify and other projects, in Snow we allow ourselves to disallow certain states if (a) they are highly uncommon in legitimate usage and (b) are dangerous to Snow.

So how about dropping innerHTML set attempts that specifically make use of these special problematic tags? For example, if the html contains a mglyph and/or mtext tags, just block the whole innerHTML set attempt entirely?

Just thinking out loud here, would that be effective?

@mmndaniel

Copy link
Copy Markdown
Contributor Author

I don't think it's the way forward because it's possible to implement mutation attack without any "special" tags, just svg, style, etc are enough. See this PR, I suspect that's the right approach to address it.

@weizman

weizman commented Jul 17, 2023

Copy link
Copy Markdown
Member

ending up with #123

@weizman weizman closed this Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bypass using mXSS

2 participants