TL;DR
JSProtect is a high-throughput, parallelized obfuscation framework designed for industrial-scale JavaScript applications like WeChat Mini-Games. By utilizing a novel Parallel-Aware Scope Analysis (PASA) algorithm, it processes 20MB codebases in minutes (down from 13 hours) while maintaining near-native performance and reducing code size inflation from over 1,000% to just 20%.
What Problem Does This Paper Address?
The WeChat Mini-Game ecosystem serves over 500 million monthly active users, but it faces a rampant "code porting" problem: adversaries steal source code, make minor modifications, and redeploy games on competing platforms.
While code obfuscation is the standard defense, existing tools (like JS-Obfuscator or JScrambler) fail when applied to modern, large-scale games. The authors identify a "Scalability Crisis" characterized by three failures:
- Time/Memory Explosion: Processing a 20MB game can take over 13 hours and consume 22GB of RAM because traditional tools are single-threaded and load the entire Abstract Syntax Tree (AST) into memory.
- Performance Degradation: Obfuscation often introduces heavy computational overhead, dropping game frame rates from a smooth 60 FPS to an unplayable 1 FPS.
- Code Bloat: Traditional renaming strategies exhaust short identifiers and resort to long random strings, turning a 20MB game into a 200MB+ monster that exceeds platform upload limits.
Methods
The core innovation of JSProtect is the Parallel-Aware Scope Analysis (PASA) algorithm. Unlike traditional global analysis, PASA identifies "scope independence" and "dependency boundaries." This enables two critical optimizations:
- Independent Namespace Management: Instead of using a global pool of unique variable names, JSProtect treats each function scope as an isolated namespace. This allows it to aggressively reuse the shortest possible identifiers (e.g.,
a,b,c) across disjoint scopes without conflicts, drastically curbing code size. - Independent Code Partitioning: PASA identifies semantically independent code units. This allows the framework to distribute the obfuscation workload across multiple CPU cores for true parallel processing.
- Performance-Aware Transformations: To maintain 60 FPS, the authors implemented "Single-Variable Property Access" (avoiding expensive expression evaluations) and "Memoization via Guard Variables" (ensuring obfuscated values in loops are calculated only once).
Datasets
The authors evaluated JSProtect using a comprehensive suite of JavaScript codebases:
- Test262: The official ECMAScript conformance test suite (to ensure 100% semantic equivalence).
- Mini-Game Engines: Five mainstream engines including Cocos Creator, Egret, and LayaAir.
- Real-World Games: 100 production-level WeChat Mini-Games.
- Popular Libraries: 15 open-source libraries like jQuery, Vue.js, and React.
- Performance Benchmarks: PixiJS (for rendering) and JSZip (for CPU-intensive tasks).
Key Insights and Ideas
- Scope is the Key to Scale: The "aha moment" is that deep scope analysis isn't just for correctness; it's the foundation for both parallelization and size optimization. If you know exactly where a variable's "life" begins and ends, you can stop worrying about global collisions.
- Streaming vs. Monolithic AST: By using a streaming architecture and independent partitioning, JSProtect avoids the "memory explosion" of loading a massive, multi-megabyte AST into a single process.
- Thwarting AI: The paper highlights that modern obfuscation must resist not just static analysis tools, but also Large Language Models (LLMs). They found that increasing Cyclomatic Complexity (the number of paths through code) is highly effective at confusing models like GPT-4o.
Key Results
- Speedup: For a 20MB codebase, JSProtect finished in 141 seconds, whereas the leading open-source baseline took 13 hours (a ~336x speedup).
- Size Control: JSProtect maintained a 20% inflation rate on large files, compared to over 1,000% inflation from baseline tools.
- Runtime Performance: In PixiJS benchmarks, JSProtect maintained 60 FPS (native speed), while other tools dropped the frame rate to between 1 and 30 FPS.
- Security: JSProtect reduced the output prediction accuracy of LLMs (GPT-4o, DeepSeek-V3) to near-random levels (as low as 1.7%), proving its resilience against AI-driven deobfuscation.
- Real-World Impact: Since deployment on the WeChat platform (protecting ~10,000 games), instances of game plagiarism have decreased by 91%.
Limitations and Future Work
While highly effective, the authors acknowledge the "adversarial evolution." As deobfuscation tools (and LLMs) become more sophisticated, obfuscation techniques must continue to evolve. The paper primarily focuses on JavaScript; while many techniques are applicable to other dynamic languages, the specific PASA implementation is JS-centric. Future work may involve tighter integration with WebAssembly translation for even more "opaque" protection of core game logic.
Summary updated