中风险
审批功能不会自动保护自定义后端端点
原文依据:5 处发现了什么
该 mixin 提供审批管理接口,但 `isCallerApproved()` 只用于前端界面控制。每个自定义公开后端函数仍需单独加入服务端审批或授权检查。
为什么需要注意
如果应用只隐藏前端功能而遗漏后端检查,未批准用户仍可能直接调用公开端点并执行本应受保护的操作。
该候选准确指出了集成边界:mixin 会公开审批管理端点,但不会自动为应用自定义的后端端点执行审批检查。迁移文档明确说 `isCallerApproved()` 只用于前端界面控制,并要求保留 canister 端守卫;若开发者仅隐藏前端功能而未在每个自定义公开函数中检查审批或管理员权限,未获批准的调用者仍可能直接调用后端功能。用户应要求作者确认所有敏感自定义端点均有服务端守卫,并通过后端调用测试验证。
IMPORTANT: Apply the right authorization and/or approval check to each custom public function.查看另外 4 个位置
# User Approval Flow- Check approval status (`isCallerApproved`)- If not approved, show option to request approval (`requestApproval`)- Block access to main features for non-approved users- Admins have access to all features of the application- Display approval status clearly in the UICustom endpoints that guard on approval status continue to use the top-level `approvalState`:```motokopublic shared ({ caller }) func protectedFeature() : async () { if (not (UserApproval.isApproved(approvalState, caller) or AccessControl.hasPermission(accessControlState, caller, #admin))) { Runtime.trap("Unauthorized: Only approved users can perform this action"); };};```Keep these canister-side guards. The mixin-provided `isCallerApproved()` is a public query for frontend UI gating only; it does not enforce approval on custom backend endpoints.Keep these canister-side guards. The mixin-provided `isCallerApproved()` is a public query for frontend UI gating only; it does not enforce approval on custom backend endpoints.- [ ] Remove the four mixin-provided functions from `main.mo` and any custom mixins (keep top-level `UserApproval.initState(...)`)- [ ] Update any custom approval guards to use the top-level `approvalState`. Do not replace them with a frontend `isCallerApproved()` check- [ ] Run `mops install`, `mops build`, and `mops lint`