-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix namespace switching bugs, release 3.1.2 #142
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
notriddle
changed the title
Fix namespace switching bugs
Fix namespace switching bugs, release 3.1.2
Jul 8, 2021
Reported as security vulnerability via private email.
I can take a better look in an hour or two, but I didn't see anything obviously wrong. |
Thanks. I'm also filing a RUSTSEC advisory. |
notriddle
added a commit
to notriddle/advisory-db
that referenced
this pull request
Jul 8, 2021
Shnatsel
pushed a commit
to rustsec/advisory-db
that referenced
this pull request
Jul 8, 2021
* Add rust-ammonia/ammonia#142 * Update RUSTSEC-0000-0000.md * Update RUSTSEC-0000-0000.md
lnicola
reviewed
Jul 8, 2021
lnicola
approved these changes
Jul 8, 2021
Awesome. Let's go! |
bora r+ |
@bors r+ ? |
bors ping |
pong |
bors r+ |
Oops. |
Build succeeded: |
And both releases are now published! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reported as security vulnerability via private email.
The issue happens if developers added to the list of allowed tags any
tag which is parsed in RCDATA state, PLAINTEXT state or RCDATA state,
that is:
An example in the wild is Plume, that allows iframe. So in next
examples I'll assume the following policy:
In HTML namespace
<iframe>
is parsed specially; that is, its content istreated as text. For instance, the following html:
Is parsed into the following DOM tree:
So iframe cannot have any children other than a text node.
The same is not true, though, in "foreign content"; that is, within
<svg>
or<math>
tags. The following html:is parsed differently:
So in SVG namespace iframe can have children.
Ammonia disallows but it keeps its content after deleting it. And
the parser internally keeps track of the namespace of the element. So
assume we have the following snippet:
It is parsed into:
This DOM tree is harmless from ammonia point of view because the piece
of code that looks like XSS is in a title attribute. Hence, the
resulting "safe" HTML from ammonia would be:
However, at this point, the information about namespace is lost, which
means that the browser will parse this snippet into:
Leading to XSS.
To solve this issue, check for unexpected namespace switches after cleanup.
Elements which change namespace at an unexpected point are removed.
This function returns
true
ifchild
should be kept, andfalse
if itshould be removed.