Home

mweinbach / agent-coworker

publicmweinbach/agent-coworker
Overview Code History Branches Pull requestsIssuesInsights
main
HomeOverview Code PRsIssues

fix: comprehensive security & correctness remediation from 20-domain audit

5 months ago

a6c1996
Authored
mweinbach5/20/2026, 1:42:39 AM
Phase 1 — Security (11 CRITICALs fixed):
- fix(xss): escape OAuth failure HTML message param (oauth-server.ts)
- fix(xss): apply escapeHtml/escapeMarkdownUrl to citation markers
- fix(xss): switch DOMPurify FORBID_ATTR to ALLOWED_ATTR allowlist
- fix(security): remove yolo:true hardcode in buildFallbackWorkspace & normalizeState
- fix(security): validate approval/ask responses via Zod in transportAdapter
- fix(security): set maxPayloadLength 4MB on WebSocket server
- fix(security): validate config paths stay inside workspace via isPathInside
- fix(security): sanitize ANSI escape sequences in CLI terminal output
- fix(security): isolate session tokens into per-device Secure Store keys
- fix(security): zero sharedKey Uint8Array before nulling in resetSecureChannel

Phase 2 — Correctness (10 items fixed, 1 false positive):
- fix(agent): replace micro-tick stream settlement with direct await + timeout
- fix(runtime): codexPayloadThreadId -> codexPayloadTurnId in usage handler
- fix(tools): add .catch(reject) to bash.ts promise chain
- fix(runtime): fix operator precedence in error message fallback
- fix(runtime): always resolve finalResult promise in openaiEventStream.end()
- fix(cli): use nextSocket instead of stale socket ref in onServerRequest
- fix(cli): add .catch on microtask line buffer promise
- fix(cli): reset disconnectNotified at start of connectToServer
- fix(client): wrap enqueueNotification throw in notify() with try/catch
- fix(mobile): remove scaffold assistant response from submitComposer
- fix(mobile): replace Date.now() thread IDs with crypto.randomUUID()
- fix(mobile): add console.warn in jsonRpcClient silent catch blocks

Tests: 26+ new tests added (terminal sanitizer, path traversal, config)
Audit: 20 parallel subagents audited 250+ files across 20 domains

Parent4967616

136 files changed
  • apps/desktop/electron/ipc.ts+6−1
  • apps/desktop/electron/ipc/files.ts+3−1
  • apps/desktop/electron/main.ts+68−49
  • apps/desktop/electron/services/persistence.ts+1−1
  • apps/desktop/src/app/store.actions/bootstrap.ts+2−2
  • apps/desktop/src/app/store.actions/workspaceDefaults.ts+6−4
  • apps/desktop/src/app/store.helpers.ts+1−1
  • apps/desktop/src/app/store.helpers/controlSocket.ts
