Skip to content

armgit / xerj

Public Imported from GitHub
0

AI search engine and MCP server for bots and agents. One Rust binary indexes code, docs, logs, JSONL/CSV and PDFs for BM25 full-text, vector and hybrid search, code search without grep, agent memory and RAG. Elasticsearch-compatible API; Corpus Hub serves hundreds of reference memory corpora.

docs(case-study): recover interrupted sweep + verify 8 dropped candidates + trigger traces

Xerj Squad A5364715eb35d
diff --git a/docs/case-studies/wordpress-security-audit/FINDINGS.md b/docs/case-studies/wordpress-security-audit/FINDINGS.md
index fd117de69..d596f9e25 100644
--- a/docs/case-studies/wordpress-security-audit/FINDINGS.md
+++ b/docs/case-studies/wordpress-security-audit/FINDINGS.md
@@ -140,6 +140,27 @@ but **not** `manage_network_users` POSTs `action=adduser` (valid `add-user` nonc
an existing user's email, `role=administrator`, no `noconfirmation` -> stored ->
invitee visits the link -> becomes administrator.
+**Exact trigger (traced to the HTTP request):**
+```
+POST /wp-admin/network/user-new.php (multisite; also wp-admin/user-new.php)
+Cookie: <logged-in site admin: has create_users + promote_users, NOT manage_network_users>
+Content-Type: application/x-www-form-urlencoded
+
+action=adduser
+&_wpnonce_add-user=<valid nonce from the Add-User form>
+&[email protected] # must resolve via get_user_by('email')
+&role=administrator # <-- injected; NOT in the inviter's editable_roles
+ # (omit 'noconfirmation' so the email-invitation else-branch runs)
+```
+Server stores `new_user_{key} = { user_id, email, role:'administrator' }` (line 100,
+**no `wp_ensure_editable_role`**). Second-order trigger — the invitee clicks:
+```
+GET /newbloguser/<key>/ # init hook maybe_add_existing_user_to_blog -> add_user_to_blog -> set_role('administrator')
+```
+No re-check on confirmation. Conditions to actually cross a boundary: (a) multisite,
+(b) an `editable_roles` filter that restricts this inviter below `administrator`
+(else `wp_ensure_editable_role` is a no-op and the role was assignable anyway).
+
**Honest severity — conditional, defense-in-depth in stock.** In a *stock* install
`get_editable_roles()` returns all roles, so `wp_ensure_editable_role` is a no-op
and the inviter could assign that role anyway — **no boundary is crossed**. The gap
diff --git a/docs/case-studies/wordpress-security-audit/ZERODAY-SWEEP.md b/docs/case-studies/wordpress-security-audit/ZERODAY-SWEEP.md
index 0d325a737..d51077681 100644
--- a/docs/case-studies/wordpress-security-audit/ZERODAY-SWEEP.md
+++ b/docs/case-studies/wordpress-security-audit/ZERODAY-SWEEP.md
@@ -53,3 +53,67 @@ the whole earlier audit) are the daily driver; this deep sweep is the periodic
## Reproduce
The workflow script is under the session's `workflows/scripts/`; re-run points the
same reviewer/verifier prompts at any file list (`review_files.json`).
+
+---
+
+## Recovery after the usage-limit interruption
+
+The run hit the weekly usage limit near the end. Reading the workflow
+`journal.jsonl` (one `result` line per agent) recovers exactly what completed:
+
+- **Review phase: 177/177 batches finished → all 883 files WERE analyzed.** No
+ file was left unreviewed. (This is the important recovery result: the coverage
+ of the *review* is complete.)
+- **Verify phase: 36/44 candidates verified; 8 dropped** at the limit. So the gap
+ is 8 *unverified candidates*, not unanalyzed files — recoverable by reading the
+ code directly (no agents needed).
+
+### The 8 dropped candidates — hand-verified by the lead (reading real code)
+
+| candidate | lead verdict |
+|---|---|
+| `blocks/cover.php:102` (oEmbed KSES bypass) | **REFUTED** — the block builds a *fixed* `<iframe>` template with `esc_url($iframe_src)`; it does not emit the provider's raw HTML. Not injectable. |
+| `feed-rss2-comments.php:107` (`]]>` CDATA breakout) | **Plausible, low–medium, unconfirmed.** `comment_text()` output sits inside `<![CDATA[…]]>`; `wp_kses_post` does not escape a literal `]]>`, so a comment containing `]]>` can close the CDATA and inject markup into the **comments RSS feed**. Trigger: unauthenticated comment on a post with comments-feed enabled; impact is on **feed consumers/aggregators** that render it unsanitized — not a WP-site compromise. Needs a feed-reader test to confirm; reported as a candidate. |
+| `block-supports/custom-css.php:258` (edit_css scope) | **Plausible, medium, unconfirmed.** The custom-CSS strip is wired to `content_save_pre`/`content_filtered_save_pre` (post-content saves). If block-widget saves via the REST widgets path don't pass those filters, a user with `edit_theme_options` but not `edit_css`/`unfiltered_html` could store custom CSS. Trigger: authenticated `edit_theme_options` user, block-widget REST save. Needs the widget-save-path trace to confirm. |
+| `rest .../widgets-controller.php:178` (context=edit scoping) | Candidate — read-scoping on `show_in_rest` sidebars; low, needs confirmation. |
+| `rest .../global-styles-controller.php:256` (per-block css not validated) | Candidate — `validate_custom_css` only on top-level `styles.css`, low. |
+| `rest .../abilities-v1-run-controller.php:163` (404-vs-403 info leak) | Candidate — ability-name enumeration; info-disclosure, low. |
+| `wp-mail.php:170` (From-header → post author) | **Design-level**, by-documentation (Post-by-Email trusts the mailbox); not a code bug. |
+| `wp-trackback.php:75` (UTF-7 charset filter) | WordPress **deliberately blocks** UTF-7 trackbacks here — the code is the mitigation, not a bug. Likely FP. |
+
+**Net after recovery:** the one lead-confirmed *new* finding remains
+`user-new.php` role injection (FINDINGS.md #4); `cover.php`, `wp-mail.php`,
+`wp-trackback.php` are refuted/by-design; `feed-rss2-comments.php` and
+`custom-css.php` are plausible-but-unconfirmed candidates worth a follow-up
+(feed-reader test / widget-save-path trace) when the usage budget resets.
+
+## How XERJ makes this discoverable vs. a full-context-window search
+
+The naive alternative — feed the whole codebase to a model and ask "find bugs" —
+fails on **three** axes this sweep exposes:
+
+1. **It doesn't fit.** WP core is ~5.2M tokens; a 200k window holds ~4% of it.
+ You *must* chunk, and chunking is where interprocedural bugs (the
+ `user-new.php` role flows into `add_user_to_blog` two files away) get split
+ apart and lost. XERJ holds the whole call graph as **facts** (~26k tokens for
+ the structured audit) so the agent reasons over all 883 files without loading
+ their text.
+2. **It can't compare siblings without the map.** The `user-new.php` bug is a
+ *missing sibling guard* — visible only when you see all three role-sinks
+ together. XERJ's `wpsinks`/`wpauthz` indices return "every call to
+ `add_option`/`add_existing_user_to_blog` with a role arg" in one query, so the
+ reviewer is *handed the three siblings to compare*; a windowed scan reads them
+ in different chunks and never lines them up.
+3. **It re-reads everything every time.** A full-context pass pays the whole token
+ cost per question. XERJ builds the index once and every subsequent query
+ (sinks, patterns, authz posture, gadget reachability, taint) is ~hundreds to a
+ few thousand tokens. The per-file *deep* sweep (~10.8M tokens, 222 agents) is
+ the thorough backstop; the XERJ structured passes (~26k) are the daily driver —
+ and XERJ is what let the sweep **target** the 883 security-relevant files
+ instead of blindly chunking 1,492.
+
+The division of labour: **XERJ narrows and proves coverage and hands the reviewer
+the right neighbours to compare; the per-file read catches the logic/inconsistency
+gaps the facts don't encode.** Neither alone found `user-new.php` — the structural
+graph passed it (a cap check *was* present), and a blind full-context scan would
+have split its cross-file flow. Together they caught it.