令åã«ãªã£ãä»ãContent-Typeãããã®Charsetä»ä¸ã«ããã¯ãã¹ãµã¤ãã¹ã¯ãªããã£ã³ã°ã«ã¤ãã¦èãã¦ã¿ã
çµç·¯
ãªãä»ãã®Content-Typeãããã®Charsetã§ã®XSSã«è¨åãã¦ãããã¨ãã㨠IPAã§å ¬éããã¦ããå®å ¨ãªã¦ã§ããµã¤ãã®ä½ãæ¹ã«ããè³æã§ãã®é ç®ãä»ã ã«ãã©ãã¼ããã¦ããããã ã
ãã®é
ç®ã令åã¨ãªã£ãç¾å¨ããã©ãã¼ãå¿
è¦ãªã®ãæ¤è¨¼ãã¦ããããã
TL;DR
ããææåºæºããé¤å¤ãã¦ãè¯ãã®ã§ã¯ãªãããã
è¢«å®³ã®æããããå ´åã¯IE11以åã®ãã©ã¦ã¶ã§ãã¤ãéå®çãªã®ã§ã
Content-Typeãããã®XSS??
ãã¡ãã¯ã©ããããã¨ãã¨ãããã¨ã
ãã©ã¦ã¶ã®æåã³ã¼ãã®è§£éã«ãã£ã¦å®è¡ãããã¯ãã¹ãµã¤ãã¹ã¯ãªããã£ã³ã°ã®å¯¾çã«ã¤ãã¦ã®é
ç®ãªã®ã§ããã
é常ãä½ã対çããã¦ããªãWebã¢ããªã±ã¼ã·ã§ã³ã§ããã°
ã¦ã¼ã¶ã®å
¥åå¤ããµãã¿ã¤ãºããã«ç»é¢ã«åºåãã¦ãã¾ãå ´åã«XSS(ã¯ãã¹ãµã¤ãã¹ã¯ãªããã£ã³ã°)ã®å±éºæ§ãããã
ãããããTESTãã!
â
ããããã<script>alert(1)</script>ãã!
ããããUTF-7 ã¨ããæåã³ã¼ããå©ç¨ããå ´åã«ãXSSã®å¯è½æ§ãåå¨ããã(ã¯ã¦ãªã®ãªã³ã¯ãããæ
å ±ãæ¾ããã!)
ããããã+ADw-script+AD4-alert(1)+ADw-/script+AD4-ãã!
ãã®+ADwããå§ã¾ãæååã¯UTF-7ã§ã¯
<script>alert(1)</script>ã¨ãªãã
ãã®HTMLããã©ã¦ã¶ãUTF-7ã¨è§£éããå ´åã«JSãå®è¡ããã
ãªã®ã§ããã©ã¦ã¶ã«ããUTF-7ã¨è§£éãããªãæ§ã«ã
ã¬ã¹ãã³ã¹ã®Content-Typeãããã®Charsetä»ä¸ããã¦XSSã鲿¢ãã¾ãããã¨ãããã¨ãªã®ã§ããã
ä»åã¯ãã®UTF-7ã§å®è¡å¯è½ãªXSSã®èå¼±æ§ã«ã¤ãã¦èãã¦ããããã
ããããã®çµç·¯ã¯IEã®Content-Typeç¡è¦ã«ããã£ãã¨æãã
ä»ã§ããIEã¯æä¾å
ã®Microsoftã§ããã使ç¨ãæ¨å¥¨ãã¦ããªãã¨ãããã¨ãªã®ã§ãããã®ææ³ã大åã¬ã¬ã·ã¼ã«ãªã£ãã®ã§ã¯ãªããã
ã©ã®ãã¿ã¼ã³ã§XSSã®èå¼±æ§ãåå¨ããã®ã
ã»ãã¥ãªãã£ãã§ãã¯ãªã¹ãã§ã¯ä»¥ä¸ã®æ§ã«è¨åããã¦ããã
å ¨ã¦ã®ã¦ã§ãã¢ããªã±ã¼ã·ã§ã³ã«å ±éã®å¯¾ç: (æ ¹æ¬ç対çã¨ãã¦) HTTPã¬ã¹ãã³ã¹ãããã®Content-Typeãã£ã¼ã«ãã«æåã³ã¼ãï¼charsetï¼ã®æå®ãè¡ãã
ã§ã¯æåã³ã¼ãï¼charsetï¼ã®æå®ãè¡ããªãã£ãå ´åã«ã©ããªãã®ã
å®éã«è©¦ãã¦ã¿ãã
- æ³å®ãããç°å¢
UTF-8ãShift-JISçã§åä½ãã¦ãããµã¤ãã§HTMLã§charsetãæå®ãå¿ãã¦
ã¬ã¹ãã³ã¹ãããã®Content-Typeãã£ã¼ã«ãã«charsetãä»ä¸ãã¦ããªãå ´åã®æåã確èªããã
HTML
<html> <body> +ADw-script+AD4-alert(1)+ADw-/script+AD4- </body> </html>
ã¬ã¹ãã³ã¹ããã(å
±é)
HTTP/1.1 200 OK Content-type: text/html
èå¼±æ§ãåå¨ããªãå ´åã¯ã以ä¸ã®æ§ã«è¨å·ããã®ã¾ã¾ç»é¢ã«è¡¨ç¤ºãããã ãã«ãªãã
(以ä¸ã¯Chrome)

