//nefariousplan

Safe Mode Was Opt In

A library exposes sanitization as opt-in flags with unsafe defaults. A caller wiring the library's output into a sink that interprets the result as code (raw HTML, SQL, shell) accepts the unsafe defaults by reaching for the library's static or factory helper instead of constructing the instance and setting the flags. The flags exist in the library; the fix is to set them.

A library ships an unsafe default and a safe alternative side by side. The safe alternative is one argument to pass, one flag to set, one constructor overload to prefer, one submodule to import, one method to chain. The library's documentation often names it. The library's own test suite often exercises it. The library ships the safe alternative on the same day it ships the unsafe one, and the version numbers march in lockstep for years.

The consumer reaches for the library's default. The default helper, the top-level import, the zero-argument constructor, the factory that was shortest to type. The library's output feeds a sink that interprets the result as code: raw HTML goes to a renderer, a string goes to a subprocess argv, bytes go to a deserializer, a path goes to a filesystem call, a config value goes to a capability lookup, a script goes to the host JVM. The default is unsafe at that sink, and the sink runs because the consumer never set the flag.

The flags exist in the library. The fix is to set them. The gap between the two is the CVE.

Mechanism

The pattern has four parts. A library whose feature surface includes a security-relevant knob. A default for that knob that is the dangerous value. A consumer whose call reaches a sink that interprets the library's output as code. A caller-side omission that leaves the knob at its default.

The library carries both options because the library's feature set is wider than any one consumer's deployment. A Markdown renderer must emit HTML for consumers that embed Markdown inside pages they trust the author of and must refuse HTML for consumers that render community-submitted comments. A JSON or XML deserializer must reconstruct classes for callers that trust the input and must refuse construction for callers that do not. A script engine must give scripts host access for operators that need extension points and must sandbox scripts for operators that do not. Shipping both modes is not the mistake. Shipping the dangerous mode as the one the consumer gets by not asking is the mechanism this class names.

The library documents the safe option. EspoCRM's Michelf exhibit names no_markup and no_entities as public properties of the parser. vm2's Buffer.alloc exhibit names bufferAllocLimit in the changelog of the release that introduced it, with the value Infinity. SAP's Visual Composer has had a Setting Secure Mode help page on the vendor's own documentation site for twenty years while shipping SecurityMode = false. Yamcs's Nashorn has had NashornScriptEngineFactory.getScriptEngine(ClassFilter) since JDK 8 in March 2014. GD's Perl exhibit names the three-argument form of open() that Perl 5.6.0 introduced on March 22, 2000. Documentation does not change the default. The default is what the consumer gets by not asking.

The consumer calls the library. The call site reads for naturalness in the consumer's own language. defaultTransform. new VM(). open(my $fh, $path). unserialize($data). AutoTokenizer.from_pretrained. factory.getScriptEngine(). from jinja2 import Environment. Action::make()->action(...). register_post_type('wpcode', array('public' => false)). allowTypes(whitelist). None of those call sites pass the flag that would make the library safe for the sink the result reaches. The library's output then runs: the HTML goes into a Handlebars triple-brace that declares its input safe; the class is deserialized with a constructor the attacker chose; the path is opened for write when the input was dot-dot; the script resolves java.lang.Runtime at the top of the host JVM; the Markdown's <script> renders; the LLM-emitted JSON task record constructs with allow_shell = true; the WordPress REST handler accepts post_type = wpcode and the shortcode evals the body.

The fix is almost always one line. no_markup = true. addPermission(NoTypePermission.NONE). '<', . allowed_classes => false. trust_remote_code=False. getScriptEngine(classFilter). from jinja2.sandbox import SandboxedEnvironment as Environment. ->authorize(...). 'capability_type' => 'wpcode'. LANGFLOW_CORS_ORIGINS=https://exact.host. The patch diff's size is a measurement of how small the required intervention was. The volume of exhibits that accept the same intervention is the measurement of how often the consumer did not reach for it.

The failure repeats because the API surface of the library does not force the consumer to confront the choice. A function that accepts the dangerous option as a default-valued parameter is callable without the parameter. A factory helper that wires the library's own preferred defaults is shorter than the constructor it wraps. A top-level module import is one line, and the sandbox submodule import is two. Shopper's Filament exhibit is the shape made quantitative: the chained ->authorize(...) method on the Action::make() builder is one syntactic unit, and the same commit that added it to twelve CVE-producing call sites added it to twenty-five more where no CVE had yet been filed. The dangerous call site is syntactically smaller, and syntactic size is the dimension developers minimize when the language gives them two options for the same effect. The library carried the safe path. The library did not carry it as the shorter path.

