Skip to content

Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.

fix(computer): report disabled extension file access on everyday Chrome uploads

jeffrey72a1b495501d
diff --git a/apps/computer/local-daemon/README.md b/apps/computer/local-daemon/README.md
index eab4cb87..04d071ec 100644
--- a/apps/computer/local-daemon/README.md
+++ b/apps/computer/local-daemon/README.md
@@ -704,7 +704,11 @@ one seat in it. When every installed version of the Playwright Extension in
the profile is 0.5.0 or later, the extension keeps several Playwright clients
connected, each in its own tab group. Each Agent then has its own seat, and
Agents work in their own background tabs at once. An earlier extension may drop
-one client when the next connects, so its whole profile is one seat. Release
+one client when the next connects, so its whole profile is one seat. Chrome lets the extension
+set a file input only when the user turns on Allow access to file URLs for it,
+which is off by default. When the profile's preferences show it off, the Daemon
+fails `browser_file_upload` with `BROWSER_FILE_ACCESS_DISABLED` before Chrome
+sees it, and the Agent asks the user to turn it on; the file chooser stays open. Release
bundles patch Playwright to keep focus emulation on its CDP connections, this
Chrome and the Agent Chrome alike. Without it a background tab is hidden: it
stops rendering, clicks wait for it, and mouse and key events are lost. One task or Live call holds a seat at a time, so tasks of
diff --git a/apps/computer/local-daemon/internal/linger/localtools/browser.go b/apps/computer/local-daemon/internal/linger/localtools/browser.go
index 43ea8673..1d8d77ef 100644
--- a/apps/computer/local-daemon/internal/linger/localtools/browser.go
+++ b/apps/computer/local-daemon/internal/linger/localtools/browser.go
@@ -157,6 +157,10 @@ func (op *operation) nativeBrowserCall(ctx context.Context, name string, args js
// which later tasks of the same Agent reuse.
// A rejected token fails the call: it never falls back to the Agent profile.
func (op *operation) userChromeCall(ctx context.Context, chrome *browserConnection, name string, args json.RawMessage, confirmed *bool) (json.RawMessage, error) {
+ if name == "browser_file_upload" && uploadsFiles(args) && extensionFileAccessOff(op.manager.env, chrome.Profile) {
+ *confirmed = true
+ return nil, errUserChromeFileAccess
+ }
var err error
if op.browser == nil {
session, err := op.manager.checkoutUserChrome(ctx, op, chrome)
@@ -189,6 +193,17 @@ func (op *operation) userChromeCall(ctx context.Context, chrome *browserConnecti
return result, err
}
+var errUserChromeFileAccess = errors.New("BROWSER_FILE_ACCESS_DISABLED: the user's Chrome does not let the Playwright Extension read local files, so no file was attached. Ask the user to open chrome://extensions/?id=" + playwrightExtensionID + " and turn on Allow access to file URLs, then call browser_file_upload again; the file chooser is still open")
+
+// uploadsFiles reports whether browser_file_upload arguments name files; a
+// call without paths only cancels the file chooser.
+func uploadsFiles(args json.RawMessage) bool {
+ var input struct {
+ Paths []string `json:"paths"`
+ }
+ return json.Unmarshal(args, &input) == nil && len(input.Paths) > 0
+}
+
// holdBrowserCalls admits one browser call of this Operation at a time. The
// calls share op.browser, op.nativeBrowser, op.nativeProxy and the owner's
// Chrome session, which a call replaces when the owner connects mid-task.
diff --git a/apps/computer/local-daemon/internal/linger/localtools/user_chrome.go b/apps/computer/local-daemon/internal/linger/localtools/user_chrome.go
index 939b2370..4527dffc 100644
--- a/apps/computer/local-daemon/internal/linger/localtools/user_chrome.go
+++ b/apps/computer/local-daemon/internal/linger/localtools/user_chrome.go
@@ -143,6 +143,40 @@ func versionAtLeast(version string, minimum [3]int) bool {
return true
}
+// extensionFileAccessOff reports whether the profile's preferences show the
+// Playwright Extension without file access. Chrome rejects the extension's
+// DOM.setFileInputFiles without it, and only the user can turn it on. Chrome
+// keeps the switch, off by default, in Secure Preferences or Preferences.
+// Unreadable preferences report false so that Chrome decides.
+func extensionFileAccessOff(env []string, profile string) bool {
+ data := chromeUserDataDirectory(env)
+ if data == "" {
+ return false
+ }
+ read := false
+ for _, name := range []string{"Secure Preferences", "Preferences"} {
+ encoded, err := os.ReadFile(filepath.Join(data, profile, name))
+ if err != nil {
+ continue
+ }
+ var prefs struct {
+ Extensions struct {
+ Settings map[string]struct {
+ AllowFileAccess *bool `json:"newAllowFileAccess"`
+ } `json:"settings"`
+ } `json:"extensions"`
+ }
+ if json.Unmarshal(encoded, &prefs) != nil {
+ continue
+ }
+ read = true
+ if setting := prefs.Extensions.Settings[playwrightExtensionID].AllowFileAccess; setting != nil && *setting {
+ return false
+ }
+ }
+ return read
+}
+
// userChromeSeat names what one task holds in the owner's everyday Chrome:
// its Agent's own tabs when the extension keeps several clients, or else the
// whole profile. Tasks of one seat take turns; seats of one profile do not.
diff --git a/apps/computer/local-daemon/internal/linger/localtools/user_chrome_test.go b/apps/computer/local-daemon/internal/linger/localtools/user_chrome_test.go
index 09e00128..f31a7447 100644
--- a/apps/computer/local-daemon/internal/linger/localtools/user_chrome_test.go
+++ b/apps/computer/local-daemon/internal/linger/localtools/user_chrome_test.go
@@ -810,3 +810,53 @@ func TestLiveCallStopsWaitingWithItsCaller(t *testing.T) {
t.Fatalf("err=%v, want the caller's deadline", err)
}
}
+
+func TestFileUploadReportsExtensionWithoutFileAccess(t *testing.T) {
+ if runtime.GOOS != "darwin" && runtime.GOOS != "windows" {
+ t.Skip("the everyday Chrome is connected on macOS and Windows")
+ }
+ writePrefs := func(env []string, name, body string) {
+ t.Helper()
+ if err := os.WriteFile(filepath.Join(chromeUserDataDirectory(env), "Default", name), []byte(body), 0o600); err != nil {
+ t.Fatal(err)
+ }
+ }
+ setting := func(value string) string {
+ return `{"extensions":{"settings":{"` + playwrightExtensionID + `":{"location":1` + value + `}}}}`
+ }
+ for _, test := range []struct {
+ name string
+ prefs map[string]string
+ off bool
+ }{
+ {"no preferences", nil, false},
+ {"unreadable preferences", map[string]string{"Secure Preferences": "{"}, false},
+ {"default off", map[string]string{"Secure Preferences": setting("")}, true},
+ {"turned off", map[string]string{"Secure Preferences": setting(`,"newAllowFileAccess":false`)}, true},
+ {"turned on", map[string]string{"Secure Preferences": setting(`,"newAllowFileAccess":true`)}, false},
+ {"turned on in Preferences", map[string]string{"Secure Preferences": setting(""), "Preferences": setting(`,"newAllowFileAccess":true`)}, false},
+ } {
+ env := chromeHome(t, "0.6.0_0")
+ for name, body := range test.prefs {
+ writePrefs(env, name, body)
+ }
+ if got := extensionFileAccessOff(env, "Default"); got != test.off {
+ t.Errorf("%s: file access off = %v, want %v", test.name, got, test.off)
+ }
+ }
+
+ m := newConnectionManager(t)
+ m.env = chromeHome(t, "0.6.0_0")
+ writePrefs(m.env, "Secure Preferences", setting(""))
+ op := &operation{manager: m, label: "linger-test", userChrome: &browserConnection{Profile: "Default"}}
+ _, err := op.nativeBrowserCall(t.Context(), "browser_file_upload", json.RawMessage(`{"paths":["/tmp/report.txt"]}`))
+ if !errors.Is(err, errUserChromeFileAccess) {
+ t.Fatalf("an upload the extension cannot perform reached Chrome: %v", err)
+ }
+ if op.browser != nil {
+ t.Fatal("the refused upload started a Playwright session")
+ }
+ if uploadsFiles(json.RawMessage(`{}`)) || uploadsFiles(json.RawMessage(`{"paths":[]}`)) {
+ t.Fatal("cancelling the file chooser was treated as an upload")
+ }
+}