hexo-theme-fluid icon indicating copy to clipboard operation
hexo-theme-fluid copied to clipboard

LeanCloud 统计避免恶意篡改

Open AnzhiZhang opened this issue 2 years ago • 3 comments

请确认

问题描述

使用 LeanCloud 统计访问量,发现可以访问 API 实现恶意篡改访问量。

示例

import requests
print(requests.put(
    'https://n7i9euyn.api.lncldglobal.com/1.1/classes/Counter/xxx',
    json={"time": 200},
    headers={
        'x-lc-id': 'xxx',
        'x-lc-key': 'xxx'
    }
).json())

URL 的参数在请求返回中: image ID 和 Key 在请求头中: image

我已成功在我的博客和 您的博客 测试以上代码篡改访问量成功。

尝试的解决方案

AnzhiZhang avatar Jun 09 '22 07:06 AnzhiZhang

安全域名只对 JavaScript SDK 有效

后续计划通过类似于 hexo-leancloud-counter-security 来解决这个问题

zkqiang avatar Jun 09 '22 08:06 zkqiang

另外可以参考 https://leaferx.online/2018/02/11/lc-security/ 前半部分

去设置 beforeUpdate 参数校验,我的博客已经加上去了

zkqiang avatar Jun 09 '22 09:06 zkqiang

补充一点:需要修改 LeanCloud 数据库权限,仅保留 findupdate 即可

AnzhiZhang avatar Jun 09 '22 09:06 AnzhiZhang