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
3 changes: 3 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,9 @@ during the wait.
and instruction roots. Reads and watches share explicit-root authorization;
session references grant reads only, not listing or writes. Credential exclusions
apply to canonical targets too.
Credential ownership checks resolve configured symlinks even when the final target is missing, without collapsing native `link/..` traversal. Profile config roots visible in a requested or canonical path remain protected when `profiles/` cannot be listed. Compare inode identities through original configured paths, not only potentially lossy string realpaths.
Record failures inspecting requested paths separately from owned credential directories and files. Known-secret matches remain denied first. Otherwise, a requested metadata failure terminates that operation with 404 `file_not_found`, even if a later lookup would succeed; never continue with an unclassified path. If the request metadata is sound but ownership metadata is unavailable, return 503 `credential_policy_unavailable` until it is accessible. Missing paths remain ordinary absence. Never change user filesystem permissions automatically.
Read owned directory entries and unresolved symlink targets as bytes: an undecodable protected filename, profile or target makes ownership metadata unavailable, while unrelated byte-named assets do not. For missing macOS targets, account for Unicode normalization and calibrate case aliases through existing directory metadata without creating files or crossing filesystem devices. This is not a portable filesystem-equivalence guarantee: prospective aliases on Linux casefold mounts and legacy HFS+ ignorable-character rules lack native coverage.
- Successful selection, default cwd and worktree operations grant roots on the
owning daemon. Browsing alone grants nothing. Main's `getAllowedFileRoots()`
remains for the unrelated local config/import/skills readers, not workspace APIs.
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ All notable changes to **omp-web** (`@kahme247/ompweb`) are documented in this f
### Fixes & Improvements

- **Windows host updates allow more time for safety checks.** The process inventory gets up to 20 seconds to start and finish on a busy machine, instead of five. Shared installations and failed or unreadable inventories still block the update before the daemon is stopped.
- **Credential copies and config `.env` files stay private without blocking independent uploads.** The file viewer and upload preflight/overwrite deny editor swaps and backups such as `.agent.db.swp`, `agent.db~`, `.models.yml.swp` and `models.yml-backup` only directly in omp's actual agent directories (including profiles). `.env` and `.env.*` are also denied at genuine default/profile config roots and agent directories, including their symlinked real targets. Same-named session uploads, workspace files and package assets remain readable and replaceable.
These checks run on the file's owning host, including remote hosts. An upload batch containing a protected target is refused before any file in that batch is published, and publication rechecks each target before replacing it.
Profile `.env` files stay private even when the profiles directory cannot be listed. If credential ownership metadata is unreadable, the file service returns 503 rather than guessing that an off-tree alias is safe; restore the daemon user's access to that metadata to resume ordinary file access. Uploads also refuse credential targets behind dangling, relative or chained configured symlinks, without creating the missing credential file.
Ownership checks also retain native file identities when POSIX filenames cannot be decoded as UTF-8. On macOS, missing credential targets remain protected through filesystem case aliases, without creating calibration files.
A failed lookup of the requested path stops that request, even if the filesystem recovers immediately afterward. It cannot fall through to a later successful read of credential bytes.
- **Table charts show every numeric column at once.** Columns that share a unit are drawn as grouped bars with a legend, instead of one column at a time behind a selector, and columns with different units each get their own chart in the same panel. Rows are labelled with the first descriptive column, so an index column such as `#` is no longer used as the label or charted. Values that start with `about`, `approx.`, `approximately`, `around` or `roughly` are read as estimates instead of making the column unchartable. The axis labels now line up with the bars, and the SVG export contains all of the charts.
Charts remain readable on browsers without CSS subgrid. Tables with more than five same-unit measures are split into additional charts so no legend repeats a colour.
- **Finished background tool calls no longer show up as running.** A `bash` or `task` call that omp moved to the background kept reporting progress after it returned, and ompweb counted each report as a running tool. Opening the chat mid-run then listed those long-finished calls as empty running rows below the transcript until the next event, and an open chat could briefly show a finished call as running again. Calls that returned before an ompweb server restart can still show this once.
Expand All @@ -44,6 +49,8 @@ All notable changes to **omp-web** (`@kahme247/ompweb`) are documented in this f
- **Explorer confinement upgrades without changing older daemon contracts.** The original boolean `listFiles` operation remains available to older web servers. The Explorer uses the separately advertised `listFilesInRoot` capability; a daemon without it returns an explicit upgrade-required response rather than an unconfined listing.
- **Reconnecting uploads no longer leave Send blocked by a hanging retry.** The five-minute deadline stops an in-flight retry as well as its back-off, keeping staged bytes for Retry. A connection lost midway through an HTTP response resumes automatically, and tooltips identify network failures instead of showing only “Upload failed”.
- **Files named `agent.db` or `models.yml` open again unless they are omp's own.** The file viewer refused those names anywhere under `~/.omp`, so an uploaded `agent.db` could not be opened from its link. It now refuses only the files omp keeps in its agent directory (and a profile's), with their SQLite sidecars, backups and `models.yaml`/`models.json`. Both symlinked agent directories and individually symlinked credential files keep their real targets protected, including targets with different names; unrelated uploaded copies still open.
Hard-linked aliases of those owned secrets are denied too, by comparing device and inode identity. Independent copies still open, even with identical contents, and upload preflight and overwrite cannot modify a credential through an alias.
On Windows, alternate data streams attached to protected files are denied too, including aliases and attempts to create a new stream. Independent streams remain available, and literal colon-named files on POSIX keep their ordinary meaning.
- **Uploads no longer leave submitted messages or restored pages stuck.** A slow attachment copy keeps its session alive even after you switch chats. Commands that change Advisor wait until that preparation is dispatched before they may replace the session's child. Returning through browser Back/Forward shows Retry for an interrupted upload instead of leaving Send permanently blocked.
- **Attachment retries no longer accept missing files or stale upload errors.** An attachment removed or replaced by a directory is reported as missing before it is marked complete. Failed receipt writes leave the staged file available to retry without creating a duplicate, and cancellation cannot be undone by an attachment still finishing. Replies from earlier upload attempts no longer fail a newer Retry. Retrying also waits for failed-write cleanup, so an old attempt cannot delete the new attempt's staged files.
- **A conflicting upload start no longer interrupts the original file.** Reusing an upload ID with another filename or MIME type is rejected before changing the active transfer, so the original upload continues normally.
Expand Down
2 changes: 1 addition & 1 deletion graphify-out/graph.json

