Skip to content

armgit / mso

Public Imported from GitHub
0

Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.

fix: keep credentials out of Composio cache keys

Abdurrahman Fakhrul073819c17f76
diff --git a/app/api/v1/integrations/composio/session/handler.ts b/app/api/v1/integrations/composio/session/handler.ts
index b6f87e95..17c15ccc 100644
--- a/app/api/v1/integrations/composio/session/handler.ts
+++ b/app/api/v1/integrations/composio/session/handler.ts
@@ -16,7 +16,7 @@ async function selection(user: unknown, connection: unknown) {
const selected = selectConnection(state, "composio", { user: identity(user, "user"), connection: identity(connection, "connection") });
if (selected.connection.source !== "direct") throw new IntegrationError("external_source_requires_own_executor", 409);
const backing = resolveSharedConnection(state, selected.user, selected.connection).connection;
- return { user: selected.user, values: backing.values, scope: composioConnectionScope(selected.connection.uid, backing.revision, backing.values) };
+ return { user: selected.user, values: backing.values, cacheable: !backing.uid.startsWith("legacy:"), scope: composioConnectionScope(selected.connection.uid, backing.uid, backing.revision) };
}
export async function handleGetComposioSession(req: NextRequest): Promise<Response> {
@@ -45,6 +45,7 @@ export async function handlePostComposioSession(req: NextRequest): Promise<Respo
values: selected.values,
user: selected.user,
cacheScope: selected.scope,
+ cacheable: selected.cacheable,
refresh: input.refresh === true,
});
void audit({
diff --git a/app/api/v1/integrations/composio/session/route.test.ts b/app/api/v1/integrations/composio/session/route.test.ts
index 795a6f51..f2fa9584 100644
--- a/app/api/v1/integrations/composio/session/route.test.ts
+++ b/app/api/v1/integrations/composio/session/route.test.ts
@@ -103,6 +103,43 @@ describe("POST /api/v1/integrations/composio/session", () => {
expect(vi.mocked(fetch)).toHaveBeenCalledTimes(1);
});
+ it("invalidates a shared session when its backing connection is rotated or replaced", async () => {
+ const file = path.join(root, "infra.json");
+ const state = JSON.parse(await fs.readFile(file, "utf8"));
+ const original = state.users.lara.connections.composio.project;
+ state.users.lara.connections.composio.alias = { ...original, id: "alias", uid: "alias-1", values: {}, sharedFrom: { user: "lara", provider: "composio", connection: "project" } };
+ await fs.writeFile(file, JSON.stringify(state), { mode: 0o600 });
+ const calls: string[] = [];
+ vi.stubGlobal("fetch", vi.fn(async (_url: unknown, init: RequestInit) => {
+ calls.push(String((init.headers as Record<string, string>)["x-api-key"]));
+ return new Response(JSON.stringify({ session_id: `trs_${calls.length}`, mcp: { url: `https://backend.composio.dev/tool_router/v3/trs_${calls.length}/mcp`, headers: { authorization: "session-token" } } }), { status: 201 });
+ }));
+ const alias = { user: "lara", connection: "alias" };
+ expect((await route.POST(request(alias))).status).toBe(200);
+ expect((await route.POST(request(alias))).status).toBe(200);
+ const { saveConnectionValues } = await import("@/lib/infra/connection-service");
+ await saveConnectionValues("composio", { user: "lara", connection: "project" }, { apiKey: "ak_rotated_synthetic" }, { uid: "conn-1", revision: 1 });
+ expect((await route.POST(request(alias))).status).toBe(200);
+ const updated = JSON.parse(await fs.readFile(file, "utf8"));
+ updated.users.lara.connections.composio.project.uid = "replacement-1";
+ updated.users.lara.connections.composio.project.values.apiKey = "ak_replacement_synthetic";
+ await fs.writeFile(file, JSON.stringify(updated), { mode: 0o600 });
+ expect((await route.POST(request(alias))).status).toBe(200);
+ expect(calls).toEqual(["ak_project_synthetic", "ak_rotated_synthetic", "ak_replacement_synthetic"]);
+ const sessions = await fs.readFile(path.join(root, "composio-sessions.json"), "utf8");
+ expect(sessions).not.toContain("ak_project_synthetic");
+ expect(sessions).not.toContain("ak_rotated_synthetic");
+ });
+
+ it("never reads or writes cached sessions for legacy credentials", async () => {
+ await fs.writeFile(path.join(root, "infra.json"), JSON.stringify({ providers: { composio: { apiKey: "ak_legacy_synthetic" } } }), { mode: 0o600 });
+ const legacy = { user: "legacy", connection: "default" };
+ expect((await route.POST(request(legacy))).status).toBe(200);
+ expect((await route.POST(request(legacy))).status).toBe(200);
+ expect(vi.mocked(fetch)).toHaveBeenCalledTimes(2);
+ await expect(fs.access(path.join(root, "composio-sessions.json"))).rejects.toMatchObject({ code: "ENOENT" });
+ });
+
it("never leaks the composed credential when upstream returns no headers", async () => {
vi.stubGlobal("fetch", vi.fn(async () => new Response(JSON.stringify({ session_id: SESSION_ID, mcp: { type: "http", url: MCP_URL } }), { status: 201 })));
const response = await route.POST(request());
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index a1996106..d869612e 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -8,6 +8,7 @@ this is the *what*, and it is what Settings → Account → About shows as “Wh
**Fixed**
+- keep credentials out of Composio cache keys
- preserve window drafts and modal focus
- bind Composio sessions to selected connections
- guard concurrent workflow replacements
diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md
index 5a987163..38aaedc7 100644
--- a/docs/PROGRESS.md
+++ b/docs/PROGRESS.md
@@ -10,6 +10,8 @@ The existing 55-group frontend audit is tracked in [the implementation ledger](e
Settings retains operational input in the existing exact-window memory store, tags sensitive drafts for selective cleanup, preserves nonsecret editor buffers at auth boundaries, orders session probes across logout and blocks navigation during submitted provider writes. Responsive drawers acquire focus on open, including Shortcuts; the actual full Settings remount and five-shell/two-theme focus regressions are wired into mandatory release journeys. Workspace saves acknowledge only the revision saved, video draft baselines come from their load, and Camoufox aborts its current operation on unmount. Workflow source copy/restore share the action lock and preserve newer edits. Composio uses an authorized explicit owner/connection and a credential-revision-bound cache; frame fallback says readiness is unknown instead of inferring success from load.
+Composio session cache identity uses selected and backing connection UIDs plus the backing revision, without hashing credentials. Legacy projected connections bypass cache reads and writes because their identity and revision are not durable. Focused route tests cover rotation and shared-backing replacement.
+
Focused unit and mounted synthetic component checks passed during implementation. External headless fixtures cover selected five-shell/two-theme/320–844 samples with a prior CSS build; they are not exact-SHA release proof. Full local, pinned scanner and remote results must be recorded for the final commit before merge readiness; real devices, assistive technology and upstream vendor behavior remain explicit limits. No production deployment, host data or tunnel was changed.
## 2026-11-03: frontend contract for every feature and agent
diff --git a/docs/evidence/2026-11-04-final-surfaces.md b/docs/evidence/2026-11-04-final-surfaces.md
index 8cb5b13b..9f870bde 100644
--- a/docs/evidence/2026-11-04-final-surfaces.md
+++ b/docs/evidence/2026-11-04-final-surfaces.md
@@ -8,7 +8,7 @@ No production provider, credential, installation, or external frame was used.
|---|---|---|
| PX-01 | Infrastructure superseded reads are aborted. | Prior candidate source; reversed delayed project and zone responses have not been rerun after the fix. |
| PX-02 | Loading, empty, failure, stale and refresh affordances are distinct. | Prior candidate source; 403, retry and provider-switch journeys remain unverified. |
-| PX-03 | Same-origin, source-checked manager owner message; explicit named connection in panel; owner-only server validation; session cache scoped to connection UID, backing revision and credential digest. Selection changes clear results and abort requests. | Synthetic route tests exercise two owners, two keys, reuse, rotation and wrong-owner connection rejection; 38 focused tests pass. Browser owner-switch, out-of-order UI requests and manager-to-panel handshake remain unverified. No upstream call is made in tests. |
+| PX-03 | Same-origin, source-checked manager owner message; explicit named connection in panel; owner-only server validation; session cache scoped to selected and backing connection UIDs and backing revision. Legacy projected credentials bypass cache reads and writes. Selection changes clear results and abort requests. | Synthetic route tests exercise two owners, reuse, credential rotation, replacement of shared backing, legacy bypass and wrong-owner rejection. Browser owner-switch, out-of-order UI requests and manager-to-panel handshake remain unverified. No upstream call is made in tests. |
| PX-04 | Create App fields have associated labels. | Prior candidate source; label click and multiple-window browser checks remain unverified. |
| PX-05 | Accent swatches wrap and expose selection. | Prior candidate source; coarse 320/390 and 200% text checks remain unverified. |
| PX-06 | Nonsecret drafts are scoped to window with discard guards. | Prior candidate source; remount, two windows and cancelled discard remain unverified. |
diff --git a/lib/infra/composio-session.ts b/lib/infra/composio-session.ts
index 50047cea..8a538b06 100644
--- a/lib/infra/composio-session.ts
+++ b/lib/infra/composio-session.ts
@@ -91,6 +91,7 @@ export async function composioSessionForUser(input: {
user?: string;
refresh?: boolean;
cacheScope?: string;
+ cacheable?: boolean;
toolkits?: string[];
authConfigs?: Record<string, string>;
fetchImpl?: (value: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
@@ -100,7 +101,7 @@ export async function composioSessionForUser(input: {
const profile = state.users[user];
if (!profile) throw new IntegrationError("user_not_found", 404);
const instanceId = state.instanceId, userUid = profile.uid;
- if (!input.refresh) {
+ if (input.cacheable !== false && !input.refresh) {
const stored = await readComposioSession(instanceId, userUid, input.cacheScope);
if (stored) return { sessionId: stored.sessionId, mcpUrl: stored.mcpUrl, mcpHeaders: stored.mcpHeaders, ...(stored.expiresAt !== undefined ? { expiresAt: stored.expiresAt } : {}), reused: true, user };
}
@@ -112,15 +113,17 @@ export async function composioSessionForUser(input: {
fetchImpl: input.fetchImpl,
});
const key = storeKey(instanceId, userUid) + (input.cacheScope ? `:${input.cacheScope}` : "");
- await withSecurityStoreLock(composioSessionStorePath(), async () => {
- const store = await readComposioSessions();
- store.sessions[key] = { ...created, instanceId, userUid, createdAt: Date.now() };
- await writeComposioSessions(store);
- });
+ if (input.cacheable !== false) {
+ await withSecurityStoreLock(composioSessionStorePath(), async () => {
+ const store = await readComposioSessions();
+ store.sessions[key] = { ...created, instanceId, userUid, createdAt: Date.now() };
+ await writeComposioSessions(store);
+ });
+ }
return { ...created, reused: false, user };
}
/** Bind a cached session to the exact connection and credential revision. */
-export function composioConnectionScope(uid: string, revision: number, values: InfraProviderValues): string {
- return createHash("sha256").update(JSON.stringify([uid, revision, values.apiKey ?? "", values.orgApiKey ?? ""])).digest("hex");
+export function composioConnectionScope(uid: string, backingUid: string, revision: number): string {
+ return createHash("sha256").update(JSON.stringify([uid, backingUid, revision])).digest("hex");
}