Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

feat: errorStackSanitized capability at full stealth level

Luigi Agosti51936bb6158e
diff --git a/internal/assets/stealth.js b/internal/assets/stealth.js
index 929fa88d..f5b4b104 100644
--- a/internal/assets/stealth.js
+++ b/internal/assets/stealth.js
@@ -70,7 +70,8 @@ const seededRandom = (function() {
})();
const stackSanitizerPatterns = [
- /\b(?:maskFunctionAsNative|wrapCallableAsNative|wrapConstructableAsNative)\b/,
+ /\b(?:Object|Reflect)\.(?:apply|construct|get|set)\b/,
+ /\b(?:maskFunctionAsNative|wrapCallableAsNative|wrapConstructableAsNative|createNativeLikeGetter)\b/,
/__pinchtab_/,
/\bProxy\b/
];
@@ -111,11 +112,11 @@ function wrapCallableAsNative(fn, applyHandler) {
return fn;
}
try {
- return new Proxy(fn, {
+ return new Proxy(fn, wrapProxyHandlerWithSanitizedErrors({
apply(target, thisArg, args) {
return applyHandler(target, thisArg, args || []);
}
- });
+ }));
} catch (e) {
return fn;
}
@@ -126,14 +127,14 @@ function wrapConstructableAsNative(fn, constructHandler) {
return fn;
}
try {
- return new Proxy(fn, {
+ return new Proxy(fn, wrapProxyHandlerWithSanitizedErrors({
apply(target, thisArg, args) {
return constructHandler(target, args || [], target);
},
construct(target, args, newTarget) {
return constructHandler(target, args || [], newTarget || target);
}
- });
+ }));
} catch (e) {
return fn;
}
@@ -163,6 +164,31 @@ function sanitizeErrorStack(error) {
return error;
}
+function sanitizeThrownError(error) {
+ if (stealthLevel !== 'full') return error;
+ return sanitizeErrorStack(error);
+}
+
+function wrapProxyHandlerWithSanitizedErrors(handler) {
+ if (!handler || typeof handler !== 'object') return handler;
+ const wrapped = {};
+ for (const trap of Object.keys(handler)) {
+ if (typeof handler[trap] === 'function') {
+ const original = handler[trap];
+ wrapped[trap] = function() {
+ try {
+ return original.apply(this, arguments);
+ } catch (e) {
+ throw sanitizeThrownError(e);
+ }
+ };
+ } else {
+ wrapped[trap] = handler[trap];
+ }
+ }
+ return wrapped;
+}
+
// ═══════════════════════════════════════════════════════════════════════════
// LIGHT LEVEL - Safe, no functional impact
// ═══════════════════════════════════════════════════════════════════════════
diff --git a/internal/stealth/bundle.go b/internal/stealth/bundle.go
index 0752671d..bd1e58d7 100644
--- a/internal/stealth/bundle.go
+++ b/internal/stealth/bundle.go
@@ -219,6 +219,7 @@ func capabilityMap(level Level, headless bool) map[string]bool {
}
if level == LevelFull {
caps["functionToStringMasked"] = true
+ caps["errorStackSanitized"] = true
if headless {
caps["webglSpoofing"] = true
}
diff --git a/internal/stealth/bundle_test.go b/internal/stealth/bundle_test.go
index bcb3cc77..b3f6c7e1 100644
--- a/internal/stealth/bundle_test.go
+++ b/internal/stealth/bundle_test.go
@@ -65,8 +65,8 @@ func TestStatusFromBundleReflectsCurrentCapabilityShape(t *testing.T) {
if status.Capabilities["iframeIsolation"] {
t.Fatal("expected current full mode to keep iframe isolation capability disabled")
}
- if status.Capabilities["errorStackSanitized"] {
- t.Fatal("expected current full mode to keep stack sanitization disabled")
+ if !status.Capabilities["errorStackSanitized"] {
+ t.Fatal("expected full mode to report stack sanitization")
}
if !status.Capabilities["functionToStringMasked"] {
t.Fatal("expected full mode to report function-toString masking")
diff --git a/tests/e2e/fixtures/stealth-capabilities.html b/tests/e2e/fixtures/stealth-capabilities.html
index 1155d57c..b0f0d572 100644
--- a/tests/e2e/fixtures/stealth-capabilities.html
+++ b/tests/e2e/fixtures/stealth-capabilities.html
@@ -401,7 +401,7 @@
matchMediaNameNative: typeof window.matchMedia !== 'function' || safe(() => window.matchMedia.name === 'matchMedia', false),
maxTouchPointsDefined: typeof navigator.maxTouchPoints !== 'undefined',
iframeIsolation,
- errorStackSanitized: false,
+ errorStackSanitized: fullModeRuntime,
stackProbe: stackProbe.stack,
functionToStringMasked: fullModeRuntime,
iframeFunctionToStringParity,
diff --git a/tests/e2e/scenarios/infra/stealth-extended.sh b/tests/e2e/scenarios/infra/stealth-extended.sh
index 7c724351..bce4dbeb 100644
--- a/tests/e2e/scenarios/infra/stealth-extended.sh
+++ b/tests/e2e/scenarios/infra/stealth-extended.sh
@@ -78,7 +78,11 @@ run_stealth_level_matrix() {
assert_json_eq "$RESULT" '.capabilities.iframeIsolation' 'false' "status keeps iframe isolation disabled at full"
assert_json_eq "$RESULT" '.capabilities.functionToStringMasked' 'true' "status enables toString masking at full"
fi
- assert_json_eq "$RESULT" '.capabilities.errorStackSanitized' 'false' "status keeps stack sanitization disabled at medium+"
+ if [ "$STEALTH_LEVEL" = "full" ]; then
+ assert_json_eq "$RESULT" '.capabilities.errorStackSanitized' 'true' "status enables stack sanitization at full"
+ else
+ assert_json_eq "$RESULT" '.capabilities.errorStackSanitized' 'false' "status keeps stack sanitization disabled at medium"
+ fi
if [ "$STEALTH_LEVEL" != "full" ]; then
assert_json_eq "$RESULT" '.capabilities.functionToStringMasked' 'false' "status keeps toString masking disabled at medium"
fi
@@ -156,7 +160,7 @@ run_stealth_level_matrix() {
else
assert_eval_poll "window.__stealthCapabilities.chromeRuntimeConnect" "false" "connect remains absent at full"
assert_eval_poll "window.__stealthCapabilities.iframeIsolation" "false" "iframe isolation remains absent at full"
- assert_eval_poll "window.__stealthCapabilities.errorStackSanitized" "false" "stack sanitization remains absent at full"
+ assert_eval_poll "window.__stealthCapabilities.errorStackSanitized" "true" "stack sanitization is active at full"
assert_eval_poll "window.__stealthCapabilities.functionToStringMasked" "true" "native-looking toString masking is active at full"
assert_eval_poll "window.__stealthCapabilities.iframeFunctionToStringParity" "true" "same-origin iframes get consistent toString masking at full"
fi