Skip to content

Harden option actions, tracking, and release workflows - #93

Merged
jdevalk merged 13 commits into
developfrom
codex/hardening-fixes
Nov 18, 2026
Merged

jdevalk merged 13 commits into
developfrom
codex/hardening-fixes

Conversation

@jdevalk

@jdevalk jdevalk commented Nov 13, 2026

Copy link
Copy Markdown
Member

Autoload changes currently delete and recreate options, which can lose data or permanently save filtered values. This change updates only the autoload flag, protects essential WordPress options, and validates option identifiers without changing their contents.

  • Use wp_set_option_autoload_values() for single and bulk changes; preserve false-valued options and report failed writes.
  • Protect core options and the current site's roles option, including database-collation aliases. Hide destructive controls for protected rows and confirm single and bulk deletion.
  • Preserve exact string identifiers, validate bounded bulk arrays and autoload states, harden sorting, and rely consistently on core REST authentication.
  • Bound tracking to 10,000 stored names and 1,000 names per request, and batch option lookups. Mark incomplete observations and pause unused-option recommendations. Migration retains observations that were not saved; reset completes before reporting success and suppresses that request's shutdown write. Lock timeouts and SQL failures propagate to the UI.
  • Restrict the tracking-page exception to authorized admin requests and guard PHP source files against direct access.
  • Pin deployment actions to commit SHAs, scope workflow permissions, fix the scheduled scan's repository condition, exclude development files from releases, and validate the community plugin map's structure. Run admin JavaScript regressions in CI.

Option-value access remains available to users with manage_options; the admin screen and README now explain that values may contain credentials, including on multisite.

Validation: PHP syntax, WordPress coding standards, PHPStan, five JavaScript regression tests, plugin-map validation plus 12 malformed fixtures, and release-file inclusion/exclusion checks passed. Integration regressions passed against an isolated PHP 8.3 / WordPress 7.1-alpha / MariaDB 11.4 installation, covering exact names, raw-value preservation, protected options, actual lock contention, failed SQL writes, retries, partial migration, and synchronous reset. Browser verification and execution against the minimum WordPress version remain outstanding.

Related: #79, #92.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Test on Playground
Test this pull request on the Playground
or download the zip

@jdevalk
jdevalk requested a review from ilicfilip November 17, 2026 10:53
ilicfilip and others added 4 commits November 17, 2026 13:46
- Protect the active theme's real theme_mods_{stylesheet} option instead of the
  non-existent "theme_mods"; inactive themes' leftovers stay removable.
- Protect salts and keys WordPress stores in the database when wp-config.php
  doesn't define them.
- Build the lowercased protected-name map once per request and resolve bulk
  collation aliases with a single IN query instead of one query per name.
- Compare the sort direction case-insensitively again, as develop did.
- Pin the new javascript-regressions job's actions to commit SHAs.
- Fetch a full page in the list-response test so fixtures aren't paginated
  away on sites with more than 25 matching options.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The tracking-limited flag paused unused-option recommendations site-wide and
only a manual reset cleared it, yet it was set by routine events: a 1s lock
timeout under concurrent traffic, any request reading over 1,000 options, or a
transient SQL error. Legacy migrations over 10,000 names could never finish,
and pruning deleted the oldest (core) rows.

- Drop the GET_LOCK serialisation; the 10,000-name cap is now a soft limit
  checked without a lock. No MySQL-only lock functions or DELETE ... LIMIT.
- Set the flag only when a new name is actually dropped for capacity, or one
  request reads more names than storage holds. Write failures don't set it.
- Detect existing names with a SQL join, so case/accent variants of a stored
  row count as existing, matching the primary key's collation.
- Migrate legacy data without the cap so migration always completes.
- Never prune rows, and don't truncate reads at the limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wpdb parses the first FROM to check the table charset for non-ASCII queries;
a leading subquery made every at-capacity write with a non-ASCII name fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Write failures no longer pause recommendations, so the notice now names the
only remaining cause: a full tracking table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ilicfilip and others added 3 commits November 17, 2026 14:09
SQLite folds case but not accents, so 'sitéurl' is a distinct, unprotected
option there; the test now only expects 403 where the engine maps the name to
a protected row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SQLite's case folding is ASCII-only, so vary only the ASCII letters; the name
stays non-ASCII to keep exercising wpdb's charset check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ilicfilip

