{"id":477747,"date":"2023-08-09T09:19:35","date_gmt":"2023-08-09T09:19:35","guid":{"rendered":""},"modified":"2023-09-05T11:15:18","modified_gmt":"2023-09-05T11:15:18","slug":"json-hijacking","status":"publish","type":"wiki","link":"https:\/\/oneproxy.pro\/cn\/wiki\/json-hijacking\/","title":{"rendered":"JSON\u52ab\u6301"},"content":{"rendered":"<p>JSON \u52ab\u6301\uff0c\u4e5f\u79f0\u4e3a\u201cJavaScript \u5bf9\u8c61\u8868\u793a\u6cd5\u52ab\u6301\u201d\uff0c\u662f\u4e00\u79cd\u5b89\u5168\u6f0f\u6d1e\uff0c\u4f1a\u5f71\u54cd\u4f7f\u7528 JSON\uff08JavaScript \u5bf9\u8c61\u8868\u793a\u6cd5\uff09\u4f5c\u4e3a\u6570\u636e\u4ea4\u6362\u683c\u5f0f\u7684 Web \u5e94\u7528\u7a0b\u5e8f\u3002\u5f53\u5e94\u7528\u7a0b\u5e8f\u6ca1\u6709\u9002\u5f53\u5730\u9632\u8303\u6b64\u7c7b\u653b\u51fb\u65f6\uff0c\u6b64\u6f0f\u6d1e\u5141\u8bb8\u653b\u51fb\u8005\u4ece\u53d7\u5bb3\u8005\u7684\u6d4f\u89c8\u5668\u4e2d\u7a83\u53d6\u654f\u611f\u6570\u636e\u3002 JSON \u52ab\u6301\u5229\u7528\u540c\u6e90\u7b56\u7565\uff0c\u8fd9\u662f\u4e00\u79cd\u5b89\u5168\u63aa\u65bd\uff0c\u53ef\u9632\u6b62\u7f51\u9875\u5411\u4e0e\u63d0\u4f9b\u7f51\u9875\u7684\u57df\u4e0d\u540c\u7684\u57df\u53d1\u51fa\u8bf7\u6c42\u3002<\/p>\n<h2>JSON \u52ab\u6301\u7684\u8d77\u6e90\u548c\u9996\u6b21\u63d0\u53ca\u7684\u5386\u53f2\u3002<\/h2>\n<p>JSON \u52ab\u6301\u6700\u65e9\u7531 Jeremiah Grossman \u4e8e 2006 \u5e74\u53d1\u73b0\u5e76\u8bb0\u5f55\u3002\u5728\u4ed6\u7684\u7814\u7a76\u4e2d\uff0c\u4ed6\u53d1\u73b0\u5229\u7528 JSON \u54cd\u5e94\u7684 Web \u5e94\u7528\u7a0b\u5e8f\u5f88\u5bb9\u6613\u53d7\u5230\u6b64\u6f0f\u6d1e\u7684\u5f71\u54cd\uff0c\u56e0\u4e3a\u7f3a\u4e4f\u6807\u51c6\u7684\u9632\u62a4\u65b9\u6cd5\u3002\u7b2c\u4e00\u6b21\u63d0\u5230 JSON \u52ab\u6301\u5f15\u8d77\u4e86\u4eba\u4eec\u5bf9\u5728\u6ca1\u6709\u9002\u5f53\u5b89\u5168\u63aa\u65bd\u7684\u60c5\u51b5\u4e0b\u4f7f\u7528 JSON \u4f5c\u4e3a\u6570\u636e\u4ea4\u6362\u683c\u5f0f\u76f8\u5173\u7684\u6f5c\u5728\u98ce\u9669\u7684\u5173\u6ce8\u3002<\/p>\n<h2>\u6709\u5173 JSON \u52ab\u6301\u7684\u8be6\u7ec6\u4fe1\u606f\u3002\u6269\u5c55 JSON \u52ab\u6301\u4e3b\u9898\u3002<\/h2>\n<p>\u5f53 Web \u5e94\u7528\u7a0b\u5e8f\u5728\u672a\u5b9e\u73b0\u9002\u5f53\u7684\u5b89\u5168\u673a\u5236\uff08\u4f8b\u5982\u5b89\u5168 JSON \u54cd\u5e94\u5305\u88c5\u5668\uff09\u7684\u60c5\u51b5\u4e0b\u63d0\u4f9b JSON \u6570\u636e\u65f6\uff0c\u5c31\u4f1a\u53d1\u751f JSON \u52ab\u6301\u3002\u901a\u5e38\uff0c\u5f53\u7f51\u9875\u4ece\u670d\u52a1\u5668\u8bf7\u6c42 JSON \u6570\u636e\u65f6\uff0c\u5b83\u4f1a\u6536\u5230\u4e00\u4e2a\u5408\u6cd5\u7684 JSON \u5bf9\u8c61\uff0c\u8be5\u5bf9\u8c61\u53ef\u4ee5\u5f88\u5bb9\u6613\u5730\u88ab\u9875\u9762\u4e0a\u7684 JavaScript \u4ee3\u7801\u89e3\u6790\u548c\u4f7f\u7528\u3002<\/p>\n<p>\u7136\u800c\uff0c\u5728JSON\u52ab\u6301\u7684\u60c5\u51b5\u4e0b\uff0c\u653b\u51fb\u8005\u53ef\u4ee5\u5229\u7528\u540c\u6e90\u7b56\u7565\u6765\u7a83\u53d6JSON\u6570\u636e\u3002\u653b\u51fb\u8005\u6b3a\u9a97\u53d7\u5bb3\u8005\u7684\u6d4f\u89c8\u5668\u5411\u653b\u51fb\u8005\u63a7\u5236\u7684\u6076\u610f\u670d\u52a1\u5668\u53d1\u51fa\u8de8\u6e90\u8bf7\u6c42\u3002\u7531\u4e8e\u540c\u6e90\u7b56\u7565\u4e0d\u9002\u7528\u4e8e JSON \u8bf7\u6c42\uff08\u4e0e\u4f20\u7edf\u7684 Ajax \u8bf7\u6c42\u4e0d\u540c\uff09\uff0c\u56e0\u6b64\u6076\u610f\u670d\u52a1\u5668\u53ef\u4ee5\u76f4\u63a5\u63a5\u6536 JSON \u6570\u636e\u3002<\/p>\n<p>\u5982\u679c\u7f3a\u5c11\u9002\u5f53\u7684\u5b89\u5168\u6807\u5934\u6216\u54cd\u5e94\u5305\u88c5\u5668\uff08\u4f8b\u5982\u201cX-Content-Type-Options: nosniff\u201d\u6216\u201cwhile(1);\u201d\uff09\uff0c\u653b\u51fb\u8005\u5c31\u53ef\u4ee5\u6210\u529f\u6267\u884c JSON \u52ab\u6301\u653b\u51fb\u3002\u901a\u8fc7\u7a83\u53d6\u654f\u611f\u6570\u636e\uff0c\u653b\u51fb\u8005\u53ef\u80fd\u4f1a\u635f\u5bb3\u7528\u6237\u7684\u9690\u79c1\u548c\u5b89\u5168\u3002<\/p>\n<h2>JSON\u52ab\u6301\u7684\u5185\u90e8\u7ed3\u6784\u3002 JSON \u52ab\u6301\u662f\u5982\u4f55\u5de5\u4f5c\u7684\u3002<\/h2>\n<p>JSON \u52ab\u6301\u4e3b\u8981\u9488\u5bf9\u4f7f\u7528 JSON \u54cd\u5e94\u800c\u4e0d\u91c7\u7528\u7279\u5b9a\u5b89\u5168\u6280\u672f\u7684 Web \u5e94\u7528\u7a0b\u5e8f\u3002\u653b\u51fb\u7684\u5185\u90e8\u7ed3\u6784\u6d89\u53ca\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<ol>\n<li>\u53d7\u5bb3\u8005\u7684\u6d4f\u89c8\u5668\u5411 Web \u670d\u52a1\u5668\u53d1\u9001 JSON \u6570\u636e\u8bf7\u6c42\u3002<\/li>\n<li>Web \u670d\u52a1\u5668\u5904\u7406\u8bf7\u6c42\u5e76\u5728\u54cd\u5e94\u4e2d\u53d1\u56de JSON \u6570\u636e\u3002<\/li>\n<li>\u653b\u51fb\u8005\u6b3a\u9a97\u53d7\u5bb3\u8005\u7684\u6d4f\u89c8\u5668\u53d1\u51fa\u989d\u5916\u7684\u8de8\u57df\u8bf7\u6c42\uff0c\u8be5\u8bf7\u6c42\u5b9a\u5411\u5230\u653b\u51fb\u8005\u7684\u670d\u52a1\u5668\u3002<\/li>\n<li>\u7531\u4e8e\u540c\u6e90\u7b56\u7565\u4e0d\u9002\u7528\u4e8e JSON \u8bf7\u6c42\uff0c\u653b\u51fb\u8005\u7684\u670d\u52a1\u5668\u76f4\u63a5\u62e6\u622a\u6765\u81ea\u53d7\u5bb3\u8005\u6d4f\u89c8\u5668\u7684 JSON \u54cd\u5e94\u3002<\/li>\n<li>\u653b\u51fb\u8005\u73b0\u5728\u53ef\u4ee5\u8bbf\u95ee\u654f\u611f\u7684 JSON \u6570\u636e\uff0c\u800c\u8fd9\u4e9b\u6570\u636e\u672c\u5e94\u53ea\u80fd\u5728 Web \u5e94\u7528\u7a0b\u5e8f\u7684\u57df\u5185\u8bbf\u95ee\u3002<\/li>\n<\/ol>\n<h2>JSON\u52ab\u6301\u7684\u5173\u952e\u7279\u5f81\u5206\u6790\u3002<\/h2>\n<p>JSON \u52ab\u6301\u7684\u4e3b\u8981\u7279\u5f81\u5305\u62ec\uff1a<\/p>\n<ul>\n<li>\u5229\u7528\u540c\u6e90\u7b56\u7565\uff1aJSON\u52ab\u6301\u5229\u7528\u540c\u6e90\u7b56\u7565\u5bf9JSON\u8bf7\u6c42\u7684\u8c41\u514d\uff0c\u4f7f\u5f97\u653b\u51fb\u8005\u53ef\u4ee5\u62e6\u622aJSON\u54cd\u5e94\u3002<\/li>\n<li>\u7f3a\u4e4f\u6b63\u786e\u7684\u54cd\u5e94\u5305\u88c5\u5668\uff1a\u7f3a\u4e4f\u5b89\u5168\u7684 JSON \u54cd\u5e94\u5305\u88c5\u5668\uff0c\u4f8b\u5982\u201cwhile(1);\u201d\u6216\u201cX-Content-Type-Options: nosniff\u201d\u53ef\u80fd\u4f1a\u4f7f Web \u5e94\u7528\u7a0b\u5e8f\u5bb9\u6613\u53d7\u5230 JSON \u52ab\u6301\u3002<\/li>\n<li>\u5173\u6ce8 JSON \u7aef\u70b9\uff1a\u653b\u51fb\u4ee5\u5229\u7528 JSON \u7aef\u70b9\u8fdb\u884c\u6570\u636e\u4ea4\u6362\u7684 Web \u5e94\u7528\u7a0b\u5e8f\u4e3a\u4e2d\u5fc3\u3002<\/li>\n<\/ul>\n<h2>JSON \u52ab\u6301\u7684\u7c7b\u578b<\/h2>\n<p>\u6839\u636e\u6267\u884c\u653b\u51fb\u7684\u65b9\u6cd5\uff0cJSON \u52ab\u6301\u53ef\u5206\u4e3a\u4e24\u79cd\u4e3b\u8981\u7c7b\u578b\uff1a<\/p>\n<ol>\n<li>\n<p><strong>\u76f4\u63a5JSON\u52ab\u6301\uff1a<\/strong> \u5728\u8fd9\u79cd\u7c7b\u578b\u7684\u653b\u51fb\u4e2d\uff0c\u653b\u51fb\u8005\u4f1a\u6b3a\u9a97\u53d7\u5bb3\u8005\u7684\u6d4f\u89c8\u5668\u76f4\u63a5\u5411\u653b\u51fb\u8005\u7684\u670d\u52a1\u5668\u53d1\u9001 JSON \u8bf7\u6c42\u3002\u7136\u540e\u653b\u51fb\u8005\u7684\u670d\u52a1\u5668\u76f4\u63a5\u63a5\u6536 JSON \u6570\u636e\uff0c\u65e0\u9700\u4efb\u4f55\u989d\u5916\u6b65\u9aa4\u3002<\/p>\n<\/li>\n<li>\n<p><strong>JSONP\uff08\u5e26\u586b\u5145\u7684 JSON\uff09\u52ab\u6301\uff1a<\/strong> JSONP \u662f\u4e00\u79cd\u7528\u4e8e\u514b\u670d\u53d1\u51fa\u8de8\u57df\u8bf7\u6c42\u7684\u540c\u6e90\u7b56\u7565\u9650\u5236\u7684\u6280\u672f\u3002\u5728 JSONP \u52ab\u6301\u4e2d\uff0c\u653b\u51fb\u8005\u64cd\u7eb5 JSONP \u56de\u8c03\u51fd\u6570\u6765\u63a5\u6536 JSON \u6570\u636e\u5e76\u53ef\u80fd\u63d0\u53d6\u654f\u611f\u4fe1\u606f\u3002<\/p>\n<\/li>\n<\/ol>\n<p>\u4e0b\u9762\u7684\u6bd4\u8f83\u8868\u7a81\u51fa\u663e\u793a\u4e86\u4e24\u79cd\u7c7b\u578b\u7684 JSON \u52ab\u6301\u4e4b\u95f4\u7684\u5dee\u5f02\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>\u7c7b\u578b<\/th>\n<th>\u65b9\u6cd5<\/th>\n<th>\u4f18\u70b9<\/th>\n<th>\u7f3a\u70b9<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u76f4\u63a5JSON\u52ab\u6301<\/td>\n<td>\u5229\u7528 JSON \u8bf7\u6c42\u7684\u540c\u6e90\u7b56\u7565<\/td>\n<td>\u6267\u884c\u7b80\u5355\uff0c\u76f4\u63a5\u8bbf\u95eeJSON\u6570\u636e<\/td>\n<td>\u5728\u65e5\u5fd7\u4e2d\u66f4\u660e\u663e\uff0c\u66f4\u5bb9\u6613\u68c0\u6d4b<\/td>\n<\/tr>\n<tr>\n<td>JSONP\u52ab\u6301<\/td>\n<td>\u64cd\u4f5c JSONP \u56de\u8c03\u51fd\u6570<\/td>\n<td>\u53ef\u80fd\u7ed5\u8fc7\u540c\u6e90\u7b56\u7565<\/td>\n<td>\u9700\u8981\u6613\u53d7\u653b\u51fb\u7684 JSONP \u5b9e\u73b0<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>JSON\u52ab\u6301\u7684\u4f7f\u7528\u65b9\u6cd5\u3001\u4f7f\u7528\u4e2d\u9047\u5230\u7684\u95ee\u9898\u4ee5\u53ca\u89e3\u51b3\u65b9\u6848\u3002<\/h2>\n<h3>\u5229\u7528\u65b9\u6cd5<\/h3>\n<p>JSON \u52ab\u6301\u53ef\u7528\u4e8e\u83b7\u53d6\u654f\u611f\u4fe1\u606f\uff0c\u4f8b\u5982\u7528\u6237\u51ed\u636e\u3001\u8eab\u4efd\u9a8c\u8bc1\u4ee4\u724c\u6216 JSON \u54cd\u5e94\u4e2d\u5b58\u50a8\u7684\u5176\u4ed6\u654f\u611f\u6570\u636e\u3002\u653b\u51fb\u8005\u53ef\u80fd\u4f1a\u6ee5\u7528\u88ab\u76d7\u6570\u636e\u6765\u5b9e\u73b0\u5404\u79cd\u6076\u610f\u76ee\u7684\u3002<\/p>\n<h3>\u95ee\u9898\u4e0e\u89e3\u51b3\u65b9\u6848<\/h3>\n<p>JSON \u52ab\u6301\u7684\u4e3b\u8981\u95ee\u9898\u662f\u8bb8\u591a\u4f7f\u7528 JSON \u4f5c\u4e3a\u6570\u636e\u4ea4\u6362\u683c\u5f0f\u7684 Web \u5e94\u7528\u7a0b\u5e8f\u7f3a\u4e4f\u6807\u51c6\u7684\u5b89\u5168\u63aa\u65bd\u3002\u4e3a\u4e86\u51cf\u8f7b\u4e0e JSON \u52ab\u6301\u76f8\u5173\u7684\u98ce\u9669\uff0c\u5f00\u53d1\u4eba\u5458\u548c\u7f51\u7ad9\u7ba1\u7406\u5458\u53ef\u4ee5\u5b9e\u65bd\u4ee5\u4e0b\u89e3\u51b3\u65b9\u6848\uff1a<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u5168 JSON \u54cd\u5e94\u5305\u88c5\u5668\uff1a<\/strong> \u5c06 JSON \u54cd\u5e94\u5c01\u88c5\u5728\u5b89\u5168\u5305\u88c5\u5668\u4e2d\uff0c\u4f8b\u5982\u201cwhile(1);\u201d\u6216\u201cX-Content-Type-Options\uff1anosniff\u201d\u3002\u8fd9\u53ef\u4ee5\u9632\u6b62\u6d4f\u89c8\u5668\u76f4\u63a5\u89e3\u6790 JSON \u6570\u636e\uff0c\u4ece\u800c\u4f7f\u6f5c\u5728\u653b\u51fb\u8005\u65e0\u6cd5\u8bbf\u95ee\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u8de8\u6e90\u8d44\u6e90\u5171\u4eab\uff08CORS\uff09\uff1a<\/strong> \u5b9e\u65bdCORS\u7b56\u7565\u53ef\u4ee5\u9650\u5236\u5bf9JSON\u6570\u636e\u7684\u8de8\u57df\u8bbf\u95ee\uff0c\u6709\u6548\u9632\u6b62\u653b\u51fb\u8005\u5229\u7528\u540c\u6e90\u7b56\u7565\u8c41\u514d\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u57fa\u4e8e\u4ee4\u724c\u7684\u8eab\u4efd\u9a8c\u8bc1\uff1a<\/strong> \u5229\u7528 OAuth \u7b49\u57fa\u4e8e\u4ee4\u724c\u7684\u8eab\u4efd\u9a8c\u8bc1\u65b9\u6cd5\uff0c\u6709\u52a9\u4e8e\u9632\u6b62\u672a\u7ecf\u6388\u6743\u7684\u8bbf\u95ee\u5e76\u51cf\u8f7b JSON \u52ab\u6301\u7684\u5f71\u54cd\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u5185\u5bb9\u5b89\u5168\u7b56\u7565 (CSP)\uff1a<\/strong> \u901a\u8fc7\u914d\u7f6e CSP \u6807\u5934\uff0c\u7ba1\u7406\u5458\u53ef\u4ee5\u63a7\u5236\u5141\u8bb8\u54ea\u4e9b\u57df\u5728\u5176\u7f51\u9875\u4e0a\u6267\u884c\u811a\u672c\uff0c\u4ece\u800c\u964d\u4f4e JSON \u52ab\u6301\u7684\u98ce\u9669\u3002<\/p>\n<\/li>\n<\/ol>\n<h2>\u4ee5\u8868\u683c\u548c\u5217\u8868\u7684\u5f62\u5f0f\u5217\u51fa\u4e3b\u8981\u7279\u5f81\u4ee5\u53ca\u4e0e\u7c7b\u4f3c\u672f\u8bed\u7684\u5176\u4ed6\u6bd4\u8f83\u3002<\/h2>\n<p>\u4e0b\u9762\u662f JSON \u52ab\u6301\u7c7b\u4f3c\u672f\u8bed\u548c\u76f8\u5173\u6982\u5ff5\u7684\u5bf9\u7167\u8868\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>\u5b66\u671f<\/th>\n<th>\u63cf\u8ff0<\/th>\n<th>\u4e0d\u540c\u4e4b\u5904<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>JSON\u52ab\u6301<\/td>\n<td>\u5229\u7528 JSON \u8bf7\u6c42\u7684\u540c\u6e90\u7b56\u7565\u8c41\u514d\u7684\u6f0f\u6d1e\u3002<\/td>\n<td>\u7279\u5b9a\u4e8e JSON \u54cd\u5e94\uff0c\u9488\u5bf9\u6ca1\u6709\u5b89\u5168 JSON \u54cd\u5e94\u5305\u88c5\u5668\u7684 Web \u5e94\u7528\u7a0b\u5e8f\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u8de8\u7ad9\u811a\u672c<\/td>\n<td>\u5c06\u6076\u610f\u811a\u672c\u6ce8\u5165 Web \u5e94\u7528\u7a0b\u5e8f\u4ee5\u7a83\u53d6\u6570\u636e\u6216\u52ab\u6301\u7528\u6237\u4f1a\u8bdd\u7684\u653b\u51fb\u3002<\/td>\n<td>\u4e13\u6ce8\u4e8e\u6ce8\u5165\u811a\u672c\uff0c\u800c JSON \u52ab\u6301\u7684\u76ee\u6807\u662f\u76f4\u63a5\u8bbf\u95ee JSON \u6570\u636e\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u8de8\u7ad9\u8bf7\u6c42\u4f2a\u9020 (CSRF)<\/td>\n<td>\u653b\u51fb\u8bf1\u9a97\u7528\u6237\u5728\u53d7\u4fe1\u4efb\u7684\u7ad9\u70b9\u4e0a\u6267\u884c\u4e0d\u9700\u8981\u7684\u64cd\u4f5c\u3002<\/td>\n<td>CSRF \u5173\u6ce8\u7528\u6237\u64cd\u4f5c\uff0c\u800c JSON \u52ab\u6301\u5219\u6d89\u53ca\u5229\u7528 JSON \u7684\u540c\u6e90\u7b56\u7565\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u4e0e JSON \u52ab\u6301\u76f8\u5173\u7684\u672a\u6765\u524d\u666f\u548c\u6280\u672f\u3002<\/h2>\n<p>\u968f\u7740 Web \u6280\u672f\u7684\u53d1\u5c55\uff0c\u4e0e JSON \u52ab\u6301\u76f8\u5173\u7684\u6f5c\u5728\u98ce\u9669\u4e5f\u5728\u4e0d\u65ad\u589e\u52a0\u3002\u5f00\u53d1\u4eba\u5458\u548c\u5b89\u5168\u4e13\u5bb6\u4e0d\u65ad\u5bfb\u6c42\u521b\u65b0\u65b9\u6cd5\u6765\u9632\u6b62\u6b64\u7c7b\u6f0f\u6d1e\u3002\u672a\u6765\u4e0e JSON \u52ab\u6301\u76f8\u5173\u7684\u4e00\u4e9b\u6f5c\u5728\u89c2\u70b9\u548c\u6280\u672f\u53ef\u80fd\u5305\u62ec\uff1a<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u5168 JSON \u54cd\u5e94\u5305\u88c5\u5668\u7684\u6807\u51c6\u5316\uff1a<\/strong> \u91c7\u7528\u6807\u51c6\u5316\u7684\u5b89\u5168 JSON \u54cd\u5e94\u5305\u88c5\u5668\u53ef\u4ee5\u4f7f\u5f00\u53d1\u4eba\u5458\u66f4\u8f7b\u677e\u5730\u4fdd\u62a4 JSON \u6570\u636e\u514d\u53d7\u52ab\u6301\u653b\u51fb\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u6539\u8fdb\u4e86 JSON \u7684\u540c\u6e90\u7b56\u7565\uff1a<\/strong> \u589e\u5f3a\u540c\u6e90\u7b56\u7565\u4ee5\u66f4\u5168\u9762\u5730\u6db5\u76d6 JSON \u8bf7\u6c42\u53ef\u4ee5\u964d\u4f4e JSON \u52ab\u6301\u7684\u98ce\u9669\u3002<\/p>\n<\/li>\n<li>\n<p><strong>Web \u5e94\u7528\u7a0b\u5e8f\u9632\u706b\u5899 (WAF) \u7684\u8fdb\u6b65\uff1a<\/strong> Web \u5e94\u7528\u7a0b\u5e8f\u9632\u706b\u5899\u53ef\u4ee5\u7ed3\u5408\u66f4\u590d\u6742\u7684\u7b97\u6cd5\u6765\u6709\u6548\u5730\u68c0\u6d4b\u548c\u963b\u6b62 JSON \u52ab\u6301\u5c1d\u8bd5\u3002<\/p>\n<\/li>\n<li>\n<p><strong>JSON Web \u4ee4\u724c (JWT) \u7684\u91c7\u7528\u7387\u589e\u52a0\uff1a<\/strong> JWT \u63d0\u4f9b\u4e86\u4e00\u79cd\u5728\u5404\u65b9\u4e4b\u95f4\u4f5c\u4e3a JSON \u5bf9\u8c61\u4f20\u8f93\u4fe1\u606f\u7684\u5b89\u5168\u65b9\u5f0f\uff0c\u4f7f\u5176\u4e0d\u6613\u53d7\u5230 JSON \u52ab\u6301\u3002<\/p>\n<\/li>\n<\/ol>\n<h2>\u5982\u4f55\u4f7f\u7528\u4ee3\u7406\u670d\u52a1\u5668\u6216\u5982\u4f55\u5c06\u4ee3\u7406\u670d\u52a1\u5668\u4e0e JSON \u52ab\u6301\u76f8\u5173\u8054\u3002<\/h2>\n<p>\u4ee3\u7406\u670d\u52a1\u5668\u53ef\u4ee5\u5145\u5f53\u5ba2\u6237\u7aef\u548c Web \u670d\u52a1\u5668\u4e4b\u95f4\u7684\u4e2d\u4ecb\uff0c\u4ece\u800c\u5728\u964d\u4f4e JSON \u52ab\u6301\u98ce\u9669\u65b9\u9762\u53d1\u6325\u4f5c\u7528\u3002\u4ee5\u4e0b\u662f\u4ee3\u7406\u670d\u52a1\u5668\u4e0e JSON \u52ab\u6301\u7684\u5173\u8054\u65b9\u5f0f\uff1a<\/p>\n<ol>\n<li>\n<p><strong>\u8bf7\u6c42\u8fc7\u6ee4\uff1a<\/strong> \u4ee3\u7406\u670d\u52a1\u5668\u53ef\u4ee5\u914d\u7f6e\u4e3a\u8fc7\u6ee4\u4f20\u5165\u7684 JSON \u8bf7\u6c42\uff0c\u963b\u6b62\u90a3\u4e9b\u663e\u793a\u51fa\u6f5c\u5728 JSON \u52ab\u6301\u5c1d\u8bd5\u8ff9\u8c61\u7684\u8bf7\u6c42\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u54cd\u5e94\u5305\u88c5\uff1a<\/strong> \u4ee3\u7406\u670d\u52a1\u5668\u53ef\u4ee5\u5728\u5c06 JSON \u54cd\u5e94\u4f20\u9012\u7ed9\u5ba2\u6237\u7aef\u4e4b\u524d\u4f7f\u7528\u5b89\u5168\u54cd\u5e94\u6807\u5934\uff08\u4f8b\u5982\u201cwhile(1);\u201d\uff09\u6765\u5305\u88c5 JSON \u54cd\u5e94\uff0c\u4ece\u800c\u63d0\u4f9b\u989d\u5916\u7684\u5b89\u5168\u5c42\u3002<\/p>\n<\/li>\n<li>\n<p><strong>CORS \u7ba1\u7406\uff1a<\/strong> \u4ee3\u7406\u670d\u52a1\u5668\u53ef\u4ee5\u6267\u884c\u4e25\u683c\u7684 CORS \u7b56\u7565\uff0c\u9632\u6b62\u5bf9 JSON \u6570\u636e\u8fdb\u884c\u672a\u7ecf\u6388\u6743\u7684\u8bbf\u95ee\uff0c\u5e76\u6700\u5927\u9650\u5ea6\u5730\u964d\u4f4e JSON \u52ab\u6301\u7684\u98ce\u9669\u3002<\/p>\n<\/li>\n<\/ol>\n<h2>\u76f8\u5173\u94fe\u63a5<\/h2>\n<p>\u6709\u5173JSON\u52ab\u6301\u548cWeb\u5e94\u7528\u7a0b\u5e8f\u5b89\u5168\u7684\u66f4\u591a\u4fe1\u606f\uff0c\u60a8\u53ef\u4ee5\u53c2\u8003\u4ee5\u4e0b\u8d44\u6e90\uff1a<\/p>\n<ol>\n<li><a href=\"https:\/\/owasp.org\/www-community\/attacks\/JSON_Hijacking\" target=\"_new\" rel=\"noopener nofollow\">OWASP JSON \u52ab\u6301<\/a><\/li>\n<li><a href=\"https:\/\/www.jeremiahgrossman.com\/2006\/01\/advanced-web-attack-techniques-using.html\" target=\"_new\" rel=\"noopener nofollow\">\u6770\u91cc\u7c73\u4e9a\u00b7\u683c\u7f57\u65af\u66fc\u7684\u535a\u5ba2<\/a><\/li>\n<li><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/Security\/Same-origin_policy\" target=\"_new\" rel=\"noopener nofollow\">Mozilla \u5f00\u53d1\u8005\u7f51\u7edc (MDN) \u2013 \u540c\u6e90\u653f\u7b56<\/a><\/li>\n<\/ol>\n<p>\u8bf7\u8bb0\u4f4f\uff0c\u4e86\u89e3\u5e76\u89e3\u51b3 JSON \u52ab\u6301\u7684\u98ce\u9669\u5bf9\u4e8e Web \u5e94\u7528\u7a0b\u5e8f\u5f00\u53d1\u4eba\u5458\u548c\u7ba1\u7406\u5458\u786e\u4fdd\u7528\u6237\u6570\u636e\u7684\u5b89\u5168\u548c\u9690\u79c1\u81f3\u5173\u91cd\u8981\u3002\u5b9e\u65bd\u6700\u4f73\u5b9e\u8df5\u5e76\u53ca\u65f6\u4e86\u89e3\u6700\u65b0\u7684\u5b89\u5168\u63aa\u65bd\u5c06\u6709\u52a9\u4e8e\u9632\u8303\u6b64\u7c7b\u6f0f\u6d1e\u3002<\/p>","protected":false},"featured_media":477748,"menu_order":0,"template":"","meta":{"_acf_changed":false,"content-type":"","inline_featured_image":false,"footnotes":""},"class_list":["post-477747","wiki","type-wiki","status-publish","has-post-thumbnail","hentry"],"acf":{"faq_title":"Frequently Asked Questions about <mark>JSON Hijacking: An Encyclopedia Article<\/mark>","faq_items":[{"question":"What is JSON hijacking?","answer":"<p>JSON hijacking, also known as \"JavaScript Object Notation hijacking,\" is a security vulnerability that affects web applications using JSON as a data interchange format. It allows attackers to steal sensitive data from the victim's browser when the application lacks proper security measures.<\/p>"},{"question":"Who discovered JSON hijacking, and when was it first mentioned?","answer":"<p>JSON hijacking was first discovered and documented by Jeremiah Grossman in 2006. He brought attention to this vulnerability, highlighting the risks associated with using JSON without appropriate security measures.<\/p>"},{"question":"How does JSON hijacking work?","answer":"<p>JSON hijacking exploits the same-origin policy exemption for JSON requests. The attacker tricks the victim's browser into making an additional cross-origin request, which is intercepted by the attacker's server, granting them direct access to the JSON data.<\/p>"},{"question":"What are the key features of JSON hijacking?","answer":"<p>Key features include exploiting the same-origin policy, absence of secure JSON response wrappers, and targeting web applications using JSON endpoints for data exchange.<\/p>"},{"question":"What are the types of JSON hijacking?","answer":"<p>JSON hijacking can be classified into two types:<\/p><ol><li>Direct JSON hijacking: The attacker tricks the victim's browser to send JSON directly to the attacker's server.<\/li><li>JSONP hijacking: The attacker manipulates the JSONP callback function to extract JSON data.<\/li><\/ol>"},{"question":"How can JSON hijacking be mitigated?","answer":"<p>To prevent JSON hijacking, developers can implement secure JSON response wrappers, utilize CORS policies, employ token-based authentication, and configure Content Security Policy (CSP) headers.<\/p>"},{"question":"How does JSON hijacking differ from Cross-Site Scripting (XSS) and Cross-Site Request Forgery (CSRF)?","answer":"<p>JSON hijacking targets the direct access to JSON data exploiting same-origin policy. XSS injects malicious scripts into web apps, while CSRF tricks users into performing unwanted actions on trusted sites.<\/p>"},{"question":"What are the future perspectives and technologies related to JSON hijacking?","answer":"<p>Future developments may include standardized secure JSON response wrappers, improved same-origin policy for JSON, and increased adoption of JSON Web Tokens (JWT) for secure data transmission.<\/p>"},{"question":"How can proxy servers help protect against JSON hijacking?","answer":"<p>Proxy servers can act as intermediaries between clients and web servers, filtering requests, wrapping responses securely, and managing CORS to minimize the risk of JSON hijacking.<\/p>"}]},"_links":{"self":[{"href":"https:\/\/oneproxy.pro\/cn\/wp-json\/wp\/v2\/wiki\/477747","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oneproxy.pro\/cn\/wp-json\/wp\/v2\/wiki"}],"about":[{"href":"https:\/\/oneproxy.pro\/cn\/wp-json\/wp\/v2\/types\/wiki"}],"version-history":[{"count":0,"href":"https:\/\/oneproxy.pro\/cn\/wp-json\/wp\/v2\/wiki\/477747\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/oneproxy.pro\/cn\/wp-json\/wp\/v2\/media\/477748"}],"wp:attachment":[{"href":"https:\/\/oneproxy.pro\/cn\/wp-json\/wp\/v2\/media?parent=477747"}],"curies":[{"name":"\u53ef\u6e7f\u6027\u7c89\u5242","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}