The distance between the safe primitive and the unsafe call site collapses across exhibits. EspoCRM and vm2 had the flags in the library and the call site in a separate project. Zyxel collapses the distance to the same organization: the library (an in-house DAL framework) and the consumer (zcfgFeDal_LoginPrivilege_Get) are both inside Zyxel. Everest Forms collapses it to fifty-four lines inside one foreach in one file. WPCode collapses it to a three-file gap inside one plugin where the same author who wrote wpcode_edit_php_snippets did not write 'capability_type' => 'wpcode'. AutoGPT collapses it to the default argument of one function in one codebase. The pattern's recurrence is independent of organizational distance; the mechanism is syntactic ergonomics, not communication failure.

Three cases are worth naming because they look adjacent and are not. Setting Was Advisory names the case where the consumer did pass the flag and a wrapper layer flipped it inside the library, with no log or callback. Default Is The Mitigation names the structure of a patch whose only change is moving a default value, leaving the unsafe code path reachable through the same request surface. Extension As Mitigation names a library that offers a generic subclass, callback, or hook framed in documentation as the safety handoff, without wiring any specific dangerous input to any specific primitive. Safe Mode Was Opt In names the state before any of those: the library exposed a specific safety primitive wired to a specific dangerous input, and the consumer did not engage it.

The patch commit in every exhibit is either the engagement or the version flip that removes the choice. Netty's strictLineParsing is the variant where the maintainer flipped the default and preserved the unsafe code path behind a flag; the pattern continues to describe the shipped binary of every operator who set the flag back for backwards compatibility. Fastjson's SafeMode and Mermaid's securityLevel: sandbox are the variant where the patch declines to flip the default and the advisory recommends the flag as a defense in depth measure. The audit-readable scope of the fix is a sentence in the advisory; the runtime behavior depends on every downstream developer reading the advisory, knowing a security mode exists, and remembering to toggle it.

Exhibits

CVE-2025-34291: Langflow's CORS Middleware Warns It Is Exploitable, Then Installs The Exploit. Langflow extends the pattern from libraries shipped to developers into a deployed service shipped to operators. The unsafe defaults live in services/settings/base.py as cors_origins = "*" and cors_allow_credentials = True, and in services/settings/auth.py as REFRESH_SAME_SITE = "none". The vendor's response to the July 29, 2025 HackerOne report is on the record in the pull-request history: PR #9441 ("fix: update CORS configuration and add env vars to allow for user control") would have auto-disabled credentials when origins were wildcarded and flipped the refresh cookie's SameSite default from none to lax. It was closed September 8, 2025. The replacement commit (bfc7c8b, September 11) added LANGFLOW_CORS_ORIGINS and LANGFLOW_CORS_ALLOW_CREDENTIALS as opt-in environment variables and added a function called warn_about_future_cors_changes to main.py that logs at every startup that the current configuration "allows all origins with credentials." The function is called from create_app on the line immediately before the CORS middleware is installed with the unsafe defaults. The default did not change until 1.7.0, four months later. The vm2 exhibit shipped a regression test asserting the default still allocated 64 MB host buffers; the Langflow exhibit shipped a startup log line confirming the default was still exploitable. The vm2, DeepSeek-TUI, and AutoGPT exhibits all sit at library-distribution boundaries; Langflow extends the pattern to a deployed AI agent platform where the operator is the consumer that never read the documentation.

CVE-2026-8832: WPCode Ships A Custom Capability System. The Post Type Was Registered Without It.. WPCode 2.3.5 is the catalog's tightest collapse of the pattern to date. WordPress's register_post_type is the library function; capability_type and capabilities are the security-relevant options with unsafe defaults (capability_type defaults to 'post', binding any CPT to the WordPress post-edit capability family). The consumer (wpcode_register_post_type in includes/post-type.php) is a thirty-three-line function that passes three keys (public, show_ui, can_export) and omits the security-relevant ones. The sink is eval() in WPCode_Snippet_Execute::run_eval. The damning detail is that the plugin SHIPS the safe alternative: includes/capabilities.php defines wpcode_edit_php_snippets and wpcode_edit_snippets, and includes/class-wpcode-capabilities.php grants them only to roles with manage_options. The custom capability system that gates the plugin's UI was never bound to the CPT. The same author who wrote the safe capabilities did not reference them in register_post_type. The Everest Forms exhibit had a fifty-four-line gap between the safe wrapper and the unsafe primitive in one foreach; WPCode has a three-file gap inside one plugin, with a wp_import_post_data_raw filter sixteen lines below the CPT registration that proves the developer understood untrusted inbound content should not become a wpcode post.

