以编程方式防止基于浏览器的代码提出HTTP请求
如何防止第三方JS代码从我的Web应用程序中提出HTTP请求?
带有水疗框架(例如React)的基于节点的Web应用程序,将导入数百个(即使不是数千个)的第三方软件包。我没有希望审查所有安全漏洞的来源,零日的利用意味着补丁可能为时已晚。我特别担心由代码提出的HTTP请求,这些请求会收集并将用户数据发送到外部服务。
我想在第三方库中的任何代码进行HTTP请求,无论是通过致电fetch()
,xmlhttprequest
,form posting还是任何其他方式。
我可以想象包装Fet> Fetch
和其他功能,这些功能有效地使其有效,以便只有我的应用程序的代码才能使用它们。
不过,我担心会错过的攻击向量,尤其是围绕DOM操纵,可以将元素插入,例如导致HTTP请求的图像标签,该元素在Querystring中发送有效载荷。
我对构建时间(静态代码分析)以及运行时解决方案感兴趣。而且,如果存在处理任务的现有软件,那就好多了。
How to prevent 3rd-party JS code from making an HTTP request from my web app?
A Node-based web app with an SPA framework (e.g React) imports hundreds, if not thousands, of 3rd-party packages. I have no hope of reviewing all that source for security vulnerabilities and zero-day exploits mean patches can come too late. I'm particularly worried about HTTP requests being made by code that would collect and send user data to outside services.
I would like to prevent any code in 3rd-party libraries making HTTP requests, whether it be through calls to fetch()
, XMLHttpRequest
, form-posting, or any other means.
I can imagine wrapping fetch
and other functions with my own versions of these that effectively make it so that only my app's code can use them.
Still, I worry there will be attack vectors I'll miss, especially around DOM manipulation where elements could be inserted like image tags that cause an HTTP request that sends a payload in the querystring.
I'm interested in build-time (static code analysis), as well as run-time solutions. And if there is existing software that handles the task, so much the better.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论