修复多项安全漏洞
安全修复清单: 1. 验证码改为图片方式返回,防止明文泄露 2. CORS配置从环境变量读取,不再使用通配符"*" 3. VIP API添加@admin_required装饰器,统一认证 4. 用户登录统一错误消息,防止用户枚举 5. IP限流不再信任X-Forwarded-For头,防止伪造绕过 6. 密码强度要求提升(8位+字母+数字) 7. 日志不���记录完整session/cookie内容,防止敏感信息泄露 8. XSS防护:日志输出和Bug反馈内容转义HTML 9. SQL注入防护:LIKE查询参数转义 10. 路径遍历防护:截图目录白名单验证 11. 验证码重放防护:验证前删除验证码 12. 数据库连接池健康检查 13. 正则DoS防护:限制数字匹配长度 14. Account类密码私有化,__repr__不暴露密码 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,26 @@ def take_screenshot(config):
|
||||
screenshot_path = config['screenshot_path']
|
||||
cookies_file = config.get('cookies_file', '')
|
||||
|
||||
# 安全修复:验证截图路径在允许的目录内,防止路径遍历攻击
|
||||
ALLOWED_SCREENSHOT_DIRS = [
|
||||
'/root/zsglpt/screenshots',
|
||||
'/root/zsglpt/static/screenshots',
|
||||
'/tmp/zsglpt_screenshots'
|
||||
]
|
||||
|
||||
def is_safe_screenshot_path(path):
|
||||
"""验证截图路径是否安全"""
|
||||
abs_path = os.path.abspath(path)
|
||||
return any(abs_path.startswith(os.path.abspath(allowed_dir))
|
||||
for allowed_dir in ALLOWED_SCREENSHOT_DIRS)
|
||||
|
||||
if not is_safe_screenshot_path(screenshot_path):
|
||||
return {
|
||||
'success': False,
|
||||
'message': '非法截图路径',
|
||||
'screenshot_path': ''
|
||||
}
|
||||
|
||||
result = {
|
||||
'success': False,
|
||||
'message': '',
|
||||
|
||||
Reference in New Issue
Block a user