ãªã¼ãã³ãªãã¤ã¬ã¯ã¿ãèå¼±æ§ã¨ã¿ãªãã¹ããã¯è°è«ãåãããã¨ããã§ããGoogleçã®ä¸é¨ã®ãµã¤ãã¯ãèªãµã¤ãã®ãªã¼ãã³ãªãã¤ã¬ã¯ã¿ãèå¼±æ§ã¨ãã¦ã¯ã¿ã¦ãã¾ãããä¸æ¹ã§ãèå¼±æ§æ¤æ»ã®ç¾å ´ã§ã¯ãè¦ã¤ããã°èå¼±æ§ã¨ãã¦å ±åãããã¨ãå¤ãã¨æãã¾ãã
ãã®è¾ºã®è°è«ã¯ããã¦ããã¦ããªã¼ãã³ãªãã¤ã¬ã¯ã¿ã®æ¤æ»ã¯ããã©ã¦ã¶ã®ç¹æ§ããããã§æå¤ã¨ããªã¨ã¼ã·ã§ã³ãå¤ãã¦é¢ç½ãã®ã§ãæ¬æ¥ã®æ¥è¨ã§åãä¸ãã¦ã¿ããã¨æãã¾ãã
大ã¾ãã«ããã¨ããªãã¤ã¬ã¯ãã¯ã302å¿çã®LocationããããRefreshï¼HTTPããããMETAã¿ã°ï¼ãJavaScriptã«ãããã®ãããã¾ãããæ¬æ¥ã¯302å¿çã®Locationãããã®ãªãã¤ã¬ã¯ã¿ã«ã¤ãã¦åãä¸ãã¾ãã
ãã¿ã¼ã³1ï¼ãµããã¡ã¤ã³é¨åã«å¤ãå ¥ãå ´å
以ä¸ã®ããã«ããµããã¡ã¤ã³ã®ç®æãåçãªã±ã¼ã¹ã§ãã
Location: http://{$u}.hatena.ne.jp/hoge
ãã®ãªãã¤ã¬ã¯ã¿ï¼"redir.cgi" ã¨ãã¾ãï¼ãæªç¨ãã¦ã"example.com" ãã¡ã¤ã³ã«ãªãã¤ã¬ã¯ãããããã¨ãç®æãã¾ãããªãã$uã®æ£å¸¸ãªå¤ã¯ "www" ã§ãLFï¼%0A U+000Aï¼ã¯ä½¿ããªãã¨ãã¾ãã
ã¾ãã¯ãä¸çªåºæ¬çãªæ¤æ»æåå3ã¤ã§ãã
â 1A: redir.cgi?u=example.com/www ãâ Location: http://example.com/www.hatena.ne.jp/hoge â 1B: redir.cgi?u=example.com?www ãâ Location: http://example.com?www.hatena.ne.jp/hoge â 1C: redir.cgi?u=example.com%23www (%23 => #) ãâ Location: http://example.com#www.hatena.ne.jp/hoge
ä¸ã®1Aã1Bã1Cã§ã¯ãURLå ã§åºåãã¨ãã¦ä½¿ç¨ããã "/", "?", "#" ã使ã£ã¦ãã¾ãã
ã¢ããªããã©ãã¯ãªã¹ãã§ãã©ã¡ã¼ã¿uã®å¤ãã§ãã¯ããã¦ããã¨ãã¦ããä¸ã®3ã¤ã®è¨å·ã«ã¤ãã¦ã¯å¯¾çããã¦ãããã¨ã¯å²ã¨ããã¾ãããã®å ´åã¯ã以ä¸ã®1Dã1Fã試ãã¾ãã
â 1D: redir.cgi?u=example.com;www ãâ Location: http://example.com;www.hatena.ne.jp/hoge â 1E: redir.cgi?u=example.com:80www ãâ Location: http://example.com:80www.hatena.ne.jp/hoge â 1F: redir.cgi?u=example.com\www ãâ Location: http://example.com\www.hatena.ne.jp/hoge
1D, 1E㯠";" 㨠":" ã使ç¨ãã¦ãã¾ãããããããFirefoxãOperaã§ãã¹ãåã®çµç«¯ã¨ãã¦èªèããã"example.com" ã«ãªãã¤ã¬ã¯ããã¾ãã":" ã使ãå ´åã¯ããã®ç´å¾ã«å¦¥å½ãªãã¼ãçªå·ãä»ã㦠":80" ã®ãããªå¤ã«ããªããã°ãªãã¤ã¬ã¯ããã¾ããã
1F㯠"/" ã®ä»£ããã« "\" ã使ã£ã¦ãã¾ããIEãChromeã§åä½ãã¾ãã
次ããã¯å¶å¾¡æåã使ãæ¤æ»æååã§ãã
â 1G: redir.cgi?u=example.com%00www ãâ ① Location: http://example.com ãâ ② Location: http://example.com[0x00]www.hatena.ne.jp/hoge
1Gã¯NULLï¼%00 U+0000ï¼ã使ã£ã¦ãã¾ããå¿çã®Locationãããã2ãã¿ã¼ã³æ¸ãã¦ãã¾ãããApacheä¸ã®CGIãPHPã§è©¦ãã¦ã¿ãã¨ãNULL以éãæ¶ãã¦ãªããªã£ã①ã®Locationããããè¿ããã¾ãããã®å ´åã¯ãå½ç¶ "example.com" ã«ãªãã¤ã¬ã¯ããã¾ãã
ä»®ã«ã②ã®ãããªå¿çãè¿ã£ã¦ããããã¦ãã®ãã©ã¦ã¶ã¯HTTPãããã®NULL以éãç¡è¦ããã®ã§ã"example.com" ã«ãªãã¤ã¬ã¯ããã¾ãï¼Safariã ãã¯éãï¼ã
ããä¸ã¤å¶å¾¡æåã使ãæ¤æ»æååã§ãã
â 1H: redir.cgi?u=example.com%0Dwww ãâ Location: http://example.com[0x0D]www.hatena.ne.jp/hoge
IEãOperaãChromeã§ã¯ãCRï¼%0D U+000Dï¼ä»¥éãç¡è¦ããã¦ã"example.com" ã«ãªãã¤ã¬ã¯ããã¾ããæ£ç¢ºã«è¨ãã¨ããããã®ãã©ã¦ã¶ã¯CRããããè¡ã®åºåãã¨ãã¦èªèãã¦ãã¾ããã¤ã¾ãããã®æ¤æ»æååã¯ãHTTP Header Injectionãå©ç¨ãã¦ãã¾ãã
ãã¿ã¼ã³2ï¼ã¹ã©ãã·ã¥ãå é ã«ä»ããããå ´å
ä½ãè¦ã¾ãããããããªã±ã¼ã¹ã§ãã
Location: /{$u}
$uã®æ£å¸¸ãªå¤ã¯ "foo/bar.cgi" ã§ãLFï¼%0A U+000Aï¼ã¯ä½¿ããªãã¨ãã¾ãã
ãããªã±ã¼ã¹ã§ã®åºæ¬çãªæ¤æ»æååã¯ä»¥ä¸ã§ãã
â 2A: redir.cgi?u=/example.com/foo/bar.cgi ãâ Location: //example.com/foo/bar.cgi
URLã®å é ã®ã"http:" ã "https:" ã¯çç¥å¯è½ãªã®ã§ã2A㯠"example.com" ã«ãªãã¤ã¬ã¯ããã¾ãã
ããã¦ãã®ã¢ããªã¯ä¸ã®2Aã§è©°ãã®ã§ãããå é ã« "/" ã使ããªãå ´åã¯ä»¥ä¸ã®ãããªæ¤æ»æååãããã¾ãã
â 2B: redir.cgi?u=\example.com/foo/bar.cgi ãâ Location: /\example.com/foo/bar.cgi â 2C: redir.cgi?u=%09/example.com/foo/bar.cgi ãâ Location: /[0x09]/example.com/foo/bar.cgi
2Bã§ã¯ã"/" ã®ä»£ããã« "\" ã使ã£ã¦ãã¾ããIEãChromeã§åä½ãã¾ãã2Cã¯ã¿ãï¼%09 U+0009ï¼ã使ã£ã¦ãã¾ããIEãChromeã¯ãURLã«å«ã¾ããã¿ãçã®æåãç¡è¦ããããã2Aã¨åæ§ã«åä½ãã¾ãã
ãã¿ã¼ã³3ï¼Locationãããã®å é ã«å¤ãå ¥ãå ´å
ãããªã±ã¼ã¹ã§ããä¸çªè¯ãè¦ããã¿ã¼ã³ã§ãã
Location: {$u}
$uã®æ£å¸¸ãªå¤ã¯ "http://www.hatena.ne.jp/foo/" ã§ãLFï¼%0A U+000Aï¼ã¯ä½¿ããªãã¨ãã¾ãã
å¤é¨ã«ãªãã¤ã¬ã¯ãããªãããã«ããã©ã¡ã¼ã¿uã®å¤ãä½ããã®æ¹æ³ã§ãã§ãã¯ãã¦ãã¦ãããããä¸å®å ¨ãªãã°ä¸ã®3Aã3Bãéã£ã¦ãã¾ãããããã¾ããï¼ãã®ãããªå¤ãéããã¨ã¯å°ãªãããã¾ããï¼ã
â 3A: redir.cgi?u=http://www.hatena.ne.jp.example.com/foo/ ãâ Location: http://www.hatena.ne.jp.example.com/foo/ â 3B: redir.cgi?u=http://example.com/http://www.hatena.ne.jp/foo/ ãâ Location: http://example.com/http://www.hatena.ne.jp/foo/
å ã®URLï¼http://www.hatena.ne.jp/ï¼ã®ãµããã¡ã¤ã³ï¼wwwï¼ã®ç®æã®ãã§ãã¯ãä¸å®å ¨ãªãã°ãä¸ã®3Cãéã£ã¦ãã¾ãããããã¾ããã
â 3C: redir.cgi?u=http://example.com?.hatena.ne.jp/foo/ ãâ Location: http://example.com?.hatena.ne.jp/foo/
ããã¿ã¼ã³1ï¼ãµããã¡ã¤ã³é¨åã«å¤ãå ¥ãå ´åãã§è¦ãããã«ãä¸ã®3Cã® "?" ã®ç®æãã";", "#", ":80", "\", NULL, CR ãªã©ã«å¤ããããªã¨ã¼ã·ã§ã³ãããã¾ãã
å é ã "/" ã§å§ã¾ãå¤ã許容ãããå ´åã¯ãä¸ã®3Dã®ãããªæ¤æ»ãã¿ã¼ã³ãéãããããã¾ããã
â 3D: redir.cgi?u=//example.com/foo/ ãâ Location: //example.com/foo/
ããã¿ã¼ã³2ï¼ã¹ã©ãã·ã¥ãå é ã«ä»ããããå ´åãã§ã¿ãããã«ãä¸ã®3Dã® "/" ã "\" ã«ãããªã©ã®ããªã¨ã¼ã·ã§ã³ãããã¾ãã
ãã¹ããããã©ã¦ã¶
IE8ãFirefox3.6ãOpera10ãSafari5ãChrome9ï¼ããããWindows Vistaçï¼ã