クロスサイトスクリプティング DOM json - yujitounai/helloworld GitHub Wiki
JSONを読み込んでそのままhtmlとして表示するDOM based XSS Access-Control-Allow-OriginヘッダありでJSONを返すサーバーからデータをFetchする
<!DOCTYPE html>
<head>
<meta charset="UTF-8" >
</head>
<body>
<div class="box">location.hrefのXSS<br>
<form method="get" action="">search
<input name="word" type="text">
<input type="submit">
</form>
<span id="ads">
</span>
<script>
document.getElementById('ads').innerHTML = decodeURI(location.href);
</script>
</div>
</body>
</html>
const express = require('express')
const app = express()
const port = 3002
//入力値をそのまま返すだけのサーバー
app.get('/', (request, response) => {
var key = request.query.key;
var value = request.query.value;
var param = { key: value };
response.header({'Access-Control-Allow-Origin': '*'})
response.json(param)
});
app.listen(port, () => console.log(`Example app listening on port ${port}!`))
http://localhost:9001/xss-json.html?http://localhost:3002/?key=test&value=%3cimg%20src=0%20onerror=alert(1)%3E