Skip to content

Commit 1d5270b

Browse files
authored
Merge pull request #169 from aictrl-dev/fix/issue-50-dependabot-alerts
fix(deps): resolve Dependabot alerts — MCP SDK 1.32.1 (GHSA-6qxp-vccf-f47h), turbo, @babel/core (#50)
2 parents b86fc9d + 9ec6cf4 commit 1d5270b

6 files changed

Lines changed: 483 additions & 48 deletions

File tree

‎bun.lock‎

Lines changed: 188 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"packages/*"
1919
],
2020
"catalog": {
21+
"@babel/core": "7.29.7",
2122
"hono": "4.10.7",
2223
"hono-openapi": "1.1.2",
2324
"@hono/zod-validator": "0.4.2",
@@ -70,7 +71,7 @@
7071
"prettier": "3.6.2",
7172
"semver": "^7.6.0",
7273
"sst": "3.18.10",
73-
"turbo": "2.5.6"
74+
"turbo": "2.11.9"
7475
},
7576
"dependencies": {
7677
"@aws-sdk/client-s3": "3.933.0",
@@ -96,6 +97,7 @@
9697
"web-tree-sitter"
9798
],
9899
"overrides": {
100+
"@babel/core": "catalog:",
99101
"@types/bun": "catalog:",
100102
"@types/node": "catalog:"
101103
},

‎packages/cli/package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"@ai-sdk/vercel": "1.0.33",
5353
"@ai-sdk/xai": "2.0.51",
5454
"@aws-sdk/credential-providers": "3.993.0",
55-
"@babel/core": "7.28.4",
55+
"@babel/core": "catalog:",
5656
"@gitlab/gitlab-ai-provider": "3.6.0",
5757
"@octokit/webhooks-types": "7.6.1",
5858
"@openrouter/ai-sdk-provider": "1.5.4",
@@ -92,7 +92,7 @@
9292
"@aictrl/util": "workspace:*",
9393
"@clack/prompts": "1.0.0-alpha.1",
9494
"@gitlab/opencode-gitlab-auth": "1.3.3",
95-
"@modelcontextprotocol/sdk": "1.29.0",
95+
"@modelcontextprotocol/sdk": "1.32.1",
9696
"@octokit/graphql": "9.0.2",
9797
"@octokit/rest": "catalog:",
9898
"@opentui/core": "0.1.81",

‎packages/cli/src/mcp/auth.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ export namespace McpAuth {
1010
refreshToken: z.string().optional(),
1111
expiresAt: z.number().optional(),
1212
scope: z.string().optional(),
13+
// Authorization server that issued the tokens, stamped by the MCP SDK. The SDK
14+
// never presents a refresh token to a different authorization server.
15+
issuer: z.string().optional(),
1316
})
1417
export type Tokens = z.infer<typeof Tokens>
1518

@@ -18,6 +21,9 @@ export namespace McpAuth {
1821
clientSecret: z.string().optional(),
1922
clientIdIssuedAt: z.number().optional(),
2023
clientSecretExpiresAt: z.number().optional(),
24+
// Authorization server the client was registered with, stamped by the MCP SDK.
25+
// The SDK never presents these client credentials to a different one.
26+
issuer: z.string().optional(),
2127
})
2228
export type ClientInfo = z.infer<typeof ClientInfo>
2329

