简体   繁体   English

React.js 中的安全问题

[英]Questions on Security in React.js

I am building my first application on React.JS and I am wondering how to implement simple security in on the client-side because there are some vulnerabilities that I see such as if you view page source the script tags show you all the Components that you made with all the functioning and rendered pages, Also if there is a basic method to stop XSS from happening that I can build on I would like to see that as well.我正在 React.JS 上构建我的第一个应用程序,我想知道如何在客户端实现简单的安全性,因为我看到了一些漏洞,例如,如果您查看页面源代码,脚本标签会显示您的所有组件使用所有功能和呈现的页面制作,此外,如果有一种基本方法可以阻止 XSS 的发生,我可以在此基础上进行构建,我也希望看到这一点。

I am concerned about how anyone can view a page source on react and see the components from the script tag我担心任何人都可以在 react 上查看页面源并从脚本标签中查看组件

You're not going to be able to prevent people from looking at the code source on the browser, since the browser has to see it and render it.您将无法阻止人们查看浏览器上的代码源,因为浏览器必须看到并呈现它。 You can make it a little harder for people to get to the inspect element, but there is always a way to get to it.你可以让人们更难到达检查元素,但总有办法到达它。

As for XSS, all you can do on the client side is validating input and sanitizing, but you can get around that via watching the network traffic and submitting bad data directly through your own http requests.至于 XSS,您在客户端所能做的就是验证输入和清理,但您可以通过观察网络流量并通过您自己的 http 请求直接提交不良数据来解决这个问题。

Client side is just that, served to the client.客户端就是这样,服务于客户端。

What do you mean by sources?你说的来源是什么意思? It's still a JavaScript and everybody can see the sources, but they will be uglified and minified by Webpack.它仍然是 JavaScript 并且每个人都可以看到来源,但它们将被 Webpack 丑化和缩小。 Regarding XSS.关于 XSS。 Don't worry about it using React.不用担心使用 React。 Your code is already protected thanks to JSX.由于 JSX,您的代码已经受到保护。 String variables in views are escaped automatically.视图中的字符串变量会自动转义。

I suggest you to secure you're service in back-end, because anyone can request to the server trough Postman and can record and repeat your request in BurpSuite;我建议您在后端保护您的服务,因为任何人都可以通过 Postman 向服务器请求,并且可以在 BurpSuite 中记录和重复您的请求; then use security solutions in your back-end code after that use Object Schema validator in your React app to prevent users XSS attacks.然后在您的后端代码中使用安全解决方案,然后在您的 React 应用程序中使用 Object 模式验证器来防止用户 XSS 攻击。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM