【发布时间】:2016-11-28 21:19:36
【问题描述】:
我的 node.js 服务器期望从未经身份验证(不受信任)的客户端接收字符串化 JSON 对象。
服务器使用 JSON.parse 来处理数据。 是否可以在来自 websocket 的 JOSN 数据中注入“威胁和操纵”命令?
是否需要考虑任何安全预防措施?
javascript解析中是否有“htmlspecialchars() in php”之类的东西?
服务器:
wsBoss = new WSServer(portboss);
wsBoss.on('connection', function (socket) {
console.log('connected to boss');
socket.on('message', function (msg) {
console.log(JSON.parse(msg).topGeo[0]);
var msgsms="HI";
socket.send(msgsms);
});
客户:
var data={"topGeo":topGeo,
"bottomGeo":bottomGeo,
"concLoad":concLoad}
console.log(topGeo,bottomGeo,depth,generalLoad,concLoad,intervLoad,mode,joistType,units);
websocket.send(JSON.stringify(data));
【问题讨论】:
标签: javascript json node.js security parsing