Authored by 李奇

历史消息漏洞修改、uid删除暴露

@@ -42,7 +42,6 @@ exports.page = (req, res, next) => { @@ -42,7 +42,6 @@ exports.page = (req, res, next) => {
42 imCs: global.yoho.config.domains.imCs, 42 imCs: global.yoho.config.domains.imCs,
43 imSocket: global.yoho.config.domains.imSocket, 43 imSocket: global.yoho.config.domains.imSocket,
44 userData: { 44 userData: {
45 - uid: uid,  
46 encrypteduid: crypto.encryption(null, uid + ''), 45 encrypteduid: crypto.encryption(null, uid + ''),
47 avatar: helpers.image(userinfo.head_ico, 100, 100), 46 avatar: helpers.image(userinfo.head_ico, 100, 100),
48 uname: userinfo.profile_name 47 uname: userinfo.profile_name
@@ -80,15 +79,10 @@ exports.getOrders = (req, res, next) => { @@ -80,15 +79,10 @@ exports.getOrders = (req, res, next) => {
80 * 79 *
81 */ 80 */
82 exports.fetchHistory = (req, res) => { 81 exports.fetchHistory = (req, res) => {
83 - let uid = req.user.uid;  
84 -  
85 - if (!uid) {  
86 - uid = req.query.uid;  
87 - }  
88 -  
89 - const endTime = req.query.endTime; 82 + const encryptedUid = req.body.encryptedUid;
  83 + const endTime = req.body.endTime;
90 84
91 - imApi.fetchImHistory(uid, endTime).then(result => { 85 + imApi.fetchImHistory(encryptedUid, endTime).then(result => {
92 res.json(result); 86 res.json(result);
93 }); 87 });
94 }; 88 };
@@ -115,16 +109,11 @@ exports.msghistory = (req, res) => { @@ -115,16 +109,11 @@ exports.msghistory = (req, res) => {
115 * content 留言内容 109 * content 留言内容
116 */ 110 */
117 exports.saveMSG = (req, res) => { 111 exports.saveMSG = (req, res) => {
118 - let uid = req.user.uid;  
119 -  
120 - if (!uid) {  
121 - uid = req.body.uid;  
122 - }  
123 - 112 + let encryptedUid = req.body.encryptedUid;
124 const conversationId = req.body.conversationId; 113 const conversationId = req.body.conversationId;
125 const content = req.body.content; 114 const content = req.body.content;
126 115
127 - imApi.saveMessage(uid, conversationId, content) 116 + imApi.saveMessage(encryptedUid, conversationId, content)
128 .then(result => { 117 .then(result => {
129 res.json(result); 118 res.json(result);
130 }); 119 });
@@ -139,14 +128,9 @@ exports.saveMSG = (req, res) => { @@ -139,14 +128,9 @@ exports.saveMSG = (req, res) => {
139 * 2. 失败情况 128 * 2. 失败情况
140 */ 129 */
141 exports.fetchOrders = (req, res) => { 130 exports.fetchOrders = (req, res) => {
142 - let uid = req.user.uid; 131 + let encryptedUid = req.body.encryptedUid;
143 132
144 - if (!uid) {  
145 - uid = req.query.uid;  
146 - }  
147 -  
148 -  
149 - imApi.fetchOrderList(uid) 133 + imApi.fetchOrderList(encryptedUid)
150 .then(result => { 134 .then(result => {
151 imModel.handleOrderList(result.data, 128, 170); 135 imModel.handleOrderList(result.data, 128, 170);
152 res.json(result); 136 res.json(result);
@@ -159,19 +143,13 @@ exports.fetchOrders = (req, res) => { @@ -159,19 +143,13 @@ exports.fetchOrders = (req, res) => {
159 }; 143 };
160 144
161 exports.saveEvalute = (req, res) => { 145 exports.saveEvalute = (req, res) => {
162 - let uid = req.user.uid;  
163 -  
164 - if (!uid) {  
165 - uid = req.body.uid;  
166 - }  
167 -  
168 - 146 + const encryptedUid = req.body.encryptedUid;
169 const conversationId = req.body.conversationId; 147 const conversationId = req.body.conversationId;
170 const promoter = req.body.promoter; 148 const promoter = req.body.promoter;
171 const stars = req.body.stars; 149 const stars = req.body.stars;
172 const reasonMsg = req.body.reasonMsg || ''; 150 const reasonMsg = req.body.reasonMsg || '';
173 151
174 - imApi.saveEvalute(uid, conversationId, promoter, stars, reasonMsg) 152 + imApi.saveEvalute(encryptedUid, conversationId, promoter, stars, reasonMsg)
175 .then(result => { 153 .then(result => {
176 return res.json(result); 154 return res.json(result);
177 }).catch(() => { 155 }).catch(() => {
@@ -184,12 +162,7 @@ exports.saveEvalute = (req, res) => { @@ -184,12 +162,7 @@ exports.saveEvalute = (req, res) => {
184 162
185 163
186 exports.queryGlobalOrder = (req, res) => { 164 exports.queryGlobalOrder = (req, res) => {
187 - let uid = req.user.uid;  
188 -  
189 - if (!uid) {  
190 - uid = req.query.uid;  
191 - }  
192 - 165 + let encryptedUid = req.body.encryptedUid;
193 166
194 let emptyOrder = { 167 let emptyOrder = {
195 code: 200, 168 code: 200,
@@ -197,7 +170,7 @@ exports.queryGlobalOrder = (req, res) => { @@ -197,7 +170,7 @@ exports.queryGlobalOrder = (req, res) => {
197 message: '获取失败' 170 message: '获取失败'
198 }; 171 };
199 172
200 - imApi.queryGlobalOrder(uid) 173 + imApi.queryGlobalOrder(encryptedUid)
201 .then(result=> { 174 .then(result=> {
202 imModel.handleOrderList(result.data, 128, 170); 175 imModel.handleOrderList(result.data, 128, 170);
203 res.json(result); 176 res.json(result);
@@ -16,15 +16,15 @@ const encryptedUid = uid => crypto.encryption(null, uid + ''); @@ -16,15 +16,15 @@ const encryptedUid = uid => crypto.encryption(null, uid + '');
16 * 新建留言信息 16 * 新建留言信息
17 * path: {host}/leavemessage/saveLeavemessage 17 * path: {host}/leavemessage/saveLeavemessage
18 * 18 *
19 - * @param {int} uid 用户id 19 + * @param {int} encryptedUid 加密用户id
20 * @param {int} conversationId 会话id 20 * @param {int} conversationId 会话id
21 * @param {str} content 留言内容 21 * @param {str} content 留言内容
22 */ 22 */
23 -exports.saveMessage = (uid, conversationId, content) => { 23 +exports.saveMessage = (encryptedUid, conversationId, content) => {
24 let params = { 24 let params = {
25 conversationId, 25 conversationId,
26 content, 26 content,
27 - encryptedUid: encryptedUid(uid) 27 + encryptedUid
28 }; 28 };
29 29
30 30
@@ -35,17 +35,17 @@ exports.saveMessage = (uid, conversationId, content) => { @@ -35,17 +35,17 @@ exports.saveMessage = (uid, conversationId, content) => {
35 35
36 /** 36 /**
37 * 查询用户聊天记录 37 * 查询用户聊天记录
38 - * @param {int} uid 用户uid 38 + * @param {string} encryptedUid 加密用户uid
39 * @param [int] pageSize 每次加载的聊天记录 39 * @param [int] pageSize 每次加载的聊天记录
40 * @param [int] startTime 40 * @param [int] startTime
41 * @param [int] endTime 41 * @param [int] endTime
42 */ 42 */
43 -exports.fetchImHistory = (uid, endTime, pageSize, startTime) => { 43 +exports.fetchImHistory = (encryptedUid, endTime, pageSize, startTime) => {
44 pageSize = pageSize || 10; 44 pageSize = pageSize || 10;
45 45
46 let params = { 46 let params = {
47 pageSize, 47 pageSize,
48 - encryptedUid: encryptedUid(uid) 48 + encryptedUid
49 }; 49 };
50 50
51 _.forEach({startTime, endTime}, (val, key) => { 51 _.forEach({startTime, endTime}, (val, key) => {
@@ -67,12 +67,12 @@ exports.fetchImHistory = (uid, endTime, pageSize, startTime) => { @@ -67,12 +67,12 @@ exports.fetchImHistory = (uid, endTime, pageSize, startTime) => {
67 67
68 /** 68 /**
69 * 获取用户订单, 默认最近10笔 69 * 获取用户订单, 默认最近10笔
70 - * @param {int} uid 用户uid 70 + * @param {string} encryptedUid 用户加密uid
71 * @param {init} createTimeBegin 开始时间 71 * @param {init} createTimeBegin 开始时间
72 */ 72 */
73 -exports.fetchOrderList = (uid, createTimeBegin) => { 73 +exports.fetchOrderList = (encryptedUid, createTimeBegin) => {
74 let params = { 74 let params = {
75 - encryptedUid: encryptedUid(uid), 75 + encryptedUid,
76 imgSize: '90x120', 76 imgSize: '90x120',
77 }; 77 };
78 78
@@ -105,10 +105,10 @@ exports.fetchOrderList = (uid, createTimeBegin) => { @@ -105,10 +105,10 @@ exports.fetchOrderList = (uid, createTimeBegin) => {
105 | reasonMsg | string | N | 其他原因 | 105 | reasonMsg | string | N | 其他原因 |
106 106
107 */ 107 */
108 -exports.saveEvalute = (uid, conversationId, promoter, stars, reasonMsg) => { 108 +exports.saveEvalute = (encryptedUid, conversationId, promoter, stars, reasonMsg) => {
109 let params = { 109 let params = {
110 conversationId, 110 conversationId,
111 - encryptedUid: encryptedUid(uid), 111 + encryptedUid,
112 promoter, 112 promoter,
113 stars, 113 stars,
114 reasonMsg 114 reasonMsg
@@ -122,9 +122,9 @@ exports.saveEvalute = (uid, conversationId, promoter, stars, reasonMsg) => { @@ -122,9 +122,9 @@ exports.saveEvalute = (uid, conversationId, promoter, stars, reasonMsg) => {
122 * 获取全球购的订单 122 * 获取全球购的订单
123 */ 123 */
124 124
125 -exports.queryGlobalOrder = uid => { 125 +exports.queryGlobalOrder = encryptedUid => {
126 let params = { 126 let params = {
127 - encryptedUid: encryptedUid(uid) 127 + encryptedUid
128 }; 128 };
129 129
130 return ImService.post('/api/order/queryGlobalOrder', params); 130 return ImService.post('/api/order/queryGlobalOrder', params);
@@ -62,7 +62,6 @@ @@ -62,7 +62,6 @@
62 62
63 <input type="hidden" id="js-im" name="im-server" value="{{imCs}}"> 63 <input type="hidden" id="js-im" name="im-server" value="{{imCs}}">
64 {{#with userData}} 64 {{#with userData}}
65 -<input type="hidden" id="js-uid" value="{{uid}}">  
66 <input type="hidden" id="js-eid" value="{{encrypteduid}}"> 65 <input type="hidden" id="js-eid" value="{{encrypteduid}}">
67 <input type="hidden" id="js-avatar" value="{{avatar}}"> 66 <input type="hidden" id="js-avatar" value="{{avatar}}">
68 <input type="hidden" id="js-uname" value="{{uname}}"> 67 <input type="hidden" id="js-uname" value="{{uname}}">
@@ -39,7 +39,6 @@ const msgTypeMap = { @@ -39,7 +39,6 @@ const msgTypeMap = {
39 }; 39 };
40 40
41 let userName = $('#js-uname').val(); 41 let userName = $('#js-uname').val();
42 -let uid = $('#js-uid').val() || 0;  
43 let encryptedUid = cmEntity.encryptedUid = $('#js-eid').val() || 0; 42 let encryptedUid = cmEntity.encryptedUid = $('#js-eid').val() || 0;
44 let userAvatar = cmEntity.userHead = socketConf.defaultUserHead; 43 let userAvatar = cmEntity.userHead = socketConf.defaultUserHead;
45 44
@@ -267,7 +266,6 @@ var chat = { @@ -267,7 +266,6 @@ var chat = {
267 266
268 this.$ratingView.on('click', '.submit', function() { 267 this.$ratingView.on('click', '.submit', function() {
269 self.ratingView.post({ 268 self.ratingView.post({
270 - uid,  
271 encryptedUid, 269 encryptedUid,
272 conversationId: cmEntity.conversationId, 270 conversationId: cmEntity.conversationId,
273 }); 271 });
@@ -762,7 +760,7 @@ var chat = { @@ -762,7 +760,7 @@ var chat = {
762 return $.Deferred().resolve(false); // eslint-disable-line 760 return $.Deferred().resolve(false); // eslint-disable-line
763 } 761 }
764 762
765 - return api.msghistory(uid, encryptedUid, msgHistory.endTime) 763 + return api.msghistory(encryptedUid, msgHistory.endTime)
766 .done(function(result) { 764 .done(function(result) {
767 if (!result || result.code !== 200 || !result.data) { 765 if (!result || result.code !== 200 || !result.data) {
768 return false; 766 return false;
@@ -5,7 +5,7 @@ const socketConf = require('./socket-config'); @@ -5,7 +5,7 @@ const socketConf = require('./socket-config');
5 const conversation = socketConf.conversationMessage; 5 const conversation = socketConf.conversationMessage;
6 const slice = Array.prototype.slice; 6 const slice = Array.prototype.slice;
7 7
8 -let uid = $('#js-uid').val(); 8 +let encryptedUid = $('#js-eid').val();
9 9
10 // EventEmitter 10 // EventEmitter
11 //-------------------------------------------------------- 11 //--------------------------------------------------------
@@ -55,7 +55,7 @@ let api = { @@ -55,7 +55,7 @@ let api = {
55 return $.post('/service/leavemsg/save.json', { 55 return $.post('/service/leavemsg/save.json', {
56 conversationId: conversation.conversationId, 56 conversationId: conversation.conversationId,
57 content, 57 content,
58 - uid 58 + encryptedUid
59 }); 59 });
60 }, 60 },
61 61
@@ -67,11 +67,11 @@ let api = { @@ -67,11 +67,11 @@ let api = {
67 fetchOrders: function(type) { 67 fetchOrders: function(type) {
68 let url = `/service/im/${type}-list`; 68 let url = `/service/im/${type}-list`;
69 69
70 - return $.post(url, {uid}); 70 + return $.post(url, {encryptedUid});
71 }, 71 },
72 72
73 // 获取10条历史记录 73 // 获取10条历史记录
74 - msghistory: function(uid, encryptedUid, endTime) { 74 + msghistory: function(encryptedUid, endTime) {
75 let url = '/service/im/fetchHistory'; 75 let url = '/service/im/fetchHistory';
76 let data = { 76 let data = {
77 encryptedUid 77 encryptedUid
@@ -83,7 +83,7 @@ let api = { @@ -83,7 +83,7 @@ let api = {
83 }, 83 },
84 84
85 saveEvalute: function(data) { 85 saveEvalute: function(data) {
86 - data.uid = uid; 86 + data.encryptedUid = encryptedUid;
87 return $.post('/service/im/saveEvalute', data); 87 return $.post('/service/im/saveEvalute', data);
88 }, 88 },
89 89