最新消息:

XSS with $(location.hash)

xss admin 1853浏览 0评论

XSS with $(location.hash)

demo

Click this link.

It works on IE, Firefox, Chrome, Opera. In Safari, location.hash is percent encoded, not work.

why?

$(“#id”) is css selector, $(“<img>”) is createElement, and $(“#<img>”) is createElement too.

how to fix

in your library

var hash = "#" + location.hash.replace(/[^\w]/g, "");
if ($(hash).size()) { ... }

or patch to jQuery

-       quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
+       quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,

examples

thanks

@t_ashula

转载请注明:jinglingshu的博客 » XSS with $(location.hash)

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址