Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/curvy-dragons-fry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@fluentui-react-native/storybook-desktop': patch
'@fluentui-react-native/storybook-desktop-runtime': patch
---

Separate Storybook bridge and attachment credentials in owner-private storage, validate versioned generated manifests, and pin native helper provenance through the trusted parent handoff before child processes can spawn helpers.

Use helper-selected per-user namespaces on Windows and forward private-storage adapters into platform-neutral CLI contracts. Resolve protected Windows projections through a digest-keyed Metro transformer on the constant workspace stub, avoiding cross-volume file-map paths and public secret copies. Normalize Windows namespace path identities while preserving macOS behavior.
5 changes: 5 additions & 0 deletions .changeset/goofy-corners-create.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@fluentui-react-native/desktop-test': patch
---

Record F6 Storybook manifest provenance, independent credential purposes, and platform qualification evidence in the lifecycle submission ledger.
7 changes: 7 additions & 0 deletions .changeset/tidy-boats-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@fluentui-react-native/desktop-driver': patch
---

Identify the unsafe ancestor when macOS private storage rejects directory aliases, permissions, or ACLs.

Expose the Windows helper's validated storage root so consumers can create protected namespaces beneath its OS-selected per-user location.
3 changes: 3 additions & 0 deletions packages/agentic/desktop-driver/references/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ specifiers, so keep it that way.
- Propagate `AbortSignal` to every host operation.
- Do not release queues or input locks until a timed-out native command settles.
- Preserve attached apps and clean only exact owned resources.
- Callers resolve existing private-storage parent directories before opening them.
macOS storage keeps rejecting symlink ancestors on subsequent operations and
identifies the failing ancestor in ownership/permissions diagnostics.
- Keep native events advisory and queries authoritative.
- Use opaque public window/element IDs and native liveness checks.
- A Storybook preview reset invalidates preview elements, not app chrome or
Expand Down
5 changes: 4 additions & 1 deletion packages/agentic/desktop-driver/references/security.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,10 @@ process recovery, automatic discovery, or supervisor wiring.
`PrivateStorage` contract through the verified Windows helper's one-shot
`--private-storage` mode, so the operating system judges ownership from open
handles and Node never trusts a path check. The default root is a per-user
folder under the local application data folder. An override must be a canonical
folder under the local application data folder, resolved through the OS
known-folder API rather than an environment variable. The returned `root`
identifies that validated directory, allowing consumers to open independently
protected child namespaces without guessing the platform location. An override must be a canonical
absolute local-drive path of at most 240 characters whose parent exists. A
missing root is created atomically with an owner-only protected DACL (one allow
entry giving the current user full control); an existing root is validated and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,16 @@ async function validateRoot(root: string, uid: number): Promise<Stats> {

async function validateAncestors(directory: string, uid: number): Promise<void> {
for (let current = directory; ; current = path.dirname(current)) {
const info = await lstat(current);
const rootOwnedSticky = info.uid === 0 && (info.mode & 0o1000) !== 0;
if (!info.isDirectory() || (info.uid !== uid && info.uid !== 0) || ((info.mode & 0o022) !== 0 && !rootOwnedSticky)) {
throw unsafeStorage();
try {
const info = await lstat(current);
const rootOwnedSticky = info.uid === 0 && (info.mode & 0o1000) !== 0;
if (!info.isDirectory() || (info.uid !== uid && info.uid !== 0) || ((info.mode & 0o022) !== 0 && !rootOwnedSticky)) {
throw unsafeStorage();
}
await rejectACL(current, true);
} catch {
throw unsafeStorage(current);
}
await rejectACL(current, true);
if (current === path.dirname(current)) break;
}
}
Expand Down Expand Up @@ -194,6 +198,11 @@ function hasCode(error: unknown, code: string): boolean {
return typeof error === 'object' && error !== null && 'code' in error && error.code === code;
}

function unsafeStorage(): Error {
return new Error('Desktop Driver private storage is unsafe or inaccessible.');
function unsafeStorage(ancestor?: string): Error {
return new Error(
'Desktop Driver private storage is unsafe or inaccessible.' +
(ancestor === undefined
? ''
: ` Check ancestor "${ancestor}": resolve directory aliases and require owner/root ownership without writable shared permissions or ACL grants.`),
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ macosDescribe('owner-validated macOS private storage', () => {
await mkdir(real, { mode: 0o700 });
await symlink(real, root);
await expect(createMacOSPrivateStorage(root)).rejects.toThrow();
await expect(createMacOSPrivateStorage(path.join(root, 'nested'))).rejects.toThrow();
await expect(createMacOSPrivateStorage(path.join(root, 'nested'))).rejects.toThrow(`Check ancestor "${root}"`);
expect(await readdir(real)).toEqual([]);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import path from 'node:path';

import type { NativeDriverArtifact } from '../native/types';
import { FakeAuthorityHelper } from '../native/windows/fakeAuthorityHelper';
import { createWindowsPrivateStorage } from './windowsPrivateStorage';
Expand Down Expand Up @@ -98,6 +100,22 @@ describe('creating Windows private storage', () => {
expect(requests()).toEqual([{ operation: 'open' }, { identity, name: 'connection.json', operation: 'read', root: defaultRoot }]);
});

test('opens a protected child namespace beneath the root selected by the helper', async () => {
const defaultRoot = 'C:\\Users\\agent\\AppData\\Local\\com.microsoft.fluentui-react-native.desktop-driver';
const childRoot = path.win32.join(defaultRoot, 'storybook-fixture');
helper.answer({ identity, ok: true, root: defaultRoot }).answer({ identity, ok: true, root: childRoot }).answer({ ok: true });

const parent = await createWindowsPrivateStorage({ artifact });
const child = await createWindowsPrivateStorage({ artifact, root: path.win32.join(parent.root, 'storybook-fixture') });
await child.publish('record', 'protected');

expect(requests()).toEqual([
{ operation: 'open' },
{ operation: 'open', root: childRoot },
{ contents: base64('protected'), identity, name: 'record', operation: 'publish', root: childRoot },
]);
});

test('maps a helper refusal to the unsafe-storage failure', async () => {
helper.answer({ detail: 'C:\\Users\\agent\\secret', ok: false, reason: 'dacl' });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ const publicationFailed = (reason: string): Error =>

/**
* Opens the Windows owner-only state root through the Windows helper. The parent must already exist. Existing roots are
* validated, never repaired. Failures carry a fixed message and a non-enumerable `reason` for diagnostics only.
* validated, never repaired. The returned root is the canonical directory validated by the helper, including when the
* helper selected its per-user default. Failures carry a fixed message and a non-enumerable `reason` for diagnostics only.
*/
export async function createWindowsPrivateStorage(options: WindowsPrivateStorageOptions): Promise<PrivateStorage> {
export async function createWindowsPrivateStorage(
options: WindowsPrivateStorageOptions,
): Promise<PrivateStorage & { readonly root: string }> {
if (process.platform !== 'win32') {
throw new Error('Windows private storage is unsupported on this platform; use a validated native ownership adapter.');
}
Expand Down Expand Up @@ -77,6 +80,7 @@ export async function createWindowsPrivateStorage(options: WindowsPrivateStorage
}

return {
root,
async read(name) {
assertPrivateRecordName(name);
const answer = await call({ name, operation: 'read' }, readAnswer, unsafeStorage);
Expand Down
Loading
Loading