Skip to content

admin: sensitive-field classes (financial, credentials, user content) + #23279 review follow-ups - #23330

Merged
Git-on-my-level merged 2 commits into
mainfrom
lane/admin-roles-2
Oct 22, 2026
Merged

Git-on-my-level merged 2 commits into
mainfrom
lane/admin-roles-2

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Design note

#23279 guarded routes with scopes and money fields with a financial redactor. This PR generalizes the field wall into a classification table: one redactor, one table, one generic wall test. Scope checks stay the authority for routes; the table is the authority for fields that ride along inside documents a route legitimately reads.

  • lib/financial-fields.ts → lib/sensitive-fields.ts: SENSITIVE_FIELD_CLASSES maps each class of sensitive data to the scope that unlocks it and the field names (plus prefixes) it covers. AdminIdentity.json applies the one deep redactor to every scoped response with the caller's effective scopes.
  • A class with scope: null is never returned to the browser by any caller — owners included — unless a route explicitly opts in per response via keep (with a comment and a wall test; no route does today). Credentials are that class.
  • Field names must mean one thing everywhere, so generic names are deliberately not classified: token (TV share links serve tokens by design), email (partner/employee emails are business contacts, not end-user data), text (release notes and announcements share it; Chat Lab sampling is gated at the route instead).
  • lib/__tests__/sensitive-wall.test.ts (renamed from financial-wall.test.ts) sweeps every scoped GET handler three ways — a deputy denied finance:read (no financial field), a deputy denied users:read (no user-content field), and an owner (no credential field) — with every document seeded with the whole table. Adding a field or a class later is one line in the table; the sweep then covers it everywhere.
  • The table is documented in web/admin/docs/data-contracts.md.

Classification table

Class Field names (plus prefixes) Unlocked by
financial money, price, payment, subscription, billing, revenue/MRR/cost, total_earned… (prefixes stripe_, payout) finance:read
credentials api_key, client_secret, code_verifier, mcp_oauth_tokens, access_token, refresh_token, webhook_secret, private_key, secret, password nothing — never returned to the browser
user-content comment (CSAT free text), transcript, memories, your_questions, all_users_questions (Chat Lab sampling) users:read

#23279 Codex review findings at HEAD

Fixed here (10):

Finding Fix Pinned by
P1 app reads return MCP integration credentials under apps:read credentials class in the wall; whole-plugins_data responses lose client_secret/mcp_oauth_tokens/… for everyone sensitive-wall.test.ts: credentials sweep + "strips integration credentials from app reads"
P1 Chat Lab samples real users' messages under content:read sampling runs only for users:read (no user-message reads otherwise); content-only callers get curated questions; the wall also strips the sampling arrays sensitive-wall.test.ts: two chat-lab tests (incl. the no-curated fallback path, where text is too generic for the wall)
P2 CSAT comments served to analytics:read without content access route scoped content:read (matches the page); free-text comment wall-gated on users:read route-scopes.test.ts (content:read policy) + sensitive-wall.test.ts CSAT test
P2 expired proposals persist as pending forever (pending queries grow without bound) the next filing persists the expiry of every stale proposal it saw (system actor, audited), as docs/team-access.md already promised agent-team.test.ts: "persists the expiry of stale proposals on the next filing"
P2 direct invites and add_member proposals not serialized both take the same per-email lock doc (invite-<digest>); membership re-checked inside the filing transaction; a live pending add-person proposal refuses a duplicate direct invite (409) until decided agent-team.test.ts: overlap test (exactly one lands) + pending-invite test
P2 org edit dialog serializes stripe_payment_id: '', 403-ing every metadata edit for partner editors the Stripe field is shown and sent only with finance:write; the PATCH response's billing fields are wall-stripped organizations-edit.test.tsx
P2 Apps page renders finance 403 error cards for Viewer/Support DashboardStats fetches/renders the two subscription cards only with finance:read dashboard-stats.test.tsx
P2 classic dashboard chat-ratings widget shows zeros for Finance (content:read endpoint) widget + section header hidden without content:read classic-dashboard-finance.test.tsx
P2 auth/invalid-id-token answered 500 added to BAD_TOKEN_CODES → 401 auth.test.ts
(support) wall coverage for non-GET scoped responses the redactor now applies to every scoped response for every caller (previously finance:read holders bypassed the copy step entirely, and only GETs were swept) the three sweeps now run one caller per class across all scoped GETs

