Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(control-api): deny high-impact Microsoft first-party GUID scopes under entra-v2 (BR2-M1)
Diego Zacariasb1c79ffb7f15
diff --git a/control-api/package-lock.json b/control-api/package-lock.jsonindex ba7fd77ac..be08f01e3 100644--- a/control-api/package-lock.json+++ b/control-api/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-api",- "version": "0.1.812",+ "version": "0.1.813","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-api",- "version": "0.1.812",+ "version": "0.1.813","dependencies": {"@clerum/display-field": "file:../packages/display-field","@clerum/grok-provider-attempt-contract": "file:../packages/grok-provider-attempt-contract",diff --git a/control-api/package.json b/control-api/package.jsonindex 45819e1dc..95c379901 100644--- a/control-api/package.json+++ b/control-api/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-api",- "version": "0.1.812",+ "version": "0.1.813","description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets","main": "dist/main.js","engines": {diff --git a/control-api/src/oauth/asProfiles.ts b/control-api/src/oauth/asProfiles.tsindex 466d076b4..1f3e14a93 100644--- a/control-api/src/oauth/asProfiles.ts+++ b/control-api/src/oauth/asProfiles.ts@@ -57,7 +57,21 @@ export const ENTRA_TENANT_AUTHORITY_TEMPLATE = 'https://login.microsoftonline.co/** RFC 6749 §3.3 scope-token; remoteMcp.ts imports it from here. */export const SCOPE_TOKEN_RE = /^[\x21\x23-\x5B\x5D-\x7E]+$/-/** First-party APIs whose tokens must never reach an MCP host, whatever the operator confirms. */+/**+ * First-party APIs whose GUID-form scopes are always rejected, whatever the operator confirms:+ * a GUID names no host, so a confirmed one would let Entra mint a token for these high-impact+ * APIs and hand it to whatever MCP host the CR points at.+ *+ * Only the GUID form is blocked. A first-party MCP server whose audience lives on its own host+ * (for example Dataverse at <org>.crm.dynamics.com/api/mcp) is connected with that host's+ * URL-form scope, which the host rule already accepts.+ *+ * Left out on purpose, because their URL-form audience lives on a host other than their MCP+ * server, so the GUID form (confirmed by the operator) is the only way to connect them:+ * - Azure DevOps (499b84ac-1321-427f-aa17-267ca6975798), MCP server at mcp.dev.azure.com;+ * - Power BI Service (00000009-0000-0000-c000-000000000000), MCP server at+ * api.fabric.microsoft.com while its URL audience is analysis.windows.net.+ */export const ENTRA_BLOCKED_RESOURCE_APPS: ReadonlyMap<string, string> = new Map([['00000003-0000-0000-c000-000000000000', 'Microsoft Graph'],['00000003-0000-0ff1-ce00-000000000000', 'SharePoint Online'],@@ -70,6 +84,11 @@ export const ENTRA_BLOCKED_RESOURCE_APPS: ReadonlyMap<string, string> = new Map(['0000000a-0000-0000-c000-000000000000', 'Microsoft Intune'],['fc780465-2017-40d4-a0c5-307022471b92', 'WindowsDefenderATP'],['00000004-0000-0ff1-ce00-000000000000', 'Skype for Business Online'],+ ['00000007-0000-0000-c000-000000000000', 'Dynamics CRM'],+ ['022907d3-0f1b-48f7-badc-1ba6abab6d66', 'Azure SQL Database'],+ ['ca7f3f0b-7d91-482c-8e09-c5d840d0eac5', 'Log Analytics API'],+ ['48ac35b8-9aa8-4d74-927d-1f4a14a0b239', 'Skype and Teams Tenant Admin API'],+ ['cc15fd57-2c6c-4117-a88c-83b1d56b4bbe', 'Microsoft Teams Services'],])/** First-party MCP APIs tied to the only host allowed to receive their tokens. */diff --git a/control-api/test/oauth.asProfiles.test.ts b/control-api/test/oauth.asProfiles.test.tsindex d945b2252..c16fdf649 100644--- a/control-api/test/oauth.asProfiles.test.ts+++ b/control-api/test/oauth.asProfiles.test.ts@@ -46,6 +46,11 @@ const BLOCKED_LITERAL: Array<[string, string]> = [['0000000a-0000-0000-c000-000000000000', 'Microsoft Intune'],['fc780465-2017-40d4-a0c5-307022471b92', 'WindowsDefenderATP'],['00000004-0000-0ff1-ce00-000000000000', 'Skype for Business Online'],+ ['00000007-0000-0000-c000-000000000000', 'Dynamics CRM'],+ ['022907d3-0f1b-48f7-badc-1ba6abab6d66', 'Azure SQL Database'],+ ['ca7f3f0b-7d91-482c-8e09-c5d840d0eac5', 'Log Analytics API'],+ ['48ac35b8-9aa8-4d74-927d-1f4a14a0b239', 'Skype and Teams Tenant Admin API'],+ ['cc15fd57-2c6c-4117-a88c-83b1d56b4bbe', 'Microsoft Teams Services'],]const KNOWN_LITERAL: Array<[string, string]> = [['fdcc1f02-fc51-4226-8753-f668596af7f7', 'workiq.svc.cloud.microsoft'],@@ -53,7 +58,7 @@ const KNOWN_LITERAL: Array<[string, string]> = []describe('closed tables', () => {- it('ENTRA_BLOCKED_RESOURCE_APPS is exactly the 11 high-impact first-party APIs', () => {+ it('ENTRA_BLOCKED_RESOURCE_APPS is exactly the 16 high-impact first-party APIs', () => {expect([...ENTRA_BLOCKED_RESOURCE_APPS.entries()]).toEqual(BLOCKED_LITERAL)})@@ -271,6 +276,11 @@ describe('profileScopeViolation', () => {'0000000a-0000-0000-c000-000000000000','fc780465-2017-40d4-a0c5-307022471b92','00000004-0000-0ff1-ce00-000000000000',+ '00000007-0000-0000-c000-000000000000',+ '022907d3-0f1b-48f7-badc-1ba6abab6d66',+ 'ca7f3f0b-7d91-482c-8e09-c5d840d0eac5',+ '48ac35b8-9aa8-4d74-927d-1f4a14a0b239',+ 'cc15fd57-2c6c-4117-a88c-83b1d56b4bbe',]const rejected = ['https://graph.microsoft.com/Mail.Read',@@ -299,8 +309,8 @@ describe('profileScopeViolation', () => {})}- it('the 11 blocked GUIDs are rejected in both forms (written as literals)', () => {- expect(blockedGuids).toHaveLength(11)+ it('the 16 blocked GUIDs are rejected in both forms (written as literals)', () => {+ expect(blockedGuids).toHaveLength(16)for (const guid of blockedGuids) {expect(profileScopeViolation('entra-v2', WORKIQ_URL, [`${guid}/x`])).toBe(`${guid}/x`)expect(profileScopeViolation('entra-v2', WORKIQ_URL, [`api://${guid}/x`])).toBe(@@ -426,6 +436,37 @@ describe('profileUnverifiedScopes', () => {})})+describe('high-impact first-party data APIs are blocked, not confirmable', () => {+ const dataApiGuids = [+ '00000007-0000-0000-c000-000000000000', // Dynamics CRM+ '022907d3-0f1b-48f7-badc-1ba6abab6d66', // Azure SQL Database+ 'ca7f3f0b-7d91-482c-8e09-c5d840d0eac5', // Log Analytics API+ '48ac35b8-9aa8-4d74-927d-1f4a14a0b239', // Skype and Teams Tenant Admin API+ 'cc15fd57-2c6c-4117-a88c-83b1d56b4bbe', // Microsoft Teams Services+ ]++ for (const guid of dataApiGuids) {+ for (const scope of [`${guid}/x`, `api://${guid}/x`]) {+ it(`${scope} is a violation and never unverified`, () => {+ expect(profileScopeViolation('entra-v2', WORKIQ_URL, [scope])).toBe(scope)+ expect(profileUnverifiedScopes('entra-v2', WORKIQ_URL, [scope])).toEqual([])+ })+ }+ }++ // Their URL-form audience lives on a host other than their MCP server, so the GUID form+ // is the only way to connect them and must stay confirmable rather than blocked.+ for (const [name, scope] of [+ ['Azure DevOps', '499b84ac-1321-427f-aa17-267ca6975798/.default'],+ ['Power BI Service', '00000009-0000-0000-c000-000000000000/.default'],+ ]) {+ it(`${name} stays an unknown GUID that needs confirmation`, () => {+ expect(profileScopeViolation('entra-v2', WORKIQ_URL, [scope])).toBeNull()+ expect(profileUnverifiedScopes('entra-v2', WORKIQ_URL, [scope])).toEqual([scope])+ })+ }+})+describe('audience classification properties', () => {const knownOrBlockedGuid = fc.constantFrom(...BLOCKED_LITERAL.map(([g]) => g),diff --git a/control-api/test/oauth.remoteSpecCoherence.test.ts b/control-api/test/oauth.remoteSpecCoherence.test.tsindex 113dcb858..d0d2f5f70 100644--- a/control-api/test/oauth.remoteSpecCoherence.test.ts+++ b/control-api/test/oauth.remoteSpecCoherence.test.ts@@ -303,6 +303,19 @@ const INCOHERENT: ReadonlyArray<{reason: 'scope_audience_mismatch',consentOnly: false,},+ {+ // A CR written while Azure SQL was still an unknown GUID must stop resolving once it is+ // blocked; the server's own scope next to it does not save it.+ label: 'entra-v2 with the Work IQ scope plus an Azure SQL Database GUID scope',+ oauth: () =>+ workIqWithScopes([+ WORKIQ_GUID_SCOPE,+ '022907d3-0f1b-48f7-badc-1ba6abab6d66/user_impersonation',+ ]),+ remote: workIqRemote,+ reason: 'scope_audience_mismatch',+ consentOnly: false,+ },{label: 'entra-v2 with a Microsoft Graph URL scope',oauth: () => workIqWithScopes(['https://graph.microsoft.com/x']),diff --git a/docs/how-to/connect-oauth-connector.md b/docs/how-to/connect-oauth-connector.mdindex 076cdd7dc..0d1a346fe 100644--- a/docs/how-to/connect-oauth-connector.md+++ b/docs/how-to/connect-oauth-connector.md@@ -225,9 +225,20 @@ from you, and both are checked the same way.**Blocked APIs.** Microsoft Graph, SharePoint Online, Exchange Online, AzureService Management, Azure AD Graph, Azure Key Vault, Azure Storage, Office 365Management APIs, Microsoft Intune, Microsoft Defender for Endpoint-(WindowsDefenderATP), and Skype for Business Online. These are high-impact-Microsoft APIs that never host an MCP server, so a token for them must never-reach one.+(WindowsDefenderATP), Skype for Business Online, Dynamics CRM, Azure SQL+Database, Log Analytics API, Skype and Teams Tenant Admin API, and Microsoft+Teams Services. These are high-impact Microsoft APIs, and a GUID form names no+host, so a confirmed one would let a token for them reach any MCP server. Only+the GUID form is blocked: a Microsoft MCP server whose audience is on its own+host (for example Dataverse at `<org>.crm.dynamics.com/api/mcp`) is connected+with a URL-form scope on that host, which is accepted as usual.++Azure DevOps and Power BI are deliberately not on this list. Their URL-form+audience lives on a host other than their MCP server, so their GUID form (for+example `00000009-0000-0000-c000-000000000000/.default` for Power BI) is the+only way to connect them; it is accepted after you confirm it, like any other+unknown API. That path is allowed by the audience policy but has not been+verified end to end against either server (see **Not supported** below).**The server's own scope is required.** At least one scope must name theserver's API (a URL on its host, or a GUID form that is accepted or@@ -269,10 +280,11 @@ scopes, fails when the user connects.**Not supported:**-- MCP servers whose scope lives on a different host than the server, such as- Power BI (`api.fabric.microsoft.com/v1/mcp/powerbi`, with scopes on- `analysis.windows.net`). The URL form is rejected, and the GUID form with- confirmation has not been verified.+- Verified support for MCP servers whose scope lives on a different host than+ the server, such as Power BI (`api.fabric.microsoft.com/v1/mcp/powerbi`, with+ scopes on `analysis.windows.net`) or Azure DevOps (`mcp.dev.azure.com`). The+ URL form is rejected; the GUID form is accepted after confirmation, but has+ not been verified end to end.- National clouds (`login.microsoftonline.us`, `login.partner.microsoftonline.cn`),personal Microsoft accounts (`consumers`), and the v1 authority(`sts.windows.net`).