跳转到正文
报告库
用途分类 / 数据分析

Extension Authorization Skill 安全审计

作者说它能做什么(原文)

Authorization system with role-based access control. Must-have for all apps that manage personal or access-restricted data.

第三方安全检查结论

先别安装或运行

已检查文件
2
发现的风险
2
会不会运行危险命令?检查是否下载程序后直接运行、让他人远程控制电脑,或藏起要运行的命令。未发现风险
会不会泄露文件和密钥?检查是否发送含密码或密钥的文件,以及代码里是否直接写了密钥。发现 1 项风险
中风险

启用属性回调后,登录会把身份邮箱写入应用状态

原文依据:5 处
发现了什么

该 Skill 建议在登录回调中接收身份提供商属性,并示例将邮箱按主体写入持久应用状态。此收集发生在每次登录回调中,不只是用户主动填写资料时。

为什么需要注意

应用会持有可识别个人的邮箱数据;任何后续备份、管理接口、状态导出或应用漏洞都可能扩大该数据的暴露范围。

该风险有条件地成立:只有应用把非空回调传给 `MixinAuthorization` 时,已验证的姓名、邮箱和 SSO 属性才会在每次登录时交给应用。示例把邮箱按主体写入应用的 `emails` 映射,并提供当前登录者读取自己邮箱的接口。用户可要求作者说明保存期限、删除方式及具体用途,或要求保持第二个参数为 `null`、仅收集必要属性。源码没有显示邮箱被发送到外部服务。

SKILL.md:178来自说明文档打开原文件
`MixinAuthorization` can capture the user's verified Internet Identity attributes (name and email) at sign-in. Pass a callback as the second argument instead of `null`; it runs once per sign-in, after the attribute bundle has been verified.
查看另外 4 个位置
SKILL.md:199来自说明文档打开原文件
Store them in your own state and expose a getter to read them back:
SKILL.md:211来自说明文档打开原文件
  let emails : Map.Map<Principal, Text>;  include MixinAuthorization(    accessControlState,    ?(func(caller : Principal, attrs : { name : ?Text; email : ?Text; sso : ?Text }) {      switch (attrs.email) {        case (?email) { emails.add(caller, email) };        case null {};      };    }),
SKILL.md:213来自说明文档打开原文件
  include MixinAuthorization(    accessControlState,    ?(func(caller : Principal, attrs : { name : ?Text; email : ?Text; sso : ?Text }) {      switch (attrs.email) {        case (?email) { emails.add(caller, email) };        case null {};      };    }),  );
SKILL.md:223来自说明文档打开原文件
  public query ({ caller }) func getCallerEmail() : async ?Text {    emails.get(caller);  };};
会不会删除文件或一直在后台运行?检查是否大范围删除文件、改写磁盘,或设置自动启动。未发现风险
会不会绕过安全保护?检查是否跳过网站安全验证、开放过多文件权限,或取消操作前的确认。发现 1 项风险
高风险

新部署可被首个登录者取得管理员权限

原文依据:4 处
发现了什么

系统无需预置密钥、邀请或所有者确认,就自动把首个通过身份验证的用户设为管理员。管理员随后可使用角色管理能力,内部检查只确认调用者当前是否为管理员。

为什么需要注意

如果公开部署后真正的所有者不是第一个登录者,其他人可能先取得最高权限,并控制角色及所有受管理员保护的数据和操作。

该风险有源码支持:首次通过身份验证的登录者会在无需令牌、密钥或所有者确认的情况下自动成为管理员;角色分配接口存在,而其保护依赖当前管理员身份。因此,在新部署对预期所有者之前可公开访问时,先登录的其他人可能取得角色管理权。用户可要求作者提供部署时预设管理员、邀请机制或启用前的所有者认领步骤,并在完成初始化前限制访问。

SKILL.md:39来自说明文档打开原文件
  public func initState() : AccessControlState;  public func getUserRole(state : AccessControlState, caller : Principal) : UserRole;  public func assignRole(state : AccessControlState, caller : Principal, user : Principal, role : UserRole);  public func isAdmin(state : AccessControlState, caller : Principal) : Bool;  public func hasPermission(state : AccessControlState, caller : Principal, requiredRole : UserRole) : Bool;};
查看另外 3 个位置
SKILL.md:46来自说明文档打开原文件
Initialization is handled internally by `MixinAuthorization` -- do not call `initialize` directly. The first authenticated user to log in automatically becomes admin; no token or secret is required.
SKILL.md:170来自说明文档打开原文件
- Anonymous principals are treated as guests.- `assignRole` includes an admin-only guard internally.- Use `shared({ caller })` for authenticated endpoints that modify data.
SKILL.md:40来自说明文档打开原文件
  public func getUserRole(state : AccessControlState, caller : Principal) : UserRole;  public func assignRole(state : AccessControlState, caller : Principal, user : Principal, role : UserRole);  public func isAdmin(state : AccessControlState, caller : Principal) : Bool;
