google / google/chrome-ssh-agent

Client-added keys not persisted past Service Worker restart

Open
#25 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
289
Forks
39
PR merge metrics
No merged PRs in 30d

Description

Chrome is requiring all extensions to move to Manifest V3 in Chrome, which means using [Service Workers](https://developer.chrome.com/docs/extensions/mv3/intro/mv3-overview/#service-workers) instead of a persistent background page.
Service Workers have the Chrome will forcibly suspend them after some time (see https://bugs.chromium.org/p/chromium/issues/detail?id=1152255). This means the instance of the [Agent](https://pkg.go.dev/golang.org/x/crypto/ssh/agent#Agent) is destroyed, losing all of its loaded keys.

We can list the loaded keys, but we only get back [Key](https://pkg.go.dev/golang.org/x/crypto/ssh/agent#Key) instances which (understandably) do not contain the private key material. This makes it impossible for us to save them to be added back when the Service Worker restarts.

For keys loaded via the extension's UI, this is fine since our code loads them to the agent. We store the private key unencrypted in memory in `chrome.storage.session` (which is fine since the private key was in the `Agent` anyways), which allows us to add it back when the Service Worker restarts.

However, then a connected ssh client adds a key to the agent, we don't see the private key, and hence have no way to restore it.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.