openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

Security: Unvalidated session-token-updated window event in CoreStateProvider

Open Liohtml opened this issue 6 months ago • 0 comments

Summary

app/src/providers/CoreStateProvider.tsx — the onSessionTokenUpdated handler accepts a sessionToken from event.detail with no structural validation. Any code with window access (including agent-rendered content) can dispatch this custom event with an arbitrary string that becomes the app's auth token for all subsequent API and socket calls.

Location

app/src/providers/CoreStateProvider.tsx — core-state:session-token-updated event handler

Impact

Medium — Token injection/replacement. An XSS or IPC compromise can replace the legitimate session token with an attacker-controlled value.

Suggested Fix

Validate the token structurally before accepting:

function isPlausibleJwt(token: string): boolean {
  const parts = token.split('.');
  if (parts.length !== 3) return false;
  try {
    const payload = JSON.parse(atob(parts[1]));
    return typeof payload.exp === 'number' && payload.exp * 1000 > Date.now();
  } catch { return false; }
}

Liohtml avatar May 16 '26 14:05 Liohtml