diff --git a/packages/@sanity/cli/src/util/remoteTemplate.ts b/packages/@sanity/cli/src/util/remoteTemplate.ts index 77db18ec5e9..71df5a694d4 100644 --- a/packages/@sanity/cli/src/util/remoteTemplate.ts +++ b/packages/@sanity/cli/src/util/remoteTemplate.ts @@ -14,6 +14,11 @@ import {x} from 'tar' import {type CliApiClient, type PackageJson} from '../types' +const DISALLOWED_PATHS = [ + // Prevent security risks from unknown GitHub Actions + '/.github/', +] + const ENV_VAR = { ...REQUIRED_ENV_VAR, READ_TOKEN: 'SANITY_API_READ_TOKEN', @@ -181,6 +186,9 @@ export async function downloadAndExtractRepo( const pathSegments = posixPath.split(posix.sep) rootPath = pathSegments.length ? pathSegments[0] : null } + for (const disallowedPath of DISALLOWED_PATHS) { + if (posixPath.includes(disallowedPath)) return false + } return posixPath.startsWith(`${rootPath}${filePath ? `/${filePath}/` : '/'}`) }, }),