Large diffs are not rendered by default.

186 changes: 186 additions & 0 deletions lib/file-access.native-identity.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
import assert from "node:assert/strict";
import { spawnSync } from "node:child_process";
import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import test from "node:test";
import { jitiPath, nodeBinary, repo } from "./hosts/update-fixture.test-helper.mjs";

// Run real Node: string realpaths and directory entries can lose POSIX byte names.
const CHILD = `
const assert = require("node:assert/strict");
const fs = require("node:fs");
const path = require("node:path");
const f = JSON.parse(process.env.FIXTURE);
const agent = path.join(f.root, "agent");
const workspace = path.join(f.root, "workspace");
fs.mkdirSync(agent); fs.mkdirSync(workspace);
const byteName = Buffer.concat([Buffer.from(f.backup ? agent + "/agent.db.bak-" : workspace + "/vault-"), Buffer.from([0xff]), Buffer.from(".sqlite")]);
const target = f.dangling ? Buffer.concat([byteName, Buffer.from("/link")]) : byteName;
try {
if (f.dangling) { fs.mkdirSync(byteName); fs.symlinkSync(path.join(workspace, "ordinary.sqlite"), target); }
else fs.writeFileSync(target, "private fixture bytes\\n");
}
catch (error) {
if (error.code === "EILSEQ" || error.code === "EINVAL") { console.log(JSON.stringify({ unsupported: error.code })); process.exit(0); }
throw error;
}
const configured = path.join(agent, "agent.db");
const alias = path.join(workspace, "ordinary.sqlite");
if (!f.backup) fs.symlinkSync(target, configured);
if (!f.dangling) {
fs.linkSync(target, alias);
assert.equal(fs.statSync(f.backup ? target : configured).ino, fs.statSync(alias).ino);
assert.equal(fs.readFileSync(f.backup ? target : configured, "utf8"), "private fixture bytes\\n");
}
const jiti = require(f.jiti).createJiti(path.join(f.repo, "package.json"), { tsconfigPaths: true });
(async () => {
const { isOmpSecretFile } = await jiti.import(path.join(f.repo, "lib/file-access.ts"));
const { authorizeFileAccess } = await jiti.import(path.join(f.repo, "lib/file-authorization.ts"));
const measure = async file => {
try {
const decision = await authorizeFileAccess([file], null, false, new Set([workspace]));
return { secret: isOmpSecretFile(file), ok: decision.ok, status: decision.ok ? 200 : decision.status };
} catch (error) {
if (typeof error.status !== "number" || typeof error.code !== "string") throw error;
return { ok: false, status: error.status, code: error.code };
}
};
if (!f.backup) { console.log(JSON.stringify(await measure(alias))); return; }
const unrelated = Buffer.concat([Buffer.from(agent + "/asset-"), Buffer.from([0xff]), Buffer.from(".bin")]);
const control = path.join(workspace, "asset-link.bin");
fs.writeFileSync(unrelated, "independent bytes\\n"); fs.linkSync(unrelated, control);
const before = await measure(alias);
fs.renameSync(target, path.join(agent, "agent.db.bak-saved"));
console.log(JSON.stringify({ before, after: await measure(alias), control: await measure(control) }));
})().catch(error => { console.error(error); process.exit(1); });
`;

