Skip to content

Commit 299e6e5

Browse files
authored
Merge pull request TriDefender#45 from LX2000WASD/fix/captcha-raf-and-rejection-noise
fix(captcha): 补上 rAF 别名,并给 getter 探测的 rejected promise 加 sink
2 parents 0e63b00 + f99e618 commit 299e6e5

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)