Copy link
Copy Markdown
Collaborator

Reviewed this. The autoload, protection and input-validation fixes are solid and worth landing. The tracking-limit part caused regressions, though, so I've put the fixes in two follow-up PRs that target this branch. They change different code, so they merge cleanly in either order. A local trial merge of both passes every check.

#94: option actions

  • theme_mods isn't a real option name. Core stores theme_mods_{stylesheet}, so Customizer settings could still be deleted. It now protects the active theme's mods and leaves inactive themes' leftovers removable.
  • Adds the salts and keys core stores in wp_options when wp-config.php doesn't define them. Deleting those logs everyone out.
  • Sort direction was compared case-sensitively, so DESC sorted ascending. It's lowercased again, as on develop.
  • Builds the protected-name map once per request, and checks bulk-action aliases with one IN query instead of one query per name.
  • Pins the actions in the new javascript-regressions job to exact commits.
  • Test fix: tests/hardening.php read only the first 25 list rows, so it fails on this branch on any site with more than 25 used-not-autoloaded options.

#95: tracking limits

Routine events set the tracking_limited flag, and only a manual reset cleared it:

  • the 1s GET_LOCK timeout taken on every request;
  • any request reading more than 1,000 options;
  • any SQL error.

Also: migrations over 10,000 names could never finish, and pruning deleted the oldest (core) rows. #95 removes the lock and keeps the cap as a soft limit. The flag is now set only when a name is actually dropped for capacity. Migration always completes, and nothing is pruned.

Reproduced on this branch:

Details and test evidence are in each PR description. Separately, #96 removes the empty playground-merged.yml, which has caused a failed run on every push.

jdevalk and others added 4 commits November 18, 2026 14:07
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…endations

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…tions

The REST tests from #100 asserted the old behaviour. Adjust them to the hardened
routes: schema validation rejects unknown autoload values, missing options are
reported as update_failed instead of 404 or being skipped silently, and the
in-handler nonce checks are gone (core REST authentication checks cookie nonces).
The admin page only pauses tracking for an administrator in wp-admin, so cover
both that and the front-end case.

Add tests for what the hardening introduces: protected options can't be deleted
or have their autoload flag changed, a protected name refuses a whole batch, and
malformed option names are rejected.

Make js/admin-script.js pass the JS lint job that develop now has: Prettier
formatting, eslint-disable comments moved to the lines they apply to, and the
DataTable lookup moved after the early return.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Plugin readme preview

Open preview · Commit ec69382

29 passed · 1 warning · 0 notes

Warnings

  • “Tested up to” is 7.2; the latest WordPress major release is 7.1. Test with 7.1 and update the header.
Passed checks (29)
  • 76 / 150 characters in the short description.
  • Plugin name header recognized.
  • License header recognized: GPL-3.0-or-later.
  • 5 tags accepted within the five-tag limit.
  • Description is within the parser’s word limit.
  • Installation is within the parser’s word limit.
  • Faq is within the parser’s word limit.
  • Changelog is within the parser’s word limit.
  • Stable tag is declared: 1.7.1.
  • The PHP Version header is declared: 1.7.1.
  • Stable tag matches the PHP Version header: 1.7.1.
  • The readme “Requires at least” value is valid: 6.7.
  • The PHP “Requires at least” header is a numeric version: 6.7.
  • “Requires at least” matches between the readme and PHP header: 6.7.
  • The readme “Requires PHP” value is valid: 7.4.
  • The PHP “Requires PHP” header is a numeric version: 7.4.
  • “Requires PHP” matches between the readme and PHP header: 7.4.
  • “Tested up to” 7.2 meets the minimum WordPress version 6.7.
  • Installation content is present.
  • FAQ content is present.
  • Changelog content is present.
  • Screenshot captions are present.
  • The first changelog release matches Stable tag: 1.7.1.
  • The first changelog release matches PHP Version: 1.7.1.
  • Banner image loaded.
  • Plugin icon loaded.
  • Screenshot 1 has a matching image and caption.
  • Screenshot 2 has a matching image and caption.
  • Plugin PHP header loaded.

Readme and PHP-header checks only; this does not test plugin runtime compatibility.

@jdevalk
jdevalk merged commit 052cf74 into develop Nov 18, 2026
15 checks passed
@jdevalk
jdevalk deleted the codex/hardening-fixes branch November 18, 2026 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants