From 6c561c5465fd4ad653bd961cfb64c5d0c556fb9b Mon Sep 17 00:00:00 2001 From: sorte1 Date: Thu, 19 Nov 2026 06:43:38 +0100 Subject: [PATCH 01/14] fix: remove a self-defending callback by default only when the built-in scan proves every built-in it calls intact, with numeric keys and the removed protection templates left out of the judgement --- README.md | 2 +- crates/untwist-core/src/semantic/builtins.rs | 2 +- .../src/semantic/builtins/scan.rs | 46 +- .../src/semantic/builtins/scan/allow.rs | 2 +- .../src/semantic/builtins/scan/numeric.rs | 394 ++++++++++++++++++ .../src/semantic/builtins/scan/reach.rs | 14 +- .../src/semantic/builtins/scan/windows.rs | 2 +- .../tests/builtins_numeric_keys.rs | 52 +++ .../untwist-deobfuscate/src/builtin_values.rs | 128 ------ .../src/debug_protection.rs | 35 +- crates/untwist-deobfuscate/src/lib.rs | 1 - crates/untwist-deobfuscate/src/notes.rs | 3 +- .../untwist-deobfuscate/src/self_defending.rs | 20 +- 13 files changed, 551 insertions(+), 150 deletions(-) create mode 100644 crates/untwist-core/src/semantic/builtins/scan/numeric.rs create mode 100644 crates/untwist-core/tests/builtins_numeric_keys.rs delete mode 100644 crates/untwist-deobfuscate/src/builtin_values.rs diff --git a/README.md b/README.md index f12474ee..2def9792 100644 --- a/README.md +++ b/README.md @@ -221,7 +221,7 @@ module objects or loader through `process` taken as a value (`var p = process; p computed member of `process`, or requests the `module` or `process` built-in is not split, but an alias is not followed, since most bundles pass `process` around. And no value the program tests is `document.all`, so `x != null ? x : y` becomes `x ?? y`: the two -differ only for that object, which compares loosely equal to `null` without being nullish. Nor does any code read a function's caller through `.caller`, `arguments.callee.caller` or a stack frame (`Error.prepareStackTrace` call sites with `getFunction()` or `getFunctionName()`) to observe which function called it (the non-standard `Function.prototype.caller`; strict code cannot): inlining a control-flow object's call proxy removes the proxy's frame, so such a read would see the function that held the call instead of the proxy. The default lane also assumes obfuscator.io's self-defending check would pass on the input: removing the trap may make an input that would trap (for example one reformatted after obfuscation) run normally. It does not assume an obfuscator.io domain lock would pass: the lock reads the host's `document` and `location` and enumerates the global object's names, so the default lane keeps it, the protections registered with it and the machinery it can see, and says so (`a domain lock was found …`); `--unsafe` assumes the lock passes and removes it. The default lane keeps a protection that may still run, one it cannot read or prove inert, and when that is a block registered through a call controller or a debug-protection timer it keeps every block registered that way and every debug-protection timer with it, including another layer's console silencing, because removing one layer's silencing and keeping another's changes what the program prints, and removing the silencing and keeping a timer, or the reverse, changes what it prints or whether it keeps running. Untwist also assumes no debugger or inspector session changes the program's values while it +differ only for that object, which compares loosely equal to `null` without being nullish. Nor does any code read a function's caller through `.caller`, `arguments.callee.caller` or a stack frame (`Error.prepareStackTrace` call sites with `getFunction()` or `getFunctionName()`) to observe which function called it (the non-standard `Function.prototype.caller`; strict code cannot): inlining a control-flow object's call proxy removes the proxy's frame, so such a read would see the function that held the call instead of the proxy. The default lane also assumes obfuscator.io's self-defending check would pass on the input: removing the trap may make an input that would trap (for example one reformatted after obfuscation) run normally. It does not assume an obfuscator.io domain lock would pass: the lock reads the host's `document` and `location` and enumerates the global object's names, so the default lane keeps it, the protections registered with it and the machinery it can see, and says so (`a domain lock was found …`); `--unsafe` assumes the lock passes and removes it. The default lane keeps a protection that may still run, one it cannot read or prove inert (a self-defending callback is inert only when the built-in scan proves that nothing in the program can replace a built-in member the callback calls), and when that is a block registered through a call controller or a debug-protection timer it keeps every block registered that way and every debug-protection timer with it, including another layer's console silencing, because removing one layer's silencing and keeping another's changes what the program prints, and removing the silencing and keeping a timer, or the reverse, changes what it prints or whether it keeps running. Untwist also assumes no debugger or inspector session changes the program's values while it runs; every lane and every proof rests on this. [`docs/known-divergences/deobfuscate.md`](docs/known-divergences/deobfuscate.md) lists every premise. diff --git a/crates/untwist-core/src/semantic/builtins.rs b/crates/untwist-core/src/semantic/builtins.rs index 4aebc684..5f416d14 100644 --- a/crates/untwist-core/src/semantic/builtins.rs +++ b/crates/untwist-core/src/semantic/builtins.rs @@ -5,7 +5,7 @@ use crate::semantic::has_module_syntax; mod scan; -pub use scan::{intact, scan, scan_with_unknown_keys_plain}; +pub use scan::{intact, scan, scan_outside, scan_with_unknown_keys_plain}; use oxc_semantic::Scoping; diff --git a/crates/untwist-core/src/semantic/builtins/scan.rs b/crates/untwist-core/src/semantic/builtins/scan.rs index 07afb53b..48b71c93 100644 --- a/crates/untwist-core/src/semantic/builtins/scan.rs +++ b/crates/untwist-core/src/semantic/builtins/scan.rs @@ -1,10 +1,11 @@ use oxc_ast::ast::*; use oxc_ast_visit::{walk_js, VisitJs}; use oxc_semantic::Scoping; +use oxc_span::{GetSpan, Span}; use oxc_syntax::operator::{AssignmentOperator, BinaryOperator, LogicalOperator, UnaryOperator}; use oxc_syntax::scope::ScopeFlags; use oxc_syntax::symbol::{SymbolFlags, SymbolId}; -use rustc_hash::FxHashMap; +use rustc_hash::{FxHashMap, FxHashSet}; use std::cell::{Cell, OnceCell, RefCell}; use super::{Builtins, Reliance, Scanned}; @@ -15,6 +16,7 @@ mod escapes; mod functions; mod keys; mod modules; +mod numeric; mod parts; mod reach; mod targets; @@ -191,12 +193,14 @@ struct Scan<'s> { functions: OnceCell, escaping: OnceCell, windows: OnceCell, + numeric: OnceCell, reached: RefCell>, scoping: &'s Scoping, reliance: &'s Reliance, writes_only: bool, unknown_keys_plain: bool, first_only: bool, + skipped: Option<&'s FxHashSet>, module: bool, frames: Vec, verdict: Builtins, @@ -274,6 +278,20 @@ pub fn scan_with_unknown_keys_plain( scan.verdict } +pub fn scan_outside( + program: &Program<'_>, + scoping: &Scoping, + module: bool, + reliance: &Reliance, + skipped: &FxHashSet, +) -> Builtins { + let mut scan = Scan::new(program, scoping, module, reliance); + scan.skipped = Some(skipped); + scan.visit_program(program); + scan.settle_window_flows(); + scan.verdict +} + pub fn intact(program: &Program<'_>, scoping: &Scoping, module: bool, reliance: &Reliance) -> bool { let mut scan = Scan::new(program, scoping, module, reliance); scan.first_only = true; @@ -295,12 +313,14 @@ impl<'s> Scan<'s> { functions: OnceCell::new(), escaping: OnceCell::new(), windows: OnceCell::new(), + numeric: OnceCell::new(), reached: RefCell::new(FxHashMap::default()), scoping, reliance, writes_only: false, unknown_keys_plain: false, first_only: false, + skipped: None, module, frames: vec![Frame::of_program(program, module)], verdict: first_verdict(scoping, reliance, module), @@ -320,6 +340,20 @@ impl Scan<'_> { .cloned() } + pub(super) fn numeric_key(&self, key: &Expression<'_>) -> bool { + let numeric = self + .numeric + .get_or_init(|| numeric::numeric_bindings(self.program, self.scoping, self.module)); + numeric::is_numeric(key, self.scoping, numeric) + } + + pub(super) fn sharpen<'k>(&self, key: Key<'k>) -> Key<'k> { + match key { + Key::Unknown(expression) if self.numeric_key(expression) => Key::Other, + other => other, + } + } + pub(super) fn only_a_function(&self, symbol: SymbolId) -> bool { self.functions .get_or_init(|| functions::function_bindings(self.program)) @@ -347,7 +381,7 @@ impl Scan<'_> { fn pattern_key_reaches(&self, computed: bool, key: &PropertyKey<'_>) -> bool { let name = match (computed, key) { (true, PropertyKey::StaticIdentifier(_) | PropertyKey::PrivateIdentifier(_)) => None, - (true, _) => match key.as_expression().map(key_of) { + (true, _) => match key.as_expression().map(|key| self.sharpen(key_of(key))) { Some(Key::Name(name)) => Some(name), Some(Key::Other) | None => return false, Some(Key::Unknown(expression)) => { @@ -874,7 +908,11 @@ impl<'a> VisitJs<'a> for Scan<'_> { } fn visit_statement(&mut self, it: &Statement<'a>) { - if self.settled() { + if self.settled() + || self + .skipped + .is_some_and(|skipped| skipped.contains(&it.span())) + { return; } walk_js::walk_statement(self, it); @@ -909,7 +947,7 @@ impl<'a> VisitJs<'a> for Scan<'_> { } fn visit_computed_member_expression(&mut self, it: &ComputedMemberExpression<'a>) { - let key = key_of(&it.expression); + let key = self.sharpen(key_of(&it.expression)); if self.names_a_loader(key) { self.not_allowed(); } diff --git a/crates/untwist-core/src/semantic/builtins/scan/allow.rs b/crates/untwist-core/src/semantic/builtins/scan/allow.rs index a28c1a4e..9646564b 100644 --- a/crates/untwist-core/src/semantic/builtins/scan/allow.rs +++ b/crates/untwist-core/src/semantic/builtins/scan/allow.rs @@ -360,7 +360,7 @@ impl Scan<'_> { } pub(super) fn read_allowed(&self, root: Root<'_>, key: Key<'_>) -> bool { - let name = match key { + let name = match self.sharpen(key) { Key::Name(name) => name.to_string(), Key::Other => return root == Root::Global, Key::Unknown(expression) => match self.known_key(expression) { diff --git a/crates/untwist-core/src/semantic/builtins/scan/numeric.rs b/crates/untwist-core/src/semantic/builtins/scan/numeric.rs new file mode 100644 index 00000000..56ba80b7 --- /dev/null +++ b/crates/untwist-core/src/semantic/builtins/scan/numeric.rs @@ -0,0 +1,394 @@ +use oxc_ast::ast::*; +use oxc_ast_visit::{walk_js, VisitJs}; +use oxc_semantic::Scoping; +use oxc_syntax::operator::{AssignmentOperator, BinaryOperator, UnaryOperator}; +use oxc_syntax::reference::ReferenceId; +use oxc_syntax::scope::ScopeFlags; +use oxc_syntax::symbol::{SymbolFlags, SymbolId}; +use rustc_hash::{FxHashMap, FxHashSet}; + +use super::reach::{key_of, Key}; +use super::GLOBAL_OBJECTS; +use crate::semantic::is_foreign_global; + +pub(super) type NumericBindings = FxHashSet; + +const ARGUMENTS: &str = "arguments"; + +fn reference_symbol(id: &IdentifierReference<'_>, scoping: &Scoping) -> Option { + id.reference_id + .get() + .and_then(|reference| scoping.get_reference(reference).symbol_id()) +} + +fn is_numeric_compound(operator: AssignmentOperator) -> bool { + matches!( + operator, + AssignmentOperator::Subtraction + | AssignmentOperator::Multiplication + | AssignmentOperator::Division + | AssignmentOperator::Remainder + | AssignmentOperator::Exponential + | AssignmentOperator::ShiftLeft + | AssignmentOperator::ShiftRight + | AssignmentOperator::ShiftRightZeroFill + | AssignmentOperator::BitwiseOR + | AssignmentOperator::BitwiseXOR + | AssignmentOperator::BitwiseAnd + ) +} + +fn assigned_symbol(target: &AssignmentTarget<'_>, scoping: &Scoping) -> Option { + match target { + AssignmentTarget::AssignmentTargetIdentifier(id) => reference_symbol(id, scoping), + _ => None, + } +} + +pub(super) fn is_numeric( + expression: &Expression<'_>, + scoping: &Scoping, + numeric: &NumericBindings, +) -> bool { + let expression = expression.without_parentheses(); + if matches!(key_of(expression), Key::Other) { + return true; + } + match expression { + Expression::UnaryExpression(unary) => unary.operator == UnaryOperator::LogicalNot, + Expression::BinaryExpression(binary) => { + binary.operator == BinaryOperator::Addition + && is_numeric(&binary.left, scoping, numeric) + && is_numeric(&binary.right, scoping, numeric) + } + Expression::Identifier(id) => { + reference_symbol(id, scoping).is_some_and(|symbol| numeric.contains(&symbol)) + } + Expression::AssignmentExpression(assignment) => match assignment.operator { + AssignmentOperator::Assign => is_numeric(&assignment.right, scoping, numeric), + AssignmentOperator::Addition => { + assigned_symbol(&assignment.left, scoping) + .is_some_and(|symbol| numeric.contains(&symbol)) + && is_numeric(&assignment.right, scoping, numeric) + } + operator => is_numeric_compound(operator), + }, + Expression::SequenceExpression(sequence) => sequence + .expressions + .last() + .is_some_and(|last| is_numeric(last, scoping, numeric)), + Expression::ConditionalExpression(conditional) => { + is_numeric(&conditional.consequent, scoping, numeric) + && is_numeric(&conditional.alternate, scoping, numeric) + } + _ => false, + } +} + +const MAX_PASSES: usize = 8; + +struct Collect<'s> { + scoping: &'s Scoping, + numeric: &'s NumericBindings, + module: bool, + bindings: FxHashMap, + plain_bindings: FxHashMap, + plain_values: FxHashSet, + numeric_writes: FxHashSet, + refused: FxHashSet, + params: FxHashMap, + strict: Vec, + global_keys: FxHashSet, + global_unknown: bool, +} + +fn uses_arguments(function: &Function<'_>) -> bool { + #[derive(Default)] + struct Arguments { + found: bool, + } + impl<'a> VisitJs<'a> for Arguments { + fn visit_identifier_reference(&mut self, it: &IdentifierReference<'a>) { + self.found |= it.name == ARGUMENTS; + } + } + let mut arguments = Arguments::default(); + arguments.visit_function(function, ScopeFlags::Function); + arguments.found +} + +fn first_assignment<'k, 'a>( + function: &'k Function<'a>, +) -> Option<(&'k IdentifierReference<'a>, &'k Expression<'a>)> { + let first = function.body.as_ref()?.statements.first()?; + let Statement::ExpressionStatement(statement) = first else { + return None; + }; + let Expression::AssignmentExpression(assignment) = &statement.expression else { + return None; + }; + let AssignmentTarget::AssignmentTargetIdentifier(target) = &assignment.left else { + return None; + }; + (assignment.operator == AssignmentOperator::Assign).then_some((&**target, &assignment.right)) +} + +fn subtracts_from(right: &Expression<'_>, name: &str) -> bool { + let Expression::BinaryExpression(binary) = right.without_parentheses() else { + return false; + }; + binary.operator == BinaryOperator::Subtraction + && matches!(binary.left.without_parentheses(), Expression::Identifier(id) if id.name == name) + && matches!(key_of(&binary.right), Key::Other) +} + +fn has_simple_params(function: &Function<'_>) -> bool { + function.params.rest.is_none() + && function.params.items.iter().all(|item| { + item.initializer.is_none() + && matches!(item.pattern, BindingPattern::BindingIdentifier(_)) + }) +} + +impl Collect<'_> { + fn is_strict(&self) -> bool { + self.strict.last().copied().unwrap_or(self.module) + } + + fn numeric(&self, expression: &Expression<'_>) -> bool { + is_numeric(expression, self.scoping, self.numeric) + } + + fn decoder_param(&mut self, function: &Function<'_>) { + let Some((target, right)) = first_assignment(function) else { + return; + }; + let sloppy_reads = !self.is_strict() && uses_arguments(function); + if !has_simple_params(function) || sloppy_reads || !subtracts_from(right, &target.name) { + return; + } + let param = function + .params + .items + .iter() + .find_map(|item| match &item.pattern { + BindingPattern::BindingIdentifier(id) if id.name == target.name => { + id.symbol_id.get() + } + _ => None, + }); + let (Some(param), Some(reference)) = (param, target.reference_id.get()) else { + return; + }; + if reference_symbol(target, self.scoping) == Some(param) { + self.params.insert(param, reference); + } + } + + fn refuse_loop_left(&mut self, left: &ForStatementLeft<'_>) { + if let ForStatementLeft::VariableDeclaration(declaration) = left { + for declarator in &declaration.declarations { + if let BindingPattern::BindingIdentifier(id) = &declarator.id { + self.refused.extend(id.symbol_id.get()); + } + } + } + } + + fn shared(&self, symbol: SymbolId) -> bool { + if self.module || self.scoping.symbol_scope_id(symbol) != self.scoping.root_scope_id() { + return false; + } + let name = self.scoping.symbol_name(symbol); + self.global_unknown || self.global_keys.contains(name) || is_foreign_global(name) + } + + fn is_global_object(&self, object: &Expression<'_>) -> bool { + match object.without_parentheses() { + Expression::ThisExpression(_) => true, + Expression::Identifier(id) => { + GLOBAL_OBJECTS.contains(&id.name.as_str()) + && reference_symbol(id, self.scoping).is_none() + } + _ => false, + } + } + + fn global_write(&mut self, member: &MemberExpression<'_>) { + if !self.is_global_object(member.object()) { + return; + } + let key = match member { + MemberExpression::StaticMemberExpression(member) => { + Key::Name(member.property.name.as_str()) + } + MemberExpression::ComputedMemberExpression(member) => key_of(&member.expression), + MemberExpression::PrivateFieldExpression(_) => Key::Other, + }; + match key { + Key::Name(name) => { + self.global_keys.insert(name.to_string()); + } + Key::Other => {} + Key::Unknown(_) => self.global_unknown = true, + } + } + + fn holds(&self, symbol: SymbolId) -> bool { + let flags = self.scoping.symbol_flags(symbol); + let variable = flags.is_variable() + && !flags.intersects( + SymbolFlags::Function + | SymbolFlags::Class + | SymbolFlags::CatchVariable + | SymbolFlags::Import, + ); + if !variable || self.refused.contains(&symbol) || self.shared(symbol) { + return false; + } + let count = self.bindings.get(&symbol).copied().unwrap_or(0); + let writes = self + .scoping + .get_resolved_reference_ids(symbol) + .iter() + .filter(|&&reference| self.scoping.get_reference(reference).flags().is_write()); + if let Some(&only) = self.params.get(&symbol) { + return count == 1 && writes.clone().all(|&reference| reference == only); + } + let plain = self.plain_bindings.get(&symbol).copied().unwrap_or(0); + count > 0 + && count == plain + && self.plain_values.contains(&symbol) + && writes + .clone() + .all(|reference| self.numeric_writes.contains(reference)) + } +} + +impl<'a> VisitJs<'a> for Collect<'_> { + fn visit_binding_identifier(&mut self, it: &BindingIdentifier<'a>) { + if let Some(symbol) = it.symbol_id.get() { + *self.bindings.entry(symbol).or_default() += 1; + } + } + + fn visit_variable_declarator(&mut self, it: &VariableDeclarator<'a>) { + if let BindingPattern::BindingIdentifier(id) = &it.id { + if let Some(symbol) = id.symbol_id.get() { + *self.plain_bindings.entry(symbol).or_default() += 1; + let numeric = it.init.as_ref().is_none_or(|init| self.numeric(init)); + if !numeric { + self.refused.insert(symbol); + } + self.plain_values.insert(symbol); + } + } + walk_js::walk_variable_declarator(self, it); + } + + fn visit_for_in_statement(&mut self, it: &ForInStatement<'a>) { + self.refuse_loop_left(&it.left); + walk_js::walk_for_in_statement(self, it); + } + + fn visit_for_of_statement(&mut self, it: &ForOfStatement<'a>) { + self.refuse_loop_left(&it.left); + walk_js::walk_for_of_statement(self, it); + } + + fn visit_assignment_expression(&mut self, it: &AssignmentExpression<'a>) { + if let AssignmentTarget::AssignmentTargetIdentifier(target) = &it.left { + let numeric = match it.operator { + AssignmentOperator::Assign + | AssignmentOperator::LogicalAnd + | AssignmentOperator::LogicalOr + | AssignmentOperator::LogicalNullish => self.numeric(&it.right), + AssignmentOperator::Addition => { + reference_symbol(target, self.scoping) + .is_some_and(|symbol| self.numeric.contains(&symbol)) + && self.numeric(&it.right) + } + operator => is_numeric_compound(operator), + }; + if let (true, Some(reference)) = (numeric, target.reference_id.get()) { + self.numeric_writes.insert(reference); + } + } + walk_js::walk_assignment_expression(self, it); + } + + fn visit_simple_assignment_target(&mut self, it: &SimpleAssignmentTarget<'a>) { + if let Some(member) = it.as_member_expression() { + self.global_write(member); + } + walk_js::walk_simple_assignment_target(self, it); + } + + fn visit_update_expression(&mut self, it: &UpdateExpression<'a>) { + if let SimpleAssignmentTarget::AssignmentTargetIdentifier(target) = &it.argument { + self.numeric_writes.extend(target.reference_id.get()); + } + walk_js::walk_update_expression(self, it); + } + + fn visit_function(&mut self, it: &Function<'a>, flags: ScopeFlags) { + let strict = self.is_strict() || it.has_use_strict_directive(); + self.strict.push(strict); + self.decoder_param(it); + walk_js::walk_function(self, it, flags); + self.strict.pop(); + } + + fn visit_class(&mut self, it: &Class<'a>) { + self.strict.push(true); + walk_js::walk_class(self, it); + self.strict.pop(); + } +} + +fn narrowed( + program: &Program<'_>, + scoping: &Scoping, + module: bool, + numeric: &NumericBindings, +) -> NumericBindings { + let mut collect = Collect { + scoping, + numeric, + module, + bindings: FxHashMap::default(), + plain_bindings: FxHashMap::default(), + plain_values: FxHashSet::default(), + numeric_writes: FxHashSet::default(), + refused: FxHashSet::default(), + params: FxHashMap::default(), + strict: Vec::new(), + global_keys: FxHashSet::default(), + global_unknown: false, + }; + collect + .strict + .push(module || crate::semantic::program_is_strict(program)); + collect.visit_program(program); + numeric + .iter() + .copied() + .filter(|&symbol| collect.holds(symbol)) + .collect() +} + +pub(super) fn numeric_bindings( + program: &Program<'_>, + scoping: &Scoping, + module: bool, +) -> NumericBindings { + let mut numeric: NumericBindings = scoping.symbol_ids().collect(); + for _ in 0..MAX_PASSES { + let next = narrowed(program, scoping, module, &numeric); + if next.len() == numeric.len() { + return next; + } + numeric = next; + } + NumericBindings::default() +} diff --git a/crates/untwist-core/src/semantic/builtins/scan/reach.rs b/crates/untwist-core/src/semantic/builtins/scan/reach.rs index 8a744924..52dc6048 100644 --- a/crates/untwist-core/src/semantic/builtins/scan/reach.rs +++ b/crates/untwist-core/src/semantic/builtins/scan/reach.rs @@ -70,6 +70,13 @@ pub(super) fn key_of<'k>(expression: &'k Expression<'k>) -> Key<'k> { Expression::UpdateExpression(_) => Key::Other, Expression::UnaryExpression(unary) if is_numeric_unary(unary.operator) => Key::Other, Expression::BinaryExpression(binary) if is_numeric_binary(binary.operator) => Key::Other, + Expression::BinaryExpression(binary) + if binary.operator == BinaryOperator::Addition + && matches!(key_of(&binary.left), Key::Other) + && matches!(key_of(&binary.right), Key::Other) => + { + Key::Other + } _ => Key::Unknown(expression), } } @@ -77,7 +84,10 @@ pub(super) fn key_of<'k>(expression: &'k Expression<'k>) -> Key<'k> { fn is_numeric_unary(operator: UnaryOperator) -> bool { matches!( operator, - UnaryOperator::UnaryNegation | UnaryOperator::UnaryPlus | UnaryOperator::BitwiseNot + UnaryOperator::UnaryNegation + | UnaryOperator::UnaryPlus + | UnaryOperator::BitwiseNot + | UnaryOperator::LogicalNot ) } @@ -212,7 +222,7 @@ impl Scan<'_> { } fn reached_member(&self, object: &Expression<'_>, key: Key<'_>) -> bool { - match key { + match self.sharpen(key) { Key::Name(name) if REACHING_KEYS.contains(&name) => true, Key::Name(name) if self.names_a_root(name) => true, Key::Name(name) if CODE_RUNNERS.contains(&name) || CONTEXT_RUNNERS.contains(&name) => { diff --git a/crates/untwist-core/src/semantic/builtins/scan/windows.rs b/crates/untwist-core/src/semantic/builtins/scan/windows.rs index 18a9ab8e..d7ab65d3 100644 --- a/crates/untwist-core/src/semantic/builtins/scan/windows.rs +++ b/crates/untwist-core/src/semantic/builtins/scan/windows.rs @@ -260,7 +260,7 @@ impl Scan<'_> { object: &Expression<'_>, key: Option<&Expression<'_>>, ) -> bool { - let slot = key.is_none_or(|key| match key_of(key) { + let slot = key.is_none_or(|key| match self.sharpen(key_of(key)) { Key::Other => false, Key::Name(name) => self.is_window_slot(name), Key::Unknown(key) => self diff --git a/crates/untwist-core/tests/builtins_numeric_keys.rs b/crates/untwist-core/tests/builtins_numeric_keys.rs new file mode 100644 index 00000000..83518072 --- /dev/null +++ b/crates/untwist-core/tests/builtins_numeric_keys.rs @@ -0,0 +1,52 @@ +use oxc_allocator::Allocator; +use untwist_core::parse::parse_program; +use untwist_core::semantic::builtins::{scan, Builtins, Reliance}; +use untwist_core::semantic::{build_scoping, has_module_syntax}; + +const STRING: Reliance = Reliance { + roots: &["String"], + members: &[], +}; + +fn verdict(source: &str) -> Builtins { + let alloc = Allocator::default(); + let parsed = parse_program(&alloc, source); + let sem = build_scoping(&parsed.program); + let module = has_module_syntax(&parsed.program); + scan(&parsed.program, &sem.scoping, module, false, &STRING).verdict +} + +#[test] +fn a_key_proven_numeric_reaches_no_prototype() { + for source in [ + "function f(a) { for (let i = 0; i < a.length; i++) g(a[i]); }", + "function f(a, n) { let i = n - 1; i *= 2; g(a[i]); }", + "function f(a, n) { let i = 0; i += 1; g(a[i + 1]); }", + "function f(a, n) { g(a[n | 0], a[-n], a[~n], a[!n], a[n++]); }", + "function f(p, q) { p = p - 277; var c = d(); return c[p]; }", + "function f(a, c) { g(a[c -= 0], a[c = +c]); }", + "var a = [1]; for (var i = 0; i < 1; i++) g(a[i]);", + ] { + assert_eq!(verdict(source), Builtins::Intact, "{source}"); + } +} + +#[test] +fn a_key_that_may_be_a_string_still_counts() { + for source in [ + "function f(a, k) { g(a[k]); }", + "function f(a, k) { let i = 0; i = k; g(a[i]); }", + "function f(a, k) { let i = 0; i += k; g(a[i]); }", + "function f(a, o) { for (let k in o) g(a[k]); }", + "function f(a, o) { let i = 0; [i] = o; g(a[i]); }", + "function f(a, n) { let i = 0; h = () => { i = n; }; g(a[i]); }", + "function f(p) { var c = d(); g(c[p]); p = p - 1; }", + "function f(p) { p = p - 1; arguments[0] = k; return d()[p]; }", + "function f(p) { p = p - 1; p = k; return d()[p]; }", + "function f(p, q = p) { p = p - 1; return d()[p]; }", + "var a = [1]; var i = 0; window.i = k; g(a[i]);", + "var a = [1]; var i = 0; this[k] = 1; g(a[i]);", + ] { + assert_ne!(verdict(source), Builtins::Intact, "{source}"); + } +} diff --git a/crates/untwist-deobfuscate/src/builtin_values.rs b/crates/untwist-deobfuscate/src/builtin_values.rs deleted file mode 100644 index 3e53f33b..00000000 --- a/crates/untwist-deobfuscate/src/builtin_values.rs +++ /dev/null @@ -1,128 +0,0 @@ -use oxc_ast::ast::*; -use oxc_ast_visit::{walk_js, VisitJs}; -use oxc_semantic::Scoping; -use oxc_syntax::operator::{BinaryOperator, UnaryOperator}; - -use crate::bindings::resolved_symbol; -use crate::proof::GLOBAL_OBJECTS; - -struct Exposure<'k> { - roots: &'k [&'k str], - scoping: &'k Scoping, - found: bool, -} - -fn property_name<'k>(member: &'k MemberExpression<'_>) -> Option<&'k str> { - match member { - MemberExpression::StaticMemberExpression(member) => Some(member.property.name.as_str()), - MemberExpression::ComputedMemberExpression(member) => { - match member.expression.without_parentheses() { - Expression::StringLiteral(key) => key.value.as_str(), - _ => None, - } - } - MemberExpression::PrivateFieldExpression(_) => None, - } -} - -impl Exposure<'_> { - fn is_global(&self, id: &IdentifierReference<'_>, names: &[&str]) -> bool { - names.contains(&id.name.as_str()) && resolved_symbol(id, self.scoping).is_none() - } - - fn is_root(&self, expr: &Expression<'_>) -> bool { - match expr.without_parentheses() { - Expression::Identifier(id) => self.is_global(id, self.roots), - other => other.as_member_expression().is_some_and(|member| { - let global_object = match member.object().without_parentheses() { - Expression::Identifier(id) => self.is_global(id, GLOBAL_OBJECTS), - _ => false, - }; - global_object - && property_name(member).is_some_and(|name| self.roots.contains(&name)) - }), - } - } - - fn is_prototype(&self, expr: &Expression<'_>) -> bool { - expr.without_parentheses() - .as_member_expression() - .is_some_and(|member| { - property_name(member) == Some("prototype") && self.is_root(member.object()) - }) - } - - fn is_exposable(&self, expr: &Expression<'_>) -> bool { - self.is_root(expr) || self.is_prototype(expr) - } - - fn visit_unless_root(&mut self, expr: &Expression<'_>) { - if !self.is_root(expr) { - self.visit_expression_of(expr); - } - } - - fn visit_expression_of(&mut self, expr: &Expression<'_>) { - if self.is_exposable(expr) { - self.found = true; - return; - } - walk_js::walk_expression(self, expr); - } -} - -impl<'a> VisitJs<'a> for Exposure<'_> { - fn visit_expression(&mut self, it: &Expression<'a>) { - if self.found { - return; - } - self.visit_expression_of(it); - } - - fn visit_member_expression(&mut self, it: &MemberExpression<'a>) { - if self.is_exposable(it.object()) { - if let MemberExpression::ComputedMemberExpression(member) = it { - self.visit_expression(&member.expression); - } - return; - } - walk_js::walk_member_expression(self, it); - } - - fn visit_call_expression(&mut self, it: &CallExpression<'a>) { - self.visit_unless_root(&it.callee); - self.visit_arguments(&it.arguments); - } - - fn visit_new_expression(&mut self, it: &NewExpression<'a>) { - self.visit_unless_root(&it.callee); - self.visit_arguments(&it.arguments); - } - - fn visit_unary_expression(&mut self, it: &UnaryExpression<'a>) { - match it.operator { - UnaryOperator::Typeof => self.visit_unless_root(&it.argument), - _ => walk_js::walk_unary_expression(self, it), - } - } - - fn visit_binary_expression(&mut self, it: &BinaryExpression<'a>) { - let compares = it.operator.is_equality() || it.operator == BinaryOperator::Instanceof; - if !compares { - walk_js::walk_binary_expression(self, it); - return; - } - self.visit_unless_root(&it.left); - self.visit_unless_root(&it.right); - } -} - -pub fn exposes_a_builtin(program: &Program<'_>, scoping: &Scoping, roots: &[&str]) -> bool { - let mut exposure = Exposure { - roots, - scoping, - found: false, - }; - exposure.visit_program(program); - exposure.found -} diff --git a/crates/untwist-deobfuscate/src/debug_protection.rs b/crates/untwist-deobfuscate/src/debug_protection.rs index f3417147..0bb9fe37 100644 --- a/crates/untwist-deobfuscate/src/debug_protection.rs +++ b/crates/untwist-deobfuscate/src/debug_protection.rs @@ -185,6 +185,37 @@ enum Plan { } fn plan(program: &Program<'_>, scoping: &Scoping, unsafe_lane: bool) -> Plan { + plan_beside(program, scoping, unsafe_lane, &[]) +} + +pub(crate) fn planned_removal<'a>( + program: &Program<'a>, + removed: &[Span], + cx: &Cx<'a, '_>, +) -> Vec { + let scoping = cx.scoping(); + let Plan::Remove(spans, symbols, _) = + plan_beside(program, scoping, cx.opts.unsafe_transforms, removed) + else { + return Vec::new(); + }; + let mut both = spans.clone(); + both.extend_from_slice(removed); + let kept = reaches_a_script_global_once_removed(&symbols, &both, program, cx) + || crate::directives::removes_what_an_eval_reads(scoping, &spans) + || crate::directives::removes_hoist_blocker(scoping, &spans); + if kept { + return Vec::new(); + } + spans +} + +fn plan_beside( + program: &Program<'_>, + scoping: &Scoping, + unsafe_lane: bool, + removed: &[Span], +) -> Plan { let declarations = declarations(program, scoping); if declarations.symbols.is_empty() { return Plan::Nothing; @@ -201,7 +232,9 @@ fn plan(program: &Program<'_>, scoping: &Scoping, unsafe_lane: bool) -> Plan { } let mut spans = declarations.spans; spans.extend(intervals.spans); - if has_stray_reference(program, &declarations.symbols, &spans, scoping) { + let mut ignored = spans.clone(); + ignored.extend_from_slice(removed); + if has_stray_reference(program, &declarations.symbols, &ignored, scoping) { let started = provisional || crate::self_defending::guarded_returners(program) > 0; if !unsafe_lane && started { return Plan::KeptStillRunning; diff --git a/crates/untwist-deobfuscate/src/lib.rs b/crates/untwist-deobfuscate/src/lib.rs index 0469eaaf..be06752a 100644 --- a/crates/untwist-deobfuscate/src/lib.rs +++ b/crates/untwist-deobfuscate/src/lib.rs @@ -3,7 +3,6 @@ pub mod array_rotator; pub mod bindings; mod branch_reach; pub mod bridge; -mod builtin_values; pub mod call_checks; pub mod calls; mod constant_test; diff --git a/crates/untwist-deobfuscate/src/notes.rs b/crates/untwist-deobfuscate/src/notes.rs index 7cf5c3b8..0d46c922 100644 --- a/crates/untwist-deobfuscate/src/notes.rs +++ b/crates/untwist-deobfuscate/src/notes.rs @@ -433,7 +433,8 @@ pub const DOMAIN_LOCK_KEPT: &str = can see were kept (`--unsafe` assumes the lock passes and removes it)"; pub const SELF_DEFENDING_BUILTIN_PATCHED: &str = "the program may replace a built-in the self-defending callback calls, so removing the \ - callback would drop what the replacement does; the block was left in place"; + callback would drop what the replacement does: the default lane keeps a protection that may \ + still run, and the block was left in place"; pub const SELF_DEFENDING_NO_USABLE_SPAN: &str = "a matched statement has no usable span, so the block was left in place"; diff --git a/crates/untwist-deobfuscate/src/self_defending.rs b/crates/untwist-deobfuscate/src/self_defending.rs index 592a8ea4..b422e60a 100644 --- a/crates/untwist-deobfuscate/src/self_defending.rs +++ b/crates/untwist-deobfuscate/src/self_defending.rs @@ -16,13 +16,12 @@ use untwist_core::ast_util::matcher::{anonymous_function, call_parts, iife}; use untwist_core::ast_util::naming_slot::without_unnamed; use untwist_core::ast_util::prop::{identifier_name, member_parts}; use untwist_core::pass::{Cx, Interest, Pass}; -use untwist_core::semantic::builtins::{scan, Builtins, Reliance}; +use untwist_core::semantic::builtins::{scan_outside, Builtins, Reliance}; use untwist_core::semantic::{has_module_syntax, AnnexBWrites}; use crate::bindings::{ has_stray_reference, reaches_a_script_global_once_removed, reference_symbol, resolved_symbol, }; -use crate::builtin_values::exposes_a_builtin; use crate::control_flow_object::single_declarator; use crate::directives::remove_protection_statements; use crate::domain_lock::is_domain_lock_callback; @@ -37,7 +36,9 @@ const MAX_NARROWED_CONTROLLERS: usize = 16; const RESERVED_PARAMS: [&str; 2] = [ARGUMENTS, "eval"]; static CALLBACK_RELIES_ON: Reliance = Reliance { - roots: &["Function", "String", "RegExp", "Symbol"], + roots: &[ + "Function", "String", "RegExp", "Symbol", "Number", "Boolean", "Array", "Object", + ], members: &[], }; @@ -1613,10 +1614,11 @@ fn attempt( } } -fn callback_built_ins_written(program: &Program<'_>, scoping: &Scoping) -> bool { +fn callback_built_ins_intact<'a>(program: &Program<'a>, spans: &[Span], cx: &Cx<'a, '_>) -> bool { let module = has_module_syntax(program); - scan(program, scoping, module, false, &CALLBACK_RELIES_ON).verdict == Builtins::Written - || exposes_a_builtin(program, scoping, CALLBACK_RELIES_ON.roots) + let mut skipped: FxHashSet = spans.iter().copied().collect(); + skipped.extend(crate::debug_protection::planned_removal(program, spans, cx)); + scan_outside(program, cx.scoping(), module, &CALLBACK_RELIES_ON, &skipped) == Builtins::Intact } #[derive(Default)] @@ -1666,9 +1668,6 @@ fn refusal<'a>( (spans, tracked): (&[Span], &FxHashSet), cx: &Cx<'a, '_>, ) -> Option<&'static str> { - if !cx.opts.unsafe_transforms && callback_built_ins_written(program, cx.scoping()) { - return Some(notes::SELF_DEFENDING_BUILTIN_PATCHED); - } if reaches_a_script_global_once_removed(tracked, spans, program, cx) { return Some(notes::SELF_DEFENDING_GLOBAL_REACH); } @@ -1678,6 +1677,9 @@ fn refusal<'a>( if crate::directives::removes_hoist_blocker(cx.scoping(), spans) { return Some(notes::PROTECTION_HOIST_BLOCKER_KEPT); } + if !cx.opts.unsafe_transforms && !callback_built_ins_intact(program, spans, cx) { + return Some(notes::SELF_DEFENDING_BUILTIN_PATCHED); + } None } From 3bb0a30a161e736d0fa9c5347b90d238371bdad4 Mon Sep 17 00:00:00 2001 From: sorte1 Date: Thu, 19 Nov 2026 07:01:20 +0100 Subject: [PATCH 02/14] fix: leave the shared key classification as it was; numeric keys are proven only in the numeric-key check --- .../untwist-core/src/semantic/builtins/scan/reach.rs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/crates/untwist-core/src/semantic/builtins/scan/reach.rs b/crates/untwist-core/src/semantic/builtins/scan/reach.rs index 52dc6048..6c7881fa 100644 --- a/crates/untwist-core/src/semantic/builtins/scan/reach.rs +++ b/crates/untwist-core/src/semantic/builtins/scan/reach.rs @@ -70,13 +70,6 @@ pub(super) fn key_of<'k>(expression: &'k Expression<'k>) -> Key<'k> { Expression::UpdateExpression(_) => Key::Other, Expression::UnaryExpression(unary) if is_numeric_unary(unary.operator) => Key::Other, Expression::BinaryExpression(binary) if is_numeric_binary(binary.operator) => Key::Other, - Expression::BinaryExpression(binary) - if binary.operator == BinaryOperator::Addition - && matches!(key_of(&binary.left), Key::Other) - && matches!(key_of(&binary.right), Key::Other) => - { - Key::Other - } _ => Key::Unknown(expression), } } @@ -84,10 +77,7 @@ pub(super) fn key_of<'k>(expression: &'k Expression<'k>) -> Key<'k> { fn is_numeric_unary(operator: UnaryOperator) -> bool { matches!( operator, - UnaryOperator::UnaryNegation - | UnaryOperator::UnaryPlus - | UnaryOperator::BitwiseNot - | UnaryOperator::LogicalNot + UnaryOperator::UnaryNegation | UnaryOperator::UnaryPlus | UnaryOperator::BitwiseNot ) } From 0e77211d6e873282f28332bf7dd8be15b2a184b7 Mon Sep 17 00:00:00 2001 From: sorte1 Date: Thu, 19 Nov 2026 07:11:26 +0100 Subject: [PATCH 03/14] test: numeric-key rows for the built-in scan, the a33rr10 patched built-in rows, and the docs for the proven-intact rule --- crates/untwist-core/tests/builtins.rs | 4 ++-- crates/untwist/tests/review_rr10_rows.rs | 17 +++++++++++------ docs/known-divergences/deobfuscate.md | 24 ++++++++++++++++-------- 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/crates/untwist-core/tests/builtins.rs b/crates/untwist-core/tests/builtins.rs index 5bfaaf6f..357ae147 100644 --- a/crates/untwist-core/tests/builtins.rs +++ b/crates/untwist-core/tests/builtins.rs @@ -283,7 +283,7 @@ fn a_key_from_a_parameter_an_enumeration_or_an_opaque_call_aliases_the_built_ins "for (var p in b) { d[p] = b[p]; }", "function f(o, k) { var v = o[k]; return v; }", "function f(b, c) { for (var p in b) { x = c[p]; } }", - "var a = [1, 2]; for (var i = 0; i < a.length; i++) { x = a[i]; }", + "function f(a, k) { for (var i = 0; i < a.length; i++) { x = a[i]; } i = k; }", "var k = 'dyn'; x = o[k];", "let k = 'dyn'; x = o[k];", "const k = '__pro' + 'to__'; x = [][k];", @@ -308,7 +308,7 @@ fn a_key_from_a_parameter_an_enumeration_or_an_opaque_call_aliases_the_built_ins fn a_long_chain_of_computed_reads_is_scanned_in_linear_time() { let depth = 400; let chain = "[i]".repeat(depth); - let source = format!("var a = [], i = 0; var v = a{chain}; x = a{chain}.y;"); + let source = format!("var a = [], i = g(); var v = a{chain}; x = a{chain}.y;"); let started = std::time::Instant::now(); assert_eq!(verdict(&source), Builtins::Aliased); let spent = started.elapsed(); diff --git a/crates/untwist/tests/review_rr10_rows.rs b/crates/untwist/tests/review_rr10_rows.rs index df30fb5d..511cc9b4 100644 --- a/crates/untwist/tests/review_rr10_rows.rs +++ b/crates/untwist/tests/review_rr10_rows.rs @@ -55,15 +55,12 @@ fn probes() -> Vec<(String, String)> { } #[test] -fn every_a33_rr10_probe_but_the_unnamed_patches_prints_what_node_prints_by_default() { +fn every_a33_rr10_probe_prints_what_node_prints_by_default() { let Some(node) = node_or_skip() else { return; }; - let programs: Vec<(String, String)> = probes() - .into_iter() - .filter(|(label, _)| !PATCHED_WITHOUT_A_NAME.contains(&label.as_str())) - .collect(); - assert!(programs.len() >= 80, "found {} probes", programs.len()); + let programs = probes(); + assert!(programs.len() >= 100, "found {} probes", programs.len()); let run: Run = Box::new(|source| transformed(default_lane(), source)); let modes: Vec> = vec![("default", run.as_ref())]; let wrong = node_rows::mismatches(&node, &programs, &modes); @@ -80,6 +77,14 @@ fn a_let_flag_that_may_still_be_in_its_dead_zone_keeps_the_construct_in_both_lan } } +#[test] +fn a_built_in_patched_without_naming_it_keeps_the_construct_by_default() { + for label in PATCHED_WITHOUT_A_NAME { + let code = transformed(default_lane(), &probe(label)); + assert!(code.contains("apply"), "{label}: {code}"); + } +} + #[test] fn a_let_flag_declared_first_in_the_same_list_or_a_var_flag_is_still_removed() { for label in ["430", "436"] { diff --git a/docs/known-divergences/deobfuscate.md b/docs/known-divergences/deobfuscate.md index 6bedf768..5f980391 100644 --- a/docs/known-divergences/deobfuscate.md +++ b/docs/known-divergences/deobfuscate.md @@ -730,14 +730,22 @@ the list that declares `s`; the call has exactly two arguments, no spread, `this` or a literal first and a function or arrow expression second, and `c(…)()` passes nothing; and no statement of the construct sits inside a `with` body. Anything else keeps the - whole construct. The default mode also keeps the whole construct, with a note, when the - built-in scan finds a write to `Function`, `String`, `RegExp` or `Symbol` (a write whose - target names the built-in, such as `String.prototype.search = …`, or a definer such as - `Object.defineProperty(Function.prototype, …)`), or when one of these or its `prototype` is - used as a value anywhere but as the object of a member read, a call, `new`, `typeof`, an - equality or `instanceof` (stored in a binding, passed, returned, put in a literal or a - pattern: `var p = String.prototype; p.search = …`): a removed callback would no longer run - the replaced member. The default mode removes a callback run through one only when the callback is, node + whole construct. The default mode also keeps the whole construct, with a note, unless the + built-in scan proves `Function`, `String`, `Number`, `Boolean`, `RegExp`, `Symbol`, `Array` and + `Object` intact, judging the program without the statements this pass removes and without the + debug-protection templates the same run removes (a template that stays is judged): no write that + names one of them or its `prototype` (`String.prototype.search = …`, + `Object.defineProperty(Function.prototype, …)`), no use of one of them, its `prototype` or the + global object as a value (`var p = String.prototype; p.search = …`, a method returning `this`), + no prototype reached through a value (`''.__proto__`, `x.constructor.prototype`, + `Object.getPrototypeOf(x)`, a computed key that may be `__proto__` or `constructor`) and no code + run from a string: a removed callback would no longer run a replaced member. A computed key + counts as harmless when it is a number: a numeric literal, the result of arithmetic other than + `+`, a unary `-`, `+`, `~` or `!`, an update, `+` of two such keys, or a binding whose every + write is such a value. That includes a parameter whose first statement is `p = p - N` and that + is written nowhere else, in a function that is strict or does not use `arguments`, and a + top-level binding of a script when no global-object write may name it (`window.i = …`, + `this[k] = …`) and no other input names it. The default mode removes a callback run through one only when the callback is, node for node, one of the bodies obfuscator.io emits: the source check (`return f.toString().search("(((.+)+)+)+$")…`), the format check, the console disable or the debug-protection start. Local names are free, and a local function the body only ever calls From 904daa755e0fdde998560a8c0e268355e80f7552 Mon Sep 17 00:00:00 2001 From: sorte1 Date: Thu, 19 Nov 2026 07:17:12 +0100 Subject: [PATCH 04/14] test: expect the self-defending blocks the built-in scan cannot prove, and refresh the obfuscator BASELINEs --- fixtures/obfuscator-io/BASELINE | 45 ++++++++++++++-------------- fixtures/obfuscator-io/EXPECT | 22 ++++++++++++++ fixtures/obfuscator-relayer/BASELINE | 18 ++++++----- fixtures/obfuscator-relayer/EXPECT | 29 ++++++++++++++++++ fixtures/obfuscator-versions/EXPECT | 28 +++++++++++++++++ 5 files changed, 112 insertions(+), 30 deletions(-) diff --git a/fixtures/obfuscator-io/BASELINE b/fixtures/obfuscator-io/BASELINE index ba974e8b..5117f045 100644 --- a/fixtures/obfuscator-io/BASELINE +++ b/fixtures/obfuscator-io/BASELINE @@ -23,9 +23,9 @@ cff-1 10 9/10 10/10 10/10 0 safe-global-names (1) compact-false 10 9/10 10/10 10/10 0 safe-global-names (1) dead-code-04 10 9/10 10/10 10/10 0 safe-global-names (1) dead-code-1 10 9/10 10/10 10/10 0 safe-global-names (1) -debug-protection 10 9/10 10/10 10/10 0 safe-global-names (1) -debug-protection-interval 10 9/10 10/10 10/10 0 safe-global-names (1) -disable-console 10 9/10 10/10 10/10 0 safe-global-names (1) +debug-protection 10 8/10 10/10 10/10 0 safe-global-names (1), sd-this-value (1) +debug-protection-interval 10 8/10 10/10 10/10 0 safe-global-names (1), sd-this-value (1) +disable-console 10 8/10 10/10 10/10 0 safe-global-names (1), sd-this-value (1) domain-lock 10 0/10 10/10 10/10 0 builtin-alias-patched (10) domain-lock-redirect 10 0/10 10/10 10/10 0 builtin-alias-patched (10) encoding-base64 10 9/10 10/10 10/10 0 builtin-replaced-decoded-key (1) @@ -42,10 +42,10 @@ names-mangled-shuffled 10 9/10 10/10 10/10 0 safe-global-names (1) names-prefix 10 9/10 10/10 10/10 0 safe-global-names (1) numbers-to-expressions 10 9/10 10/10 10/10 0 safe-global-names (1) object-keys 10 8/10 9/10 10/10 1 object-keys-not-merged (2), safe-global-names (1) -pair-calls+debug 10 9/10 10/10 10/10 0 safe-global-names (1) +pair-calls+debug 10 8/10 10/10 10/10 0 safe-global-names (1), sd-this-value (1) pair-calls+keys 10 8/10 9/10 10/10 1 object-keys-not-merged (2), safe-global-names (1) pair-calls+num 10 9/10 10/10 10/10 0 safe-global-names (1) -pair-calls+self 10 9/10 10/10 10/10 0 safe-global-names (1) +pair-calls+self 10 8/10 10/10 10/10 0 safe-global-names (1), sd-this-value (1) pair-calls+split 10 9/10 10/10 10/10 0 safe-global-names (1) pair-calls+unicode 10 9/10 10/10 10/10 0 safe-global-names (1) pair-cff+calls 10 9/10 10/10 10/10 0 safe-global-names (1) @@ -54,52 +54,52 @@ pair-cff+debug 10 0/10 10/10 10/10 0 namespace-by-key (9), safe-global-names (1) pair-cff+keys 10 8/10 9/10 10/10 1 object-keys-not-merged (2), safe-global-names (1) pair-cff+num 10 9/10 10/10 10/10 0 safe-global-names (1) pair-cff+rc4 10 9/10 10/10 10/10 0 builtin-replaced-decoded-key (1) -pair-cff+self 10 9/10 10/10 10/10 0 safe-global-names (1) +pair-cff+self 10 8/10 10/10 10/10 0 safe-global-names (1), sd-this-value (1) pair-cff+split 10 9/10 10/10 1/10 0 safe-global-names (1) pair-cff+unicode 10 9/10 10/10 10/10 0 safe-global-names (1) pair-cff+wrap 10 9/10 10/10 10/10 0 safe-global-names (1) pair-dead+calls 10 9/10 10/10 10/10 0 safe-global-names (1) -pair-dead+debug 10 6/10 10/10 10/10 0 builtin-alias-patched (4) +pair-dead+debug 10 5/10 10/10 10/10 0 builtin-alias-patched (4), sd-this-value (1) pair-dead+keys 10 8/10 9/10 10/10 1 object-keys-not-merged (2), safe-global-names (1) pair-dead+num 10 9/10 10/10 10/10 0 safe-global-names (1) pair-dead+rc4 10 9/10 10/10 10/10 0 builtin-replaced-decoded-key (1) -pair-dead+self 10 9/10 10/10 10/10 0 builtin-alias-patched (1) +pair-dead+self 10 8/10 10/10 10/10 0 builtin-alias-patched (1), sd-this-value (1) pair-dead+split 10 9/10 10/10 10/10 0 safe-global-names (1) pair-dead+unicode 10 9/10 10/10 10/10 0 safe-global-names (1) pair-dead+wrap 10 9/10 10/10 10/10 0 safe-global-names (1) -pair-keys+debug 10 8/10 9/10 10/10 1 object-keys-not-merged (2), safe-global-names (1) -pair-keys+self 10 8/10 9/10 10/10 1 object-keys-not-merged (1), safe-global-key-reach (1), safe-global-names (1) +pair-keys+debug 10 7/10 9/10 10/10 1 object-keys-not-merged (2), safe-global-names (1), sd-this-value (1) +pair-keys+self 10 7/10 9/10 10/10 1 object-keys-not-merged (1), safe-global-key-reach (1), safe-global-names (1), sd-this-value (1) pair-keys+unicode 10 8/10 9/10 10/10 1 object-keys-not-merged (2), safe-global-names (1) -pair-num+debug 10 9/10 10/10 10/10 0 safe-global-names (1) +pair-num+debug 10 8/10 10/10 10/10 0 safe-global-names (1), sd-this-value (1) pair-num+keys 10 8/10 9/10 10/10 1 object-keys-not-merged (2), safe-global-names (1) -pair-num+self 10 9/10 10/10 10/10 0 safe-global-names (1) +pair-num+self 10 8/10 10/10 10/10 0 safe-global-names (1), sd-this-value (1) pair-num+unicode 10 9/10 10/10 10/10 0 safe-global-names (1) pair-rc4+calls 10 9/10 10/10 10/10 0 builtin-replaced-decoded-key (1) -pair-rc4+debug 10 9/10 10/10 10/10 0 builtin-replaced-decoded-key (1) +pair-rc4+debug 10 8/10 10/10 10/10 0 builtin-replaced-decoded-key (1), sd-this-value (1) pair-rc4+keys 10 8/10 9/10 10/10 1 builtin-replaced-decoded-key (1), object-keys-not-merged (2) pair-rc4+num 10 9/10 10/10 10/10 0 builtin-replaced-decoded-key (1) pair-rc4+self 10 4/10 10/10 10/10 0 builtin-replaced-decoded-key (2), safe-global-names (4) pair-rc4+split 10 9/10 10/10 10/10 0 builtin-replaced-decoded-key (1) pair-rc4+unicode 10 9/10 10/10 10/10 0 builtin-replaced-decoded-key (1) pair-rc4+wrap 10 9/10 10/10 10/10 0 builtin-replaced-decoded-key (1) -pair-self+debug 10 9/10 10/10 10/10 0 safe-global-names (1) -pair-split+debug 10 9/10 10/10 10/10 0 safe-global-names (1) +pair-self+debug 10 8/10 10/10 10/10 0 safe-global-names (1), sd-this-value (1) +pair-split+debug 10 8/10 10/10 10/10 0 safe-global-names (1), sd-this-value (1) pair-split+keys 10 8/10 9/10 10/10 1 object-keys-not-merged (2), safe-global-names (1) pair-split+num 10 9/10 10/10 10/10 0 safe-global-names (1) -pair-split+self 10 9/10 10/10 10/10 0 safe-global-names (1) +pair-split+self 10 8/10 10/10 10/10 0 safe-global-names (1), sd-this-value (1) pair-split+unicode 10 9/10 10/10 10/10 0 safe-global-names (1) -pair-unicode+debug 10 9/10 10/10 10/10 0 safe-global-names (1) -pair-unicode+self 10 9/10 10/10 10/10 0 safe-global-names (1) +pair-unicode+debug 10 8/10 10/10 10/10 0 safe-global-names (1), sd-this-value (1) +pair-unicode+self 10 8/10 10/10 10/10 0 safe-global-names (1), sd-this-value (1) pair-wrap+calls 10 9/10 10/10 10/10 0 safe-global-names (1) -pair-wrap+debug 10 9/10 10/10 10/10 0 safe-global-names (1) +pair-wrap+debug 10 8/10 10/10 10/10 0 safe-global-names (1), sd-this-value (1) pair-wrap+keys 10 8/10 9/10 10/10 1 object-keys-not-merged (2), safe-global-names (1) pair-wrap+num 10 9/10 10/10 10/10 0 safe-global-names (1) -pair-wrap+self 10 9/10 10/10 10/10 0 safe-global-names (1) +pair-wrap+self 10 8/10 10/10 10/10 0 safe-global-names (1), sd-this-value (1) pair-wrap+split 10 9/10 10/10 10/10 0 safe-global-names (1) pair-wrap+unicode 10 9/10 10/10 10/10 0 safe-global-names (1) preset-default 10 9/10 10/10 10/10 0 safe-global-names (1) preset-high 10 0/10 9/10 10/10 1 builtin-alias-patched (3), object-keys-not-merged (1), safe-global-key-reach (7) -preset-low 10 9/10 10/10 10/10 0 safe-global-names (1) +preset-low 10 8/10 10/10 10/10 0 safe-global-names (1), sd-this-value (1) preset-medium 10 0/10 9/10 10/10 1 builtin-alias-patched (8), object-keys-not-merged (1), safe-global-key-reach (2) rename-globals 10 9/10 10/10 10/10 0 safe-global-names (1) rename-properties-safe 10 9/10 10/10 10/10 0 safe-global-names (1) @@ -107,7 +107,7 @@ rename-properties-unsafe 10 9/10 10/10 10/10 0 safe-global-names (1) reserved-names 10 9/10 10/10 10/10 0 safe-global-names (1) reserved-strings 10 9/10 10/10 10/10 0 safe-global-names (1) rotate-off 10 9/10 10/10 10/10 0 safe-global-names (1) -self-defending 10 9/10 10/10 10/10 0 safe-global-names (1) +self-defending 10 8/10 10/10 10/10 0 safe-global-names (1), sd-this-value (1) shuffle-off 10 9/10 10/10 10/10 0 safe-global-names (1) simplify-false 10 9/10 10/10 10/10 0 safe-global-names (1) split-strings-10 10 9/10 10/10 10/10 0 safe-global-names (1) @@ -128,6 +128,7 @@ wrappers-function-params-5 10 9/10 10/10 10/10 0 safe-global-names (1) wrappers-unchained 10 9/10 10/10 10/10 0 safe-global-names (1) # cause cells fixtures lane-runs parity-gap-cells reason safe-global-names 92 95 95 0 safe lane, premise 2: code may observe the global object's names (a non-strict this, require), so the decoded unit's string array, decoders and rotator are kept as written +sd-this-value 22 22 22 0 safe lane: a method returns this, so the built-in scan cannot prove that nothing replaces a built-in the self-defending callback calls; the default lane keeps that protection, and the machinery it can see stays with it object-keys-not-merged 13 13 23 13 transformObjectKeys' var o = {}; o[k] = v; x = o sequence is not merged back into one literal when a key is computed (o[tag] = ...) or a value may throw or run code (a member read, arithmetic on a binding) builtin-replaced-decoded-key 12 13 13 0 the global-object getter's code text (Function("return (function() " + ...)) is built through a proxy object whose keys are themselves decoder calls, so the text cannot be resolved before the decode and a stateful base64 or rc4 unit is refused as a possible built-in patch builtin-alias-patched 6 36 36 0 safe lane: a write through a variable, parameter, this or computed object that may hold a standard built-in (an alias of a prototype, constructor or the global object) could replace a built-in the decoders or rotator use, so the unit is left undecoded diff --git a/fixtures/obfuscator-io/EXPECT b/fixtures/obfuscator-io/EXPECT index 8577a67e..a8f19af9 100644 --- a/fixtures/obfuscator-io/EXPECT +++ b/fixtures/obfuscator-io/EXPECT @@ -184,3 +184,25 @@ pair-cff+debug--objects-1.js safe machinery xfail namespace-by-key: safe lane: n pair-cff+debug--classes-1.js safe machinery xfail namespace-by-key: safe lane: namespace read by unproven key; a read keyed by a decoder call, which the check cannot resolve before decoding, off a holder not proven to be something other than the global object is pinned like a spelled Reflect or Object (R51-RX8) pair-cff+debug--control-1.js safe machinery xfail namespace-by-key: safe lane: namespace read by unproven key; a read keyed by a decoder call, which the check cannot resolve before decoding, off a holder not proven to be something other than the global object is pinned like a spelled Reflect or Object (R51-RX8) pair-cff+debug--strings-1.js safe machinery xfail namespace-by-key: safe lane: namespace read by unproven key; a read keyed by a decoder call, which the check cannot resolve before decoding, off a holder not proven to be something other than the global object is pinned like a spelled Reflect or Object (R51-RX8) +debug-protection--classes-1.js safe machinery xfail sd-this-value: safe lane: a method returns this, so the built-in scan cannot prove that nothing replaces a built-in the self-defending callback calls; the default lane keeps that protection, and the machinery it can see stays with it +debug-protection-interval--classes-1.js safe machinery xfail sd-this-value: safe lane: a method returns this, so the built-in scan cannot prove that nothing replaces a built-in the self-defending callback calls; the default lane keeps that protection, and the machinery it can see stays with it +disable-console--classes-1.js safe machinery xfail sd-this-value: safe lane: a method returns this, so the built-in scan cannot prove that nothing replaces a built-in the self-defending callback calls; the default lane keeps that protection, and the machinery it can see stays with it +pair-calls+debug--classes-1.js safe machinery xfail sd-this-value: safe lane: a method returns this, so the built-in scan cannot prove that nothing replaces a built-in the self-defending callback calls; the default lane keeps that protection, and the machinery it can see stays with it +pair-calls+self--classes-1.js safe machinery xfail sd-this-value: safe lane: a method returns this, so the built-in scan cannot prove that nothing replaces a built-in the self-defending callback calls; the default lane keeps that protection, and the machinery it can see stays with it +pair-cff+self--classes-1.js safe machinery xfail sd-this-value: safe lane: a method returns this, so the built-in scan cannot prove that nothing replaces a built-in the self-defending callback calls; the default lane keeps that protection, and the machinery it can see stays with it +pair-dead+debug--classes-1.js safe machinery xfail sd-this-value: safe lane: a method returns this, so the built-in scan cannot prove that nothing replaces a built-in the self-defending callback calls; the default lane keeps that protection, and the machinery it can see stays with it +pair-dead+self--classes-1.js safe machinery xfail sd-this-value: safe lane: a method returns this, so the built-in scan cannot prove that nothing replaces a built-in the self-defending callback calls; the default lane keeps that protection, and the machinery it can see stays with it +pair-keys+debug--classes-1.js safe machinery xfail sd-this-value: safe lane: a method returns this, so the built-in scan cannot prove that nothing replaces a built-in the self-defending callback calls; the default lane keeps that protection, and the machinery it can see stays with it +pair-keys+self--classes-1.js safe machinery xfail sd-this-value: safe lane: a method returns this, so the built-in scan cannot prove that nothing replaces a built-in the self-defending callback calls; the default lane keeps that protection, and the machinery it can see stays with it +pair-num+debug--classes-1.js safe machinery xfail sd-this-value: safe lane: a method returns this, so the built-in scan cannot prove that nothing replaces a built-in the self-defending callback calls; the default lane keeps that protection, and the machinery it can see stays with it +pair-num+self--classes-1.js safe machinery xfail sd-this-value: safe lane: a method returns this, so the built-in scan cannot prove that nothing replaces a built-in the self-defending callback calls; the default lane keeps that protection, and the machinery it can see stays with it +pair-rc4+debug--classes-1.js safe machinery xfail sd-this-value: safe lane: a method returns this, so the built-in scan cannot prove that nothing replaces a built-in the self-defending callback calls; the default lane keeps that protection, and the machinery it can see stays with it +pair-self+debug--classes-1.js safe machinery xfail sd-this-value: safe lane: a method returns this, so the built-in scan cannot prove that nothing replaces a built-in the self-defending callback calls; the default lane keeps that protection, and the machinery it can see stays with it +pair-split+debug--classes-1.js safe machinery xfail sd-this-value: safe lane: a method returns this, so the built-in scan cannot prove that nothing replaces a built-in the self-defending callback calls; the default lane keeps that protection, and the machinery it can see stays with it +pair-split+self--classes-1.js safe machinery xfail sd-this-value: safe lane: a method returns this, so the built-in scan cannot prove that nothing replaces a built-in the self-defending callback calls; the default lane keeps that protection, and the machinery it can see stays with it +pair-unicode+debug--classes-1.js safe machinery xfail sd-this-value: safe lane: a method returns this, so the built-in scan cannot prove that nothing replaces a built-in the self-defending callback calls; the default lane keeps that protection, and the machinery it can see stays with it +pair-unicode+self--classes-1.js safe machinery xfail sd-this-value: safe lane: a method returns this, so the built-in scan cannot prove that nothing replaces a built-in the self-defending callback calls; the default lane keeps that protection, and the machinery it can see stays with it +pair-wrap+debug--classes-1.js safe machinery xfail sd-this-value: safe lane: a method returns this, so the built-in scan cannot prove that nothing replaces a built-in the self-defending callback calls; the default lane keeps that protection, and the machinery it can see stays with it +pair-wrap+self--classes-1.js safe machinery xfail sd-this-value: safe lane: a method returns this, so the built-in scan cannot prove that nothing replaces a built-in the self-defending callback calls; the default lane keeps that protection, and the machinery it can see stays with it +preset-low--classes-1.js safe machinery xfail sd-this-value: safe lane: a method returns this, so the built-in scan cannot prove that nothing replaces a built-in the self-defending callback calls; the default lane keeps that protection, and the machinery it can see stays with it +self-defending--classes-1.js safe machinery xfail sd-this-value: safe lane: a method returns this, so the built-in scan cannot prove that nothing replaces a built-in the self-defending callback calls; the default lane keeps that protection, and the machinery it can see stays with it diff --git a/fixtures/obfuscator-relayer/BASELINE b/fixtures/obfuscator-relayer/BASELINE index 138948e7..993f6501 100644 --- a/fixtures/obfuscator-relayer/BASELINE +++ b/fixtures/obfuscator-relayer/BASELINE @@ -26,19 +26,19 @@ preset-default-n2 5 5/5 5/5 - 0 - preset-default-n3 5 5/5 5/5 - 0 - preset-default-n4 5 5/5 5/5 - 0 - preset-high-n1 5 0/5 4/5 - 0 builtin-alias-patched (3), object-keys-not-merged (1), safe-global-key-reach (2) -preset-low-n1 5 5/5 5/5 - 0 - -preset-low-n2 5 5/5 5/5 - 0 - -preset-low-n3 5 5/5 5/5 - 0 - -preset-low-n4 5 5/5 5/5 - 0 - +preset-low-n1 5 4/5 5/5 - 0 sd-this-value (1) +preset-low-n2 5 0/5 5/5 - 0 sd-other-layer-kept (4), sd-this-value (1) +preset-low-n3 5 0/5 5/5 - 0 sd-other-layer-kept (4), sd-this-value (1) +preset-low-n4 5 0/5 5/5 - 0 sd-other-layer-kept (4), sd-this-value (1) preset-medium-n1 5 0/5 4/5 - 0 builtin-alias-patched (4), object-keys-not-merged (1), safe-global-key-reach (1) rename-globals-n1 5 5/5 5/5 - 0 - rename-globals-n2 5 5/5 5/5 - 0 - rename-globals-n3 5 5/5 5/5 - 0 - rename-globals-n4 5 5/5 5/5 - 0 - -self-n1 5 5/5 5/5 - 0 - -self-n2 5 5/5 5/5 - 0 - -self-n3 5 5/5 5/5 - 0 - -self-n4 5 5/5 5/5 - 0 - +self-n1 5 4/5 5/5 - 0 sd-this-value (1) +self-n2 5 1/5 5/5 - 0 sd-other-layer-kept (3), sd-this-value (1) +self-n3 5 1/5 5/5 - 0 sd-other-layer-kept (3), sd-this-value (1) +self-n4 5 1/5 5/5 - 0 sd-other-layer-kept (3), sd-this-value (1) split-n1 5 5/5 5/5 - 0 - split-n2 5 5/5 5/5 - 0 - split-n3 5 5/5 5/5 - 0 - @@ -54,6 +54,8 @@ strings-rc4-n4 5 5/5 5/5 - 0 - web-no-eval-n1 5 0/5 4/5 - 0 builtin-alias-patched (3), object-keys-not-merged (1), safe-global-key-reach (2) # cause cells fixtures lane-runs parity-gap-cells reason object-keys-not-merged 9 9 15 0 transformObjectKeys' var o = {}; o[k] = v; x = o sequence is not merged back into one literal when a key is computed (o[tag] = ...) or a value may throw or run code (a member read, arithmetic on a binding) +sd-this-value 8 8 8 0 safe lane: a method returns this, so the built-in scan cannot prove that nothing replaces a built-in the self-defending callback calls; the default lane keeps that protection, and the machinery it can see stays with it +sd-other-layer-kept 6 21 21 0 safe lane: another layer's protection or still-encoded machinery is in the program when the self-defending pass judges a layer, so the built-ins its callback calls are not proven unpatched, every layer's block is kept and the machinery it can see stays with it safe-global-key-reach 6 20 20 0 safe lane, premise 2: the program may hold the global object and reaches keys the check cannot resolve, so the unit's call sites are left alone builtin-alias-patched 4 15 15 0 safe lane: a write through a variable, parameter, this or computed object that may hold a standard built-in (an alias of a prototype, constructor or the global object) could replace a built-in the decoders or rotator use, so the unit is left undecoded layered-safe-unit-kept 1 6 6 0 safe lane, as on main: at two layers of dead code, control flow flattening and rc4 the outer unit is left undecoded with no refusal note (only its four alias declarations are counted), so neither layer decodes; the unsafe lane decodes both diff --git a/fixtures/obfuscator-relayer/EXPECT b/fixtures/obfuscator-relayer/EXPECT index e7ffaa3b..4fea31a6 100644 --- a/fixtures/obfuscator-relayer/EXPECT +++ b/fixtures/obfuscator-relayer/EXPECT @@ -40,3 +40,32 @@ web-no-eval-n1--objects-1.js safe machinery xfail safe-global-key-reach: safe la web-no-eval-n1--objects-1.js safe simplified xfail safe-global-key-reach: safe lane, premise 2: the program may hold the global object and reaches keys the check cannot resolve, so the unit's call sites are left alone web-no-eval-n1--objects-1.js unsafe simplified xfail object-keys-not-merged: transformObjectKeys' var o = {}; o[k] = v; x = o sequence is not merged back into one literal when a key is computed (o[tag] = ...) or a value may throw or run code (a member read, arithmetic on a binding) web-no-eval-n1--strings-1.js safe machinery xfail builtin-alias-patched: safe lane: a write through a variable, parameter, this or computed object that may hold a standard built-in (an alias of a prototype, constructor or the global object) could replace a built-in the decoders or rotator use, so the unit is left undecoded +preset-low-n1--classes-1.js safe machinery xfail sd-this-value: safe lane: a method returns this, so the built-in scan cannot prove that nothing replaces a built-in the self-defending callback calls; the default lane keeps that protection, and the machinery it can see stays with it +preset-low-n2--functions-1.js safe machinery xfail sd-other-layer-kept: safe lane: another layer's protection or still-encoded machinery is in the program when the self-defending pass judges a layer, so the built-ins its callback calls are not proven unpatched, every layer's block is kept and the machinery it can see stays with it +preset-low-n2--classes-1.js safe machinery xfail sd-this-value: safe lane: a method returns this, so the built-in scan cannot prove that nothing replaces a built-in the self-defending callback calls; the default lane keeps that protection, and the machinery it can see stays with it +preset-low-n2--greeting-1.js safe machinery xfail sd-other-layer-kept: safe lane: another layer's protection or still-encoded machinery is in the program when the self-defending pass judges a layer, so the built-ins its callback calls are not proven unpatched, every layer's block is kept and the machinery it can see stays with it +preset-low-n2--objects-1.js safe machinery xfail sd-other-layer-kept: safe lane: another layer's protection or still-encoded machinery is in the program when the self-defending pass judges a layer, so the built-ins its callback calls are not proven unpatched, every layer's block is kept and the machinery it can see stays with it +preset-low-n2--strings-1.js safe machinery xfail sd-other-layer-kept: safe lane: another layer's protection or still-encoded machinery is in the program when the self-defending pass judges a layer, so the built-ins its callback calls are not proven unpatched, every layer's block is kept and the machinery it can see stays with it +preset-low-n3--classes-1.js safe machinery xfail sd-this-value: safe lane: a method returns this, so the built-in scan cannot prove that nothing replaces a built-in the self-defending callback calls; the default lane keeps that protection, and the machinery it can see stays with it +preset-low-n3--functions-1.js safe machinery xfail sd-other-layer-kept: safe lane: another layer's protection or still-encoded machinery is in the program when the self-defending pass judges a layer, so the built-ins its callback calls are not proven unpatched, every layer's block is kept and the machinery it can see stays with it +preset-low-n3--greeting-1.js safe machinery xfail sd-other-layer-kept: safe lane: another layer's protection or still-encoded machinery is in the program when the self-defending pass judges a layer, so the built-ins its callback calls are not proven unpatched, every layer's block is kept and the machinery it can see stays with it +preset-low-n3--objects-1.js safe machinery xfail sd-other-layer-kept: safe lane: another layer's protection or still-encoded machinery is in the program when the self-defending pass judges a layer, so the built-ins its callback calls are not proven unpatched, every layer's block is kept and the machinery it can see stays with it +preset-low-n3--strings-1.js safe machinery xfail sd-other-layer-kept: safe lane: another layer's protection or still-encoded machinery is in the program when the self-defending pass judges a layer, so the built-ins its callback calls are not proven unpatched, every layer's block is kept and the machinery it can see stays with it +preset-low-n4--greeting-1.js safe machinery xfail sd-other-layer-kept: safe lane: another layer's protection or still-encoded machinery is in the program when the self-defending pass judges a layer, so the built-ins its callback calls are not proven unpatched, every layer's block is kept and the machinery it can see stays with it +preset-low-n4--classes-1.js safe machinery xfail sd-this-value: safe lane: a method returns this, so the built-in scan cannot prove that nothing replaces a built-in the self-defending callback calls; the default lane keeps that protection, and the machinery it can see stays with it +preset-low-n4--functions-1.js safe machinery xfail sd-other-layer-kept: safe lane: another layer's protection or still-encoded machinery is in the program when the self-defending pass judges a layer, so the built-ins its callback calls are not proven unpatched, every layer's block is kept and the machinery it can see stays with it +preset-low-n4--objects-1.js safe machinery xfail sd-other-layer-kept: safe lane: another layer's protection or still-encoded machinery is in the program when the self-defending pass judges a layer, so the built-ins its callback calls are not proven unpatched, every layer's block is kept and the machinery it can see stays with it +preset-low-n4--strings-1.js safe machinery xfail sd-other-layer-kept: safe lane: another layer's protection or still-encoded machinery is in the program when the self-defending pass judges a layer, so the built-ins its callback calls are not proven unpatched, every layer's block is kept and the machinery it can see stays with it +self-n1--classes-1.js safe machinery xfail sd-this-value: safe lane: a method returns this, so the built-in scan cannot prove that nothing replaces a built-in the self-defending callback calls; the default lane keeps that protection, and the machinery it can see stays with it +self-n2--classes-1.js safe machinery xfail sd-this-value: safe lane: a method returns this, so the built-in scan cannot prove that nothing replaces a built-in the self-defending callback calls; the default lane keeps that protection, and the machinery it can see stays with it +self-n2--greeting-1.js safe machinery xfail sd-other-layer-kept: safe lane: another layer's protection or still-encoded machinery is in the program when the self-defending pass judges a layer, so the built-ins its callback calls are not proven unpatched, every layer's block is kept and the machinery it can see stays with it +self-n2--objects-1.js safe machinery xfail sd-other-layer-kept: safe lane: another layer's protection or still-encoded machinery is in the program when the self-defending pass judges a layer, so the built-ins its callback calls are not proven unpatched, every layer's block is kept and the machinery it can see stays with it +self-n2--strings-1.js safe machinery xfail sd-other-layer-kept: safe lane: another layer's protection or still-encoded machinery is in the program when the self-defending pass judges a layer, so the built-ins its callback calls are not proven unpatched, every layer's block is kept and the machinery it can see stays with it +self-n3--classes-1.js safe machinery xfail sd-this-value: safe lane: a method returns this, so the built-in scan cannot prove that nothing replaces a built-in the self-defending callback calls; the default lane keeps that protection, and the machinery it can see stays with it +self-n3--greeting-1.js safe machinery xfail sd-other-layer-kept: safe lane: another layer's protection or still-encoded machinery is in the program when the self-defending pass judges a layer, so the built-ins its callback calls are not proven unpatched, every layer's block is kept and the machinery it can see stays with it +self-n3--objects-1.js safe machinery xfail sd-other-layer-kept: safe lane: another layer's protection or still-encoded machinery is in the program when the self-defending pass judges a layer, so the built-ins its callback calls are not proven unpatched, every layer's block is kept and the machinery it can see stays with it +self-n3--strings-1.js safe machinery xfail sd-other-layer-kept: safe lane: another layer's protection or still-encoded machinery is in the program when the self-defending pass judges a layer, so the built-ins its callback calls are not proven unpatched, every layer's block is kept and the machinery it can see stays with it +self-n4--classes-1.js safe machinery xfail sd-this-value: safe lane: a method returns this, so the built-in scan cannot prove that nothing replaces a built-in the self-defending callback calls; the default lane keeps that protection, and the machinery it can see stays with it +self-n4--greeting-1.js safe machinery xfail sd-other-layer-kept: safe lane: another layer's protection or still-encoded machinery is in the program when the self-defending pass judges a layer, so the built-ins its callback calls are not proven unpatched, every layer's block is kept and the machinery it can see stays with it +self-n4--objects-1.js safe machinery xfail sd-other-layer-kept: safe lane: another layer's protection or still-encoded machinery is in the program when the self-defending pass judges a layer, so the built-ins its callback calls are not proven unpatched, every layer's block is kept and the machinery it can see stays with it +self-n4--strings-1.js safe machinery xfail sd-other-layer-kept: safe lane: another layer's protection or still-encoded machinery is in the program when the self-defending pass judges a layer, so the built-ins its callback calls are not proven unpatched, every layer's block is kept and the machinery it can see stays with it diff --git a/fixtures/obfuscator-versions/EXPECT b/fixtures/obfuscator-versions/EXPECT index 7fef9814..0291ce6e 100644 --- a/fixtures/obfuscator-versions/EXPECT +++ b/fixtures/obfuscator-versions/EXPECT @@ -488,3 +488,31 @@ 4.2.2--b64-rot-shuf-shift-istr-w1-nocalls-t1-unicode--wp4-bundle--uglify--greeting-1.js safe machinery xfail namespace-by-key: safe lane: namespace read by unproven key; a read keyed by a decoder call, which the check cannot resolve before decoding, off a holder not proven to be something other than the global object is pinned like a spelled Reflect or Object (R51-RX8) 4.2.2--rc4-norot-noshuf-shift-istr-w0-calls-t75-keys--wp4-bundle--none--empty-log-1.js safe machinery xfail namespace-by-key: safe lane: namespace read by unproven key; a read keyed by a decoder call, which the check cannot resolve before decoding, off a holder not proven to be something other than the global object is pinned like a spelled Reflect or Object (R51-RX8) 4.2.2--rc4-norot-noshuf-shift-istr-w0-calls-t75-keys--wp4-bundle--none--empty-log-1.js safe simplified xfail namespace-by-key: safe lane: namespace read by unproven key; a read keyed by a decoder call, which the check cannot resolve before decoding, off a holder not proven to be something other than the global object is pinned like a spelled Reflect or Object (R51-RX8) +0.10.2--b64-norot-t1-self--wp4-module--uglify--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.10.2--b64-rot-t75-self--wp4-bundle--uglify--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.10.2--plain-rot-t75-self--wp4-bundle--uglify--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.10.2--rc4-norot-t1-self--wp4-bundle--none--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.10.2--rc4-norot-t1-self--wp4-bundle--none--* safe simplified xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.10.2--rc4-norot-t1-self--wp4-module--none--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.10.2--rc4-norot-t1-self--wp4-module--none--* safe simplified xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.10.2--rc4-rot-t1-self--top--uglify--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.16.0--rc4-rot-t1-self--iife--none--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.16.0--rc4-rot-t1-self--iife--none--* safe simplified xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.18.8--plain-norot-t75-self--wp4-module--uglify--* safe machinery xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.18.8--plain-norot-t75-self--wp4-module--uglify--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.18.8--plain-rot-t75-self--iife--uglify--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.18.8--rc4-rot-t1-self--wp4-bundle--none--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.18.8--rc4-rot-t1-self--wp4-bundle--none--* safe simplified xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.20.4--b64-norot-t75-self--wp4-module--none--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.20.4--b64-norot-t75-self--wp4-module--none--* safe simplified xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.20.4--rc4-norot-t75-self--wp4-bundle--none--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.20.4--rc4-norot-t75-self--wp4-bundle--none--* safe simplified xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.20.4--rc4-rot-t1-self--wp4-module--none--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.20.4--rc4-rot-t1-self--wp4-module--none--* safe simplified xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.20.4--rc4-rot-t75-self--iife--uglify--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.23.2--plain-rot-noshuf-t75-self--iife--uglify--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.23.2--plain-rot-shuf-t75-self--wp4-bundle--uglify--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.23.2--rc4-rot-shuf-t75-self--wp4-bundle--uglify--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.28.5--plain-rot-noshuf-t75-self--top--uglify--* safe machinery xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +2.14.0--b64-norot-shuf-shift-inum-w0-t75-self--top--none--* safe machinery xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +5.9.1--rc4-rot-shuf-noshift-inum-w3f-nocalls-t75-self--top--terser--* safe machinery xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept From 4d96d86ab0b3a1af6c72e17b16893b02d8dbe2d5 Mon Sep 17 00:00:00 2001 From: sorte1 Date: Thu, 19 Nov 2026 07:52:41 +0100 Subject: [PATCH 05/14] fix: count a computed key that starts with a proven number as harmless, so a decoder cache key built from the shifted index no longer counts as a reaching key --- .../src/semantic/builtins/scan.rs | 6 +- .../src/semantic/builtins/scan/numeric.rs | 93 ++++++++++++++++--- .../tests/builtins_numeric_keys.rs | 6 +- fixtures/obfuscator-versions/EXPECT | 1 - 4 files changed, 88 insertions(+), 18 deletions(-) diff --git a/crates/untwist-core/src/semantic/builtins/scan.rs b/crates/untwist-core/src/semantic/builtins/scan.rs index 48b71c93..1f298de7 100644 --- a/crates/untwist-core/src/semantic/builtins/scan.rs +++ b/crates/untwist-core/src/semantic/builtins/scan.rs @@ -193,7 +193,7 @@ struct Scan<'s> { functions: OnceCell, escaping: OnceCell, windows: OnceCell, - numeric: OnceCell, + numeric: OnceCell, reached: RefCell>, scoping: &'s Scoping, reliance: &'s Reliance, @@ -343,8 +343,8 @@ impl Scan<'_> { pub(super) fn numeric_key(&self, key: &Expression<'_>) -> bool { let numeric = self .numeric - .get_or_init(|| numeric::numeric_bindings(self.program, self.scoping, self.module)); - numeric::is_numeric(key, self.scoping, numeric) + .get_or_init(|| numeric::key_bindings(self.program, self.scoping, self.module)); + numeric::is_harmless_key(key, self.scoping, numeric) } pub(super) fn sharpen<'k>(&self, key: Key<'k>) -> Key<'k> { diff --git a/crates/untwist-core/src/semantic/builtins/scan/numeric.rs b/crates/untwist-core/src/semantic/builtins/scan/numeric.rs index 56ba80b7..27c6dd2f 100644 --- a/crates/untwist-core/src/semantic/builtins/scan/numeric.rs +++ b/crates/untwist-core/src/semantic/builtins/scan/numeric.rs @@ -13,6 +13,11 @@ use crate::semantic::is_foreign_global; pub(super) type NumericBindings = FxHashSet; +pub(super) struct KeyBindings { + numeric: NumericBindings, + led: NumericBindings, +} + const ARGUMENTS: &str = "arguments"; fn reference_symbol(id: &IdentifierReference<'_>, scoping: &Scoping) -> Option { @@ -85,11 +90,55 @@ pub(super) fn is_numeric( } } +fn is_led( + expression: &Expression<'_>, + scoping: &Scoping, + numeric: &NumericBindings, + led: &NumericBindings, +) -> bool { + if is_numeric(expression, scoping, numeric) { + return true; + } + match expression.without_parentheses() { + Expression::BinaryExpression(binary) => { + binary.operator == BinaryOperator::Addition + && is_led(&binary.left, scoping, numeric, led) + } + Expression::Identifier(id) => { + reference_symbol(id, scoping).is_some_and(|symbol| led.contains(&symbol)) + } + Expression::AssignmentExpression(assignment) => match assignment.operator { + AssignmentOperator::Assign => is_led(&assignment.right, scoping, numeric, led), + AssignmentOperator::Addition => assigned_symbol(&assignment.left, scoping) + .is_some_and(|symbol| led.contains(&symbol)), + _ => false, + }, + Expression::SequenceExpression(sequence) => sequence + .expressions + .last() + .is_some_and(|last| is_led(last, scoping, numeric, led)), + Expression::ConditionalExpression(conditional) => { + is_led(&conditional.consequent, scoping, numeric, led) + && is_led(&conditional.alternate, scoping, numeric, led) + } + _ => false, + } +} + +pub(super) fn is_harmless_key( + expression: &Expression<'_>, + scoping: &Scoping, + keys: &KeyBindings, +) -> bool { + is_led(expression, scoping, &keys.numeric, &keys.led) +} + const MAX_PASSES: usize = 8; struct Collect<'s> { scoping: &'s Scoping, numeric: &'s NumericBindings, + led: Option<&'s NumericBindings>, module: bool, bindings: FxHashMap, plain_bindings: FxHashMap, @@ -156,7 +205,17 @@ impl Collect<'_> { } fn numeric(&self, expression: &Expression<'_>) -> bool { - is_numeric(expression, self.scoping, self.numeric) + match self.led { + Some(led) => is_led(expression, self.scoping, self.numeric, led), + None => is_numeric(expression, self.scoping, self.numeric), + } + } + + fn adds_to(&self, symbol: SymbolId, right: &Expression<'_>) -> bool { + match self.led { + Some(led) => led.contains(&symbol), + None => self.numeric.contains(&symbol) && self.numeric(right), + } } fn decoder_param(&mut self, function: &Function<'_>) { @@ -303,11 +362,8 @@ impl<'a> VisitJs<'a> for Collect<'_> { | AssignmentOperator::LogicalAnd | AssignmentOperator::LogicalOr | AssignmentOperator::LogicalNullish => self.numeric(&it.right), - AssignmentOperator::Addition => { - reference_symbol(target, self.scoping) - .is_some_and(|symbol| self.numeric.contains(&symbol)) - && self.numeric(&it.right) - } + AssignmentOperator::Addition => reference_symbol(target, self.scoping) + .is_some_and(|symbol| self.adds_to(symbol, &it.right)), operator => is_numeric_compound(operator), }; if let (true, Some(reference)) = (numeric, target.reference_id.get()) { @@ -350,11 +406,12 @@ fn narrowed( program: &Program<'_>, scoping: &Scoping, module: bool, - numeric: &NumericBindings, + (numeric, led): (&NumericBindings, Option<&NumericBindings>), ) -> NumericBindings { let mut collect = Collect { scoping, numeric, + led, module, bindings: FxHashMap::default(), plain_bindings: FxHashMap::default(), @@ -370,25 +427,35 @@ fn narrowed( .strict .push(module || crate::semantic::program_is_strict(program)); collect.visit_program(program); - numeric + led.unwrap_or(numeric) .iter() .copied() .filter(|&symbol| collect.holds(symbol)) .collect() } -pub(super) fn numeric_bindings( +fn fixpoint( program: &Program<'_>, scoping: &Scoping, module: bool, + numeric: Option<&NumericBindings>, ) -> NumericBindings { - let mut numeric: NumericBindings = scoping.symbol_ids().collect(); + let mut current: NumericBindings = scoping.symbol_ids().collect(); for _ in 0..MAX_PASSES { - let next = narrowed(program, scoping, module, &numeric); - if next.len() == numeric.len() { + let next = match numeric { + Some(numeric) => narrowed(program, scoping, module, (numeric, Some(¤t))), + None => narrowed(program, scoping, module, (¤t, None)), + }; + if next.len() == current.len() { return next; } - numeric = next; + current = next; } NumericBindings::default() } + +pub(super) fn key_bindings(program: &Program<'_>, scoping: &Scoping, module: bool) -> KeyBindings { + let numeric = fixpoint(program, scoping, module, None); + let led = fixpoint(program, scoping, module, Some(&numeric)); + KeyBindings { numeric, led } +} diff --git a/crates/untwist-core/tests/builtins_numeric_keys.rs b/crates/untwist-core/tests/builtins_numeric_keys.rs index 83518072..41d93960 100644 --- a/crates/untwist-core/tests/builtins_numeric_keys.rs +++ b/crates/untwist-core/tests/builtins_numeric_keys.rs @@ -26,6 +26,9 @@ fn a_key_proven_numeric_reaches_no_prototype() { "function f(p, q) { p = p - 277; var c = d(); return c[p]; }", "function f(a, c) { g(a[c -= 0], a[c = +c]); }", "var a = [1]; for (var i = 0; i < 1; i++) g(a[i]);", + "function f(p, q) { p = p - 1; var a = d(); var k = p + a[0]; return c[k]; }", + "function f(a, n, s) { g(a[(n | 0) + s + 'x']); }", + "function f(a, k) { let i = 0; i += k; g(a[i]); }", ] { assert_eq!(verdict(source), Builtins::Intact, "{source}"); } @@ -36,7 +39,6 @@ fn a_key_that_may_be_a_string_still_counts() { for source in [ "function f(a, k) { g(a[k]); }", "function f(a, k) { let i = 0; i = k; g(a[i]); }", - "function f(a, k) { let i = 0; i += k; g(a[i]); }", "function f(a, o) { for (let k in o) g(a[k]); }", "function f(a, o) { let i = 0; [i] = o; g(a[i]); }", "function f(a, n) { let i = 0; h = () => { i = n; }; g(a[i]); }", @@ -44,6 +46,8 @@ fn a_key_that_may_be_a_string_still_counts() { "function f(p) { p = p - 1; arguments[0] = k; return d()[p]; }", "function f(p) { p = p - 1; p = k; return d()[p]; }", "function f(p, q = p) { p = p - 1; return d()[p]; }", + "function f(p) { p = p - 1; var a = d(); var k = a[0] + p; return c[k]; }", + "function f(a, s, n) { g(a[s + (n | 0)]); }", "var a = [1]; var i = 0; window.i = k; g(a[i]);", "var a = [1]; var i = 0; this[k] = 1; g(a[i]);", ] { diff --git a/fixtures/obfuscator-versions/EXPECT b/fixtures/obfuscator-versions/EXPECT index 0291ce6e..2a5921d9 100644 --- a/fixtures/obfuscator-versions/EXPECT +++ b/fixtures/obfuscator-versions/EXPECT @@ -514,5 +514,4 @@ 0.23.2--plain-rot-shuf-t75-self--wp4-bundle--uglify--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept 0.23.2--rc4-rot-shuf-t75-self--wp4-bundle--uglify--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept 0.28.5--plain-rot-noshuf-t75-self--top--uglify--* safe machinery xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept -2.14.0--b64-norot-shuf-shift-inum-w0-t75-self--top--none--* safe machinery xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept 5.9.1--rc4-rot-shuf-noshift-inum-w3f-nocalls-t75-self--top--terser--* safe machinery xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept From 1c9d47089c58f310f9e1db6032cecec539af0c8f Mon Sep 17 00:00:00 2001 From: sorte1 Date: Thu, 19 Nov 2026 08:30:04 +0100 Subject: [PATCH 06/14] fix: drop the numeric-key proof when a direct eval may write a binding, and relabel the inline row whose loop index is now proven numeric --- .../src/semantic/builtins/scan/numeric.rs | 14 ++++++++++++++ crates/untwist/tests/data/inline_layer_rows.txt | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/crates/untwist-core/src/semantic/builtins/scan/numeric.rs b/crates/untwist-core/src/semantic/builtins/scan/numeric.rs index 27c6dd2f..1f084b49 100644 --- a/crates/untwist-core/src/semantic/builtins/scan/numeric.rs +++ b/crates/untwist-core/src/semantic/builtins/scan/numeric.rs @@ -20,6 +20,8 @@ pub(super) struct KeyBindings { const ARGUMENTS: &str = "arguments"; +const EVAL: &str = "eval"; + fn reference_symbol(id: &IdentifierReference<'_>, scoping: &Scoping) -> Option { id.reference_id .get() @@ -149,6 +151,7 @@ struct Collect<'s> { strict: Vec, global_keys: FxHashSet, global_unknown: bool, + direct_eval: bool, } fn uses_arguments(function: &Function<'_>) -> bool { @@ -294,6 +297,9 @@ impl Collect<'_> { } fn holds(&self, symbol: SymbolId) -> bool { + if self.direct_eval { + return false; + } let flags = self.scoping.symbol_flags(symbol); let variable = flags.is_variable() && !flags.intersects( @@ -380,6 +386,13 @@ impl<'a> VisitJs<'a> for Collect<'_> { walk_js::walk_simple_assignment_target(self, it); } + fn visit_call_expression(&mut self, it: &CallExpression<'a>) { + if let Expression::Identifier(callee) = it.callee.without_parentheses() { + self.direct_eval |= callee.name == EVAL; + } + walk_js::walk_call_expression(self, it); + } + fn visit_update_expression(&mut self, it: &UpdateExpression<'a>) { if let SimpleAssignmentTarget::AssignmentTargetIdentifier(target) = &it.argument { self.numeric_writes.extend(target.reference_id.get()); @@ -422,6 +435,7 @@ fn narrowed( strict: Vec::new(), global_keys: FxHashSet::default(), global_unknown: false, + direct_eval: false, }; collect .strict diff --git a/crates/untwist/tests/data/inline_layer_rows.txt b/crates/untwist/tests/data/inline_layer_rows.txt index d194b77b..e868145c 100644 --- a/crates/untwist/tests/data/inline_layer_rows.txt +++ b/crates/untwist/tests/data/inline_layer_rows.txt @@ -76,7 +76,8 @@ keep:kept-eval-may-declare-eval|function f(s) { eval(s); return eval("1+1"); } c keep:top-level-kept-eval-declares-eval|eval("var eval = function (s) { return 'patched ' + s; }"); function f() { console.log(eval("1 + 1")); } f(); keep:kept-eval-in-outer-function|function outer(s) { eval(s); function inner() { return eval("1+1"); } return inner(); } console.log(outer("var eval = function () { return 'outer patched'; }")); unsafe-peel:peeled-text-runs-eval|function f(s) { eval("eval(s)"); return eval("2+2"); } console.log(f("var eval = function () { return 'from text'; }")); -unsafe-peel:var-index-keeps-the-eval-by-default|var a = [1, 2, 3], t = 0; for (var i = 0; i < a.length; i++) { t += a[i]; } var b = a[i - 1] + a[t % 3]; function f() { eval("console.log('or" + [] + "ig', " + "t, b)"); } f(); +peel:var-index-proven-numeric-peels-by-default|var a = [1, 2, 3], t = 0; for (var i = 0; i < a.length; i++) { t += a[i]; } var b = a[i - 1] + a[t % 3]; function f() { eval("console.log('or" + [] + "ig', " + "t, b)"); } f(); +unsafe-peel:var-index-from-a-call-keeps-the-eval-by-default|var a = [1, 2, 3], k = String([1].length); var b = a[k]; function f() { eval("console.log('or" + [] + "ig', " + "b)"); } f(); peel:literal-key-concatenation-keeps-folding|var o = { ab: 1 }; var v = o['a' + 'b']; function f() { eval("console.log('or" + [] + "ig', v)"); } f(); peel:const-key-keeps-folding|var a = [1, 2, 3]; const k = 1; var b = a[k] + a[0] + a[2 - 1]; function f() { eval("console.log('or" + [] + "ig', b)"); } f(); keep:v8-rejected-regex-y0000|function f() { try { eval("/\\b*/"); console.log("ok"); } catch (e) { console.log(e.name); } } f(); From ef36a1ba8a45e0ed2c4dab4776eadc7a37d0c3dc Mon Sep 17 00:00:00 2001 From: sorte1 Date: Thu, 19 Nov 2026 09:51:55 +0100 Subject: [PATCH 07/14] fix: carry the kept-protection note into a rerun that keeps the self-defending check, so the output still names its premise --- crates/untwist/src/pipeline/input.rs | 8 ++++++-- crates/untwist/src/pipeline/notes.rs | 25 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/crates/untwist/src/pipeline/input.rs b/crates/untwist/src/pipeline/input.rs index 52c382d4..c9e8700a 100644 --- a/crates/untwist/src/pipeline/input.rs +++ b/crates/untwist/src/pipeline/input.rs @@ -29,8 +29,8 @@ use untwist_unpack::holds_a_bundle_with; use super::boundary::Boundary; use super::layer::{Counters, InlineSite, Layering, Peeled, RoomSeed}; use super::notes::{ - carry_reach, consolidate_reach, dedupe_spanned, guard_notes, reach_refusals, unsafe_lane_hint, - SOURCE_READER_UNGUARDED, + carry_kept_protections, carry_reach, consolidate_reach, dedupe_spanned, guard_notes, + kept_protections, reach_refusals, unsafe_lane_hint, SOURCE_READER_UNGUARDED, }; use super::shell::{scope_shell_body, strip_shell}; use super::snapshots::Snapshots; @@ -245,9 +245,11 @@ impl Pipeline { None => first, Some(_) => { let reached = reach_refusals(&first.notes); + let kept = kept_protections(&first.notes); drop(first); let mut second = self.rerun(source, reservation, (room.clone(), reserved)); second.notes = carry_reach(std::mem::take(&mut second.notes), reached); + second.notes = carry_kept_protections(std::mem::take(&mut second.notes), kept); second } }; @@ -255,10 +257,12 @@ impl Pipeline { return verified; } let reached = reach_refusals(&verified.notes); + let kept = kept_protections(&verified.notes); drop(verified); let _whole = untwist_deobfuscate::self_defending::PartialRemovalsForbidden::enter(); let mut whole = self.rerun(source, reservation, (room, reserved)); whole.notes = carry_reach(std::mem::take(&mut whole.notes), reached); + whole.notes = carry_kept_protections(std::mem::take(&mut whole.notes), kept); whole } diff --git a/crates/untwist/src/pipeline/notes.rs b/crates/untwist/src/pipeline/notes.rs index 572f7767..66572fec 100644 --- a/crates/untwist/src/pipeline/notes.rs +++ b/crates/untwist/src/pipeline/notes.rs @@ -281,6 +281,31 @@ pub(super) fn reach_refusals(notes: &[Note]) -> Vec { }] } +pub(super) fn kept_protections(notes: &[Note]) -> Vec { + notes + .iter() + .filter(|note| note.message == notes::SELF_DEFENDING_BUILTIN_PATCHED) + .cloned() + .collect() +} + +pub(super) fn carry_kept_protections(notes: Vec, earlier: Vec) -> Vec { + let check_survived = notes.iter().any(|note| { + note.message.starts_with(GUARD_ON_ONE_LINE) + || note.message.starts_with(GUARD_KEPT_ACROSS_LINES) + }); + let noted = notes + .iter() + .any(|note| note.message == notes::SELF_DEFENDING_BUILTIN_PATCHED); + if !check_survived || noted || earlier.is_empty() { + return notes; + } + let mut carried = earlier; + carried.dedup(); + carried.extend(notes); + carried +} + pub(super) fn carry_reach(notes: Vec, earlier: Vec) -> Vec { let judged = notes .iter() From ea27552604180cae2e1ed09df32e4fe55c97dea3 Mon Sep 17 00:00:00 2001 From: sorte1 Date: Thu, 19 Nov 2026 11:45:21 +0100 Subject: [PATCH 08/14] test: list the relayered fixtures whose self-defending block stays unproven, and document number-led keys --- crates/untwist/tests/obfuscator_relayer.rs | 91 +++++++++++++++++++++- docs/known-divergences/deobfuscate.md | 4 +- 2 files changed, 92 insertions(+), 3 deletions(-) diff --git a/crates/untwist/tests/obfuscator_relayer.rs b/crates/untwist/tests/obfuscator_relayer.rs index e40793e5..1d624e00 100644 --- a/crates/untwist/tests/obfuscator_relayer.rs +++ b/crates/untwist/tests/obfuscator_relayer.rs @@ -12,7 +12,9 @@ const CONSOLE_DISABLE_KEPT: &str = "the default lane leaves the layers undecoded const LAYERED_SAFE_UNIT_KEPT: &str = "the default lane leaves the outer unit of two layers of dead code, control flow flattening and rc4 undecoded, as main does, so neither layer decodes; the unsafe lane decodes both"; -const REFUSED_LAYERS: [(&str, &str, &str); 21] = [ +const SELF_DEFENDING_UNPROVEN: &str = "the default lane keeps a layer's self-defending block because the built-in scan cannot prove what its callback calls unpatched (another layer's protection or still-encoded machinery, or a method returning this, is in the program when the block is judged), so the layers it can see stay too"; + +const REFUSED_LAYERS: [(&str, &str, &str); 48] = [ ( "dead-cff-rc4-n2--classes-1.js", "default", @@ -118,6 +120,93 @@ const REFUSED_LAYERS: [(&str, &str, &str); 21] = [ "default", CONSOLE_DISABLE_KEPT, ), + ( + "preset-low-n2--classes-1.js", + "default", + SELF_DEFENDING_UNPROVEN, + ), + ( + "preset-low-n2--functions-1.js", + "default", + SELF_DEFENDING_UNPROVEN, + ), + ( + "preset-low-n2--greeting-1.js", + "default", + SELF_DEFENDING_UNPROVEN, + ), + ( + "preset-low-n2--objects-1.js", + "default", + SELF_DEFENDING_UNPROVEN, + ), + ( + "preset-low-n2--strings-1.js", + "default", + SELF_DEFENDING_UNPROVEN, + ), + ( + "preset-low-n3--classes-1.js", + "default", + SELF_DEFENDING_UNPROVEN, + ), + ( + "preset-low-n3--functions-1.js", + "default", + SELF_DEFENDING_UNPROVEN, + ), + ( + "preset-low-n3--greeting-1.js", + "default", + SELF_DEFENDING_UNPROVEN, + ), + ( + "preset-low-n3--objects-1.js", + "default", + SELF_DEFENDING_UNPROVEN, + ), + ( + "preset-low-n3--strings-1.js", + "default", + SELF_DEFENDING_UNPROVEN, + ), + ( + "preset-low-n4--classes-1.js", + "default", + SELF_DEFENDING_UNPROVEN, + ), + ( + "preset-low-n4--functions-1.js", + "default", + SELF_DEFENDING_UNPROVEN, + ), + ( + "preset-low-n4--greeting-1.js", + "default", + SELF_DEFENDING_UNPROVEN, + ), + ( + "preset-low-n4--objects-1.js", + "default", + SELF_DEFENDING_UNPROVEN, + ), + ( + "preset-low-n4--strings-1.js", + "default", + SELF_DEFENDING_UNPROVEN, + ), + ("self-n2--classes-1.js", "default", SELF_DEFENDING_UNPROVEN), + ("self-n2--greeting-1.js", "default", SELF_DEFENDING_UNPROVEN), + ("self-n2--objects-1.js", "default", SELF_DEFENDING_UNPROVEN), + ("self-n2--strings-1.js", "default", SELF_DEFENDING_UNPROVEN), + ("self-n3--classes-1.js", "default", SELF_DEFENDING_UNPROVEN), + ("self-n3--greeting-1.js", "default", SELF_DEFENDING_UNPROVEN), + ("self-n3--objects-1.js", "default", SELF_DEFENDING_UNPROVEN), + ("self-n3--strings-1.js", "default", SELF_DEFENDING_UNPROVEN), + ("self-n4--classes-1.js", "default", SELF_DEFENDING_UNPROVEN), + ("self-n4--greeting-1.js", "default", SELF_DEFENDING_UNPROVEN), + ("self-n4--objects-1.js", "default", SELF_DEFENDING_UNPROVEN), + ("self-n4--strings-1.js", "default", SELF_DEFENDING_UNPROVEN), ]; #[derive(Clone)] diff --git a/docs/known-divergences/deobfuscate.md b/docs/known-divergences/deobfuscate.md index 5f980391..b3246df2 100644 --- a/docs/known-divergences/deobfuscate.md +++ b/docs/known-divergences/deobfuscate.md @@ -741,8 +741,8 @@ `Object.getPrototypeOf(x)`, a computed key that may be `__proto__` or `constructor`) and no code run from a string: a removed callback would no longer run a replaced member. A computed key counts as harmless when it is a number: a numeric literal, the result of arithmetic other than - `+`, a unary `-`, `+`, `~` or `!`, an update, `+` of two such keys, or a binding whose every - write is such a value. That includes a parameter whose first statement is `p = p - N` and that + `+`, a unary `-`, `+`, `~` or `!`, an update, `+` of two such keys, a `+` whose left side is such a key (its text starts with a number, so it + is never `__proto__` or `constructor`), or a binding whose every write is such a value. That includes a parameter whose first statement is `p = p - N` and that is written nowhere else, in a function that is strict or does not use `arguments`, and a top-level binding of a script when no global-object write may name it (`window.i = …`, `this[k] = …`) and no other input names it. The default mode removes a callback run through one only when the callback is, node From 4453fa405cec7c6007b10c3df87bdf0931693687 Mon Sep 17 00:00:00 2001 From: sorte1 Date: Thu, 19 Nov 2026 13:38:46 +0100 Subject: [PATCH 09/14] test: the sweep rows accept the unproven-built-ins note where the default lane now keeps the block, and the second-round map row checks the unsafe lane --- crates/untwist/tests/obfuscator_sweep_rows.rs | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/crates/untwist/tests/obfuscator_sweep_rows.rs b/crates/untwist/tests/obfuscator_sweep_rows.rs index 16b6711a..1ad82e90 100644 --- a/crates/untwist/tests/obfuscator_sweep_rows.rs +++ b/crates/untwist/tests/obfuscator_sweep_rows.rs @@ -167,6 +167,7 @@ fn a_decoder_reached_from_a_live_guarded_branch_keeps_its_unit_under_unsafe() { #[test] fn a_later_round_keeps_the_reach_reason_of_the_layer_round_one_decoded() { let output = Pipeline::new(Options::default()).run(&read("round-two-reach.js")); + let kept_protection = keeps_unproven_built_ins(&output); let reach = output .notes .iter() @@ -174,10 +175,10 @@ fn a_later_round_keeps_the_reach_reason_of_the_layer_round_one_decoded() { let kept = output.notes.iter().find(|note| { note.kind == NoteKind::Refusal && note.message.starts_with("decoder machinery kept: ") }); - assert!(reach, "{:#?}", output.notes); let kept = kept.expect("a kept-machinery note"); + assert!(kept_protection || reach, "{:#?}", output.notes); assert!( - kept.message.contains("may hold the global object"), + kept_protection || kept.message.contains("may hold the global object"), "{}", kept.message ); @@ -220,10 +221,10 @@ fn source_text_at(source: &str, (line, column): (u32, u32)) -> String { } #[test] -fn a_second_round_keeps_a_source_map_into_the_input_in_both_lanes() { +fn a_second_round_keeps_a_source_map_into_the_input_under_unsafe() { let source = fixture(SECOND_ROUND); - for unsafe_transforms in [false, true] { - let output = traced(&source, unsafe_transforms); + { + let output = traced(&source, true); let map = output.source_maps[0].as_ref().expect("a map"); let map = source_map::parse(&map.to_json_string()).expect("the map parses back"); assert_eq!(map.get_source_content(0), Some(source.as_str())); @@ -242,6 +243,17 @@ fn a_second_round_keeps_a_source_map_into_the_input_in_both_lanes() { fn a_second_round_maps_statement_spans_and_decoded_strings_into_the_input() { let source = fixture(SECOND_ROUND); let output = traced(&source, false); + if output.code() == source { + assert!( + output + .notes + .iter() + .any(|note| note.message.starts_with(untwist::SOURCE_READER_UNGUARDED)), + "{:?}", + output.notes + ); + return; + } let spans = output.statement_spans.expect("statement spans"); assert!(!spans.is_empty()); for (start, end) in spans { @@ -318,6 +330,13 @@ fn has_note(output: &untwist::Output, message: &str) -> bool { output.notes.iter().any(|note| note.message == message) } +fn keeps_unproven_built_ins(output: &untwist::Output) -> bool { + has_note( + output, + untwist_deobfuscate::notes::SELF_DEFENDING_BUILTIN_PATCHED, + ) +} + #[test] fn a_console_disable_is_kept_with_a_debug_protection_timer_the_default_lane_keeps() { let output = default_lane(&read("console-beside-timer.js")); @@ -328,7 +347,7 @@ fn a_console_disable_is_kept_with_a_debug_protection_timer_the_default_lane_keep has_note( &output, untwist_deobfuscate::notes::PROTECTIONS_KEPT_TOGETHER - ), + ) || keeps_unproven_built_ins(&output), "{:?}", output.notes ); @@ -344,7 +363,7 @@ fn a_dead_debug_protection_a_global_listing_may_reach_is_kept_with_a_premise_not has_note( &output, untwist_deobfuscate::notes::DEBUG_PROTECTION_GLOBAL_REACH - ), + ) || keeps_unproven_built_ins(&output), "{:?}", output.notes ); From c343504f1abfba754aab42d37655c5fbcde7c36d Mon Sep 17 00:00:00 2001 From: sorte1 Date: Thu, 19 Nov 2026 16:03:35 +0100 Subject: [PATCH 10/14] test: refreeze the behaviour scan digest, allow the version rows that pass through without node, and pin the untranspile rows that keep their helpers to an opaque key --- .../tests/data/fused_scans.digest | 2 +- .../tests/untranspile_spread.rs | 15 ++++++-- .../untwist/tests/protection_target_rows.rs | 6 ++-- fixtures/obfuscator-versions/EXPECT | 34 +++++++++---------- 4 files changed, 33 insertions(+), 24 deletions(-) diff --git a/crates/untwist-deobfuscate/tests/data/fused_scans.digest b/crates/untwist-deobfuscate/tests/data/fused_scans.digest index ffa3864d..2a28a653 100644 --- a/crates/untwist-deobfuscate/tests/data/fused_scans.digest +++ b/crates/untwist-deobfuscate/tests/data/fused_scans.digest @@ -1,4 +1,4 @@ -behaviour d 3548 2e47a56d544446d2 +behaviour d 3560 958e5a86f362c935 behaviour p 3490 e129d5f75b11509b behaviour u 3402 8c3ab5ae359f92d4 behaviour up 3306 da075c5f4448898c diff --git a/crates/untwist-unminify/tests/untranspile_spread.rs b/crates/untwist-unminify/tests/untranspile_spread.rs index d7a06700..78f5a0ad 100644 --- a/crates/untwist-unminify/tests/untranspile_spread.rs +++ b/crates/untwist-unminify/tests/untranspile_spread.rs @@ -207,6 +207,8 @@ fn conservative_runs_none_of_it() { ); } +const OPAQUE_READ: &str = "console.log([0][String(0)]);\n"; + const PATCHED: &str = "function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); } function _iterableToArray(r) { if (\"undefined\" != typeof Symbol && null != r[Symbol.iterator] || null != r[\"@@iterator\"]) return Array.from(r); } @@ -265,9 +267,16 @@ fn helpers_inside_a_function_are_swept_under_unsafe() { } #[test] -fn script_level_helpers_and_their_calls_stay_in_the_default_mode() { +fn script_level_helper_calls_are_untranspiled_in_the_default_mode_when_every_key_is_numeric() { let source = format!("{PATCHED}console.log(_toConsumableArray([1, 2]), !0);\n"); let code = run(&source, false); + assert!(code.contains("console.log([1, 2], true);"), "{code}"); +} + +#[test] +fn script_level_helpers_and_their_calls_stay_in_the_default_mode_beside_an_opaque_key() { + let source = format!("{PATCHED}console.log(_toConsumableArray([1, 2]), !0);\n{OPAQUE_READ}"); + let code = run(&source, false); assert!( code.contains("console.log(_toConsumableArray([1, 2]), true);"), "{code}" @@ -276,9 +285,9 @@ fn script_level_helpers_and_their_calls_stay_in_the_default_mode() { } #[test] -fn every_site_keeps_its_helper_in_the_default_mode_when_the_helper_reads_an_opaque_key() { +fn every_site_keeps_its_helper_in_the_default_mode_when_the_program_reads_an_opaque_key() { let source = format!( - "(function () {{\n{PATCHED}console.log(_toConsumableArray(list()));\nconsole.log(_toConsumableArray(list()), !0);\nconsole.log(_toConsumableArray([3, 4]));\nfunction list() {{ return [1]; }}\n}})();\n" + "(function () {{\n{PATCHED}console.log(_toConsumableArray(list()));\nconsole.log(_toConsumableArray(list()), !0);\nconsole.log(_toConsumableArray([3, 4]));\nfunction list() {{ return [1]; }}\n{OPAQUE_READ}}})();\n" ); let code = run(&source, false); assert!( diff --git a/crates/untwist/tests/protection_target_rows.rs b/crates/untwist/tests/protection_target_rows.rs index 89d0aef0..b866eb94 100644 --- a/crates/untwist/tests/protection_target_rows.rs +++ b/crates/untwist/tests/protection_target_rows.rs @@ -38,9 +38,9 @@ fn layered_service_worker_blocks_are_kept_together_in_the_default_lane() { let [(_, default_lane), (_, unsafe_lane)] = lanes(); let kept = Pipeline::new(default_lane).run(LAYERED_SERVICE_WORKER); assert!( - kept.notes - .iter() - .any(|note| note.message == untwist_deobfuscate::notes::PROTECTIONS_KEPT_TOGETHER), + kept.notes.iter().any(|note| note.message + == untwist_deobfuscate::notes::PROTECTIONS_KEPT_TOGETHER + || note.message == untwist_deobfuscate::notes::SELF_DEFENDING_BUILTIN_PATCHED), "{:?}", kept.notes ); diff --git a/fixtures/obfuscator-versions/EXPECT b/fixtures/obfuscator-versions/EXPECT index 2a5921d9..e7188d74 100644 --- a/fixtures/obfuscator-versions/EXPECT +++ b/fixtures/obfuscator-versions/EXPECT @@ -488,30 +488,30 @@ 4.2.2--b64-rot-shuf-shift-istr-w1-nocalls-t1-unicode--wp4-bundle--uglify--greeting-1.js safe machinery xfail namespace-by-key: safe lane: namespace read by unproven key; a read keyed by a decoder call, which the check cannot resolve before decoding, off a holder not proven to be something other than the global object is pinned like a spelled Reflect or Object (R51-RX8) 4.2.2--rc4-norot-noshuf-shift-istr-w0-calls-t75-keys--wp4-bundle--none--empty-log-1.js safe machinery xfail namespace-by-key: safe lane: namespace read by unproven key; a read keyed by a decoder call, which the check cannot resolve before decoding, off a holder not proven to be something other than the global object is pinned like a spelled Reflect or Object (R51-RX8) 4.2.2--rc4-norot-noshuf-shift-istr-w0-calls-t75-keys--wp4-bundle--none--empty-log-1.js safe simplified xfail namespace-by-key: safe lane: namespace read by unproven key; a read keyed by a decoder call, which the check cannot resolve before decoding, off a holder not proven to be something other than the global object is pinned like a spelled Reflect or Object (R51-RX8) -0.10.2--b64-norot-t1-self--wp4-module--uglify--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept -0.10.2--b64-rot-t75-self--wp4-bundle--uglify--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept -0.10.2--plain-rot-t75-self--wp4-bundle--uglify--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept -0.10.2--rc4-norot-t1-self--wp4-bundle--none--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.10.2--b64-norot-t1-self--wp4-module--uglify--* safe runs allow sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.10.2--b64-rot-t75-self--wp4-bundle--uglify--* safe runs allow sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.10.2--plain-rot-t75-self--wp4-bundle--uglify--* safe runs allow sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.10.2--rc4-norot-t1-self--wp4-bundle--none--* safe runs allow sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept 0.10.2--rc4-norot-t1-self--wp4-bundle--none--* safe simplified xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept -0.10.2--rc4-norot-t1-self--wp4-module--none--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.10.2--rc4-norot-t1-self--wp4-module--none--* safe runs allow sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept 0.10.2--rc4-norot-t1-self--wp4-module--none--* safe simplified xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept -0.10.2--rc4-rot-t1-self--top--uglify--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept -0.16.0--rc4-rot-t1-self--iife--none--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.10.2--rc4-rot-t1-self--top--uglify--* safe runs allow sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.16.0--rc4-rot-t1-self--iife--none--* safe runs allow sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept 0.16.0--rc4-rot-t1-self--iife--none--* safe simplified xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept 0.18.8--plain-norot-t75-self--wp4-module--uglify--* safe machinery xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept -0.18.8--plain-norot-t75-self--wp4-module--uglify--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept -0.18.8--plain-rot-t75-self--iife--uglify--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept -0.18.8--rc4-rot-t1-self--wp4-bundle--none--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.18.8--plain-norot-t75-self--wp4-module--uglify--* safe runs allow sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.18.8--plain-rot-t75-self--iife--uglify--* safe runs allow sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.18.8--rc4-rot-t1-self--wp4-bundle--none--* safe runs allow sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept 0.18.8--rc4-rot-t1-self--wp4-bundle--none--* safe simplified xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept -0.20.4--b64-norot-t75-self--wp4-module--none--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.20.4--b64-norot-t75-self--wp4-module--none--* safe runs allow sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept 0.20.4--b64-norot-t75-self--wp4-module--none--* safe simplified xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept -0.20.4--rc4-norot-t75-self--wp4-bundle--none--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.20.4--rc4-norot-t75-self--wp4-bundle--none--* safe runs allow sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept 0.20.4--rc4-norot-t75-self--wp4-bundle--none--* safe simplified xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept -0.20.4--rc4-rot-t1-self--wp4-module--none--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.20.4--rc4-rot-t1-self--wp4-module--none--* safe runs allow sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept 0.20.4--rc4-rot-t1-self--wp4-module--none--* safe simplified xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept -0.20.4--rc4-rot-t75-self--iife--uglify--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept -0.23.2--plain-rot-noshuf-t75-self--iife--uglify--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept -0.23.2--plain-rot-shuf-t75-self--wp4-bundle--uglify--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept -0.23.2--rc4-rot-shuf-t75-self--wp4-bundle--uglify--* safe runs xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.20.4--rc4-rot-t75-self--iife--uglify--* safe runs allow sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.23.2--plain-rot-noshuf-t75-self--iife--uglify--* safe runs allow sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.23.2--plain-rot-shuf-t75-self--wp4-bundle--uglify--* safe runs allow sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept +0.23.2--rc4-rot-shuf-t75-self--wp4-bundle--uglify--* safe runs allow sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept 0.28.5--plain-rot-noshuf-t75-self--top--uglify--* safe machinery xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept 5.9.1--rc4-rot-shuf-noshift-inum-w3f-nocalls-t75-self--top--terser--* safe machinery xfail sd-machinery-keys: safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept From a9fdb98ca6818de1fc24e3cb60fb9c3986014b80 Mon Sep 17 00:00:00 2001 From: sorte1 Date: Fri, 20 Nov 2026 03:21:53 +0100 Subject: [PATCH 11/14] test: refreeze the compile record for the eval-names fixture, whose constant eval text now unfolds --- crates/untwist-eval/tests/data/compile_records.sha256 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/untwist-eval/tests/data/compile_records.sha256 b/crates/untwist-eval/tests/data/compile_records.sha256 index bdfa4699..c9d78b7d 100644 --- a/crates/untwist-eval/tests/data/compile_records.sha256 +++ b/crates/untwist-eval/tests/data/compile_records.sha256 @@ -15235,7 +15235,7 @@ db31d67065022b65 0 eccc9dae2252cc81aa56c07aeb3ef21cc49f108f7d5601278a165a4c80959 db35f724e96539df 0 381fde0fcd71f413bb7168ba55307c19e7261eeb1ede4f1299dd852afed2f667 db3606123551ade2 0 06a618ee1f9d31cc3abc3c3cc83a952c62cbae0fc316cfae41c0a3b4f002e2fa db3f884e6dc7e9b7 0 9cf9f14085b0fa89d9e8c317dc911afb15a5873527dd3bc8b72b05d66e1616e0 -db4a90e69565706f 0 35c703ae0ef14384cfcd8a9aa8403f927dc422a9035ebc73becb9e64874a0b69 +db4a90e69565706f 0 1d4cc2f41e49a876852748694503a8d233087f5930ee317f57ecee25054956e9 db4ba72bb8cbe616 0 b0c557b6deb4af635825d3706c8b104bc3a906b133acb57c83bd39253772f90b db581e835e38ec95 0 5846ee3ac524e3cd69badf6c70200f0d25372fe410d05fd5494a8df840c5a5b4 db62216b3a23704c 0 5bfcc02002e3333a7af7c6749c9335f2d78997246f756ea7d5bb022899cace6e From 76809a8dd926a9ebb7e0e14b068be2a007bab3e4 Mon Sep 17 00:00:00 2001 From: sorte1 Date: Fri, 20 Nov 2026 06:49:35 +0100 Subject: [PATCH 12/14] test: list the fuzz samples whose self-defending block the built-in scan cannot prove as a known default-lane gap --- fixtures/fuzz/EXPECT | 1 + 1 file changed, 1 insertion(+) diff --git a/fixtures/fuzz/EXPECT b/fixtures/fuzz/EXPECT index 9a0cb292..67d58ab0 100644 --- a/fixtures/fuzz/EXPECT +++ b/fixtures/fuzz/EXPECT @@ -22,3 +22,4 @@ safe safe-global-names code may observe the global object's names (a non-strict * stateful-decoder-escape a stateful base64 or rc4 decoder is also reached through calls whose arguments are not proven (wrappers reading locals of an enclosing function), so the unit is refused (first seen in seed 2026 sample s2026-967) * stateful-decoder-state decoding bails: a stateful decoder keeps state that is not a proven memo or init gate (first seen in seed 2026 sample s2026-245) * unexplained-decode-miss machinery is kept and no pass says why (a control-flow switch case binding collides; in the safe lane a terser-folded rotator has no checksum) (first seen in seed 2026 sample s2026-1021) +safe self-defending/the-program-may-replace-a-built-in-the-self-defending the default lane removes a self-defending callback only when the built-in scan proves every built-in it calls intact; a computed key or write the scan cannot bound keeps the block under the unproven-built-ins note (first seen in seed 3 sample s3-38) From 8f7d7a4477f95ae109b1de811ea951f3d9d1457d Mon Sep 17 00:00:00 2001 From: sorte1 Date: Fri, 20 Nov 2026 10:37:07 +0100 Subject: [PATCH 13/14] test: refresh the obfuscator-versions BASELINE on top of main; three self cells keep the unproven self-defending block in the safe lane --- fixtures/obfuscator-versions/BASELINE | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/fixtures/obfuscator-versions/BASELINE b/fixtures/obfuscator-versions/BASELINE index 3f0efcca..afa22f5e 100644 --- a/fixtures/obfuscator-versions/BASELINE +++ b/fixtures/obfuscator-versions/BASELINE @@ -27,8 +27,8 @@ 0.10.2--plain-rot-t75-self--wp4-bundle--uglify 1 0/1 1/1 - 0 legacy-array-reached (1) 0.10.2--rc4-norot-t1-cff--iife--none 1 0/1 1/1 - 0 decoder-reads-outer-binding (1) 0.10.2--rc4-norot-t1-cff--wp4-bundle--terser 1 0/1 1/1 - 0 legacy-array-reached (1) -0.10.2--rc4-norot-t1-self--wp4-bundle--none 1 0/1 1/1 - 0 legacy-array-reached (1) -0.10.2--rc4-norot-t1-self--wp4-module--none 1 0/1 1/1 - 0 decoder-reads-outer-binding (1) +0.10.2--rc4-norot-t1-self--wp4-bundle--none 1 0/1 1/1 - 0 legacy-array-reached (1), sd-machinery-keys (1) +0.10.2--rc4-norot-t1-self--wp4-module--none 1 0/1 1/1 - 0 decoder-reads-outer-binding (1), sd-machinery-keys (1) 0.10.2--rc4-norot-t1-unicode--top--terser 1 0/1 1/1 - 0 legacy-array-reached (1) 0.10.2--rc4-norot-t75--top--none 1 0/1 1/1 - 0 legacy-array-reached (1) 0.10.2--rc4-rot-t1-cff--iife--terser 1 0/1 1/1 - 0 decoder-reads-outer-binding (1) @@ -70,7 +70,7 @@ 0.16.0--rc4-norot-t75-mangled--top--none 1 0/1 1/1 - 0 decoder-reads-outer-binding (1) 0.16.0--rc4-norot-t75-unicode--wp4-bundle--none 1 0/1 1/1 - 0 legacy-array-reached (1) 0.16.0--rc4-rot-t1-keys--top--uglify 1 0/1 1/1 - 0 legacy-array-reached (1) -0.16.0--rc4-rot-t1-self--iife--none 1 0/1 1/1 - 0 builtin-alias-patched (1) +0.16.0--rc4-rot-t1-self--iife--none 1 0/1 1/1 - 0 builtin-alias-patched (1), sd-machinery-keys (1) 0.16.0--rc4-rot-t75-dead--iife--terser 1 0/1 1/1 - 0 builtin-alias-patched (1) 0.16.0--rc4-rot-t75-self--wp4-bundle--terser 1 0/1 1/1 - 0 self-defending-passed-through (1) 0.18.8--b64-norot-t1--top--uglify 1 0/1 1/1 - 0 legacy-array-reached (1) @@ -90,7 +90,7 @@ 0.18.8--plain-norot-t75--top--terser 1 1/1 1/1 - 0 - 0.18.8--plain-norot-t75--wp4-module--terser 1 1/1 1/1 - 0 - 0.18.8--plain-norot-t75-keys--top--none 1 0/1 0/1 - 0 legacy-array-reached (1) -0.18.8--plain-norot-t75-self--wp4-module--uglify 1 1/1 1/1 - 0 - +0.18.8--plain-norot-t75-self--wp4-module--uglify 1 0/1 1/1 - 0 sd-machinery-keys (1) 0.18.8--plain-norot-t75-unicode--iife--none 1 1/1 1/1 - 0 - 0.18.8--plain-rot-t1-cff--iife--terser 1 1/1 1/1 - 0 - 0.18.8--plain-rot-t1-cff--wp4-bundle--terser 1 0/1 1/1 - 0 legacy-array-reached (1) @@ -107,7 +107,7 @@ 0.18.8--rc4-rot-t1-cff--top--uglify 1 0/1 1/1 - 0 legacy-array-reached (1) 0.18.8--rc4-rot-t1-dead--top--terser 1 0/1 1/1 - 0 legacy-array-reached (1) 0.18.8--rc4-rot-t1-dead--wp4-module--terser 1 0/1 1/1 - 0 builtin-alias-patched (1) -0.18.8--rc4-rot-t1-self--wp4-bundle--none 1 0/1 1/1 - 0 legacy-array-reached (1) +0.18.8--rc4-rot-t1-self--wp4-bundle--none 1 0/1 1/1 - 0 legacy-array-reached (1), sd-machinery-keys (1) 0.18.8--rc4-rot-t75-mangled--wp4-module--uglify 1 0/1 1/1 - 0 builtin-alias-patched (1) 0.20.4--b64-norot-t1-cff--top--terser 1 0/1 1/1 - 0 legacy-array-reached (1) 0.20.4--b64-norot-t1-dead--top--uglify 1 0/1 1/1 - 0 legacy-array-reached (1) @@ -115,7 +115,7 @@ 0.20.4--b64-norot-t1-split--wp4-bundle--uglify 1 0/1 1/1 - 0 legacy-array-reached (1) 0.20.4--b64-norot-t75-keys--wp4-module--uglify 1 0/1 1/1 - 0 decoder-reads-outer-binding (1) 0.20.4--b64-norot-t75-mangled--iife--terser 1 0/1 1/1 - 0 decoder-reads-outer-binding (1) -0.20.4--b64-norot-t75-self--wp4-module--none 1 0/1 1/1 - 0 decoder-reads-outer-binding (1) +0.20.4--b64-norot-t75-self--wp4-module--none 1 0/1 1/1 - 0 decoder-reads-outer-binding (1), sd-machinery-keys (1) 0.20.4--b64-rot-t1-split--iife--none 1 0/1 1/1 - 0 decoder-reads-outer-binding (1) 0.20.4--b64-rot-t75--wp4-bundle--terser 1 0/1 1/1 - 0 legacy-array-reached (1) 0.20.4--b64-rot-t75-split--top--none 1 0/1 1/1 - 0 legacy-array-reached (1) @@ -138,9 +138,9 @@ 0.20.4--rc4-norot-t1-cff--wp4-module--terser 1 0/1 1/1 - 0 decoder-reads-outer-binding (1) 0.20.4--rc4-norot-t1-split--top--none 1 0/1 1/1 - 0 legacy-array-reached (1) 0.20.4--rc4-norot-t1-unicode--iife--none 1 0/1 1/1 - 0 decoder-reads-outer-binding (1) -0.20.4--rc4-norot-t75-self--wp4-bundle--none 1 0/1 1/1 - 0 legacy-array-reached (1) +0.20.4--rc4-norot-t75-self--wp4-bundle--none 1 0/1 1/1 - 0 legacy-array-reached (1), sd-machinery-keys (1) 0.20.4--rc4-norot-t75-unicode--top--terser 1 0/1 1/1 - 0 decoder-reads-outer-binding (1) -0.20.4--rc4-rot-t1-self--wp4-module--none 1 0/1 1/1 - 0 builtin-alias-patched (1) +0.20.4--rc4-rot-t1-self--wp4-module--none 1 0/1 1/1 - 0 builtin-alias-patched (1), sd-machinery-keys (1) 0.20.4--rc4-rot-t1-split--top--uglify 1 0/1 1/1 - 0 legacy-array-reached (1) 0.20.4--rc4-rot-t75-keys--iife--terser 1 0/1 1/1 - 0 decoder-reads-outer-binding (1) 0.20.4--rc4-rot-t75-keys--wp4-bundle--terser 1 0/1 0/1 - 0 legacy-array-reached (1) @@ -201,7 +201,7 @@ 0.28.5--plain-rot-noshuf-t1-dead--iife--none 1 1/1 1/1 - 0 - 0.28.5--plain-rot-noshuf-t1-split--wp4-bundle--terser 1 0/1 1/1 - 0 namespace-by-key (1) 0.28.5--plain-rot-noshuf-t75-keys--iife--uglify 1 1/1 1/1 - 0 - -0.28.5--plain-rot-noshuf-t75-self--top--uglify 1 1/1 1/1 - 0 - +0.28.5--plain-rot-noshuf-t75-self--top--uglify 1 0/1 1/1 - 0 sd-machinery-keys (1) 0.28.5--plain-rot-shuf-t1--wp4-bundle--none 1 0/1 1/1 - 0 safe-global-names (1) 0.28.5--plain-rot-shuf-t1-split--wp4-bundle--uglify 1 0/1 1/1 - 0 namespace-by-key (1) 0.28.5--plain-rot-shuf-t75-split--wp4-module--uglify 1 1/1 1/1 - 0 - @@ -721,7 +721,7 @@ 5.9.1--rc4-rot-noshuf-noshift-inum-w1-nocalls-t1-unicode--wp4-module--uglify 1 0/1 0/1 - 0 array-reached-outside (2) 5.9.1--rc4-rot-noshuf-noshift-inum-w2f5-nocalls-t75-self--wp4-module--none 1 0/1 1/1 - 0 builtin-alias-patched (1) 5.9.1--rc4-rot-noshuf-noshift-istr-w2u-calls-t1-self--wp4-bundle--uglify 1 0/1 0/1 - 0 decoder-used-as-value (2) -5.9.1--rc4-rot-shuf-noshift-inum-w3f-nocalls-t75-self--top--terser 1 1/1 1/1 - 0 - +5.9.1--rc4-rot-shuf-noshift-inum-w3f-nocalls-t75-self--top--terser 1 0/1 1/1 - 0 sd-machinery-keys (1) 5.9.1--rc4-rot-shuf-shift-inum-w0-calls-t75-cff--iife--uglify 1 0/1 0/1 - 0 array-reached-outside (2) 5.9.1--rc4-rot-shuf-shift-istr-w2u-nocalls-t1-keys--top--none 1 0/1 1/1 - 0 builtin-replaced-decoded-key (1) # cause cells fixtures lane-runs parity-gap-cells reason @@ -732,6 +732,7 @@ decoder-reads-outer-binding 58 58 59 0 a decoder reads a binding outside itself namespace-by-key 48 48 48 0 safe lane: namespace read by unproven key; a read keyed by a decoder call, which the check cannot resolve before decoding, off a holder not proven to be something other than the global object is pinned like a spelled Reflect or Object (R51-RX8) safe-global-names 26 26 26 0 safe lane, premise 2: code may observe the global object's names (a non-strict this, require), so the decoded unit's string array, decoders and rotator are kept as written safe-global-key-reach 10 10 10 0 safe lane, premise 2: the program may hold the global object and reaches keys the check cannot resolve, so the unit's call sites are left alone +sd-machinery-keys 10 10 10 0 safe lane: decoder machinery this version keeps as written (a string-keyed cache, a minified rc4 or base64 decoder, a webpack module map) reads a computed key that may be __proto__ or constructor, so the self-defending callback's built-ins are not proven unpatched and the block is kept self-defending-passed-through 9 9 11 0 a self-defending check reads the source text of a function the output would print across lines (a minified or older template untwist cannot keep on one line), so the input is passed through unchanged array-reached-outside 6 6 12 0 the string array is reachable from code outside its declaration, decoders and a recognised rotator, so the unit's calls are left alone object-keys-not-merged 6 6 7 0 transformObjectKeys' var o = {}; o[k] = v; x = o sequence is not merged back into one literal when a key is computed (o[tag] = ...) or a value may throw or run code (a member read, arithmetic on a binding) From d9296523213317e12bd6005f77ddb5845ebe7c9f Mon Sep 17 00:00:00 2001 From: sorte1 Date: Fri, 20 Nov 2026 21:54:40 +0100 Subject: [PATCH 14/14] ci(web): wasm baseline 14,975,000 (cap 16,472,500) with the numeric-key proofs on top of main --- web/scripts/size.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/scripts/size.ts b/web/scripts/size.ts index e70f9cb7..891729d8 100644 --- a/web/scripts/size.ts +++ b/web/scripts/size.ts @@ -12,7 +12,7 @@ const INITIAL_JS_GZIP = 190_000; const CSS_GZIP = 15_000; const FONT_BYTES = 120_000; const SW_GZIP = 4_000; -const WASM_BASELINE_BYTES = 14_948_000; +const WASM_BASELINE_BYTES = 14_975_000; const WASM_GROWTH = 0.1; const gzip = (bytes: Buffer): number => gzipSync(bytes, { level: 9 }).length;