在跨域请求中,JSONP比JSON更安全吗?

时间:2022-10-07 16:36:33

Why do browsers allow cross-origin JSONP requests and do not allow JSON requests? I know that JSON requests are not allowed to prevent XSS, but I don't see how JSONP is safer than JSON.

为什么浏览器允许跨源JSONP请求而不允许JSON请求?我知道JSON请求不允许阻止XSS,但是我不认为JSONP比JSON更安全。

In fact, could JSONP be even more dangerous because it is technically a script, where JSON is just a text string?

实际上,JSONP可能更危险,因为它在技术上是一个脚本,JSON只是一个文本字符串?

2 个解决方案

#1


3  

JSONP is not safer. It's a workaround/loophole/hack to get past the same origin policy.

JSONP是不安全。通过相同的原产地政策是一个解决办法/漏洞/黑客。

CORS is the safer alternative to JSONP.

CORS是JSONP更安全的替代品。

#2


0  

Because cross-domain JSON is blocked, sensitive data can be transmitted using JSON, rather than JSONP. This prevents XSS. Additionally, a server should not send sensitive data using JSONP. Thus, sending data using JSON protects it from unauthorized observation. JSON is safer in this sense.

由于跨域JSON被阻塞,敏感数据可以使用JSON传输,而不是JSONP。这可以防止XSS。此外,服务器不应该使用JSONP发送敏感数据。因此,使用JSON发送数据保护它免受未经授权的观察。从这个意义上讲,JSON更安全。

#1


3  

JSONP is not safer. It's a workaround/loophole/hack to get past the same origin policy.

JSONP是不安全。通过相同的原产地政策是一个解决办法/漏洞/黑客。

CORS is the safer alternative to JSONP.

CORS是JSONP更安全的替代品。

#2


0  

Because cross-domain JSON is blocked, sensitive data can be transmitted using JSON, rather than JSONP. This prevents XSS. Additionally, a server should not send sensitive data using JSONP. Thus, sending data using JSON protects it from unauthorized observation. JSON is safer in this sense.

由于跨域JSON被阻塞,敏感数据可以使用JSON传输,而不是JSONP。这可以防止XSS。此外,服务器不应该使用JSONP发送敏感数据。因此,使用JSON发送数据保护它免受未经授权的观察。从这个意义上讲,JSON更安全。