Skip to content

Commit f99e618

Browse files
committed
fix(captcha): 补上 rAF 别名,并给 getter 探测的 rejected promise 加 sink
两处独立的求解器缺口,都只表现为静默劣化,不产生可见报错。 1) requestAnimationFrame / cancelAnimationFrame 移出 HOST_CRITICAL_GLOBALS 这个跳过表的用意是"别遮蔽宿主依赖的内建",但 Bun 根本没有原生 rAF,所以跳过 别名等于让它对 guest 不可解析。feilin008 里有 9 处裸引用,只有 1 处带 typeof 保护,其余落在 Promise executor 内——因此它不会崩,只会把指纹链打断,表现为 求解成功率下降。 与 2026-08-29 修 `print` 的那次是同型问题(同样的跳过表、同样的静默劣化)。 Bun 的宿主全局没有 rAF,别名到 window 的实现不遮蔽任何东西。 2) installNativeToString 探测 getter 时产生的 rejected promise 加 sink maskObj 会调用 getter 以便给返回的函数也套上 native toString 伪装。WHATWG stream 的 `closed`/`ready` 在接收者是原型而非实例时返回一个已拒绝的 promise,没人 await,于是每次求解稳定产出 4 条 unhandledRejection: The 'closed' getter can only be used on a ReadableStreamBYOBReader The 'ready' getter can only be used on a WritableStreamDefaultWriter 探测结果本来就是丢弃的,加一个 .catch(() => {}) 即可。这类噪音会淹没真正需要 关注的诊断信息。 验证:别名安装后 bare requestAnimationFrame 解析为 function;完整一轮求解的 unhandledRejection 从 4 条 stream getter 噪音降为 0 条。
1 parent cc72906 commit f99e618

2 files changed

Lines changed: 35 additions & 2 deletions

File tree

‎src/proxy/captcha-happy.test.ts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,3 +251,25 @@ describe("alias lifecycle (install/remove descriptor contract)", () => {
251251
expect(Object.getOwnPropertyDescriptor(g, "setTimeout")?.get).toBeUndefined();
252252
});
253253
});
254+
255+
describe("browser globals the guest SDK dereferences bare", () => {
256+
test("requestAnimationFrame/cancelAnimationFrame resolve during a solve", () => {
257+
// Bun has no native rAF. While these sat in HOST_CRITICAL_GLOBALS the
258+
// alias pass skipped them, so the FeiLin bundle's 9 bare
259+
// `requestAnimationFrame` references (only one `typeof`-guarded) were
260+
// unresolvable — the same silent fingerprint degradation `print` caused,
261+
// visible only as a lower solve rate.
262+
const g: Record<string, unknown> = {};
263+
const w: Record<string, unknown> = {
264+
requestAnimationFrame: (cb: () => void) => 1,
265+
cancelAnimationFrame: () => {},
266+
};
267+
installGlobalWindowAlias(g, w, 15);
268+
try {
269+
expect(typeof g.requestAnimationFrame).toBe("function");
270+
expect(typeof g.cancelAnimationFrame).toBe("function");
271+
} finally {
272+
removeGlobalWindowAlias(g, w);
273+
}
274+
});
275+
});

‎src/proxy/captcha-happy.ts‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,13 @@ function installNativeToString(w) {
630630
try {
631631
const v = desc.get.call(obj);
632632
if (typeof v === "function") mask(v);
633-
} catch (_) {}
633+
// Probing a getter can hand back an already-rejected promise (WHATWG
634+
// stream `closed`/`ready` reject when the receiver is the prototype
635+
// rather than an instance). Nobody awaits these, so without a sink
636+
// each probe surfaced as an unhandledRejection on every solve —
637+
// noise that buried real diagnostics.
638+
else if (v && typeof v.then === "function") v.catch(() => {});
639+
} catch {}
634640
}
635641
if (depth < 3) {
636642
try {
@@ -1774,7 +1780,12 @@ async function createDom(region, prefix) {
17741780
const HOST_CRITICAL_GLOBALS = new Set([
17751781
"process", "Bun", "console", "performance", "crypto", "fetch",
17761782
"queueMicrotask", "structuredClone", "TextEncoder", "TextDecoder",
1777-
"requestAnimationFrame", "cancelAnimationFrame",
1783+
// NOTE: requestAnimationFrame/cancelAnimationFrame were removed from this
1784+
// list (2026-09-06). Bun has no native rAF, so skipping the alias left a
1785+
// bare `requestAnimationFrame` in the FeiLin bundle unresolvable (9 call
1786+
// sites, only one `typeof`-guarded) — the same silent fingerprint
1787+
// degradation that `print` caused. Aliasing the window's implementation
1788+
// shadows nothing on the host.
17781789
// NOTE: `print` was removed from this list (2026-08-29). The polyfill
17791790
// defines a harmless no-op on the window, but the alias pass skipped it,
17801791
// so under Bun (guest scripts run in the HOST realm) the Aliyun pe risk

0 commit comments

Comments
 (0)