Start with the smallest MeowShield level that matches your threat model

Start with the smallest MeowShield level that matches your threat model

人们往往倾向于打开 JavaScript 保护工具并直接选择看起来最强的预设。这种习惯通常源于将保护视为一种荣誉勋章:如果存在“高”级别,那么“低”级别一定是一个你应该尽快摆脱的妥协方案。但 MeowShield 的主页却表达了相反的观点。请从满足威胁模型的最小级别(低、中或高)开始,然后验证其兼容性和性能。我协助推广 MeowShield。本文旨在探讨在触碰具体开关之前,如何做出基于威胁模型的决策。

What a threat model is in this context

You are not protecting “the JavaScript” in the abstract. You are raising the cost of a specific kind of work an attacker can already do because the file ships to a browser or a distributed runtime. Write down three things before you choose a level: What is actually valuable in this file? Distinctive business behavior, a paid feature’s client helper, or the internals of an SDK method are typical candidates. A thin wrapper around a public library usually is not. What can an attacker already do without reading the source? Call your APIs, replay a public flow, or extract a secret you should never have put in the client. Obfuscation does not close those doors. What would a successful copy or tamper actually change for you? A cloned demo is a different problem from a modified entitlement check. If the honest answer to the last question is “they could charge themselves a different price, skip a paywall, or mint a privileged request,” the fix is server-side authorization, not a stronger preset. MeowShield is explicit that no protection is absolute, and that the goal is to increase analysis cost while preserving the behavior you need. Server-side authentication and authorization remain necessary.

在此语境下什么是威胁模型

你并不是在抽象地保护“JavaScript 代码”。由于文件会发送到浏览器或分布式运行时环境,你实际上是在增加攻击者已经能够执行的特定工作的成本。在选择级别之前,请写下三件事:该文件中真正有价值的是什么?独特的业务行为、付费功能的客户端辅助程序或 SDK 方法的内部逻辑通常是候选对象。而对公共库的简单封装通常不是。攻击者在不阅读源码的情况下已经能做什么?调用你的 API、重放公共流程或提取你不应放在客户端的密钥。混淆并不能关闭这些大门。一次成功的复制或篡改对你意味着什么?克隆一个演示程序与修改权限检查是完全不同的问题。如果对最后一个问题的诚实回答是“他们可以自行修改价格、跳过付费墙或伪造特权请求”,那么解决方案是服务器端授权,而不是更强的预设。MeowShield 明确表示没有任何保护是绝对的,其目标是在保持所需行为的同时增加分析成本。服务器端的身份验证和授权仍然是必要的。

What the three presets are for

The public docs describe the presets as baselines in the Playground, not as a ladder you must climb. Low is for first-time users and compatibility-first projects. The documented defaults keep ES5 Transform and KeepTopVar on, use Normal variable renaming, and enable Unicode plus ConstantSplitting at 50 percent. The intended first step is straightforward: paste a real file, keep those defaults, and generate output. Medium is described as stronger control-flow protection with moderate cost. The documented starting point is to switch to Medium, keep hp-basic as the control-flow baseline, and leave cfConstantSplitting, cfShuffleState, and cfDynamic off until you have a reason to change them. High is described as VM-oriented protection for critical business logic. The docs tell you to verify account permissions before you treat it as available. The documented defaults turn instMerge and instShuffle on, leave instClosure and instExtract off, leave VM anti-debug options off, and leave vmAuth off, with vmExpiry prefilled. That last detail matters: a prefilled expiry control is not an invitation to invent a licensing scheme in the client. If you do not yet know which file is worth protecting, or you have not run the output in the browsers and Node.js versions you support, Low is the honest start. Medium or High can wait until you can describe the extra analysis cost you want and have a way to measure whether the build still behaves.

三种预设的用途

