Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore(mcp): clarify secrets and file checks (#39778)
Yury Semikhatsky7bbe1ecf93a4
diff --git a/packages/playwright-core/src/tools/backend/context.ts b/packages/playwright-core/src/tools/backend/context.tsindex ca27bb4c52..e2bf838c0e 100644--- a/packages/playwright-core/src/tools/backend/context.ts+++ b/packages/playwright-core/src/tools/backend/context.ts@@ -378,6 +378,7 @@ async function checkFile(options: ContextOptions, resolvedFilename: string, flag// Trust llm to use valid characters in file names.const output = outputDir(options);const workspace = options.cwd;- if (!resolvedFilename.startsWith(output) && !resolvedFilename.startsWith(workspace))+ const withinDir = (root: string) => resolvedFilename === root || resolvedFilename.startsWith(root + path.sep);+ if (!withinDir(output) && !withinDir(workspace))throw new Error(`File access denied: ${resolvedFilename} is outside allowed roots. Allowed roots: ${output}, ${workspace}`);}diff --git a/packages/playwright-core/src/tools/mcp/config.d.ts b/packages/playwright-core/src/tools/mcp/config.d.tsindex 5839adca85..4bc76ea30c 100644--- a/packages/playwright-core/src/tools/mcp/config.d.ts+++ b/packages/playwright-core/src/tools/mcp/config.d.ts@@ -143,9 +143,9 @@ export type Config = {sharedBrowserContext?: boolean;/**- * Secrets are used to prevent LLM from getting sensitive data while- * automating scenarios such as authentication.- * Prefer the browser.contextOptions.storageState over secrets file as a more secure alternative.+ * Secrets are used to replace matching plain text in the tool responses to prevent the LLM+ * from accidentally getting sensitive data. It is a convenience and not a security feature,+ * make sure to always examine information coming in and from the tool on the client.*/secrets?: Record<string, string>;@@ -216,8 +216,10 @@ export type Config = {};/**- * Whether to allow file uploads from anywhere on the file system.- * By default (false), file uploads are restricted to paths within the MCP roots only.+ * allowUnrestrictedFileAccess acts as a guardrail to prevent the LLM from accidentally+ * wandering outside its intended workspace. It is a convenience defense to catch unintended+ * file access, not a secure boundary; a deliberate attempt to reach other directories can be+ * easily worked around, so always rely on client-level permissions for true security.*/allowUnrestrictedFileAccess?: boolean;