Skip to content
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

Default protection against target=_blank vulnerability #49

Open
kamsar opened this issue Aug 29, 2016 · 1 comment
Open

Default protection against target=_blank vulnerability #49

kamsar opened this issue Aug 29, 2016 · 1 comment

Comments

@kamsar
Copy link
Contributor

kamsar commented Aug 29, 2016

There's a big security hole with using target=_blank links to other sites.

I cooked up a vanilla one-liner to automatically disable the vulnerability, which imo should go into the default js kit because most CMSes do not enable setting the rel correctly so generated content is unlikely to be protected.

What do you guys think?

Array.from(document.querySelectorAll('a[target=_blank]')).filter(function(e) { return !e.rel || e.rel.indexOf('noopener') < 0 }).forEach(function(e) { e.rel = (e.rel||'') + ' noopener noreferrer'; });
@krambuhl
Copy link
Contributor

This looks like a smart addition. maybe surfacing this as security "component"?

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

No branches or pull requests

2 participants