公开文档将这些预设描述为 Playground 中的基准,而不是你必须攀爬的阶梯。“低”级别适用于初次使用者和优先考虑兼容性的项目。文档中的默认设置保持 ES5 转换和 KeepTopVar 开启,使用常规变量重命名,并启用 Unicode 以及 50% 的常量拆分。预期的第一步很简单:粘贴一个真实文件,保持这些默认设置,然后生成输出。“中”级别被描述为具有适中成本的更强控制流保护。文档建议的起点是切换到“中”,保持 hp-basic 作为控制流基准,并保持 cfConstantSplitting、cfShuffleState 和 cfDynamic 关闭,直到你有理由更改它们。“高”级别被描述为针对关键业务逻辑的虚拟机导向保护。文档提醒你在将其视为可用之前先验证账户权限。文档中的默认设置开启 instMerge 和 instShuffle,保持 instClosure 和 instExtract 关闭,保持虚拟机反调试选项关闭,并保持 vmAuth 关闭,同时预填 vmExpiry。最后一个细节很重要:预填的过期控制并不是让你在客户端发明授权机制的邀请。如果你还不知道哪个文件值得保护,或者还没有在你支持的浏览器和 Node.js 版本中运行过输出结果,“低”级别是一个诚实的起点。等到你能描述你想要的额外分析成本,并且有方法衡量构建版本是否仍然正常运行时,再考虑“中”或“高”级别。

Choose the file as carefully as the level

A common mismatch is to wrap an entire application bundle at High because a few functions are sensitive. That usually raises download and runtime cost for code that is not what you care about, and it makes failures harder to isolate. A better first cut is the smallest module that contains the distinctive logic. Leave vendored open-source libraries alone unless you have a specific reason to include them. Keep public exports, documented types, and network contracts stable; those are the integration surface your customers or your own app already depend on. The official path is also staged: start with a preset in the Playground, understand options in Docs, then move authorized server integrations to the separate API. The API is permission-based, and credentials belong in a server-side or CI environment, never in public browser code.

像选择级别一样谨慎地选择文件

一种常见的错误做法是仅仅因为几个函数敏感,就将整个应用程序包以“高”级别进行封装。这通常会增加你并不关心的代码的下载和运行成本,并使故障更难排查。更好的初步做法是选择包含独特逻辑的最小模块。除非有特定理由,否则不要动用第三方开源库。保持公共导出、文档化类型和网络契约的稳定;这些是你客户或你自己的应用程序所依赖的集成接口。官方路径也是分阶段的:从 Playground 中的预设开始,理解文档中的选项,然后将授权的服务器集成迁移到独立的 API。该 API 基于权限控制,凭据应存放在服务器端或 CI 环境中,绝不能出现在公共浏览器代码中。

Verify before you keep the stronger build

After you generate output, do the checks the product itself emphasizes. Run, copy, or download the result and keep a compatibility check visible. Compare the protected file against the original in your own environment: does the behavior you need still hold, and is the runtime cost acceptable on the path a user actually hits? If the protected code no longer works, official troubleshooting is conservative: lower the protection level or disable some options, then add options back one at a time and re-test. If it still fails, contact support@meowshield.com with the configuration, runtime environment, and error details. A level you cannot run is not protecting anything. The smallest preset that still meets the threat you actually have, and that still ships, is the one worth keeping. If you want to try that path with one real file, start at https://meowshield.com.

在保留更强的构建版本之前进行验证

生成输出后,请执行产品本身强调的检查。运行、复制或下载结果,并保持兼容性检查可见。在你的环境中将受保护的文件与原始文件进行比较:你所需的功能是否仍然有效?在用户实际访问的路径上,运行时成本是否可以接受?如果受保护的代码无法运行,官方的故障排除建议是保守的:降低保护级别或禁用某些选项,然后逐个添加选项并重新测试。如果仍然失败,请将配置、运行时环境和错误详细信息发送至 support@meowshield.com。无法运行的级别无法提供任何保护。能够满足你实际面临的威胁且仍能正常交付的最小预设,才是值得保留的。如果你想用一个真实文件尝试这条路径,请从 https://meowshield.com 开始。