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

37 lines
1.6 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: Hole 写/读操作缺少 Service 层产品权限护栏
date: 2026-02-15
module: hole-service
problem_type: security_issue
severity: critical
symptoms:
- /api/holes 与 /api/holes/[id] 依赖登录态,缺少基于产品归属的 canEditProduct/canViewProduct 校验
- Route 可被绕过时,Service 直接写孔位数据,存在跨产品越权风险
root_cause: 权限策略停留在 Route 入参层,Service 未对 hole/panel -> product 归属做统一鉴权
resolution_type: code_fix
status: active
confidence: high
tags: [security, idor, permission, holes, service-layer]
related_patterns: [WF-HOLE-ROUTE-SERVICE-001]
---
## 现象与影响
孔位写接口在“已登录”之后直接执行写库,读接口允许匿名访问精确结构参数。缺少产品级权限校验时,攻击者可通过可猜测 ID 读取或修改不属于自己的产品孔位数据。
## 修复动作
1. 在 `src/server/services/hole.service.ts` 新增 `requireUser/getProductForPermission/assertCanViewProduct/assertCanEditProduct`。
2. 将权限护栏接入 `listByFilter/findById/findByPanelId`(查看)与 `create/createMany/update/delete/deleteMany/deleteByPanelId/deleteByFilter`(写入)。
3. 所有写入前都先解析 `hole/panel -> product` 归属,再执行 `canEditProduct`。
## 验证
- `npm run type-check -- --pretty false` 通过
- `npm test -- tests/lib/cad-panel-linking.test.ts --runInBand` 通过
## 预防策略
- 所有“资源隶属产品”的接口统一执行“Route 鉴权入口 + Service 产品权限护栏”。
- Service 层禁止依赖 Route 先验假设(例如“已经做过权限校验”)。