DSH / Atlas
2026-11-26implementedarchitecture

Computer Use consent by permission attributes

按权限属性判断自动电脑操作授权

A Windows launcher and the application that owns its windows can have different native application IDs. Feishu's Start menu entry `com.electron.Feishu` starts `Feishu\Feishu.exe`, while its window belongs to `Feishu\app\Feishu.exe` and exposes no explicit or package AUMID. Comparing one authorization ID asks the user twice for one product. Inferring relationships from publishers, directories or process ancestry group

English

Problem

A Windows launcher and the application that owns its windows can have different native application IDs. Feishu's Start menu entry com.electron.Feishu starts Feishu\Feishu.exe, while its window belongs to Feishu\app\Feishu.exe and exposes no explicit or package AUMID. Comparing one authorization ID asks the user twice for one product. Inferring relationships from publishers, directories or process ancestry groups programs that the user may intend to authorize separately. Any solution must leave native discovery, window ownership and launch waiting unchanged.

Decision

The permission controller exposes two operations: record a user's decision for an observed application, and decide whether an observed application already has one. Both compare sets of permission attributes instead of one authorization ID. A provider reports, with each selection, its authorization ID plus optional named attribute values; the Host adds the ID itself as the reserved cua.id attribute and rejects native results that supply that name. The shared matcher treats a selection and a saved record as one permission object when any attribute of the same name has a common nonempty value. Values are compared only within their own attribute name. A successful match or saved decision adds the observed values to the record, so a later observation can match through values learned from an intermediate one even when it shares no value with the first. Records connected through shared values form one group for the permission page, Revoke and Allow asking again. Matching extends recognition only: a session grant remains session-scoped, and only an explicit Always allow choice saves a cross-conversation grant. A handle stays bound to the record chosen at selection; each native operation rechecks that record, not the attribute match.

macOS is the single-attribute case. Its helper reports the existing bundle-ID or canonical executable-path digest and no other attributes, so its grants match exactly as before and its native code is unchanged.

Windows retains its discovery rules: a window's native ID is its explicit AUMID, then its package process AUMID, then its executable path, and only identical IDs merge. getApp additionally reports windows.aumid, the AUMIDs of the selected entry, its windows, their packages and the Shell, and windows.executablePath, the upper-cased executable paths of the selected windows. The selected native ID itself is always one of those values. The package reference owns the attribute rules. Shell values come from the undocumented Windows 8+ IApplicationResolver, queried on the STA thread only while building the authorization result; a failed query, or a failed second window observation, contributes no value and never fails the selection. Discovery, window ownership and launch waiting never read permission attributes.

The authorization ID keeps the Host-wide 64-hex form that CuaApplicationId validates on every platform: Windows hashes windows-aumid\0 and the native ID, as it did before grants became persistable. Because the native ID is also stored as an attribute, changing that digest later would not orphan Windows grants; only renaming an attribute or changing its normalization is a durable-format change.

Application association is checked when a window is first admitted. An admitted HWND retains its association while valid. The helper does not retain target PIDs or process start times, or repeat application-identity checks before each operation. The shared helper service identity hashes only the helper executable.

Records keep their authorization keys in profile consent storage. Shared application-consent enforcement still owns human decisions and dispatch-time checks.

Alternatives considered

Treat a launcher and its runtime as unrelated programs. By executable identity they are, and repeated approval would be consistent. The product goal is one decision per application as the user perceives it; the Start menu ID and the Shell resolver supply a common value without product-specific knowledge.

Maintain a list of product launcher and runtime layouts. Mapping specific paths to a Start menu ID covers only listed products, depends on prior knowledge of each installer layout, and changes native discovery IDs and launch targets.

Group by publisher, installation directory or process ancestry. One publisher or directory can contain independent applications; launching another process does not imply consent for it.

Combine the identifiers into one key, or require every attribute to match. Either keeps a launcher and its runtime separate whenever one value differs.

Use the raw native ID as the authorization key. Functionally sufficient once attributes exist, but the 64-hex key is a Host contract shared with macOS, legacy configuration and the permission Remote; changing it would re-key existing macOS grants, which have no attributes to match through. That is a separate cross-platform decision.

Use only documented APIs. The window property store, package APIs and app diagnostics expose no common value for Feishu's unpackaged runtime; only the Shell resolver relates it to the Start menu ID.

Retain PID and process-start metadata and revalidate ownership repeatedly. This introduces a separate application-lifetime model and additional process queries for already admitted HWNDs. This implementation accepts Windows handle validity instead.

Merge connected records into one stored record. Existing handles and other processes refer to the original record keys; group operations preserve those keys.

Consequences

Attributes group permissions; they do not authenticate publishers. An application declaring an authorized AUMID, or placed at an authorized executable path, shares that grant. Learned values persist after revocation, so a later decision applies to the whole group. Versions and copies sharing an attribute deliberately share consent; selections without a common attribute still require separate consent. Saved records on every platform gain an optional attributes field that older readers ignore.

Shared consent does not associate windows. A launcher and its runtime remain separate native application objects: a launcher handle does not operate the runtime's windows, and app.launch() on a launcher can still time out while waiting for a window with its own ID.

A new attribute source requires evidence that its values identify one product and must not derive from names, icons, publishers, directories or process ancestry. Tests cover matching across intermediate observations, attribute-name separation, the reserved cua.id name, session scope, group revocation including a group that grows during revocation, concurrent selections, restart retention, and real desktop runs showing that discovery IDs and admitted HWNDs are unchanged.

中文

问题