以ä¸ã¯ãæ¤è¨¼ãããã©ã¦ã¶ã¨ãã®çµæã§ããã
æ¤è¨¼HTMLããã®ã¾ã¾èªã¿è¾¼ãã å ´å
| ãã©ã¦ã¶ | çµæ |
|---|---|
| IE8 | åé¡ãªã |
| IE11 | åé¡ãªã |
| Edge | åé¡ãªã |
| Chrome | åé¡ãªã |
| Safari | åé¡ãªã |
| Firefox | åé¡ãªã |
IE8ã¯Content-Typeç¡è¦åé¡ãåå¨ããã®ã§ãã®ã¾ã¾XSSãå®è¡ãã¦ãããã¨æã£ã¦ããããå®éã«ã¯XSSã¯å¯¾çããã¦ããã

iframeã§èªã¿è¾¼ãã å ´å
iframeãå©ç¨ãã¦èªã¿è¾¼ãã å ´åãcharsetã®æå®ãããã¦ããªãæã¯è¦ªHTMLã®æåã³ã¼ããå©ç¨ãããããã
ãã®HTMLãå©ç¨ãã¦åããã¼ã¸ãèªã¿è¾¼ãã§ã¿ãã
<html> <head> <meta charset="UTF-7"> </head> <body> <iframe src="http://example.com/charset-xss.html"></iframe> </body> </html>
iframeã®è¦ªHTMLã®ã¬ã¹ãã³ã¹ããã
HTTP/1.1 200 OK Content-type: text/html; utf-7
以ä¸ã¯iframeããå®è¡ããå ´åã®ç»é¢


iframeã§èªã¿è¾¼ãã å ´åã®çµæ
| ãã©ã¦ã¶ | çµæ |
|---|---|
| IE8 | â»è¦ªHTMLã¨ãã¡ã¤ã³ãåããªãXSSãå®è¡ã§ãã |
| IE11 | â»è¦ªHTMLã¨ãã¡ã¤ã³ãåããªãXSSãå®è¡ã§ãã |
| Edge | åé¡ãªã |
| Chrome | åé¡ãªã |
| Safari | åé¡ãªã |
| Firefox | åé¡ãªã |
â»è¦ªHTMLã¯iframeã®å¼ã³åºãå
ã¨ãªã£ãHTML
ã¨ããçµæã§ãã£ãã
çµè«
æ¤è¨¼æã«ç¨æããç°å¢ã§ã¯IEã®ã¿iframeã§èªã¿è¾¼ãã HTMLã¨XSSã®èå¼±æ§ã®ãããã¼ã¸ãåããã¡ã¤ã³ã§ããã°å®è¡å¯è½ã§ãã£ãã
ãã®iframeã§èªã¿è¾¼ãã HTMLããå©ç¨ã§ããªãã®ã§ããã°ãæªæã®ããæ»æè
ã¯å¥ãã¡ã¤ã³ããç¨æãããã¨ãã§ããªããã
ç¾å®çã«ã¯Charsetãä»ä¸ããã¦ããªããã¨ãå©ç¨ããã¯ãã¹ãµã¤ãã¹ã¯ãªããã£ã³ã°ã¯æ»æã§ããªãã¨ãããã¨ã«ãªãã
(åããã¡ã¤ã³å
ã«charsetãä»ãã¦ããªããµã¤ãã¨iframeãèªç±ã«æå®ã§ããã¨ãããµã¤ãã¯å¥)
ææ
Edgeã¯æ¢ã«åé¡ã®å¯¾çãããã¦ããã
IE11ã§ããiframeã®å¯¾çãããã¦ããã®ã§ããã°ãã®Content-Typeãããã®Charsetä»ä¸ã®ã¯ãã¹ãµã¤ãã¹ã¯ãªããã£ã³ã°èå¼±æ§ã«ã¤ãã¦ã®é
ç®ã¯
ç¾å ´ã§ã»ãã¥ãªãã£æ
å½è
ãè¤æ°ã®ãµã¼ãã¹ã«å¯¾ãã¦ãã§ãã¯ããä¸ã§è² æ
ã«ãªã代ç©ã«ãªã£ã¦ããã®ã§ããã°
å人çã«ã¯ãã©ãã¼ãå¤ãã¦ãè¯ãæ§ãªæ°ãããã