Abused an MCP Server to Perform Lateral Movement | Critical Finding | MCP Testing Methodology
An MCP server exposed a tool that let an authenticated administrator run arbitrary SELECT queries against the backend database, and the tool's own description told the AI client to skip the role check when called directly. By registering an OAuth client and calling the MCP endpoint directly, the tester bypassed the AI client's refusal and used the SQL tool to read database secrets, including AWS access key IDs, and then list the contents of an S3 bucket.
infosecwriteups.com
Published on infosecwriteups.com
Hi everyone, in this article, I’ll talk about one of my recent assessments which invoked an MCP component.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the MCP server trusted the AI client to enforce the role check and exposed a general-purpose SQL execution tool to any authenticated caller, rather than enforcing authorisation server-side and limiting the tool to safe, parameterised queries.
Impact
An authenticated administrator could read database secrets including AWS access key IDs and list the contents of an S3 bucket, and the text implies the credentials were then used further.
What the attacker needed
Administrator account on the web application; ability to register an OAuth client; network access to the MCP endpoint
The fix
The MCP server should enforce the administrator role check on every tool call server-side and should not expose a general SQL execution tool to clients.
How it was found
- List the tools exposed by the MCP server and read their descriptions.
- Send an initialize request to the MCP endpoint and receive a 401 with a pointer to the OAuth metadata.
- Read the OAuth metadata, register a client with a localhost callback, and complete the authorisation code flow to get a bearer token.
- Call the MCP endpoint with the token to initialize and list tools.
- Call the fetch_account tool to obtain the account identifier.
- Call the execute_sql tool with queries that read database secrets and list S3 bucket contents.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
An MCP server is a service that lets an AI assistant use tools on a website, such as looking up an account or running a database query. Here the database tool was meant to be used only after a separate role check, but anyone who could talk to the server directly could call the tool without that check. The tester registered their own OAuth client, got a token, and then asked the database tool to return secrets and file listings.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.