Windows 启动器与拥有窗口的应用可能具有不同的原生应用 ID。飞书的开始菜单条目 com.electron.Feishu 启动 Feishu\Feishu.exe,窗口却属于 Feishu\app\Feishu.exe,且没有显式或打包应用 AUMID。只比较一个授权 ID 会让同一产品询问用户两次。按发布者、目录或进程祖先推断关系,又可能合并用户希望分别授权的程序。任何方案都必须保持原生应用发现、窗口归属和启动等待不变。

决策

权限控制器对外只有两个操作:为观察到的应用记录用户决定;判断观察到的应用是否已有决定。两者都比较权限属性集合,而不是单个授权 ID。提供方随每次选择报告授权 ID 和可选的命名属性值;Host 把 ID 本身作为保留属性 cua.id 加入集合,并拒绝原生结果自行提供该名称。共享匹配器在同名属性存在共同非空值时,将选择与已保存记录视为同一权限对象。属性值只在同名属性内比较。匹配成功或保存决定后,观察到的值会加入该记录,因此后续观察即使与第一次观察没有共同值,也可以通过中间观察补充的值匹配。通过共同值关联的记录在权限页、“撤销”和“允许再次询问”中作为一组处理。匹配只扩大识别范围:会话授权仍只适用于当前会话,只有明确选择“始终允许”才保存跨会话授权。句柄绑定到选择时确定的记录;每次原生操作重新检查该记录,而不是重新做属性匹配。

macOS 是单属性情形。其辅助程序报告现有的 bundle ID 或规范可执行文件路径摘要,不提供其他属性,因此授权匹配与原来完全相同,原生代码未改动。

Windows 保留原有应用发现规则:窗口的原生 ID 依次取显式 AUMID、打包应用的进程 AUMID 和可执行文件路径,只有相同 ID 才合并。getApp 另外报告 windows.aumid(所选条目、其窗口、窗口所属包和 Shell 给出的 AUMID)和 windows.executablePath(所选窗口可执行文件路径的大写形式)。所选原生 ID 本身一定是其中一个值。包参考文档维护属性规则。Shell 属性值来自未公开的 Windows 8+ IApplicationResolver,仅在生成授权结果时于 STA 线程查询;查询失败或第二次窗口观察失败时不提供属性值,也不会使选择失败。应用发现、窗口归属和启动等待从不读取权限属性。

授权 ID 保留 CuaApplicationId 在所有平台校验的 Host 级 64 位十六进制形式:Windows 对 windows-aumid\0 与原生 ID 取哈希,与授权可持久化之前相同。由于原生 ID 也保存为属性,以后更改摘要算法不会让 Windows 授权失去匹配;只有重命名属性或改变其归一化规则才是持久格式变更。

窗口首次接纳时检查应用关联。已接纳的 HWND 在有效期间保留该关联。helper 不保留目标 PID 或进程启动时间,也不在每次操作前重复检查应用身份。共享 helper 服务的身份只对 helper 可执行文件取哈希。

记录在 profile 授权存储中保留原有授权键。共享应用授权执行仍负责用户决定和操作时的检查。

考虑过的替代方案

把启动器与运行程序视为无关程序。 按可执行文件身份它们确实无关,重复授权也自洽。但产品目标是用户感知中的一个应用只决定一次;开始菜单 ID 和 Shell 解析器无需产品特定知识就能提供共同值。

维护产品启动器与运行文件布局名单。 将特定路径映射到开始菜单 ID 只覆盖名单中的产品,依赖对每种安装布局的先验知识,还会改变原生发现 ID 和启动目标。

按发布者、安装目录或进程祖先归组。 同一个发布者或目录可以包含独立应用;启动另一个进程不代表已同意访问它。

将多个标识拼成一个键,或要求全部属性相同。 只要有一个值不同,两种做法都会把启动器和运行程序分开。

直接用原生 ID 作为授权键。 有了属性之后功能上足够,但 64 位十六进制键是 macOS、旧配置和权限 Remote 共用的 Host 约定;更改它会让已有 macOS 授权换键,而 macOS 记录没有可用来匹配的属性。这是独立的跨平台决定。

只使用公开 API。 窗口属性存储、包 API 和应用诊断都无法为飞书未打包的运行程序提供共同值;只有 Shell 解析器能将它与开始菜单 ID 关联。

保留 PID 和进程启动元数据并反复验证归属。 这为已接纳 HWND 引入另一套应用生命周期模型和额外的进程查询。本实现采用 Windows 句柄有效性。

将关联记录合并为一条存储记录。 已有句柄和其他进程引用原记录键;分组操作保留这些键。

后果

属性用于权限分组,不认证发布者。声明了已授权 AUMID 或位于已授权可执行文件路径的应用会共享该授权。撤销后已学习的属性值仍保留,因此之后的决定作用于整组记录。拥有共同属性的版本和副本有意共享授权;没有共同属性的选择仍需分别授权。各平台已保存的记录新增可选 attributes 字段,旧读取方会忽略它。

共享授权不关联窗口。启动器与运行程序仍是独立的原生应用对象:启动器句柄不能操作运行程序的窗口,对启动器调用 app.launch() 时,仍可能因等待其自身 ID 的窗口而超时。

新增属性来源需要证明其值标识同一产品,且不得来自名称、图标、发布者、目录或进程祖先。测试覆盖经中间观察的匹配、属性名隔离、保留的 cua.id 名称、会话范围、分组撤销(包括撤销期间分组扩大)、并发选择、重启后保留,以及真实桌面运行中发现 ID 和已接纳 HWND 保持不变。