Boundaries

Not Setting Was Advisory. That pattern describes the case where the consumer did engage the flag at the call site and a wrapper layer inside the library flipped it back, usually to accommodate a generic framework fallback type, with no log or callback informing the caller. The flag has the API surface of an enforced control and the runtime behavior of a hint. Here the consumer did not engage the flag at all. Reading the consumer's call site tells you which pattern you are in: if the flag's value appears in the arguments or the configuration object, read the library's wrapper layer for an override and you are in Setting Was Advisory; if the flag is absent from the call site, you are here.

Not Default Is The Mitigation. That pattern describes the structure of a security patch that closes a CVE by changing a default value and preserves the unsafe code path behind a caller-controlled toggle, reachable through the same untrusted request surface. The patched binary contains the unpatched primitive. Here the pattern names the pre-patch state regardless of what the patch does: the unsafe default existed at the consumer's call site and the safe primitive existed one argument away. The two patterns compose: a Default Is The Mitigation patch leaves every unupdated consumer in Safe Mode Was Opt In against the next inbound request that flips the toggle. The Netty strictLineParsing exhibit is the clearest composition of both in the catalog.

Not Extension As Mitigation. That pattern describes a library that ships no specific safety primitive wired to a specific dangerous input, and documents a generic subclass, callback, or hook as the place where the consumer is expected to add validation. The library does not enumerate the fields or sinks past the seam; the audit the library offers is strictly narrower than the sinks the library owns. Here the library did ship a specific primitive, bound to a specific dangerous input, with a specific safe value the consumer could choose. The fix for Safe Mode Was Opt In is to pass the argument. The fix for Extension As Mitigation is to enumerate the sinks the library did not. The Xerte/elFinder exhibit sits on the boundary: elFinder's acceptedName is a callback slot explicitly wired to filename validation, which makes it a specific primitive and keeps the exhibit here; when the slot is generic and the wiring is in the consumer's head, the pattern is Extension As Mitigation.

Not Wide Default, Narrow Doc. That pattern describes a forwarding component whose inbound-to-outbound copy carries fields the reference documentation never enumerates; the fix is an opt-in allowlist at the forwarding seam and the wide default remains. Here the library is not forwarding structure; the library is choosing which of two operation modes to perform. The two patterns share the shape of a default behavior broader than the one the consumer expected, and both repair with an opt-in. The axis that distinguishes them is what the default does: forwarding versus operation-mode selection. A Wide Default is about which bytes leave the component; a Safe Mode Was Opt In is about how the component interpreted the bytes it processed.

Not Todo That Shipped. That pattern describes code whose author wrote a comment acknowledging the missing security work and shipped the comment instead of the code. The TODO is the author's record of their own knowledge of the gap. Here the library carries the primitive the comment would have asked for, and the author's call site contains no comment because the author did not know the library carried it. The two patterns can share an incident: a WPCode-shaped plugin could carry // TODO: bind custom capabilities to CPT above the three-key register_post_type call, which would make it both patterns. Absent the comment, the omission is Safe Mode Was Opt In, which the catalog treats as the more common and more structural case.

Defender playbook

For every third-party library you parse, serialize, template, deserialize, exec, or filesystem-walk through, open the library's reference documentation for its constructor and its factory helpers and list the security-relevant options. For every option whose default enables the dangerous mode, grep your codebase for call sites that reach the library and verify each one engages the flag. The audit produces a table: library, flag, default value, your call site, your value. Any cell where your value is empty is a Safe Mode Was Opt In instance waiting for the sink. Run the audit once per release of the library, because new options are added at major version bumps and your defaults silently inherit the library's.