+1
−1
  • apps/desktop/src/app/store.helpers/jsonRpcSocket.ts+0−1
  • apps/desktop/src/app/store.helpers/threadEventReducer.ts+1−3
  • apps/desktop/src/app/store.ts+40−0
  • apps/desktop/src/components/ui/checkbox.tsx+4−3
  • apps/desktop/src/lib/desktopSchemas.ts+1−1
  • apps/desktop/src/lib/filePreviewKind.ts+3−1
  • apps/desktop/src/ui/Canvas.tsx+1−5
  • apps/desktop/src/ui/ChatView.tsx+104−66
  • apps/desktop/src/ui/FilePreviewModal.tsx+23−7
  • apps/desktop/src/ui/PptxPreview.tsx+10−9
  • apps/desktop/src/ui/SlidePreview.tsx+7−6
  • apps/desktop/src/ui/menuBar/MenuBarUtilityShell.tsx+6−6
  • apps/desktop/src/ui/onboarding/DesktopOnboarding.tsx+9−1
  • apps/desktop/src/ui/quickChat/QuickChatShell.tsx+3−3
  • apps/desktop/src/ui/settings/pages/BackupPage.tsx+3−7
  • apps/desktop/src/ui/settings/pages/RemoteAccessPage.tsx+1−1
  • apps/desktop/src/ui/settings/pages/UsagePage.tsx+2−2
  • apps/desktop/src/ui/settings/pages/WorkspacesPage.tsx+3−8
  • apps/desktop/test/desktop-schemas.test.ts+2−2
  • apps/desktop/test/file-preview-modal.test.tsx+1−1
  • apps/desktop/test/filePreviewKind.test.ts+0−1
  • apps/desktop/test/helpers/mockElectron.ts+17−0
  • apps/desktop/test/ipc-files.test.ts+110−1
  • apps/desktop/test/jsdomHarness.ts+19−0
  • apps/desktop/test/message-bar-resizer.test.tsx+18−10
  • apps/desktop/test/persistence-state-sanitization.test.ts+42−0
  • apps/desktop/test/providers-page.test.ts+21−12
  • apps/desktop/test/server-manager.test.ts+0−1
  • apps/desktop/test/spreadsheet-preview.test.tsx+20−10
  • apps/desktop/test/workspace-settings-sync.test.ts+30−3
  • apps/desktop/test/workspace-startup.test.ts+1−1
  • apps/mobile/app.json+1−8
  • apps/mobile/bun.lock+98−15
  • apps/mobile/metro.config.js+7−1
  • apps/mobile/modules/cowork-pinned-https/android/build.gradle+15−0
  • apps/mobile/modules/cowork-pinned-https/android/src/main/AndroidManifest.xml+2−0
  • apps/mobile/modules/remodex-secure-transport/src/index.ts+4−1
  • apps/mobile/package.json+11−1
  • apps/mobile/postcss.config.mjs+5−0
  • apps/mobile/src/app/(app)/thread/[id].tsx+36−2
  • apps/mobile/src/app/_layout.tsx+2−0
  • apps/mobile/src/components/ui/app-button.tsx+15−35
  • apps/mobile/src/components/ui/screen.tsx+9−13
  • apps/mobile/src/components/ui/section-card.tsx+9−43
  • apps/mobile/src/features/cowork/backupStore.ts+3−0
  • apps/mobile/src/features/cowork/jsonRpcClient.ts+8−4
  • apps/mobile/src/features/cowork/mcpStore.ts+4−0
  • apps/mobile/src/features/cowork/memoryStore.ts+2−0
  • apps/mobile/src/features/cowork/offlineCache.ts+147−0
  • apps/mobile/src/features/cowork/providerStore.ts+6−1
  • apps/mobile/src/features/cowork/skillsStore.ts+8−0
  • apps/mobile/src/features/cowork/snapshotReducer.ts+4−1
  • apps/mobile/src/features/cowork/threadStore.ts+196−21
  • apps/mobile/src/features/cowork/useWorkspaceConfigQuery.ts+233−0
  • apps/mobile/src/features/cowork/workspaceBootstrap.ts+15−3
  • apps/mobile/src/features/cowork/workspaceStore.ts+14−1
  • apps/mobile/src/features/relay/secureTransportClient.ts+33−4
  • apps/mobile/src/global.css+195−0
  • apps/mobile/src/providers/MobileAppProvider.tsx+12−6
  • apps/mobile/src/tw/animated.tsx+7−0
  • apps/mobile/src/tw/image.tsx+31−0
  • apps/mobile/src/tw/index.tsx+99−0
  • src/agent.ts+49−37
  • src/auth/oauth-server.ts+10−1
  • src/cli/args.ts+17−0
  • src/cli/parser.ts+8−2
  • src/cli/repl.ts+6−1
  • src/cli/repl/authPrompts.ts+34−2
  • src/cli/repl/commandRouter.ts+15−12
  • src/cli/repl/promptController.ts+8−5
  • src/cli/repl/sanitizeTerminal.ts+44−0
  • src/cli/repl/serverEventHandler.ts+13−6
  • src/cli/repl/stateStore.ts+3−2
  • src/client/jsonRpcSocket.ts+6−2
  • src/config.ts+9−2
  • src/connect.ts+9−1
  • src/index.ts+6−1
  • src/mcp/index.ts+96−0
  • src/models/registry.ts+1−1
  • src/observability/otel.ts+8−5
  • src/observability/runtime.ts+4−0
  • src/providers/codexAppServerAuth.ts+41−20
  • src/runtime/codexAppServerRuntime.ts+211−101
  • src/runtime/openaiEventStream.ts+1−3
  • src/runtime/openaiResponsesProjector.ts+1−1
  • src/server/index.ts+7−2
  • src/server/jsonrpc/routes/session.ts+110−44
  • src/server/jsonrpc/routes/workspace.ts+1−2
  • src/server/jsonrpc/routes/workspaceBackups.ts+83−35
  • src/server/jsonrpc/schema.workspace.ts+0−1
  • src/server/jsonrpc/threadReadProjector.ts+0−4
  • src/server/jsonrpc/transportAdapter.ts+48−12
  • src/server/presentationPreview.ts+12−9
  • src/server/projection/conversationProjection.ts+0−2
  • src/server/runtime/ServerRuntime.ts+6−0
  • src/server/session/AgentSession.ts+14−0
  • src/server/session/McpManager.ts+4−0
  • src/server/session/TurnExecutionManager.ts+1−0
  • src/server/session/mcp/McpAuthFlow.ts+7−0
  • src/server/startServer.ts+1−0
  • src/server/webDesktopService.ts+2−2
  • src/session/pricing.ts+13−0
  • src/shared/displayCitationMarkers.ts+10−2
  • src/shared/googleThinking.ts+5−1
  • src/shared/projectedItems.ts+1−3
  • src/tools/bash.ts+2−2
  • test/a2ui/upsertFeedItem.test.ts+5−2
  • test/agent.test.ts+4−2
  • test/bun-test-setup.ts+30−0
  • test/cli-args.test.ts+42−0
  • test/cli-entrypoint.test.ts+54−0
  • test/cli-sanitize-terminal.test.ts+84−0
  • test/config.test.ts+83−6
  • test/connect.test.ts+5−1
  • test/helpers/mock-react-native.ts+35−0
  • test/jsonrpc.workspace-route.test.ts+0−1
  • test/mcp.cache.test.ts+159−0
  • test/mobile.thread-detail.test.tsx+249−0
  • test/mobile.thread-store.test.ts+208−43
  • test/mobileOfflineCache.test.ts+47−0
  • test/observability.otel.test.ts+55−1
  • test/presentationPreview.test.ts+8−5
  • test/providers/codex-app-server-auth.test.ts+47−0
  • test/repl.restart-failure.test.ts+2−0
  • test/repl.test.ts+130−0
  • test/session.test.ts+34−0
  • test/session/pricing.test.ts+22−1
  • test/webDesktopRoutes.test.ts+3−3