Skip to content

Fix security review findings and require header authentication - #802

Open
jdevalk wants to merge 13 commits into
developfrom
codex/security-review-fixes
Open

jdevalk wants to merge 13 commits into
developfrom
codex/security-review-fixes

Conversation

@jdevalk

@jdevalk jdevalk commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Statistics and task requests now require an Authorization: Bearer <site-token> header; URL credentials no longer grant access. This PR also restricts recommendation and page-type access and sanitizes remote lesson and branding content.

Resulting behavior

  • Branding previews require an administrator, use shareable URLs without a nonce, and cannot select branding for automatic onboarding.
  • Lessons are sanitized before storage in a versioned cache. Text fields remain plain text, while text and todo_description retain filtered HTML. Video embeds retain sandboxing and allowlisted HTTPS player hosts, including Cloudflare Stream subdomains.
  • Brand icons are parsed as XML so case-sensitive SVG attributes, gradients and clip paths survive. Scripts, styles, event handlers, external references and entity declarations are rejected.
  • Branding fetches must match the configured server's scheme and host, with redirects disabled. Explicitly configured local/private development servers remain supported.
  • Recommendation ownership/provider permissions, term capabilities and page-type access are enforced. Page to-dos are excluded from public REST responses, and plain REST to-dos remain readable and removable through the user provider.
  • Dashboard/AJAX inputs are allowlisted, rate limiting uses the connection address, and credential logging and unnecessary credentials on public content requests are removed.
  • The Apache bearer-header fallback applies only when the REST request has no Authorization header; an explicitly invalid header cannot fall back to a valid one.
  • Automatic onboarding is called only when the site has no saved key, so it sends no bearer credential. The welcome form displays remote onboarding errors and allows retrying.

Validation

All 10 GitHub Actions workflows pass on 5c14d143, including PHPUnit/integration tests, PHPStan, code style, lint, security, Plugin Check, coverage, Playwright and update/compatibility tests. Plugin Check reports warnings but no errors.

Filip reports browser verification of branding previews/icons, lesson video playback and welcome-screen errors. The review follow-up was checked against the current source. A local merge-tree check against develop at ea00838b completes without conflicts. No runtime changes were needed for this reconciliation.

Coordinated rollout

Companion server change: ProgressPlanner/progress-planner-server#68.

Existing sites need a compatibility plugin that accepts both URL credentials and the selected header before the server switches transport; the strict header-only plugin follows. Deployment and existing-key rotation are separate work.

Stacked PR #803 replaces the bearer header with X-Progress-Planner-Token to avoid interference from bearer-auth plugins. It must be coordinated with ProgressPlanner/progress-planner-server#69, and the compatibility stage must support that custom header if the pair is adopted. The custom-header change is not part of this PR.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

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

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

✅ Code Coverage Report

Metric Value
Total Coverage 36.92% 📉
Base Coverage 34.49%
Difference 📈 2.43%

⚠️ Coverage below recommended 40% threshold

🎉 Great job maintaining/improving code coverage!

📊 File-level Coverage Changes (17 files)

🆕 New Files

Class Coverage Lines
🟢 Progress_Planner\Rest\Page_Types_Controller 100.00% 6/6

📈 Coverage Improved

Class Before After Change
Progress_Planner\Page_Todos 5.00% 97.30% +92.30%
Progress_Planner\Admin\Widgets\Challenge 0.00% 85.71% +85.71%
Progress_Planner\Lessons 0.00% 71.43% +71.43%
Progress_Planner\Utils\Onboard 4.30% 35.11% +30.81%
Progress_Planner\Suggested_Tasks\Providers\User 4.55% 27.27% +22.72%
Progress_Planner\Suggested_Tasks\Providers\Tasks 36.59% 47.56% +10.97%
Progress_Planner\Admin\Widgets\Widget 25.00% 33.33% +8.33%
Progress_Planner\Suggested_Tasks 22.18% 30.18% +8.00%
Progress_Planner\UI\Branding 85.88% 88.89% +3.01%
Progress_Planner\Suggested_Tasks\Providers\Update_Term_Description 21.12% 23.93% +2.81%
Progress_Planner\Base 49.69% 50.93% +1.24%
Progress_Planner\Suggested_Tasks\Providers\Remove_Terms_Without_Posts 18.83% 19.87% +1.04%