Already fixed at HEAD in #23279 (citing the tests that pin them): atomic proposal limits (agent-team.test.ts "holds the per-agent cap under a burst of overlapping proposals"), per-target dedup across kinds ("refuses a pending proposal of another kind for the same target"), live proposals behind a long history ("keeps an older pending proposal listed…"), stale proposals displayed as expired on pure reads ("shows stale proposals as expired…"), system-actor expiry attribution (same tests), invite-email failures surfaced on approval ("tells the approver when an approved add-person invite email fails…"), partial-failure surfacing on the Team page (proposalsError/auditError rendered), Grafana embed + wall series finance-gated (route-scopes.test.ts), finance widgets hidden on the classic fallback (classic-dashboard-finance.test.tsx), write controls gated by write scopes (admin-access.test.ts pageWriteScope), access refresh on focus/60s (hooks/useAdminAccess.ts).

Obsolete: the invite-cleanup Auth-deletion race — deletion was removed from addMember; provisioning is never rolled back ("never deletes an Auth account a concurrent invite adopted").

Test evidence

npm run check in web/admin (lint + typecheck + 1041 tests) and make preflight pass. Each new test was proven to fail with its fix reverted to origin/main (or with the class removed from the table):

Reverted fix Failing test
auth/invalid-id-token classification auth.test.ts "answers an invalid token with 401, not 500"
Chat Lab sampling gate sensitive-wall.test.ts "serves no sampled chat-lab questions without users:read even when none are curated"
CSAT scope change route-scopes.test.ts "forbids a member who has every scope except content:read"
user-content class user-content sweep + CSAT comments test
credentials class credentials sweep + "shows financial fields… but never credentials" + app-reads test
shared invite lock / in-tx checks / filing-time expiry the three new agent-team.test.ts tests
org edit billing omission organizations-edit.test.tsx
Apps-page finance card gating dashboard-stats.test.tsx
classic chat-ratings gating classic-dashboard-finance.test.tsx

UI-Evidence: none -- the UI changes only hide widgets/fields callers lack the scope for; each is pinned by DOM-level component tests above

🤖 Generated with Claude Code

View guided diff Turn on auto-fix

#23279 review follow-ups

Generalize the financial field wall into a classification table
(lib/sensitive-fields.ts): one redactor, one table, one wall test that
sweeps every scoped GET per class. Credentials never reach the browser;
private user content needs users:read.

Follow-ups to #23279 Codex review findings that still apply at HEAD:
- app reads strip MCP integration credentials (credentials class)
- Chat Lab question sampling needs users:read; content:read keeps
  curated questions only
- CSAT stats gated content:read; free-text comments wall-gated users:read
- agent add_member proposals and direct invites share the per-email lock;
  membership re-checked inside the filing transaction; a pending proposal
  refuses a duplicate direct invite
- the next filing persists stale proposals' expiry (system actor)
- org edit dialog sends no billing field without finance:write
- Apps page and classic dashboard hide finance/content-scoped cards
- auth/invalid-id-token answers 401, not 500
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T18:01:14.222701Z 874d1cf PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

A member with finance:write but not finance:read sees the subscription
redacted; the edit form sent the blank Stripe field and PATCH cleared the
subscription. The form now hides the field and the route refuses billing
changes without both scopes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 874d1cf0ca

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +126 to +127
// CSAT free-text feedback rows
"comment",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Hide CSAT rows when their comment text is redacted

For a built-in Viewer, who has content:read but not users:read, this removes comment from each CSAT row while leaving the comments array nonempty because summarizeCsatRatings filters the rows before authResult.json applies redaction. The CSAT page checks only stats.comments.length and maps every remaining row, so viewers see up to 50 blank “Latest comments” cards with UID and platform metadata instead of the “No comments yet” state. Omit these rows or gate that section when users:read is absent rather than redacting only the leaf field.

Useful? React with 👍 / 👎.

// Billing is a finance action (finance:write on the server). Without it the
// Stripe field is neither shown nor sent, so an ordinary metadata edit never
// reads as an attempt to change billing.
const canBill = access ? can("finance:write") : false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Do not send a redacted billing value as an update

When a partner editor has finance:write but not finance:read—a valid combination through scope overrides—canBill is true even though the organization response redacts subscription. Opening the edit dialog therefore initializes stripe_payment_id to "", and saving any unrelated metadata sends that empty value; the PATCH handler interprets it as an explicit request to set subscription to null, silently clearing existing billing. Require read access before treating the loaded field as editable, or send the field only after the user explicitly changes it.

AGENTS.md reference: web/admin/AGENTS.md:L6-L6

Useful? React with 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit 364f09a into main Oct 22, 2026
44 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/admin-roles-2 branch October 22, 2026 18:05
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.

1 participant