function probe(t, backup = false, dangling = false) {
const root = mkdtempSync(join(tmpdir(), "omp-native-credential-"));
t.after(() => rmSync(root, { recursive: true, force: true }));
const child = spawnSync(nodeBinary(), ["-e", CHILD], {
cwd: repo, encoding: "utf8", timeout: 30_000,
env: { ...process.env, HOME: root, PI_CONFIG_DIR: ".omp", PI_CODING_AGENT_DIR: join(root, "agent"), XDG_DATA_HOME: "",
FIXTURE: JSON.stringify({ root, jiti: jitiPath, repo, backup, dangling }) },
});
assert.equal(child.status, 0, `Node exited ${child.status}: ${child.stderr}\n${child.stdout}`);
const result = JSON.parse(child.stdout.trim().split("\n").pop());
if (result.unsupported) { t.skip(`Filesystem rejects non-UTF-8 filenames (${result.unsupported})`); return null; }
return result;
}

test("a credential target's byte filename cannot hide its readable hardlink identity", { skip: process.platform !== "linux" }, (t) => {
const result = probe(t);
if (result) assert.deepEqual(result, { secret: true, ok: false, status: 403 });
});

test("undecodable owned copies fail closed without banning unrelated byte filenames", { skip: process.platform !== "linux" }, (t) => {
const result = probe(t, true);
if (!result) return;
assert.deepEqual(result.before, { ok: false, status: 503, code: "credential_policy_unavailable" });
assert.deepEqual(result.after, { secret: true, ok: false, status: 403 });
assert.deepEqual(result.control, { secret: false, ok: true, status: 200 });
});

test("undecodable dangling symlink hops cannot hide a prospective credential target", { skip: process.platform !== "linux" }, (t) => {
const result = probe(t, false, true);
if (result) assert.deepEqual(result, { ok: false, status: 503, code: "credential_policy_unavailable" });
});

test("missing configured credential targets respect native filesystem case aliases", { skip: process.platform === "win32" }, (t) => {
const root = mkdtempSync(join(tmpdir(), "omp-native-case-"));
t.after(() => rmSync(root, { recursive: true, force: true }));
const child = spawnSync(nodeBinary(), ["-e", `
const fs = require("node:fs"), path = require("node:path"), assert = require("node:assert/strict");
const f = JSON.parse(process.env.FIXTURE);
const agent = path.join(f.root, "agent"), workspace = path.join(f.root, "workspace");
fs.mkdirSync(agent); fs.mkdirSync(workspace);
fs.writeFileSync(path.join(workspace, "CaseProbe"), "fixture");
const insensitive = fs.existsSync(path.join(workspace, "caseprobe"));
const target = path.join(workspace, "Vault.SQLITE");
fs.symlinkSync(target, path.join(agent, "agent.db"));
const jiti = require(f.jiti).createJiti(path.join(f.repo, "package.json"), { tsconfigPaths: true });
(async () => {
const { isOmpSecretFile } = await jiti.import(path.join(f.repo, "lib/file-access.ts"));
if (process.platform === "linux") Object.defineProperty(process, "platform", { value: "darwin" });
assert.equal(isOmpSecretFile(target), true);
assert.equal(isOmpSecretFile(path.join(workspace, "vault.sqlite")), insensitive);
assert.equal(isOmpSecretFile(path.join(workspace, "independent.sqlite")), false);
assert.equal(fs.existsSync(target), false, "classification must not create the credential");
const calibration = path.join(workspace, "calibration");
fs.mkdirSync(calibration);
for (const [owned, alias] of [["Straße", "STRASSE"], ["STRAẞE", "STRASSE"], ["ϴ", "θ"], ["Σ", "ς"], ["Café", "Cafe\\u0301"]]) {
fs.writeFileSync(path.join(calibration, owned), "independent fixture");
const nativeAlias = fs.existsSync(path.join(calibration, alias));
fs.unlinkSync(path.join(agent, "agent.db"));
const missing = path.join(workspace, owned);
fs.symlinkSync(missing, path.join(agent, "agent.db"));
const denied = isOmpSecretFile(path.join(workspace, alias));
if (nativeAlias || owned === "Café") assert.equal(denied, true, owned);
assert.equal(fs.existsSync(missing), false);
}
console.log(JSON.stringify({ insensitive }));
})().catch(error => { console.error(error); process.exitCode = 1; });
`], {
cwd: repo, encoding: "utf8", timeout: 30_000,
env: { ...process.env, HOME: root, PI_CONFIG_DIR: ".omp", PI_CODING_AGENT_DIR: join(root, "agent"), XDG_DATA_HOME: "",
FIXTURE: JSON.stringify({ root, jiti: jitiPath, repo }) },
});
assert.equal(child.status, 0, `Node exited ${child.status}: ${child.stderr}\n${child.stdout}`);
});