📉 Coverage Decreased

Class Before After Change
Progress_Planner\Rest\Base 100.00% 96.77% -3.23%
Progress_Planner\Rest\Recommendations_Controller 92.86% 90.24% -2.62%
Progress_Planner\Page_Types 55.36% 53.68% -1.68%
Progress_Planner\Admin\Page 31.33% 31.14% -0.19%
ℹ️ About this report
  • All tests run in a single job with Xdebug coverage
  • Security tests excluded from coverage to prevent output issues
  • Coverage calculated from line coverage percentages

@github-actions

Copy link
Copy Markdown
Contributor

🔍 WordPress Plugin Check Report

⚠️ Status: Passed with warnings

📊 Report

🎯 Total Issues ❌ Errors ⚠️ Warnings
10 0 10

⚠️ Warnings (10)

📁 classes/suggested-tasks/data-collector/class-unpublished-content.php (1 warning)
📍 Line 🔖 Check 💬 Message
103 WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in Using exclusionary parameters, like post__not_in, in calls to get_posts() should be done with caution, see https://docs.wpvip.com/databases/optimize-queries/using-post__not_in/ for more information.
📁 classes/suggested-tasks/providers/class-content-review.php (4 warnings)
📍 Line 🔖 Check 💬 Message
232 WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in Using exclusionary parameters, like post__not_in, in calls to get_posts() should be done with caution, see https://docs.wpvip.com/databases/optimize-queries/using-post__not_in/ for more information.
377 WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in Using exclusionary parameters, like post__not_in, in calls to get_posts() should be done with caution, see https://docs.wpvip.com/databases/optimize-queries/using-post__not_in/ for more information.
381 WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in Using exclusionary parameters, like post__not_in, in calls to get_posts() should be done with caution, see https://docs.wpvip.com/databases/optimize-queries/using-post__not_in/ for more information.
388 WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in Using exclusionary parameters, like post__not_in, in calls to get_posts() should be done with caution, see https://docs.wpvip.com/databases/optimize-queries/using-post__not_in/ for more information.
📁 classes/activities/class-query.php (2 warnings)
📍 Line 🔖 Check 💬 Message
71 PluginCheck.Security.DirectDB.UnescapedDBParameter Unescaped parameter $table_name used in $wpdb->query()\n$table_name assigned unsafely at line 58.
163 PluginCheck.Security.DirectDB.UnescapedDBParameter Unescaped parameter $where_args used in $wpdb->get_results()\n$where_args assigned unsafely at line 153.
📁 classes/suggested-tasks/data-collector/class-terms-without-description.php (1 warning)
📍 Line 🔖 Check 💬 Message
108 PluginCheck.Security.DirectDB.UnescapedDBParameter Unescaped parameter $query used in $wpdb->get_results()\n$query assigned unsafely at line 106.
📁 classes/suggested-tasks/data-collector/class-yoast-orphaned-content.php (1 warning)
📍 Line 🔖 Check 💬 Message
111 PluginCheck.Security.DirectDB.UnescapedDBParameter Unescaped parameter $query used in $wpdb->get_row()\n$query assigned unsafely at line 98.
📁 classes/suggested-tasks/data-collector/class-terms-without-posts.php (1 warning)
📍 Line 🔖 Check 💬 Message
120 PluginCheck.Security.DirectDB.UnescapedDBParameter Unescaped parameter $query used in $wpdb->get_results()\n$query assigned unsafely at line 118.

🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check

