boardx / boardx/boardx-dev-template
安全跟踪:lib/access.ts ownerMatches() 邮箱 local-part 模糊匹配可能同族身份混淆风险(ADR-011 my-home 域)
- Dominant language
- TypeScript
- Stars
- 1
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
非阻断,来自 #803 review 顺带发现,coord-main 标记为"下一顺位可能同族"的安全跟踪项,本次不在 F07 修复范围内,先记录。
**发现**:\`apps/devportal/lib/access.ts\` 的 \`ownerMatches()\`(ADR-011 过渡期,my-home 域):
```ts
export function ownerMatches(owner: string | null | undefined, email: string): boolean {
if (!owner) return false;
if (owner === email) return true;
const local = email.split("@")[0] ?? "";
return local.replace(/\./g, "").toLowerCase() === owner.toLowerCase();
}
```
当 \`owner !== email\` 精确匹配失败时,退化成「邮箱 local-part 去点小写」与 \`owner\` 字符串比较——这是与 p30/F03(#783)、p30/F06(#798)、p30/F07(#800)同一类风险的模糊身份匹配:如果某个 \`owner\` 字符串恰好等于另一个用户邮箱 local-part 派生出的值,可能发生身份/权限混淆。
**已知调用方**(未逐一深入排查,仅列出,供后续排期时定位):
- \`app/page.tsx\`
- \`app/api/portal/dispatch/route.ts\`
- \`app/api/portal/my-tokens/route.ts\`(写路径,token 管理,优先级可能较高)
- \`app/api/portal/agents/route.ts\`
- \`app/api/portal/my-home/route.ts\`
- \`lib/dispatch.ts\`
**范围提醒**:这是 ADR-011 过渡期/my-home 域的老代码(p23 前后),不是 p30 新增的——修复前需要先搞清楚 \`owner\` 字段在这些调用方里到底存的是什么(是不是也有类似 F03/F06 场景里"handle 与真实身份锚点可以不相等"的语义),再决定是否需要同款收紧,不能照搬 findEngineerByGithubLogin 的修法(这里的数据源/身份模型可能完全不同)。
**优先级**:待排期——先记录,不阻断当前 F07 主线推进。
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in apps/devportal/lib/access.ts at ownerMatches(), then trace owner semantics through app/page.tsx, the listed portal API routes, and lib/dispatch.ts. Compare the callers with ADR-011 and the referenced F03/F06 cases before deciding whether the fallback is unsafe. Done means the identity model, affected paths, and required scope are established for a safe follow-up fix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- authorization, backend-api-design, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100