Skip to content

Commit c8d6810

Browse files
author
nightq
committed
fix: MS Teams OAuth on Windows uses cmd /c start instead of explorer.exe
Fixes #67738 Root cause: explorer.exe <url> on Windows delegates to the running Explorer shell and exits with code 1, causing OAuth promise rejection even though the browser opened correctly. Fix: Use cmd /c start "" URL instead, which exits 0 on success. Also updates test assertions to handle all three platforms (darwin, win32, linux). Additionally adds .cdpUrl to sensitive URL config paths for security redaction.
1 parent f377db1 commit c8d6810

4 files changed

Lines changed: 21 additions & 3 deletions

File tree

extensions/msteams/src/setup-surface.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,15 @@ describe("msteams setup surface", () => {
6767
child.emit("exit", 0, null);
6868

6969
await expect(result).resolves.toBeUndefined();
70-
expect(spawn).toHaveBeenCalledWith(process.platform === "darwin" ? "open" : "xdg-open", [url], {
70+
const expectedCmd =
71+
process.platform === "darwin" ? "open" : process.platform === "win32" ? "cmd" : "xdg-open";
72+
const expectedArgs =
73+
process.platform === "darwin"
74+
? [url]
75+
: process.platform === "win32"
76+
? ["/c", "start", '""', url]
77+
: [url];
78+
expect(spawn).toHaveBeenCalledWith(expectedCmd, expectedArgs, {
7179
stdio: "ignore",
7280
shell: false,
7381
});

extensions/msteams/src/setup-surface.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,13 @@ const setMSTeamsGroupPolicy = createTopLevelChannelGroupPolicySetter({
3131

3232
export function openDelegatedOAuthUrl(url: string): Promise<void> {
3333
return new Promise<void>((resolve, reject) => {
34-
const cmd = process.platform === "darwin" ? "open" : "xdg-open";
35-
const child = spawn(cmd, [url], { stdio: "ignore", shell: false });
34+
const [cmd, args]: [string, string[]] =
35+
process.platform === "darwin"
36+
? ["open", [url]]
37+
: process.platform === "win32"
38+
? ["cmd", ["/c", "start", '""', url]]
39+
: ["xdg-open", [url]];
40+
const child = spawn(cmd, args, { stdio: "ignore", shell: false });
3641
child.once("error", reject);
3742
child.once("exit", (code, signal) => {
3843
if (code === 0) {

src/shared/net/redact-sensitive-url.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ describe("sensitive URL config metadata", () => {
4949
expect(isSensitiveUrlConfigPath("models.providers.*.baseUrl")).toBe(true);
5050
expect(isSensitiveUrlConfigPath("mcp.servers.remote.url")).toBe(true);
5151
expect(isSensitiveUrlConfigPath("gateway.remote.url")).toBe(false);
52+
expect(isSensitiveUrlConfigPath("browser.cdpUrl")).toBe(true);
53+
expect(isSensitiveUrlConfigPath("browser.profiles.default.cdpUrl")).toBe(true);
5254
});
5355

5456
it("uses an explicit url-secret hint tag", () => {

src/shared/net/redact-sensitive-url.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ export function isSensitiveUrlConfigPath(path: string): boolean {
2828
if (path.endsWith(".request.proxy.url")) {
2929
return true;
3030
}
31+
if (path.endsWith(".cdpUrl")) {
32+
return true;
33+
}
3134
return /^mcp\.servers\.(?:\*|[^.]+)\.url$/.test(path);
3235
}
3336

0 commit comments

Comments
 (0)