When you consume a library whose safe mode is opt-in, wrap it in a project-local constructor whose signature omits the unsafe option entirely and whose body sets the flag on every instance. Ban direct imports or direct calls to the underlying library by linter rule, pre-commit hook, or CI grep. A single project-owned factory is the only call site to audit, and its unit test asserts that an instance produced by any public entry point of your wrapper has the flag set. The EspoCRM 9.3.4 patch wrapped Michelf's parser in a fifty-line helper that constructed with no_markup and no_entities and rerouted four call sites through it; the pattern across the wider catalog is that the project-owned wrapper is both the smallest fix and the only one that survives new call sites added after the patch.

When you ship a library, do not expose a dangerous mode behind an opt-in flag whose default enables it. If the dangerous mode must remain reachable for backwards compatibility, make choosing it explicit at the call site: a required argument the consumer must pass, a factory whose name encodes the risk (createUnsafeInstance, fromUntrustedInput), a construction that throws without the flag. The vm2 3.11.1 patch is the counter-example to avoid: a regression test in the same commit asserts a default-configured sandbox can still allocate 64 MB host buffers, and the maintainer's commit message explains that the default is non-breaking by design. An advisory recommending a flag as a "defense in depth measure" is documentation that transferred responsibility; the library's API is what enforces it. Test that any consumer call site that does not pass the flag fails to compile or fails at construction.

For every CVE you read whose patch is "set the flag," file the pre-patch call site as a probe for the same mechanism in your own codebase. The DeepSeek-TUI patch flipped two unwrap_or(true) calls to unwrap_or(false); the vm2 patch added a bufferAllocLimit option that defaults to Infinity; the WPCode patch does not yet exist and the custom-capability binding the plugin ships is still absent from the CPT registration. The pattern's exhibits are navigable in both directions: a flag's existence predicts a CVE at consumers who did not set it, and a one-line patch's shape predicts a flag whose safe value was never the default. Write regression tests that submit attacker-shaped inputs through your consumer code and assert the dangerous sink refuses them. A passing test that calls the library's default helper on malicious input and does not raise is a check-in of the pattern under your own repository name.

Kinship

Extension As Mitigation. Sibling at the library-affordance layer. Safe Mode Was Opt In is the case where the library ships a specific safety primitive wired to a specific dangerous input, and the consumer did not engage it. Extension As Mitigation is the case where the library ships no such primitive and documents a generic subclass, callback, or hook as the safety handoff. The two patterns describe how a library transfers responsibility to a consumer and differ on what it transferred. A flag transfers an argument the consumer sets. A hook transfers an audit the consumer runs. Extension As Mitigation's published boundary note points back at this pattern with the same distinction, and both pages mark the Xerte elFinder exhibit as the boundary case.

Setting Was Advisory. Sibling at the flag-engagement layer. Safe Mode Was Opt In describes the consumer who never passed the flag. Setting Was Advisory describes the consumer who did pass it and the library that silently overrode the value inside a wrapper. Both patterns name the same end state at the sink, and both repair with a check that the flag's value was honored end to end. The two populations are disjoint: a Safe Mode call site that adds the flag migrates into Setting Was Advisory if the library ignores it. Grep audits for one pattern should branch to the other when the flag appears at the call site but the sink's behavior still reflects the default.

Default Is The Mitigation. Composes at the patch-structure layer. Safe Mode Was Opt In is the pre-patch state the Default Is The Mitigation patch addresses by moving a default value. The composition is observable in the catalog: a Default Is The Mitigation patch leaves every downstream that has not updated in Safe Mode Was Opt In, and the same patch leaves every downstream that has updated in Safe Mode Was Opt In against any request that resupplies the toggle. The Netty strictLineParsing exhibit sits in both populations and tags both patterns. The SAP Visual Composer exhibit sits here and extends the pattern to a twenty-year window where the vendor and the documentation author are the same organization.

Todo That Shipped. Cousin at the author-awareness layer. Todo That Shipped describes code whose author knew what was missing and left the note in a comment. Safe Mode Was Opt In describes code whose author did not know a specific flag was available in the library they were calling, or forgot, or minimized syntax. The two are distinguishable by reading the call site: a comment acknowledging the gap moves the case to Todo That Shipped; silence at the call site keeps it here. A WPCode-shaped CPT registration that carried a TODO comment would tag both patterns, and the catalog treats the un-commented omission as the more common structural form.

The library carried the fix. The consumer carried the sink.