开发者

SSL: How to balance API performance with security?

开发者 https://www.devze.com 2023-01-25 15:29 出处:网络
APIs with terrible security are common place. Case in point - this story on TechCrunch. It begs the question, how do you balance security with performance when it comes to SSL? Obviously, sensitive开

APIs with terrible security are common place. Case in point - this story on TechCrunch.

It begs the question, how do you balance security with performance when it comes to SSL? Obviously, sensitive开发者_运维问答 information such as usernames and password should be sent over SSL. What about subsequent calls that perhaps use an API key? At what point is it okay to use an unencrypted connection when it comes to API calls that require proof of identity?


If you allow mixed content, then a man-in-the-middle, can rewrite mixed content to inject JS to steal sensitive information already in the page. With cafés and the like providing free wireless access, man-in-the-middle attacks are not all that difficult.

https://www.eff.org/pages/how-deploy-https-correctly gives a good explanation:

When hosting an application over HTTPS, there can be no mixed content; that is, all content in the page must be fetched via HTTPS. It is common to see partial HTTPS support on sites, in which the main pages are fetched via HTTPS but some or all of the media elements, stylesheets, and JavaScript in the page are fetched via HTTP.

This is unsafe because although the main page load is protected against active and passive network attack, none of the other resources are. If a page loads some JavaScript or CSS code via HTTP, an attacker can provide a false, malicious code file and take over the page’s DOM once it loads. Then, the user would be back to a situation of having no security. This is why all mainstream browsers warn users about pages that load mixed content. Nor is it safe to reference images via HTTP: What if the attacker swapped the Save Message and Delete Message icons in a webmail app?

You must serve the entire application domain over HTTPS. Redirect HTTP requests with HTTP 301 or 302 responses to the equivalent HTTPS resource.


The problem is that without understanding the performance of your application it is just wrong to try and optimize the application without metrics. This is what leads to decisions by devs to leave an API unecrypted simply thinking it's eeking out another 10ms's of performance. Simply put the best way to balance security concerns versus performance is to worry about security first, get some load from real customers(not whiteboard stick figures being obsessed over by some architect) and get real metrics from your code when you suspect performance might be an issue. I have a weird feeling that it won't be security related.


You need to gather some evidence about the alleged performance issues of SSL before you leap. You might get quite a surprise.

0

精彩评论

暂无评论...
验证码 换一张
取 消