Skip to content

[codex] reject protected admin user updates - #185

Merged
salasebas merged 1 commit into
mainfrom
codex/admin-update-protected-fields
Jul 1, 2026
Merged

[codex] reject protected admin user updates#185
salasebas merged 1 commit into
mainfrom
codex/admin-update-protected-fields

Conversation

@salasebas

Copy link
Copy Markdown
Owner

Summary

Reject protected user fields in /admin/update-user so a role with only user:update cannot mass-assign security-sensitive state such as banned, banReason, banExpires, emailVerified, timestamps, or id.

The existing role handling remains permission-gated by user:set-role.

Root Cause

Finding 6 was valid: the admin update endpoint accepted arbitrary data fields and passed them through to storage after only special-casing role. Upstream Better Auth 1.6.9 has the same broad admin update behavior, likely for custom-field compatibility, but it does not apply its normal input:false user-field filtering to the admin endpoint.

RustAuth has separate security-sensitive behavior for these fields, including dedicated permissions and ban/session side effects, so this PR hardens RustAuth instead of copying upstream behavior.

Validation

  • cargo test -p rustauth-plugins --test plugins update_user_rejects_protected_security_fields --all-features
  • cargo fmt --all --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo nextest run -p rustauth-plugins --all-features
  • git diff --check

@vercel

vercel Bot commented Jul 1, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
rustauth-docs-site Ready Ready Preview, Comment Jul 1, 2026 6:40am

@salasebas
salasebas force-pushed the codex/admin-update-protected-fields branch from bbc669e to 0638b9e Compare July 1, 2026 06:28
@salasebas
salasebas marked this pull request as ready for review July 1, 2026 06:30
@salasebas
salasebas merged commit a5b01c0 into main Jul 1, 2026
22 of 23 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 1, 2026

@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: 0638b9e9b7

ℹ️ 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 +172 to +179
} else if matches!(
field.as_str(),
"id" | "email_verified"
| "created_at"
| "updated_at"
| "banned"
| "ban_reason"
| "ban_expires"

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 Reject custom physical names for protected fields

When a deployment uses schema aliases for user columns, this check only rejects the default logical names, but the DB layer accepts both logical and physical field names when resolving updates. For example, if banned is stored as is_banned, a user:update caller can still send data: { "is_banned": true } and bypass the new protection; include the configured schema field names (from context.db_schema / admin schema options) in the protected set before building the update.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant