Repository navigation
fix(canvas): persist Hub credentials on Windows - #496
Open
arniebradfo wants to merge 12 commits into
Open
arniebradfo wants to merge 12 commits into
arniebradfo wants to merge 12 commits into
Conversation
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>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A temporary-file creation race can expose private data through an attacker-held handle despite subsequent ACL validation.
6 open issues
Create temporary files with restrictive ACLs before validation · New Accept trusted inheritable ACL entries without requiring one layout · New Allow inherit-only CREATOR OWNER entries on private directories · New Test Windows ancestor, junction, ownership, and drive access boundaries · New Add Windows CI coverage for private-store and Hub persistence tests · New Move Windows fixtures under a known-private temporary root · New
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) |
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>
weastler
approved these changes
Dec 3, 2026
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


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.