271 lines
17 KiB
Plaintext
271 lines
17 KiB
Plaintext
你需要操作移动设备,并按要求复现。
|
||
|
||
## 工作区
|
||
- /fixture/workspace/task-1
|
||
- 代码仓: `/fixture/ai_workspace` 下
|
||
|
||
## 任务契约
|
||
- 目标: 在连接的设备上跑到 SecuritySpec 里的指定场景,验证功能路线,并通过给定的frida hook日志、及关键功能截图,证明你成功进入了目标功能。
|
||
- 允许: 为完成观测,可以使用 Frida hook 修改代码或条件门禁,进入关键功能。一般来说可能是账号或服务端规则或ab等在当前条件下无法复现,需要使用hook强制开启。
|
||
- 禁止:修改代码。你的目标只是复现,不需要你改代码。
|
||
|
||
## Android 构建和安装
|
||
预处理已检出目标提交并应用 Security patch,尚未构建或安装 App。使用本节点的 RemoteX 构建方式构建并安装 APK,失败时排查修复后再复现。
|
||
|
||
## 推荐做法
|
||
→ 清空 frida-server,abmock,重置环境
|
||
→ 启动 frida-server,启动app
|
||
→ 注入脚本
|
||
→ 执行操作步骤
|
||
→ 观察 Hook
|
||
→ 通过脚本强制打开关键门禁
|
||
→ 观察 Hook
|
||
→ 修改脚本
|
||
→ 再次复现
|
||
→ 汇总证据
|
||
|
||
## 输入文件
|
||
先读取并以这些文件为准:
|
||
- /fixture/workspace/task-1/review_spec.md 原始的复现需求
|
||
- /fixture/workspace/task-1/machine_readable_repro_spec.json 人工复现的过程信息(仅参考价值)
|
||
- /fixture/workspace/task-1/TestSpec.md 你需要的复现路径
|
||
|
||
|
||
|
||
## Android 运行注意事项
|
||
- 如果你的复现需要多个设备,那你可能要通过hook等手段mock。
|
||
- ANR 弹窗不等于失败,一般来说应该忽略ANR弹窗。
|
||
- 如果同一场景持续 ANR、崩溃或弹窗阻塞复现,使用 Frida hook 短路关键阻塞点。
|
||
- 除了frida hook外,鼓励使用https://github.com/JingMatrix/Vector或https://github.com/LSPosed/LSPosed进行hook,注意观察端侧使用的真实框架。链接的设备具有root。
|
||
- 任务开始前记得检查有没有安装的xp模块,如果有作用于目标App的,记得卸载。
|
||
- 任务开始前,记得重置连接设备的frida-server环境,防止缓存导致的任务失败。
|
||
- 默认目标包是 `com.zhiliaoapp.musically`(Musically/M 包); 只有复现要求里明确要求 Trill/T 包时, 才使用 `com.ss.android.ugc.trill`。
|
||
- 登录频繁、拒登或 captcha 反复触发时,尝试切换账号或登录方式,实在不行需要你记录到最终文档。
|
||
- App启动可能会出现系统录屏请求,请同意录制。
|
||
|
||
## 执行事项
|
||
- ADB 设备由你根据任务自行选择;确定后设置 `TARGET_PHONE`,本轮所有 adb 命令都显式使用 `adb -s "$TARGET_PHONE"`。
|
||
- 你的hook脚本,以及编译出的xp模块,请放到`/fixture/workspace/task-1/artifacts/` 下
|
||
- 任务执行结束后,不要卸载app!!!任务执行过程中,不要卸载App!!!
|
||
- App内置了审查程序,你卸载会导致内部数据丢失。我会自己手动回收你执行完成的数据。
|
||
|
||
|
||
## 运行规则
|
||
- 按 SecuritySpec 的「复现路径」在真机上触达目标场景。
|
||
- 按 SecuritySpec 的「搜证方法」采集证据,证据一律落到 `/fixture/workspace/task-1/evidence/`:
|
||
- 关键场景截图 / 录屏:`shot-<run>-<desc>.<ext>`
|
||
- 日志 / 抓包 / hook 输出 / 状态快照:`eviden-<run>-<desc>.<ext>`
|
||
- 临时改动、hook 脚本及输出也放进 evidence
|
||
- 证据必须多截图,少文本,少日志
|
||
- 进程约束:严禁启动无上限后台命令。不要裸用 `cmd &`、`frida ... &`、`adb logcat ... &`、`sleep N | frida ... &` 这类不可回收写法;确需后台采集时必须写入 PID、设置明确时长, 并在本轮结束前停止它。优先使用有明确退出条件的脚本/driver;Frida 长时间 attach 不要依赖交互 CLI + pipe 保活。
|
||
- 按「判定标准」核对每个验证项:
|
||
- 无法复现、未复现、部分复现、被前置条件阻塞或证据不足,都要如实写完两份报告后结束本轮。
|
||
|
||
## 交付契约
|
||
- 全部产物落在 `/fixture/workspace/task-1/` 下。
|
||
- 整个 session 产生的任何截图、设备日志、logcat、抓包 脚本或输出,统统输出到 `/fixture/workspace/task-1/evidence/`。
|
||
- 禁止散落到 /tmp、TikTok repo 根或其他目录。
|
||
- 特别地:`/fixture/workspace/task-1/logs/` 是执行框架日志目录, 设备日志和 logcat 严禁写入或重定向到 logs/。这个目录不需操作。
|
||
|
||
- **`Conditions.jsonl`** — 本批确证的执行条件。**只能由 `conditions` 工具写入**,不要手动创建或编辑这个文件
|
||
- **`EvidenceReport.md`** written **entirely in English** (only identifiers stay in English); follow the template below for STRUCTURE and section ORDER, but translate its Chinese section headings/labels into natural English:
|
||
|
||
```markdown
|
||
# 采证报告
|
||
|
||
## 总结结论
|
||
- 总体结论: 全部复现 / 部分复现 / 未复现 / 证据不足
|
||
- 环境: 平台、设备、构建、账号、region、实验配置
|
||
- 关键阻塞:
|
||
|
||
## SPEC 验证项逐项对比
|
||
| ID | 原始验证点 | 结论 | 实际观察 | 原因分析 | 证据 |
|
||
|---|---|---|---|---|---|
|
||
| V1 | ... | 已复现 / 未复现 / 部分复现 / 证据不足 | ... | ... | evidence/... |
|
||
|
||
## 主路径执行记录
|
||
...
|
||
|
||
## 分支 / fallback / diagnostics
|
||
...
|
||
|
||
## 已知边界与不可证明项
|
||
...
|
||
|
||
## 证据索引
|
||
- evidence/...
|
||
```
|
||
|
||
章节命名和顺序必须与模板一致;"SPEC 验证项逐项对比"里的每个 V<n> 对应 SecuritySpec 判定标准里的一条,一一列全,不要合并、不要遗漏。
|
||
|
||
- **`EvidenceReport.json`** 同目录再写一份**机器可读**的搜证结论(纯 JSON,UTF-8,不加 markdown 围栏),schema 如下,枚举值必须严格用大写英文常量:
|
||
|
||
```json
|
||
{
|
||
"overall": "REPRODUCED | NOT_REPRODUCED | PARTIALLY_REPRODUCED | BLOCKED | EVIDENCE_INSUFFICIENT | NOT_APPLICABLE",
|
||
"environment": {
|
||
"platform": "android | ios",
|
||
"device": "...",
|
||
"build_ref": "...",
|
||
"account": "...",
|
||
"region": "...",
|
||
"experiments": { "<key>": "<value>" }
|
||
},
|
||
"blockers": ["..."],
|
||
"spec_items": [
|
||
{
|
||
"id": "V1",
|
||
"point": "原始验证点摘要",
|
||
"verdict": "REPRODUCED | NOT_REPRODUCED | PARTIALLY_REPRODUCED | EVIDENCE_INSUFFICIENT | NOT_APPLICABLE | BLOCKED",
|
||
"observation": "实际观察",
|
||
"cause": "原因分析",
|
||
"evidence": ["evidence/xxx.png", "evidence/yyy.log"]
|
||
}
|
||
],
|
||
"main_path": "主路径执行记录的一句话摘要",
|
||
"diagnostics": ["分支 / fallback / diagnostics 关键结论"],
|
||
"known_limits": ["已知边界与不可证明项"],
|
||
"evidence_index": ["evidence/..."]
|
||
}
|
||
```
|
||
|
||
枚举值枚举清单(供参考):
|
||
- overall/verdict 中的 `REPRODUCED` = 全部复现
|
||
- `NOT_REPRODUCED` = 未复现
|
||
- `PARTIALLY_REPRODUCED` = 部分复现
|
||
- `BLOCKED` = 前置条件阻塞
|
||
- `EVIDENCE_INSUFFICIENT` = 证据不足
|
||
- `NOT_APPLICABLE` = 不适用
|
||
|
||
两份产物必须内容一致:`EvidenceReport.md` 是人读版,`EvidenceReport.json` 是同一次搜证结论的结构化对照,字段与 md 里"SPEC 验证项逐项对比"表格一一对应,你不要生成或猜测.
|
||
|
||
任务上下文:
|
||
- 标题: 剪贴板越权读取
|
||
- 平台: android
|
||
- 目标构建 commitSHA: (默认分支 develop)
|
||
- 历史尝试次数: 1
|
||
|
||
## 一些相关知识库(仅参考)
|
||
## 执行条件记录(**本批执行必做,与写 EvidenceReport.md 同等强制**)
|
||
|
||
你是**第一个真正把这件事在真机上跑通的人**。TestSpec.md 里的执行条件(账号 / 入口路径 / 实验开关 / 构建方式 / 必要操作)是评估阶段**基于工单和代码调研推断出来的,没有在真机上验证过** —— 对不上是常态,写对了也只是碰巧。
|
||
|
||
所以本批请把「**复现并取证这个安全问题真正需要哪些条件**」逐条记下来。注意记录的对象是**条件本身**,不是"spec 哪里写错了":
|
||
|
||
```
|
||
/opt/homebrew/lib/node_modules/bun/bin/bun.exe /fixture/satellite.js conditions record --kind <类型> --scope "<业务模块>" --subject "<这条讲哪件事>" --statement "<条件是什么>" \
|
||
[--spec <predicted|contradicted|absent>] [--spec-said "<spec 原本怎么写的>"] \
|
||
[--payload '<JSON>'] [--evidence <evidence/ 下的文件名>] [--assumed]
|
||
```
|
||
|
||
- `--kind`:account / entry_path / experiment / env / tricky / pitfall —— 分别对应 账号权限 / UI 路径 / 实验开关 / 设备构建 / 必要操作 / 陷阱
|
||
- `--scope`:这条在**哪个业务模块内成立**,如 "Story 相机"、"消息盒子"。**要稳定可复用**,别写成本任务专有的描述
|
||
- `--subject`:这条**讲哪一件事**,如 "特效面板入口路径"、"发布所需账号权限"。**同一件事在不同任务里必须写成同一个 subject** —— 这是系统判定新旧知识是否冲突的依据,写飘了矛盾就永远发现不了
|
||
- `--statement`:条件本身,写成**将来别人能直接照做**的形式
|
||
- `--spec`:顺手标注 spec 猜得怎么样 —— `predicted`(spec 已写对)/ `contradicted`(spec 写错了,请一并给 `--spec-said`)/ `absent`(spec 没提到)。**这一项只是给 spec 质量打分用的,不影响这条条件是否该记**
|
||
- `--payload`:能结构化就结构化,如 `'{"abid":"7712334"}'` 或 `'{"path":["我的","设置","隐私"]}'`。有结构化载荷时冲突判定精确得多
|
||
- 默认按「真机已验证」记录;**只是你从代码里读出来、没实际跑通的,加 `--assumed`**
|
||
|
||
**要记的是"下一个同模块任务也用得上"的条件**:取证路径实际怎么走 / 需要哪个账号或权限才能触达 / 要开哪个实验或 mock / 必须冷启动才能观察到 / 抓包或 hook 需要什么前置。
|
||
|
||
**不要记**:本次特有的代码改动、具体行号、一次性环境故障、你自己的操作失误。**你为了做得更好而主动做的设计取舍也不算条件** —— 那写进 EvidenceReport.md。
|
||
|
||
- **发现一条就立刻记一条**,不要攒到最后(session 末尾必漏)。
|
||
- **本轮结束前执行一次** `/opt/homebrew/lib/node_modules/bun/bin/bun.exe /fixture/satellite.js conditions done`,它会汇总本批记了什么(无论最终证据结论如何都适用)。
|
||
- **拿不准算不算就记下来** —— 漏记的代价远大于多记。
|
||
- 这是你唯一被允许的"修正 spec"的方式:**严禁直接编辑 TestSpec.md 或 TestSpec.md**。
|
||
|
||
### 卡住时可以再查一次知识库
|
||
|
||
```
|
||
/opt/homebrew/lib/node_modules/bun/bin/bun.exe /fixture/satellite.js kb recall --target security:sec-1 "<你的问题,用你会对同事说的话写>"
|
||
```
|
||
|
||
prompt 顶部那份知识是**按平台和历史有用度**选的,跟这张单子写了什么无关 —— 所以入口路径、实验开关、账号权限这类**跟当前这个页面绑定**的知识,派发时不可能命中。**在真机上卡住的那一刻直接查**:
|
||
|
||
- 例:`/opt/homebrew/lib/node_modules/bun/bin/bun.exe /fixture/satellite.js kb recall --target security:sec-1 "Story 相机特效面板从哪进"`
|
||
- 命中的条目会**接着现有编号往下排**(顶部已经到 K6,新命中就是 K7、K8…),用法和顶部那些完全一样:采纳了就在报告里标 `〔K7〕`,并计入最后的 `KB_USED:`
|
||
- **查不到就是查不到**,它会直说;这时按你自己的调研走,别把「没查到」当成「不存在」
|
||
- 与你的代码调研冲突时,**永远以代码为准**
|
||
|
||
> 为什么值得花这几秒:被打回或进入下一批执行时,你读到的 EffectiveSpec.md 会自动带上这些已确证的条件,**你不会再踩同一个坑**;它们还会沉淀进蒸馏库,让以后同模块任务的 spec 从第一版就带着真实条件。
|
||
|
||
|
||
## 其他人工补充:
|
||
|
||
|
||
## Starting builds / pulls / deploys — use `wait-for`, don't hand-roll the wrapper
|
||
|
||
**Start a long command and wait for it, in one call:**
|
||
|
||
```bash
|
||
/opt/homebrew/lib/node_modules/bun/bin/bun.exe /fixture/satellite.js wait-for --run '<the build command you were going to run, verbatim>' \
|
||
--timeout 45m --label 'iOS build r2'
|
||
```
|
||
|
||
It does all four things for you: starts it detached (decoupled from this Bash
|
||
call), captures output to a log file, waits for it to finish, and prints the
|
||
**real exit code plus the last few dozen log lines**. No `nohup`, no
|
||
`echo $? > x.exit`, no `while true; do … sleep; done`.
|
||
|
||
**Wait for something already running:**
|
||
|
||
```bash
|
||
/opt/homebrew/lib/node_modules/bun/bin/bun.exe /fixture/satellite.js wait-for --pgrep 'airb pull' --timeout 20m --label 'pull app' # a process to exit
|
||
/opt/homebrew/lib/node_modules/bun/bin/bun.exe /fixture/satellite.js wait-for --pid 12345 --tail /tmp/build.log --timeout 30m # a specific pid
|
||
/opt/homebrew/lib/node_modules/bun/bin/bun.exe /fixture/satellite.js wait-for --file ./deploy.log --match 'pull success' --timeout 20m # a log marker
|
||
/opt/homebrew/lib/node_modules/bun/bin/bun.exe /fixture/satellite.js wait-for --until 'airb cmd "test -f /tmp/r3_build.exit"' --timeout 45m # any condition
|
||
```
|
||
|
||
Exit codes: **0 = success · 1 = the command failed (real code is in the output)
|
||
· 124 = timed out**. A timeout does **not** kill a `--run` command — it prints
|
||
the pid and a ready-made resume command, because a 40-minute build should not be
|
||
thrown away over a short `--timeout`. `--help` lists every flag.
|
||
|
||
**Copy the build command from this node's skill; do not retype it from memory.**
|
||
It is long and carries nested quoting (`--other_linker_flags`); getting that
|
||
escaping wrong costs a whole 25-minute build — which has already happened. Paste
|
||
it verbatim into `--run '…'`; only the outer single quotes need escaping.
|
||
|
||
**Why this is mandatory:** every Bash call you make is a full model turn —
|
||
thinking, generation, a full cache read. Polling a 25-minute build one
|
||
`pgrep` / `date` / `du -sh` at a time burns dozens of them. Measured across a
|
||
50-task sample, **byte-identical repeat calls were 14% of all Bash calls** — the
|
||
single largest pool of wasted time in this system. `wait-for` collapses it to one.
|
||
|
||
- The Bash tool's timeout ceiling is raised to one hour, so a single
|
||
`wait-for` really can outlast a build — but the **default is still 2 minutes**,
|
||
so pass an explicit `timeout` (in ms) on the Bash call for a long wait.
|
||
- A command that runs past its timeout without one is moved to the **background**,
|
||
where it holds the whole agent process open — this has already turned a
|
||
finished evaluation into a "timed out" one. Long commands either get a
|
||
timeout or get waited on with `wait-for`.
|
||
- **Never wait on device UI state with it.** Keep `catuse apps | grep -q …`,
|
||
`adb shell dumpsys window | grep -q mCurrentFocus` and `uiautomator dump | grep -q …`
|
||
out of `--until`. A build has a definite end — not finished yet just means not yet.
|
||
**UI state has none**: it may never appear (wrong page, a dialog on top, the app
|
||
crashed), and all you get back is "didn't happen", with no idea what page you are
|
||
actually on. Use `catuse ui` or a screenshot to look, then decide.
|
||
Measured: in the first three days, 33 timeouts burned 4.4 hours — **every one of
|
||
them this pattern**, with 3–8 minute timeouts (UI scale, not build scale).
|
||
- **Wait for a screen with `/opt/homebrew/lib/node_modules/bun/bin/bun.exe /fixture/satellite.js wait-for --ui-text '<text>'`, not a fixed `sleep`.** After a
|
||
tap / cold start / navigation, `/opt/homebrew/lib/node_modules/bun/bin/bun.exe /fixture/satellite.js wait-for --ui-text 'Inbox'` (regex, case-insensitive) reads the
|
||
UI tree every second and returns as soon as the text shows up; `--ui-gone 'Loading'` waits for
|
||
a spinner to go away. Default 30s, max 3m — seconds-scale, unlike the long waits above. On a
|
||
miss it **prints the text currently on screen**, so you know which page you are on without a
|
||
screenshot. Sampled rounds spent 3–21 minutes in hard-coded `sleep`s. Sub-second settles
|
||
(`sleep 1` after a tap) are still fine.
|
||
- `wait-for` only **waits**; it never starts anything. Start the build the way
|
||
this node normally does (backgrounded, dropping an exit-code file), then
|
||
`--until` that file exists.
|
||
- If you hit 124, report "waited N minutes, did not finish" as the fact it is.
|
||
**Do not rewrite it as "verification environment blocked"** — that is the most
|
||
expensive misdiagnosis this system produces, because it looks like infra rot
|
||
and nobody re-runs it.
|
||
|
||
|
||
|
||
---
|
||
SPEC SECTION NAMES — this task's spec is written in ENGLISH. Where the instructions above refer to a spec section by its Chinese name, look for its English heading instead:
|
||
证据目标 → Evidence goal · 复现前置 → Repro preconditions · 复现路径 → Repro path · 搜证方法 → Evidence method · 判定标准 → Verdict criteria · 风险与前置缺失 → Risks & gaps · 涉及的关键文件 / 模块 / 入口 → Key files, modules & entry points · 构建基线 → Build baseline · 目标平台/设备 → Target platform / device · 前置条件 → Preconditions · 判定成功的标志 → What counts as done.
|
||
The spec's content is authoritative regardless of which name the instructions used. |