Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

refactor: add safe list for external app protocols#17742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
BrunoQuaresma merged 3 commits intomainfrombq/refactor-protocols
May 9, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletionssite/src/modules/apps/apps.test.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -53,6 +53,22 @@ describe("getAppHref", () => {
expect(href).toBe(externalApp.url);
});

it("doesn't return the URL with the session token replaced when using unauthorized protocol", () => {
const externalApp = {
...MockWorkspaceApp,
external: true,
url: `ftp://example.com?token=${SESSION_TOKEN_PLACEHOLDER}`,
};
const href = getAppHref(externalApp, {
host: "*.apps-host.tld",
agent: MockWorkspaceAgent,
workspace: MockWorkspace,
path: "/path-base",
token: "user-session-token",
});
expect(href).toBe(externalApp.url);
});

it("returns a path when app doesn't use a subdomain", () => {
const app = {
...MockWorkspaceApp,
Expand Down
20 changes: 19 additions & 1 deletionsite/src/modules/apps/apps.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,6 +10,20 @@ import type {
// be used internally, and is highly subject to break.
export const SESSION_TOKEN_PLACEHOLDER = "$SESSION_TOKEN";

// This is a list of external app protocols that we
// allow to be opened in a new window. This is
// used to prevent phishing attacks where a user
// is tricked into clicking a link that opens
// a malicious app using the Coder session token.
const ALLOWED_EXTERNAL_APP_PROTOCOLS = [
"vscode:",
"vscode-insiders:",
"windsurf:",
"cursor:",
"jetbrains-gateway:",
"jetbrains:",
];

type GetVSCodeHrefParams = {
owner: string;
workspace: string;
Expand DownExpand Up@@ -78,7 +92,11 @@ export const getAppHref = (
{ path, token, workspace, agent, host }: GetAppHrefParams,
): string => {
if (isExternalApp(app)) {
return needsSessionToken(app)
const appProtocol = new URL(app.url).protocol;
const isAllowedProtocol =
ALLOWED_EXTERNAL_APP_PROTOCOLS.includes(appProtocol);

return needsSessionToken(app) && isAllowedProtocol
? app.url.replaceAll(SESSION_TOKEN_PLACEHOLDER, token ?? "")
: app.url;
}
Expand Down
1 change: 1 addition & 0 deletionssite/src/modules/resources/AppLink/AppLink.stories.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -80,6 +80,7 @@ export const ExternalApp: Story = {
workspace: MockWorkspace,
app: {
...MockWorkspaceApp,
url: "vscode://open",
external: true,
},
agent: MockWorkspaceAgent,
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp