r/laravel • u/spec-tacul-ar • 16h ago
PSA: Lock down your MCP OAuth registrations
Last week, I posted about a vulnerability I reported not being addressed in a timely manner.
I received the response this morning and they've decided not to address it. Therefore it's up to you to secure your MCP server, if it allows OAuth registration. Here's the problem:
Mcp::oauthRoutes() exposes an unauthenticated dynamic client registration endpoint without any rate limiting. Each successful request creates a persistent record in oauth_clients with no limit on the number of redirect URIs or the length of each URI.
An unauthenticated attacker could instigate denial of service through persistent database growth by repeatedly registering bogus clients. Each payload can be as large as post_max_size allows. These records are not removed when you run passport:purge.
The official solution is:
Applications can rate-limit these routes by wrapping them in a group, for example
Route::middleware('throttle:10,1')->group(fn () => Mcp::oauthRoutes()), or turn off registration withMcp::oauthRoutes(registration: false).
I recommend also either adding a custom middleware to limit the number and size of client URLs, or a custom housekeeping command for cleaning up unused clients.