8000 Tests: Add tests for recently fixed manipulation XSS issues by mgol · Pull Request #4685 · jquery/jquery · GitHub
[go: up one dir, main page]

Skip to content

Tests: Add tests for recently fixed manipulation XSS issues #4685

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

Merged
merged 1 commit into from
Apr 29, 2020

Conversation

mgol
Copy link
Member
@mgol mgol commented Apr 23, 2020

Summary

Add tests for recently fixed manipulation XSS issues.
Ref gh-4642
Ref gh-4647

Checklist

@mgol mgol added Needs review Tests Discuss in Meeting Reserved for Issues and PRs that anyone would like to discuss in the weekly meeting. labels Apr 23, 2020
@mgol mgol added this to the 3.5.1 milestone Apr 23, 2020
@mgol mgol self-assigned this Apr 23, 2020
assert.ok( window.xss.withArgs( currCounter ).notCalled,
"Insecure code wasn't executed, input: " + htmlString );
done();
}, 1000 );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to reduce this forced one-second frequency... what would you think about something like so?

div.appendTo( container );
div.html( htmlString );
container.append("<img src=x onerror=\"xssDone(counter)\">")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try that, thanks!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gibson042 Now that I think about it... How do we know this onerror callback will be fired as the last one? 404 responses may not be cached AFAIK so there's a risk that one will fire before the other ones are done.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, src="#" would guarantee that the invalid source is cached.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That will resolve to the current page, though, so it won't be a 404.

Also, currently all the tests succeed even if cache is disabled in the browser DevTools. I'd like to keep that working.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gibson042 I'm thinking about ways to reduce this delay but if I don't find anything reliable that'd work with cache disabled, I think I'll just merge it, we can always apply improvements later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need a 404, just need a response that isn't a successful image. And I don't see any cache concerns, but if you want to merge without the acceleration then I won't object.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point about not needing 404s. I tested your suggestion, though, and - if I understood it correctly - it looks like I was right about race conditions. See the code at:
mgol@7cd593f
I reverted the two security fixes locally & all assertions should fail but it's pretty random for me; on each refresh different ones are failing for me. I tried the esmodules tests.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An example test run below, I only run this single test. Note that the order of reported assertions is also pretty random.
Screen Shot 2020-04-28 at 23 46 05

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, raciness confirmed. I don't think that's fatal to the testing, but it would require restructuring. No worries.

@mgol mgol force-pushed the manip-security-tests branch from ccadbc6 to 40cd040 Compare April 27, 2020 21:26
@timmywil timmywil removed the Discuss in Meeting Reserved for Issues and PRs that anyone would like to discuss in the weekly meeting. label Apr 28, 2020
@mgol mgol force-pushed the manip-security-tests branch from 40cd040 to f9983f1 Compare April 28, 2020 21:50
@mgol mgol force-pushed the manip-security-tests branch from f9983f1 to 75429b4 Compare April 29, 2020 14:33
@mgol mgol merged commit dc06d68 into jquery:master Apr 29, 2020
@mgol mgol deleted the manip-security-tests branch April 29, 2020 14:39
@mgol mgol removed the Needs review label Apr 29, 2020
mgol added a commit that referenced this pull request Apr 29, 2020
mgol added a commit to mgol/jquery that referenced this pull request Apr 29, 2020
iOS 8-12 parses `<noembed>` tags differently, executing this code. This is no
different to native behavior on that OS, though, so just accept it.

Ref jquerygh-4685
@mgol
Copy link
Member Author
mgol commented Apr 29, 2020

Looks like one of the added tests fails in iOS 8 - 12. A followup fix PR, PTAL: #4694.

mgol added a commit that referenced this pull request Apr 30, 2020
iOS 8-12 parses `<noembed>` tags differently, executing this code. This is no
different to native behavior on that OS, though, so just accept it.

Ref gh-4685
Closes gh-4694
mgol added a commit that referenced this pull request Apr 30, 2020
iOS 8-12 parses `<noembed>` tags differently, executing this code. This is no
different to native behavior on that OS, though, so just accept it.

Ref gh-4685
Closes gh-4694

(cherry picked from commit 11066a9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

3 participants
0