Skip to content

feat(mcp): component_mcp refuses locked accounts (Phase 5) - #258

Open
askdba wants to merge 1 commit into
mainfrom
feat/mcp-account-locked
Open

askdba wants to merge 1 commit into
mainfrom
feat/mcp-account-locked

Conversation

@askdba

@askdba askdba commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Phase 5 item from #256: the account_locked check.

Problem

component_mcp runs each call in an impersonated "local" command-service session. Impersonation skips the login checks, so an account with ACCOUNT LOCK could still be used through the endpoint (verified in #252).

Change

  • run_as() reads account_locked from the session's security context, via mysql_thd_security_context and mysql_security_context_options. The account lookup at connect (acl_getroot → lock_account) sets it.
  • For a locked account, the call fails with ER_ACCOUNT_HAS_BEEN_LOCKED (3118, the server's own message). This happens before CONNECT is announced to the guard and before any statement runs.
  • It fails closed: a context that can't be read counts as locked.
  • Each call opens a new session, so ACCOUNT LOCK takes effect on the next call.
  • DISCONNECT is now emitted only when CONNECT was emitted. Before, it was emitted for any session with a THD.

Tests

scripts/test-mcp-endpoint.sh on mysql:26.10.0: 33 passed, 0 failed. New checks:

  • ACCOUNT LOCK → run_query and list_databases both fail with 3118;
  • ACCOUNT UNLOCK → the account works again.

The current main build fails both lock checks: it returns rows for the locked account (31/33).

Docs: docs/MCP_COMPONENTS.md and CHANGELOG.

Independent of #257 (bounded consumer). Both touch run_as(), so the second to merge gets a merge from main.

Part of #256.

🤖 Generated with Claude Code

Impersonated command-service sessions skip the login checks, ACCOUNT LOCK
included (verified in #252). run_as() now reads account_locked from the
session's security context (set by the account lookup at connect) and fails
the call with ER_ACCOUNT_HAS_BEEN_LOCKED before CONNECT is announced or any
statement runs. A context that cannot be read counts as locked.

DISCONNECT is now emitted only after CONNECT was.

test-mcp-endpoint.sh: lock -> both tools refused (3118), unlock -> works.
33 checks; the previous build fails the two lock checks.

Part of #256 (RFC 0001 Phase 5).

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

coderabbitai Bot commented Nov 2, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 57 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 962b2c41-b707-43e3-b738-0c0318f194b3
Commits

Reviewing files that changed from the base of the PR and between ff59fea and 4e14c27.

Files selected for processing: 4
  • CHANGELOG.md
  • docs/MCP_COMPONENTS.md
  • scripts/test-mcp-endpoint.sh
  • src/mcp/endpoint/component_mcp.cc
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 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-11-02T09:58:32.202795Z 4e14c27 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.

This branch has not been deployed

No deployments
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