Skip to content

fix(canvas): persist Hub credentials on Windows - #496

Open
arniebradfo wants to merge 12 commits into
build/hub/newfrom
agents/windows-canvas-credential-persistence
Open

arniebradfo wants to merge 12 commits into
build/hub/newfrom
agents/windows-canvas-credential-persistence

Conversation

@arniebradfo

@arniebradfo arniebradfo commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

Why

Canvas used Unix permission bits on Windows and rejected private credential folders. An approved Hub connection could not be saved for the next Canvas session.

What changes

Canvas checks Windows file and directory access rules on a fixed local drive. It runs the system-installed PowerShell with a system-only search path and refuses locations that fail its checks without changing permissions. The Canvas guide describes which layouts are supported. Unix storage permissions and Hub refresh-token rotation stay the same.

This PR is the credential-storage portion of the closed #463. Preview discovery and Notes are out of scope.

Disposable native Windows fixtures exercised storage and renewal against a local Hub. Desktop pairing and reconnect were not run on either machine (the Windows laptop or the managed Dev Box) because the running extension worker could not be verified to use disposable credential storage. Hosted extension jobs run on Linux, so they do not exercise the native Windows fixtures. Plugin upgrades and wider managed-profile layouts remain unverified.

Storybook screenshots

No story presentation changes.

Verify the Windows store access rules before reading or writing credentials. Keep Unix permissions and atomically replace rotated refresh tokens.

Adapt the credential storage portion of #463 without porting preview discovery or Notes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI adaptive review requested due to automatic review settings December 3, 2026 02:58
@arniebradfo
arniebradfo marked this pull request as ready for review December 3, 2026 03:08
@arniebradfo
arniebradfo requested review from a team and nshki as code owners December 3, 2026 03:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A temporary-file creation race can expose private data through an attacker-held handle despite subsequent ACL validation.

6 open issues
What changed in this PR

Updates Canvas credential storage so approved Hub connections can persist across Windows sessions, separate from the broader preview work in #463.

Changes:

  • Adds Windows access-control and storage-path checks while retaining Unix permission checks.
  • Validates temporary files before writing private data.
  • Expands connection-reopening tests and documents Windows storage requirements.
File Description
hub/​server/​routes/​api/​canvas/​extension.db.test.ts Tests reopened connections and renewal.
hub/​docs/​prototype-canvas.md Documents Windows storage requirements.
.github/​extensions/​replica-prototype/​private-store/​index.test.mjs Adds Windows permission-rejection cases.
.github/​extensions/​replica-prototype/​private-store/​index.mts Adds platform-specific storage validation.
.github/​extensions/​replica-prototype/​private-store/​index.mjs Mirrors the storage changes at runtime.
.github/​extensions/​replica-prototype/​create-hub-client/​renewal.test.mjs Checks rotated-token reuse after reopening.
.github/​extensions/​replica-prototype/​assert-windows-store-acl/​index.mts Implements Windows access-control checks.
.github/​extensions/​replica-prototype/​assert-windows-store-acl/​index.mjs Provides the runtime validation module.

Review effort: Max (adaptive)

Comment on lines +26 to +29
if ($ace.SecurityIdentifier.Value -in $trusted) {
if (([int]$ace.AceFlags -band $childInheritance) -eq $childInheritance -and $ace.SecurityIdentifier.Value -eq $user) {
$inheritsPrivateRules = $true
}
Comment on lines +33 to +34
if ($private -or (-not ([int]$ace.AceFlags -band [int][Security.AccessControl.AceFlags]::InheritOnly) -and
($ace.AccessMask -band $unsafeAncestorRights))) { exit $code }
Comment on lines +43 to +45
for ($parent = $directory.Parent; $parent; $parent = $parent.Parent) {
Assert-Acl $parent $false 3
}
Comment on lines +85 to +86
"reads existing private Windows credentials but refuses a file granting Everyone access",
{ skip: !windows },
Comment on lines +88 to +92
const directory = path.join("storage", "replica-extension-tests", randomUUID())
const file = path.join(directory, "credential")
t.after(() => rm(directory, { recursive: true, force: true }))
await mkdir(directory, { recursive: true })
await makeWindowsDirectoryPrivate(directory)
arniebradfo and others added 5 commits December 3, 2026 06:52
Keep the credential reopen and refresh-rotation regression alongside the upstream underscore-login pairing case. Preserve the published branch history for a normal push.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The malformed-record loop can take longer than the synthetic credential lifetime on Windows. Set a fresh expiry for the positive checks without changing the assertions or the renewal behavior.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Windows can return EPERM while a contender opens the lock owner during handoff. Retry only that specific read under the existing deadline, without treating the lock as abandoned. Surface the original error if contention does not clear.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
An expired credential can return no connection before validating its connection ID. Keep the fixture active throughout the invalid-record checks, including under Windows ACL overhead.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
On Windows, validate the parent path before creating a temporary file. Still verify the inherited file ACL before writing. Unix uses the same checks as before.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
directory: string,
file?: { path: string; allowMissing?: boolean },
) {
const systemRoot = process.env.SystemRoot
Resolve PowerShell from the Windows system namespace without trusting the process environment. Accept equivalent trusted inheritance layouts while continuing to reject untrusted access on the resulting credential file.

Cover native ancestor and junction rejection with disposable private fixtures.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
arniebradfo and others added 5 commits December 3, 2026 16:05
Keep the published fail-closed ACL policy while using the OS-installed verifier and a trusted working directory. Document the supported layout and verify unsupported inheritance with disposable fixtures.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use an explicit system-directory PATH so the Windows child does not inherit the parent search path. Assert the real verifier environment with a benign synthetic parent value and retain the strict ACL policy.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants