ãŸããã¿ã€ãã«ã ãã§ããã®æçš¿ãéé£ããããšã¯å¯èœã§ãã®ã§ã説æãæ¥ããŸããã¯ãã¹ãµã€ãã¹ã¯ãªããã£ã³ã°ã¯å®éã«ã¯è匱æ§ã§ã¯ãªããæ»æã ããã§ãã éãã¯äœã§ããããªããããéèŠãªã®ãããã®ãã¹ãŠã«å¯ŸåŠããæ¹æ³ãããã³XSSã«ã€ããŠä»ã®ç¥è©±ã誀解ããããããã®-ã«ããã®äžã§èªã¿ãŸãã
ãã¹ãŠã®èª€è§£ã¯èŠåºãã«å®åŒåãããé åºã¯arbitraryæçã§ãããç¹å®ã®æ»æãšè匱æ§ã®äŸãšå®éã®æ»æã®äžèŽã¯ã©ã³ãã ã§ãããæå³çã§ã¯ãããŸããã
XSS-è匱æ§
äžèšã®ããã«ãããã¯ããã§ã¯ãããŸããã ã¯ãã¹ãµã€ãã¹ã¯ãªããã£ã³ã°ã¯ã OWASPããŒãžã§ã³ãšWASCããŒãžã§ã³ã®äž¡æ¹ã«ããæ»æã§ãïŒãã¡ãããåé¡
<?php header( 'Refresh: 5; url=' . $_GET['url']); ?> <html> <head> <meta http-equiv="refresh" content="5;url=<?=$_GET['url']?>"></meta> </head> </html>
ãŸãããã®ã³ãŒãã¯ãªãã€ã¬ã¯ãæ©èœã®ä¹±çšã®åœ±é¿ãåãããããXSSãšã¯é¢ä¿ãããŸããã 次ã«ã
http://localhost/?url="><script>alert("XSS")</script><!--
ãšãã圢åŒã®ãªã¯ãšã¹ãã«ãããã¯ãã¹ãµã€ãã¹ã¯ãªããã£ã³ã°ãå®éã«ç°¡åãã€èªç¶ã«å®è£ ãããŸãã -ã¢ããªã±ãŒã·ã§ã³ã¯ã4.4.2ãŸãã¯5.1.2ããåã®æšæºçãªPHPããŒãžã§ã³ããŸãã¯å€æ°ã®ãµãŒãããŒãã£PHPå®è£ ã䜿çšããç°å¢ã«ãããã€ãããŸãããã®ã³ãŒãã¯ãHTTPå¿çãåå²ããŠé衚瀺ã«ããæ»æã«å¯ŸããŠãè匱ã§ãïŒWebã¢ããªã±ãŒã·ã§ã³ã®ã»ãã¥ãªãã£ã¯ç°å¢ã®ã»ãã¥ãªãã£ã«å¯èœãªéãäŸåããŸãïŒã
è匱æ§ãšæ»æã®éãã¯ãè匱æ§ãæé€ããããšã§ããããæªçšãããã¹ãŠã®æ»æãæé€ã§ããããšã§ãããç¹å®ã®æ»æãæé€ããŠãè匱æ§ã¯è»œæžãããŸããã ç°¡åãªäŸïŒãã®XSSãè匱æ§ãšèŠãªããã¹ã¯ãªããã«æž¡ãããURLã®åãã©ã°ã¡ã³ãã®URLãšã³ã³ãŒãã£ã³ã°ã䜿çšããŠXSSãæé€ããå Žåãããã¯ãªãã€ã¬ã¯ãæ©èœã®æªçšã®å¯èœæ§ã«åœ±é¿ããŸãã-æ»æè ã¯ãŠãŒã¶ãŒããªãã€ã¬ã¯ãã§ããŸãä»»æã®ãæ£ãã圢æãããURLã çµæãšæŠãã®ã§ã¯ãªããåå ãå æããå¿ èŠããããŸããã€ãŸããããããã¹ãŠã®æ»æãå®è¡ã§ããéåžžã«å¯äžã®è匱æ§ãæé€ããå¿ èŠããããŸãã ãã®å Žåãè匱æ§ã¯ãGET urlãã©ã¡ãŒã¿ãŒãWebãµãŒããŒã«ãã£ãŠã¹ã¯ãªããã«æž¡ããããšãããŸãã¯åºåã§äœ¿çšããåã«é©åã«åŠçãããªãããšã§ãã æããŠãã ããïŒãã®è匱æ§ã¯ã å ¥åºåããŒã¿ã®äžæ£ãªåŠçã®ã¯ã©ã¹ã«å±ããä»æ¥ç¥ãããŠããã»ãšãã©ã®æ»æãå®è¡ã§ããæãäžè¬çãªè匱æ§ã§ãã ãããã£ãŠããã®è匱æ§ãæé€ããããã«ã¯ãäž¡æ¹ã®ã¿ã€ãã®ããŒã¿ã®é©åãã€ååãªåŠçãä¿èšŒããå¿ èŠããããŸããããã®å ŽåãURLãšã³ã³ãŒãã£ã³ã°ã§ã¯äžååã§ããããšãæããã§ãã å°ãåŸã§ãã®åé¡ã«æ»ããŸãã
XSSã¯ããã·ãããã³ã¢ã¯ãã£ãã§ã
ãå®å šã«éå±ã ãšæããããçšèªã«ã€ããŠååãšè°è«ãå§ããŠãã ãããïŒCïŒã ããããããã¯ååã®åé¡ã§ããããããªããã ãã®åæ§æè ã®åé¡ããã·ã¢èªåã®éçºè ã«èª²ããããã®ã¯èª°ã®ããããããããŸããïŒãã·ã¢èªçãŠã£ãããã£ã¢ã®XSSã«é¢ããèšäºããã®é åžã«è²¢ç®ãããšã®æèŠããããŸãïŒãããã®ãããªåé¢ã¯çºçããŸãããããã§ãå®å šã«åœ¹ã«ç«ããªãããã§ã Webã¢ããªã±ãŒã·ã§ã³ã®ã»ãã¥ãªãã£ãåæããããã«å¯Ÿå¿ããè匱æ§ãæé€ãããšãã芳ç¹ãããå®éã«éèŠãªç¹å®ã®XSSã®ãã¹ãŠã®ããããã£ãåæ ããŠããŸããã XSSã¯ååçïŒç¹å¥ã«åœ¢æããããªã³ã¯ããŠãŒã¶ãŒã«éä¿¡ããå¿ èŠãããããŠãŒã¶ãŒã«ããã«åŸãããã«èª¬åŸããïŒãšã¢ã¯ãã£ãïŒãµãŒããŒã«ä¿åããããŠãŒã¶ãŒã«ããäžèŠãªãžã§ã¹ãã£ãŒãªãã«ããªã¬ãŒãããïŒã§ãããšäŒçµ±çãã€èª€ã£ãŠæ³å®ãããŠããŸãã ãã ãã次ã®äŸãèæ ®ããŠãã ãããHabratopikããã¹ãã®
<a>
ã¿ã°ã®
src
å±æ§ãè¶ ããããšãã§ããããã¿ã°ãè¶ ããããšã¯ã§ããªãHabrãšã³ãžã³ã«è匱æ§ããããšããŸãã ãã®è匱æ§ã䜿çšããŠããªã³ã¯äžã«ããŠã¹ã移åãããã¯ãªãã¯ãããªã©ã®ãã³ãã©ãŒãå®çŸ©ããããšã«ãããXSSæ»æãå®è¡ã§ããããšã¯æããã§ãã 質åïŒãã®ãããªæ»æã¯ååçã§ããããããšãèœåçã§ããïŒ äžæ¹ã§ã¯ããªã³ã¯ã¯ãµãŒããŒã«ä¿åãããæ»æããããŠãŒã¶ãŒã«é ä¿¡ããå¿ èŠã¯ãªããã¢ã¯ãã£ãã«ãªã£ãŠããããã§ãã äžæ¹ãæ»æãæåãããã«ã¯ãè¿œå ã®ãŠãŒã¶ãŒã¢ã¯ã·ã§ã³ãå¿ èŠã§ããããã¯ãååçãªæ»æã®å Žåã«ã®ã¿äžè¬çã§ãã ãã©ããã¯ã¹ïŒ ãã®ããããã¯ãã«ãšæŽé²æ¹æ³ãšãã2ã€ã®åºæºã«åŸã£ãŠXSSãåé¡ããã®ãäžè¬çã§ãã 2ã€ç®ã¯ãŸã£ããåããã¢ã¯ãã£ã/ããã·ããã§ãããããããããããå®åŒåããããŸããXSSã¯ã¢ã¯ãã£ãã§ãããããã·ãã§ã¯ãªããWebã¢ããªã±ãŒã·ã§ã³ã®æ©èœã«é¢ããŠãŠãŒã¶ãŒåŽã§äžèŠãªã¢ã¯ã·ã§ã³ãå¿ èŠãšããŸããã ãããŠã圱é¿ãã¯ãã«ã«ãããšãXSSã¯åå°ïŒæäœãã¯ãã«ãéä¿¡ãããåããªã¯ãšã¹ãã«å¿ããŠãµãŒããŒããè¿ãããïŒãå®å®ïŒãµãŒããŒã«ä¿åãããæäœãã¯ãã«ãå«ãŸãªãåããªã¯ãšã¹ãã«å¯Ÿãããã¹ãŠã®åçã§å©çšå¯èœïŒãšããã¥ã¡ã³ãã®ãªããžã§ã¯ãã¢ãã«ã«åºã¥ããŠããŸãïŒãã®å®è£ ã¯ããµãŒããŒã«èŠæ±ãéä¿¡ããã«å¯èœã§ãïŒã ãããã£ãŠãæ»æã®ç¹å®ã®äŸã®åé¡ã«å¯Ÿããæ£è§£ã¯ããå®å®-ååãã§ãã
XSSã¯ãŠãŒã¶ãŒã«å¯Ÿããæ»æã§ããããã©ãŠã¶ã§ä»»æã®ã¹ã¯ãªãããå®è¡ããããšãç®çãšããŠããŸã
æããã«ãããã¯å®å šã«çå®ã§ã¯ãããŸããã 被害è ã®ãã©ãŠã¶ã§ä»»æã®ã¹ã¯ãªãããå®è¡ããã«ã¯ãæ»æè ã«å¶åŸ¡ããããµãŒããŒäžã«ããç¹å¥ã«æºåãããããŒãžã«èªã蟌ãã ãã§ååã§ãã XSSã¯ãä»»æã®ã¹ã¯ãªããã®å®è¡ã ãã§ãªããç¹å®ã®ãµã€ãã®ãœãŒã¹ã®ã³ã³ããã¹ãã§ã®å®è¡ãç®çãšããŠãããåäžãœãŒã¹ããªã·ãŒïŒ Same Origin PolicyãSOP ïŒããã€ãã¹ãããã®çµæãWebã¢ããªã±ãŒã·ã§ã³ã®ã¯ã©ã€ã¢ã³ãéšåã®ããŒã¿ãšæ©èœã«ã¢ã¯ã»ã¹ããŸããŠãŒã¶ãŒã»ãã·ã§ã³ãšãã®ãŠãŒã¶ãŒã®æš©å©ã ããã¯ããŸãããŠãŒã¶ãŒã®ãã©ãŠã¶ã§ã¯ãªããè åšãå®è£ ããWebã¢ããªã±ãŒã·ã§ã³ã«å¯Ÿããæ»æã§ãã
ã ã»ãã¥ãªãã£Web 2.0ãé«åºŠãªãã¯ãã㯠ãã»ã¯ã·ã§ã³ã®PHDays 2012ã«ã³ãã¡ã¬ã³ã¹ã§ããã¹ãã®Anders RyanchoãèŽè¡ã«ãã·ã³ã°ã«ãœãŒã¹ããªã·ãŒãšã¯äœããç¥ã£ãŠãã人ã«æãæããŠãã ããããšããç°¡åãªè³ªåãããŸããã ç§ãããã«ãããšããç§ã¯ç¢ºèªããæºåãã§ããŠããŸãïŒãŠã§ãéçºè ãšã»ãã¥ãªãã£å°é家ã ãã§æ§æãããèŽè¡ã®3åã®1ãæãæããŸããã ãããªã«ã¯ãã®æŽå²çãªç¬éããããŸããèŠèŽè å šå¡ããã®ç¬éã«ãã¬ãŒã ã«å ¥ããªãã£ãã®ã¯æ®å¿µã§ãã æ£çŽãªãšãããWebã»ãã¥ãªãã£ã®éçºè ãå°é家ã«ãªãæ¹æ³ããããããããææ°ã®ãã©ãŠã¶ãŒãä¿è·ããããã®åºæ¬çãªã¡ã«ããºã ã«ã€ããŠãç¥ããªãã®ã§ãç§ã¯äººã ãå€åœäººã®åã§æãäžããã«ã¯ããŸãã«ãæ¥ãããããå±ã ãšæããŸããã ãã ãããããã®ããªã·ãŒã®ç°¡åãªæŠèŠã§ã2ã3段èœã®åé¡ã§ã¯ãªããããMichael Zalewskiã«ããé»åæžç±ã Browser Security Handbook ãã®ç¬¬2éšã«èå³ã®ããäººå šå¡ãéä¿¡ã§ããŸãã ãã®ãããã¯ã¯ãåãèè ãThe Tangled Webã§ããã«è©³ãã説æããŠããŸã ã ã¡ãªã¿ã«ãã©ã¡ããWebéçºãWebã¢ããªã±ãŒã·ã§ã³ã®ã»ãã¥ãªãã£åæã«æºãããã¹ãŠã®äººãèªãããšããå§ãããŸãã
XSSãšã®æŠãã¯ãŠãŒã¶ãŒã®åé¡ã§ãããå®éXSSã¯æ·±å»ã§ã¯ãããŸãã
Webã¢ããªã±ãŒã·ã§ã³ïŒäžèšåç §ïŒã«å¯Ÿãããã®æ»æãçªç¶ããã®ã¢ããªã±ãŒã·ã§ã³ã®ææè ãéçºè ã§ã¯ãªãããŠãŒã¶ãŒã®åé¡ã«ãªã£ãçç±ã¯å®å šã«ã¯æããã§ã¯ãããŸããã ããã§ãåé¡ã¯ãããããŠãŒã¶ãŒã®ä¿è·ãããäœæ¥ã確ä¿ããäžã§ã®åœŒãã®ç«å Žã§ãã XSSã®å®è£ ã«é¢é£ãããªã¹ã¯ã¯ãå®éããã°ãã°è©å€ããããããŸãã ãã ããXSSã®æåããŠãŒã¶ãŒã«ãšã£ãŠã©ãã»ã©æ·±å»ãªçµæã«ãªããã«ã€ããŠè©±ãå Žåã¯ãZeroNights 2011ã«ã³ãã¡ã¬ã³ã¹ã§çºè¡šããããµã€ãéæ»æãéããŠWebéçºè ã®ã³ââã³ãã¥ãŒã¿ãŒãžã®ç¹æš©ã¢ã¯ã»ã¹ãç²åŸããããšã«å°å¿µããååã®Denis Baranovã®ã¬ããŒããRoot through XSSããã芧ã«ãªãããšããå§ãããŸãã¹ã¯ãªããã®å®è¡ïŒæ®å¿µãªãããå©çšã§ããã®ã¯ã¹ã©ã€ãã ãã§ãããäžè¬çãªèãæ¹ã¯ãããªããªããŠãç解ã§ãããšæããŸãïŒã ã¯ã©ã€ã¢ã³ãåŽã§XSSã䜿çšããŠãæ»æè ããŠãŒã¶ãŒã®ã³ã³ãã¥ãŒã¿ãŒãžã®ç¡å¶éã®ã¢ã¯ã»ã¹ãååŸããå ŽåããªãœãŒã¹ã®è©å€ã«å¯Ÿãããã¡ãŒãžã¯ã©ãã»ã©åŒ·ãã§ããããïŒ å€§éã®XSSãã¹ã¯ãªããã£ã³ã°ã«å€æããããŒã«ããããããããšããäºå®ãèãããšãå°ãªããšãåãBeEFã䜿çšããŠãã ãã ã ããã«ãXSSã®èŠ³ç¹ãããWebã¢ããªã±ãŒã·ã§ã³ç®¡çè ã¯ä»ã®ãã¹ãŠã®ãŠãŒã¶ãŒãšãŸã£ããåããŠãŒã¶ãŒã§ããããšãå¿ããªãã§ãã ããïŒåé¡ã¯ãã®ã¯ã©ã¹ã®æ»æãšã®æŠãã§ãïŒã
XSSã¯ãHTMLãŸãã¯ã¯ã©ã€ã¢ã³ãã¹ã¯ãªãããžã®æ³šå ¥ã®çµæãšããŠã®ã¿å¯èœã§ãã
ããã ãã§ã¯ãããŸããã ããšãã°ãåè¿°ã®æ»æåå²HTTPå¿çã䜿çšããæ¹æ³ã®1ã€ã¯ãHTMLããã¥ã¡ã³ãïŒããã³ãå¿ èŠã«å¿ããŠã¯ã©ã€ã¢ã³ãã¹ã¯ãªããïŒãHTTPããããŒã«çŽæ¥åã蟌ãããšã§ãã ãªãã€ã¬ã¯ãæ©èœã®æªçšã¯ãdataïŒãŸãã¯javascriptïŒã¹ããŒã ã䜿çšããŠãã©ãŠã¶ãURLã«ãªãã€ã¬ã¯ãããããã«ãã䜿çšãããŸãã ããã«ãXSSãå®è¡ããããã®ãªãã€ã¬ã¯ãæ»æã®ããæçœã§ãªã䜿çšãå¯èœã§ãã ããšãã°ãWebã¢ããªã±ãŒã·ã§ã³ã§ã¯ããã§ã«èæ ®ãããŠãããªãã€ã¬ã¯ãã®åé¡ã®ãšã³ããªãã€ã³ãïŒ
/redirect.php?url=
å©çšå¯èœïŒã«å ããŠã次ã®ã³ãŒãã®ãã€ã³ãããããŸãã
<html> <head> <link rel="stylesheet" href="/themes/<?=$theme?>.css" type="text/css" /> </head>
åæã«ãGETãªã¯ãšã¹ãã®ãã©ã¡ãŒã¿ãŒããååŸãã
$theme
å€æ°ãåŠçãããšããã¹ãŠã®åŒçšç¬Šãšããã¯ã¹ã©ãã·ã¥ãšã¿ã°ïŒå Žåã«å¿ããŠïŒãåé€ãããæ»æè ãhrefå±æ§ãè¶ ããããšãã§ããªããªããŸãã ãã ããããã¯XSSã«ã¯å¿ èŠãããŸããã å€
../redirect.php?url=http://evilsite.domain/evilstylesheet
ãã©ã¡ãŒã¿ãŒ
$theme
䜿çšãã
../redirect.php?url=http://evilsite.domain/evilstylesheet
æ»æè ã¯ããŒãžã«ä»»æã®ã¹ã¿ã€ã«ã·ãŒããåã蟌ãããšãã§ããŸãã IEãŸãã¯FFã®ã³ã³ãã³ãã·ãŒãã䜿çšãã
body { behavior:url(../redirect.php?url=http://evilsite.domain/evilscript.htc); }
ãããŠ
body { -moz-binding: url(../redirect.php?url=http://evilsite.domain/evilscript.xml#evilcode); }
ãããããããã³ãµãŒããŒã«evilscript.htcãã¡ã€ã«ãé 眮ããããšã«ããïŒ
<PUBLIC:COMPONENT TAGNAME="xss"> <PUBLIC:ATTACH EVENT="ondocumentready" ONEVENT="main()" LITERALCONTENT="false"/> </PUBLIC:COMPONENT> <SCRIPT> function main() { alert("XSS"); } </SCRIPT>
ããã³evilscript.xmlïŒ
<?xml version="1.0"?> <bindings xmlns="http://www.mozilla.org/xbl" xmlns:html="http://www.w3.org/1999/xhtml"> <binding id="mycode"> <implementation> <constructor> alert("XSS"); </constructor> </implementation> </binding> </bindings>
圌ã¯ãããã2ã€ã®ãã©ãŠã¶ãŒã®ãŠãŒã¶ãŒã«å¯ŸããŠXSSã§æåããŠããŸãã ãã¡ãããã¹ã¿ã€ã«å®çŸ©ã«çŽæ¥æ³šå ¥ããå Žåãåæ§ã§ãã
UPDïŒã³ã¡ã³ãã§ç€ºåãããŠããããã«ã-moz-bindingã¯æè¿ãé·ãåœãåœããŸãã ã
ããŸããŸãªãã©ãŠã¶ãŒããã³HTMLããŒãžã§ã³ã§æ»æè ãå©çšã§ããXSSãã¯ãã«ã®ã»ãšãã©ã¯ã HTML5ã»ãã¥ãªãã£ã«é¢ããããŒãã·ãŒãã«èšèŒãããŠããŸã ã ããã§ããã®ã»ã¯ã·ã§ã³ã®ã¿ã€ãã«ã§è¡šæããã質åã«å¯Ÿããå æ¬çãªçããèŠã€ããããšãã§ããŸãã
ç§ã䜿çšãããã¬ãŒã ã¯ãŒã¯ã«ã¯ãXSSã«å¯Ÿããèªåä¿è·ãçµã¿èŸŒãŸããŠãããããå¿é ããå¿ èŠã¯ãããŸããã
å®éãçŸä»£ã®å€ãã®ãã¬ãŒã ã¯ãŒã¯ã§ã¯ããã®ãããªä¿è·ãå®è£ ãããŠããŸãã Code Igniterã®XSSãã£ã«ã¿ãªã³ã°ã¡ã«ããºã ãDjangoãšRoRã®æšæºãã³ãã¬ãŒããšã³ãžã³æ©èœãASP.NET / MVCã®Webä¿è·ã©ã€ãã©ãªãšãªã¯ãšã¹ãæ€èšŒã¡ã«ããºã ãªã© ãªã© ããã¯ééããªãçŽ æŽãããããšã§ããããã®æ©èœã䜿çšããªãã®ã¯æããªããšã§ãã 次ã®ããšãèæ ®ããªãã®ãæãã§ãïŒ
- DOMããŒã¹ã®XSSããWebã¢ããªã±ãŒã·ã§ã³ãä¿è·ã§ãããµãŒããŒãã¬ãŒã ã¯ãŒã¯ã¯ãããŸããã
- XSSã«å¯Ÿããèªåä¿è·ã®ããã®æ¢åã®ã¡ã«ããºã ã¯ããããæ®éçã§ã¯ãªããèæ ®ããªããã°ãªããªãå¶éããããŸããã
- ãããã®ã¡ã«ããºã ã«ãã£ãŠå®è£ ãããæ©èœã¯ãç¹å®ã®ã¯ã©ã¹ã®æ»æã«å¯Ÿæããããšãç®çãšããŠãããã³ãŒãã®è匱æ§ã«ãããäžååãªããŒã¿åŠçããä¿è·ããããšã¯ã§ããŸããã
ãããã£ãŠããŸã 泚æãå¿ èŠã§ããäžéšã®ãã¬ãŒã ã¯ãŒã¯ã§ã¯ãããã¯æ¥åžžçãªäœæ¥ã§ã¯ãªããå€å€§ãªæéã³ã¹ããå¿ èŠã«ãªãã ãã§ãã
XSSãæé€ããã«ã¯ãHTMLããã¥ã¡ã³ãã«å«ãŸãããã¹ãŠã®è¡ãéžå¥ããã ãã§ååã§ãã
ååã§ã¯ãããŸããããäžèšã¯ãã§ã«çç±ãæ€èšããŠããŸãã XSSã§ã¯ãªããXSSãåŒãèµ·ãããè匱æ§ãæé€ããå¿ èŠããããããå®å šãªããŒã¿åŠçãå¿ èŠã«ãªããŸãã ãã®ãããã¯ã¯å¥ã®ïŒããªã倧ããªïŒèšäºã«åºã¥ããŠããããããã®ãããªåŠçã®å®è£ ã®äž»èŠãªæ®µéãèŠçŽããŸãã
ããŒã¿ã®ä¿¡é Œæ§ãå€æãã
ãŸã第äžã«ãWebã¢ããªã±ãŒã·ã§ã³ã®èæ ®ãããã³ã³ããŒãã³ãå ã§æŽåæ§ãŸãã¯ä¿¡é Œæ§ãå¶åŸ¡ãããŠããªããã¹ãŠã®ããŒã¿ã¹ããªãŒã ãèå¥ããå¿ èŠããããŸãã Webã¢ããªã±ãŒã·ã§ã³ã³ã³ããŒãã³ããšã¯ãååãšããŠïŒåžžã«ã§ã¯ãããŸãããïŒã1ã€ã®OSããã»ã¹ã®ãã¬ãŒã ã¯ãŒã¯å ã§å®è¡ããããµãŒããŒãŸãã¯ã¯ã©ã€ã¢ã³ãéšåã®èŠçŽ ãæå³ããŸãã
äžèšã®äŸã§ã¯ãä¿¡é Œã§ããªãïŒãããŠå¯äžã®ïŒããŒã¿ã¯GETãªã¯ãšã¹ãæååããååŸããurlãã©ã¡ãŒã¿ãŒã§ãã
ä¿¡é Œã§ããªãããŒã¿ããã¹ãŠå ¥åãã
ã³ã³ããŒãã³ãå ã§ãã®ãããªããŒã¿ãçºçããå Žæã«ã§ããã ãè¿ãå Žæã§ãæåŸ ãããã¿ã€ããžã®å€æãä¿èšŒããå¿ èŠããããŸãã éçèšèªã§ã¯ãããã¯å®éã«ãæ€èšŒãããããŒã¿ã®éã·ãªã¢ã«åãŸãã¯è§£æã«åºã¥ããŠãã®ã¿ã€ãã®ã€ã³ã¹ã¿ã³ã¹ã«ãã£ã¹ããŸãã¯äœæããããšã§å®çŸãããŸãã ããã«ãéçèšèªã§æ§ç¯ãããã»ãšãã©ã®ææ°ã®ãã¬ãŒã ã¯ãŒã¯ã§ã¯ããã®æ©èœã¯ã¯ãšãªãã©ã¡ãŒã¿ãŒãã¢ãã«ãªããžã§ã¯ãã«ãã€ã³ãããããã®ã¡ã«ããºã ã§æ¢ã«å®è£ ãããŠããŸãã åçèšèªã§ã¯ããã¹ãŠãããæ²ãã å®éã«ã¯ããã£ã¹ãã®ã·ãã¥ã¬ãŒã·ã§ã³ã«ã€ããŠã®ã¿è©±ãããšãã§ããŸãïŒãã ããããã¯å®è¡ããå¿ èŠããããŸãïŒã ããã«ããããããããã®ãããªæ¡ä»¶ä»ãåä»ããããæèœã«å®è£ ããããšã§ãã³ã³ããŒãã³ããæ©èœããããã«èšèšããããŸãã«ãã®åã®ããŒã¿ãæã€ããšãä¿èšŒãããŸãã ã³ã³ããŒãã³ãå ã®ããŒã¿ã䜿çšãã以éã®ãã¹ãŠã®äœæ¥ã¯ãå ¥åããŒã¿ã«åºã¥ããŠäœæããããªããžã§ã¯ããä»ããŠã®ã¿å®è¡ããå¿ èŠããããŸãã ã¿ã€ãã³ã°æ®µéã®åºæ¬ååã¯ããã®åºåã§ã®æåååãªããžã§ã¯ãã®å¯èœãªéãæå°æ°ã§ããããšãèŠããŠããããšãéèŠã§ãã URLãã¡ãŒã«ã¢ãã¬ã¹ãæ¥ä»ãæå»ãªã© å ¥ååŸã¯ãæåå以å€ã®ç¹å®ã®ã¿ã€ãã®ãªããžã§ã¯ãã§ãªããã°ãªããŸããã å®éã«æååã§ããããŒã¿ã®ã¿ãã€ãŸã å®éã«ã¯ãä»»æã®ãã«ã¢ã«ãã¡ãããã®ããã¹ããå«ãŸããå ŽåããããŸãã
ç§ãã¡ã®å Žåãparse_urlïŒïŒé¢æ°ã䜿çšããŠãçµæã®é åã®èŠçŽ ã«äœåãªã¢ã³ããŒã¹ã³ã¢ã®åºçŸã®ãã§ãã¯ãå®è£ ããã ãã§ååã§ããå ã®URLã«çŠããããæåãååšããããšã瀺ããŸãFALSEïŒã çµæã®é åã«ã¯ãšãªããŒãååšããå Žåã¯ãparse_strïŒïŒã䜿çšããŠè§£æããã¯ãšãªãã©ã¡ãŒã¿ã䜿çšããŠçµæã®é£æ³é åã«çœ®ãæããå¿ èŠããããŸãã
å ¥åããããã¹ãŠã®ä¿¡é Œã§ããªãããŒã¿ã®æ€èšŒ
å ¥åããçŽåŸã«ãåä¿¡ãããªããžã§ã¯ãã®ã»ãã³ãã£ã¯ã¹ãã³ã³ããŒãã³ãã®æ©èœã«æºæ ããŠãããã©ããã確èªããå¿ èŠããããŸãã ããšãã°ãæŽæ°åãŸãã¯æ¥ä»/æå»ã®å Žåãããã¯ç¯å²ãã§ãã¯ïŒããšãã°ããã®äžã®è² ã®ããŒãžçªå·ãéééé¡ãã»ãšãã©æ©èœã®æåŸ ã«äžèŽããªãïŒãæååã®å Žåãã»ãšãã©ã®å Žåãæ£èŠè¡šçŸã®ãã§ãã¯ã§ååã§ãããŸããããè€éãªã¿ã€ãã®ãªããžã§ã¯ãã®å Žåããã®ãã£ãŒã«ããšããããã£ã®ããããã®ã»ãã³ãã£ã¯ã¹ãã§ãã¯ãå®è£ ããå¿ èŠããããŸãã æ€èšŒãã§ãã¯ã¯ãåžžã«ãã¯ã€ããªã¹ãã®ååã«åºã¥ããŠããå¿ èŠããããŸãã ããŒã¿ã®ã»ãã³ãã£ã¯ã¹ã¯èš±å¯ãããåºæºãæºãããŠããå¿ èŠããããŸãã ãã®æ®µéã®ç®çã¯ãã³ã³ããŒãã³ãå ã®ãã¹ãŠã®ããŒã¿ããå®è£ ãããŠããæ©èœã«å¯Ÿå¿ããéåã§ããªãããšãä¿èšŒããããšã§ãã
ãWebã¢ããªã±ãŒã·ã§ã³ãã§ããã¡ã€ã³ã®ãã¬ãŒã ã¯ãŒã¯å ã§ã®ã¿ãªãã€ã¬ã¯ããå®è¡ã§ãããšããŸãã ãã®å Žåãparse_urlïŒïŒã®çµæãšããŠååŸããé åã«ã¯ããã¹ãã¯ãšãªãããã³ãã©ã°ã¡ã³ãããŒã®ã¿ãååšããããšã確èªããå¿ èŠããããŸãã ã¹ããŒã ããã¹ããããã³ããŒããWebã¢ããªã±ãŒã·ã§ã³ãã¡ã€ã³ãæããŠããå Žåãé€ããä»ã®ããŒãçºèŠãããšãæ€èšŒãšã©ãŒãçºçãããªã¯ãšã¹ãåŠçãçµäºããŸãã ããäžè¬çãªã±ãŒã¹ã§ã¯ãWebã¢ããªã±ãŒã·ã§ã³ã§äœ¿çšãããŠããã«ãŒãã£ã³ã°ã¡ã«ããºã ã«ãã£ãŠãçã«æ¢åã®ã³ã³ãããŒã©ãŒãžã®æºæ ã®ãã¹ããã§ãã¯ã§ããããã«ãªãã°ãæ¬åœã«çŽ æŽãããã§ãããã ã¯ãšãªã®ãã©ã¡ãŒã¿ãŒïŒãã©ã°ã¡ã³ãã¯èšããŸã§ããããŸããïŒã§ãåãããšãã§ããã°ãæ¬åœã«ã¯ãŒã«ã§ãã
åºåãµãã¿ã€ãº
æ€èšŒããã³å ¥åããããªããžã§ã¯ããã³ã³ããŒãã³ãã®å¶éãè¶ ããŠãããã¹ãŠã®å ŽæïŒãŸãã¯åºåããŒã¿ããããã«åºã¥ããŠåœ¢æãããŠããå ŽæïŒã§ã¯ãåä¿¡åŽã«ãšã£ãŠå®å šãªãã©ãŒã ã«ããããæã¡èŸŒãå¿ èŠããããŸãã ååãšããŠãããã¯ããããããå®å šã§ãªãèŠçŽ ãåé€ããïŒãã£ã«ã¿ãªã³ã°ïŒããããããå®å šãªåçç©ã«å€æããïŒã·ãŒã«ãïŒããšã«ãã£ãŠéæãããŸãã ããŒã¿ãæçµçã«é 眮ãããå Žæã«é©åã«è¡ç管çãå®æœããå¿ èŠããããŸãã ãããã£ãŠããããã«åºã¥ããŠHTMLããã¥ã¡ã³ãã圢æããå Žåãã¿ã°éãã¿ã°å ãç¹å®ã®ã¿ã°å±æ§å ã®ããŒã¿ãã¯ã©ã€ã¢ã³ãã¹ã¯ãªãããŸãã¯ã¹ã¿ã€ã«å®çŸ©ã®ããã¹ãã«æ£ããã·ãŒã«ãããæ¹æ³ã¯ç°ãªããŸãã èšãæãããšãhtmlspecialcharsïŒïŒã¯ã©ãã§ãåžžã«ååãªæ®éçãªã¹ã¯ãªãŒãã³ã°ããŒã«ã§ã¯ãããŸããã
ç§ãã¡ã®ã±ãŒã¹ã§ã¯ãé¢æ°http_build_queryïŒïŒã䜿çšããŠãªããžã§ã¯ãã®åã®æ®µéã§ååŸãããã£ãŒã«ãã«åºã¥ããŠæ£ããURLãçæããã ãã§ããã¹èŠçŽ ã圢æãããšãã«ïŒãŸãã¯pecl_httpããhttp_build_urlïŒïŒããã³http_build_strïŒïŒã䜿çšããŠïŒã¯ãšãªããŒããšurl_encodeïŒïŒãæ§ç¯ã§ããŸãã
å®éã®ãšããããããã®ã«ãŒã«ã¯ããã®ã¯ã©ã¹ã®è匱æ§ã«ãã£ãŠåŒãèµ·ãããããã¹ãŠã®æ»æã«é¢é£ããŠããŸãã ããšãã°ãSQLã¹ããŒãã¡ã³ã ã OSã³ãã³ããªã©ã®å®è£ ã®å Žå ãŸããã»ãšãã©ã®éçºè ã¯ããµãŒããŒãã¯ã©ã€ã¢ã³ãããåä¿¡ããããŒã¿ãä¿¡é Œã§ããªãããšãé·ãéèªèããŠããŸããããåãçç±ã§å察ãåœãŠã¯ãŸããšèãã人ã¯ã»ãšãã©ããŸããã ããã§ããä¿è·ãããããŒã¿åŠçãã¯ã©ã€ã¢ã³ãåŽã§å®è£ ãããå Žåãããã«ããããµãŒããŒäžã®è匱æ§ã®æªçšã«é¢é£ããã¯ã©ã€ã¢ã³ãæ»æã®ãªã¹ã¯ãæå°éã«æããããšãã§ããŸãã
- , (: ) -, XSS « ...» , . , -.
: , ?
. . , , ( XSS). :
X-Content-Type-Options: nosniff
msdn.microsoft.com/en-us/library/ie/gg622941 (v=vs.85).aspx
X-XSS-Protection: 1; ã¢ãŒã=ãããã¯
msdn.microsoft.com/en-us/library/dd565647 (v=vs.85).aspx
X-Frame-Options: DENY
blogs.msdn.com/b/ieinternals/archive/2010/03/30/combating-clickjacking-with-x-frame-options.aspx
X-Content-Security-Policy: [ , dvcs.w3.org/hg/content-security-policy/raw-file/tip/csp-specification.dev.html ]
Strict-Transport-Security: max-age=expireTime
developer.mozilla.org/en/Security/HTTP_Strict_Transport_Security
, â , .
é 匵ã£ãŠ