for (const kind of ["resolution", "identity"]) {
test(`a transient request ${kind} failure cannot authorize credential bytes on a later successful lookup`,
{ skip: kind === "resolution" && process.platform === "win32" }, (t) => {
const root = mkdtempSync(join(tmpdir(), "omp-request-metadata-"));
t.after(() => rmSync(root, { recursive: true, force: true }));
const child = spawnSync(nodeBinary(), ["-e", `
const fs = require("node:fs"), path = require("node:path"), assert = require("node:assert/strict");
const { syncBuiltinESMExports } = require("node:module");
const f = JSON.parse(process.env.FIXTURE);
const agent = path.join(f.root, "agent"), workspace = path.join(f.root, "workspace");
fs.mkdirSync(agent); fs.mkdirSync(workspace);
const secret = path.join(agent, "agent.db"), alias = path.join(workspace, "ordinary.bin");
fs.writeFileSync(secret, "private fixture bytes");
if (f.kind === "resolution") fs.symlinkSync(secret, alias);
else fs.linkSync(secret, alias);
const jiti = require(f.jiti).createJiti(path.join(f.repo, "package.json"), { tsconfigPaths: true });
(async () => {
const { authorizeFileAccess } = await jiti.import(path.join(f.repo, "lib/file-authorization.ts"));
const native = fs.realpathSync.native, stat = fs.statSync;
let injected = false;
const aliasKey = path.normalize(alias);
const fault = (file) => {
// The read gate also uses forward slashes on Windows.
if (typeof file !== "string" || path.normalize(file) !== aliasKey || injected) return;
injected = true;
throw Object.assign(new Error("transient metadata failure"), { code: "EIO" });
};
if (f.kind === "resolution") fs.realpathSync.native = (file, ...args) => { fault(file); return native(file, ...args); };
else fs.statSync = (file, ...args) => { fault(file); return stat(file, ...args); };
syncBuiltinESMExports();
let result;
try {
const decision = await authorizeFileAccess([alias], null, false, new Set([workspace, agent]));
result = decision.ok ? { status: 200, bytes: fs.readFileSync(decision.filePath, "utf8") } : { status: decision.status, code: decision.code };
} catch (error) {
if (typeof error.status !== "number" || typeof error.code !== "string") throw error;
result = { status: error.status, code: error.code };
} finally {
fs.realpathSync.native = native; fs.statSync = stat; syncBuiltinESMExports();
}
assert.equal(injected, true, "the request metadata failure must be exercised");
const recovered = await authorizeFileAccess([alias], null, false, new Set([workspace, agent]));
assert.equal(recovered.ok, false, "a later healthy lookup must still deny the credential");
console.log(JSON.stringify({ failed: result, recovered: recovered.status }));
})().catch(error => { console.error(error); process.exitCode = 1; });
`], {
cwd: repo, encoding: "utf8", timeout: 30_000,
env: { ...process.env, HOME: root, PI_CONFIG_DIR: ".omp", PI_CODING_AGENT_DIR: join(root, "agent"), XDG_DATA_HOME: "",
FIXTURE: JSON.stringify({ root, jiti: jitiPath, repo, kind }) },
});
assert.equal(child.status, 0, `Node exited ${child.status}: ${child.stderr}\n${child.stdout}`);
assert.deepEqual(JSON.parse(child.stdout.trim().split("\n").pop()), { failed: { status: 404, code: "file_not_found" }, recovered: 403 });
});
}
Loading
Loading