‎packages/cli/src/mcp/oauth-provider.ts‎

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,7 @@ export class McpOAuthProvider implements OAuthClientProvider {
4848

4949
async clientInformation(): Promise<OAuthClientInformation | undefined> {
5050
// Check config first (pre-registered client)
51-
if (this.config.clientId) {
52-
return {
53-
client_id: this.config.clientId,
54-
client_secret: this.config.clientSecret,
55-
}
56-
}
51+
if (this.config.clientId) return this.configuredClientInformation(this.config.clientId)
5752

5853
// Check stored client info (from dynamic registration)
5954
// Use getForUrl to validate credentials are for the current server URL
@@ -67,6 +62,7 @@ export class McpOAuthProvider implements OAuthClientProvider {
6762
return {
6863
client_id: entry.clientInfo.clientId,
6964
client_secret: entry.clientInfo.clientSecret,
65+
issuer: entry.clientInfo.issuer,
7066
}
7167
}
7268

@@ -75,13 +71,16 @@ export class McpOAuthProvider implements OAuthClientProvider {
7571
}
7672

7773
async saveClientInformation(info: OAuthClientInformationFull): Promise<void> {
74+
if (this.config.clientId) return this.bindConfiguredClient(this.config.clientId, info)
75+
7876
await McpAuth.updateClientInfo(
7977
this.mcpName,
8078
{
8179
clientId: info.client_id,
8280
clientSecret: info.client_secret,
8381
clientIdIssuedAt: info.client_id_issued_at,
8482
clientSecretExpiresAt: info.client_secret_expires_at,
83+
issuer: info.issuer,
8584
},
8685
this.serverUrl,
8786
)
@@ -91,6 +90,46 @@ export class McpOAuthProvider implements OAuthClientProvider {
9190
})
9291
}
9392

93+
/**
94+
* Configured credentials, stamped with the authorization server they were first accepted by.
95+
* The SDK refuses to present a stamped client secret to any other authorization server.
96+
*/
97+
private async configuredClientInformation(clientId: string): Promise<OAuthClientInformation> {
98+
return {
99+
client_id: clientId,
100+
client_secret: this.config.clientSecret,
101+
issuer: (await this.configuredBinding(clientId))?.issuer,
102+
}
103+
}
104+
105+
/**
106+
* The stored binding of the configured client. It pins the authorization server, not the MCP
107+
* server URL, so it is read regardless of the URL the entry was saved for.
108+
*/
109+
private async configuredBinding(clientId: string): Promise<McpAuth.ClientInfo | undefined> {
110+
const clientInfo = (await McpAuth.get(this.mcpName))?.clientInfo
111+
if (clientInfo?.clientId !== clientId) return undefined
112+
return { clientId, issuer: clientInfo.issuer }
113+
}
114+
115+
/**
116+
* Stores only the authorization-server binding of configured credentials; the secret stays
117+
* in config. A different client_id means the SDK registered with another authorization server
118+
* because the configured client is bound elsewhere. Abort instead of starting an authorization
119+
* whose code exchange would be refused.
120+
*/
121+
private async bindConfiguredClient(clientId: string, info: OAuthClientInformationFull): Promise<void> {
122+
if (info.client_id !== clientId) {
123+
const bound = (await this.configuredBinding(clientId))?.issuer
124+
throw new Error(
125+
`MCP server "${this.mcpName}" advertises authorization server ${info.issuer}, but its configured OAuth client ` +
126+
`is bound to ${bound}. Run \`aictrl mcp logout ${this.mcpName}\` if the authorization server has moved.`,
127+
)
128+
}
129+
await McpAuth.updateClientInfo(this.mcpName, { clientId, issuer: info.issuer }, this.serverUrl)
130+
log.info("bound configured client to authorization server", { mcpName: this.mcpName, issuer: info.issuer })
131+
}
132+
94133
async tokens(): Promise<OAuthTokens | undefined> {
95134
// Use getForUrl to validate tokens are for the current server URL
96135
const entry = await McpAuth.getForUrl(this.mcpName, this.serverUrl)
@@ -104,6 +143,7 @@ export class McpOAuthProvider implements OAuthClientProvider {
104143
? Math.max(0, Math.floor(entry.tokens.expiresAt - Date.now() / 1000))
105144
: undefined,
106145
scope: entry.tokens.scope,
146+
issuer: entry.tokens.issuer,
107147
}
108148
}
109149

@@ -115,6 +155,7 @@ export class McpOAuthProvider implements OAuthClientProvider {
115155
refreshToken: tokens.refresh_token,
116156
expiresAt: tokens.expires_in ? Date.now() / 1000 + tokens.expires_in : undefined,
117157
scope: tokens.scope,
158+
issuer: tokens.issuer,
118159
},
119160
this.serverUrl,
120161
)
@@ -157,12 +198,20 @@ export class McpOAuthProvider implements OAuthClientProvider {
157198
return
158199
}
159200

201+
// The binding of configured credentials outlives invalidation: the secret is still in
202+
// config, and dropping the binding would let the next authorization server receive it.
203+
const binding = this.config.clientId ? await this.configuredBinding(this.config.clientId) : undefined
160204
switch (type) {
161205
case "all":
206+
if (binding) {
207+
await McpAuth.set(this.mcpName, { clientInfo: binding, serverUrl: entry.serverUrl })
208+
break
209+
}
162210
await McpAuth.remove(this.mcpName)
163211
break
164212
case "client":
165-
delete entry.clientInfo
213+
if (binding) entry.clientInfo = binding
214+
else delete entry.clientInfo
166215
await McpAuth.set(this.mcpName, entry)
167216
break
168217
case "tokens":

0 commit comments

Comments
 (0)