WuYongJie 5821d73291 初始提交:3D家具安装展示系统
包含:
- furniture-3d-system:Next.js 16 全栈应用(资产中心、产品管理、3D装配动画)
- autocad-plugin:AutoCAD 家具导出插件源码
- 资产中心改造:编辑弹窗化、删除功能、Toast反馈、自定义Select组件

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-02 14:00:19 +08:00

43 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: holes/match 权限与滥用防护收口
date: 2026-02-15
module: hole-match
problem_type: security_issue
severity: critical
symptoms:
- autoSave=true 仅校验登录态,未校验产品编辑权限
- autoSave=false 可匿名读取非公开产品匹配结果
- 匿名高频调用会触发大规模匹配计算
root_cause: 匹配链路缺少产品级权限判断与接口级节流,且计算规模没有上限
resolution_type: code_fix
status: active
confidence: high
tags: [security, permission, rate-limit, holes, match]
related_patterns: [SEC-HOLE-PERM-001]
---
## 现象与影响
`/api/holes/match` 存在“已登录即可写任意产品”和“匿名可读非公开产品”的边界缺口,同时高频请求会放大 CPU/DB 消耗。
## 修复动作
1. 在 `src/server/services/hole.service.ts` 的 `matchHardware` 增加产品解析与权限判断:
- 保存结果:`canEditProduct`
- 预览结果:`canViewProduct`
- 匿名访问:仅允许 `PUBLIC` 产品
2. 增加匹配规模上限(匿名/登录/保存分级)和五金库查询上限(1500)。
3. 在 `src/app/api/holes/match/route.ts` 增加按用户/IP 的窗口限流。
## 验证
- `npm run type-check -- --pretty false` 通过
- `npm test -- tests/lib/cad-panel-linking.test.ts --runInBand` 通过
- `npm test -- tests/api/auth-me.test.ts --runInBand` 通过
## 预防策略
- 任何“预览 + 保存”双模式接口都要在 Service 层拆分权限模型,而不是只在 Route 判断登录态。
- 计算型接口默认要有“节流 + 规模上限”双保险。