会不会误导 AI 或隐藏内容?检查工作说明是否要求 AI 忽略你的指令、干扰检查结果,或夹带看不见的文字。未发现风险
会不会偷偷改推广链接或收款方?检查是否强制替换推广链接或收款对象,同时要求隐瞒更改。未发现风险

Skill 逻辑拆解

2 个说明模块

该 Skill 通过外部 Motoko 包和 `MixinAuthorization` 向应用加入 admin、user、guest 三种角色;业务端点仍需由应用逐一调用权限检查。

查看原文
SKILL.md:24来自说明文档打开原文件
There is a prefabricated library `mo:caffeineai-authorization/access-control.mo`. It provides core authentication with role-based access control.
SKILL.md:151来自说明文档打开原文件
Apply the appropriate guard to every public function:

示例中的个人资料接口允许普通用户读写自己的资料,只有管理员可以读取其他主体的资料。

查看原文
SKILL.md:133来自说明文档打开原文件
  public shared ({ caller }) func saveCallerUserProfile(profile : Types.UserProfile) : async () {    if (not AccessControl.hasPermission(accessControlState, caller, #user)) {      Runtime.trap("Unauthorized");    };    userProfiles.add(caller, profile);  };
SKILL.md:140来自说明文档打开原文件
  public query ({ caller }) func getUserProfile(user : Principal) : async ?Types.UserProfile {    if (caller != user and not AccessControl.isAdmin(accessControlState, caller)) {      Runtime.trap("Unauthorized: Can only view your own profile");    };    userProfiles.get(user);  };};

若应用配置可选回调,登录时会接收已验证的姓名、邮箱和 SSO 域;示例把邮箱按主体永久写入应用状态,并提供仅返回当前调用者邮箱的读取接口。

查看原文
SKILL.md:178来自说明文档打开原文件
`MixinAuthorization` can capture the user's verified Internet Identity attributes (name and email) at sign-in. Pass a callback as the second argument instead of `null`; it runs once per sign-in, after the attribute bundle has been verified.
SKILL.md:211来自说明文档打开原文件
  let emails : Map.Map<Principal, Text>;  include MixinAuthorization(    accessControlState,    ?(func(caller : Principal, attrs : { name : ?Text; email : ?Text; sso : ?Text }) {      switch (attrs.email) {        case (?email) { emails.add(caller, email) };        case null {};      };    }),  );  public query ({ caller }) func getCallerEmail() : async ?Text {    emails.get(caller);  };

迁移说明要求升级后端和前端依赖并执行 `mops install`;所提供源码未包含这些依赖包的实现,因此无法从本材料审查其内部权限或属性验证逻辑。

查看原文
migration/v0.x.y-to-v1.x.y.md:46来自说明文档打开原文件
The II attribute flow (nonce, `requestAttributes`, `_internet_identity_sign_in_finish`) is handled by `@caffeineai/core-infrastructure`. Apps using `caffeineai-authorization ^1.0.0` on the backend must also run `@caffeineai/core-infrastructure ^1.0.0` on the frontend.
migration/v0.x.y-to-v1.x.y.md:54来自说明文档打开原文件
- [ ] Ensure the frontend runs `@caffeineai/core-infrastructure ^1.0.0` (see core-infrastructure migration)- [ ] Run `mops install` and verify the backend compiles without errors
从这里开始 · 工作说明SKILL.md
extension-authorization
连线表示工作说明包含的模块,不是实际运行顺序。点击模块可查看原文。

文件引用关系图

1 处引用
哪些文件发起引用引用了什么
连线表示真实的文件引用,不是运行顺序。点击节点可高亮相关连线,并查看具体文件和原文位置。虚线表示还有文件需要定位。
文件与检查记录2 个文件

检查范围与遗漏

逐文件查看涉及的内容

下方列出本次涉及的原文范围;纳入检查不代表已查清所有问题。

  • SKILL.md已纳入全文
  • migration/v0.x.y-to-v1.x.y.md已纳入全文

这份报告只针对上方版本。我们看了拿到的代码和说明文件,没有实际运行 Skill,也没有检查它另外安装的软件包。因此,这不是“保证安全”的承诺;换了版本或使用环境,结果也可能不同。

  • SKILL.md工作说明
  • migration/v0.x.y-to-v1.x.y.md配套文件

代码和说明中提到的操作

连接外部网站
SKILL.md:14来自说明文档打开原文件
# AuthorizationAuthorization extendsion for [Caffeine AI](https://caffeine.ai?utm_source=caffeine-skill&utm_medium=referral).
读取文件
SKILL.md:266来自说明文档打开原文件
Rules:- On login, if the user already has a profile, do not ask for the name again- Display the user's profile name instead of the principal id
读取了多少行
445
文件校验值(用于核对版本)
d19f0204e0dfa84c33fe812ea87363d3a3e806bb2ed5ec1a8896c67db87bc4f5