jdevalk and others added 9 commits November 13, 2026 20:50
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wp_kses lowercased viewBox, which an XML data URI ignores, and dropped
gradients, clip paths, rgb() colors and accessibility attributes. Parse the
icon with DOMDocument against an allowlist instead: no scripts, styles, event
handlers or href, and paint values limited to colors or url(#local-id).
Results are cached per request, and an unusable icon falls back to the default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Running wp_kses_post on every lesson string HTML-encoded "&" in names, IDs
and headings, which then showed up literally and was saved into page-type
terms. Only the text and todo_description fields carry markup; every other
string is now sanitized as plain text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every lesson video is a Cloudflare Stream iframe (customer-*.cloudflarestream.com),
which was not on the host allowlist, so its src was removed. Its style, allow
and loading attributes were also stripped, breaking the layout. Allow the
Cloudflare Stream host and those attributes; the sandbox stays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Lessons were re-sanitized on every cache read, and Page_Types reads them on
every init. Sanitize the remote response once before caching it. The cache key
now carries a version, so entries cached before sanitizing are never read and
are fetched again once. The tests use the class's own key instead of rebuilding it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A nonce is tied to the user and session and expires, so it cannot be put in a
shared or bookmarked preview link, and nothing generated one. The onboarding
risk it guarded against is already closed by get_branding_id( false ) in
Base::init(); the preview stays limited to administrators.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wp_safe_remote_* rejects loopback and private hosts and ports other than
80/443/8080, so a local PROGRESS_PLANNER_REMOTE_SERVER_ROOT_URL or branding
server stopped working. Both URLs are hardcoded or set in wp-config.php, and
branding fetches are pinned to the configured server's scheme and host, so use
wp_remote_* with redirects still disabled.

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

The only caller runs the onboarding request when the site has no license key,
so the Authorization header was never sent. Remove it and its test. The
server now refuses re-onboarding without the existing key, and the welcome
screen only logged that to the console; show the server's message instead
and let the user submit again.

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

Copy link
Copy Markdown
Collaborator

Review follow-up: I pushed fixes directly to this branch, one commit per finding.

  • Brand icons (07448f1): wp_kses lowercased viewBox, which an SVG data URI ignores, and dropped gradients, clip paths, rgb() colors and aria-hidden. The icon is now parsed as XML against an allowlist: no scripts, styles, event handlers or href, and url() only to #local-id. All three icons on the branding server come through unchanged.
  • Lesson text fields (4ef3373): wp_kses_post on every string encoded & in names, IDs and headings, and those names end up in page-type terms. Only text and todo_description keep HTML now; everything else is plain text.
  • Lesson videos (22d149e): every lesson video is a Cloudflare Stream iframe (customer-*.cloudflarestream.com), which wasn't on the host allowlist, so all videos lost their src. That host plus the iframe's style, allow and loading attributes are now allowed, and the sandbox stays.
  • Lessons cache (b8e5140): lessons were re-sanitized on every read, and Page_Types reads them on every init. They're now sanitized once before caching, under a versioned cache key, so old unsanitized entries are fetched again once.
  • Branding preview (41d00bf): nothing generated the _pp_branding_nonce, and a nonce is user-bound and expires, so it can't be in a shared preview link. Removed; the preview stays admin-only, and get_branding_id( false ) already keeps it from triggering onboarding.
  • Local servers (ae9b3bd): wp_safe_remote_* blocked local or private remote and branding servers, for example http://server.planner.test. Both URLs are hardcoded or set in wp-config.php, and branding fetches are pinned to the configured server's scheme and host, so this uses wp_remote_* with redirects still off.
  • Onboarding header (5c14d14): the only caller onboards when the site has no license key, so the new Authorization header was never sent. Removed it with its test. The server now refuses re-onboarding without the key, so the welcome screen shows the server's error message instead of only logging it.
  • c37d946 fixes a Prettier error in editor.js that blocked the pre-commit hook.

Checked: the full PHPUnit suite passes, and phpcs, PHPStan and lint are clean. In the browser I checked the brand preview and icon, a lesson video playing in the editor, and the welcome-screen error.

Moving the token from Authorization: Bearer to an X-Progress-Planner-Token header is in a stacked PR, #803 (server side: ProgressPlanner/progress-planner-server#69). Bearer-auth plugins such as JWT Authentication for WP REST API reject any bearer token they can't decode before our check runs. Merge or close those two together.

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