Summary
The viewer stores the AGENTMEMORY_SECRET bearer token in sessionStorage instead of localStorage. Since sessionStorage is per-tab and cleared when the tab closes, users must re-enter the token every time they open a new tab or restart their browser.
Affected code
src/viewer/index.html (around line 1207–1212 on v0.9.27):
var VIEWER_TOKEN_STORAGE_KEY = 'agentmemory-viewer-token';
// Read
try { return sessionStorage.getItem(VIEWER_TOKEN_STORAGE_KEY) || ''; } catch (_) { return ''; }
// Write
if (token) sessionStorage.setItem(VIEWER_TOKEN_STORAGE_KEY, token);
else sessionStorage.removeItem(VIEWER_TOKEN_STORAGE_KEY);
Notably, the theme preference already uses localStorage (line 1070):
localStorage.setItem('agentmemory-theme', dark ? 'dark' : 'light');
So the less-sensitive setting persists, but the auth token does not.
Impact
Suggested fix
Use localStorage instead of sessionStorage for the token. If there are XSS concerns with localStorage, consider:
- A "Remember token" checkbox (default off = sessionStorage, on = localStorage)
- Token expiry (clear after N hours)
- The existing nonce-based CSP (
script-src 'nonce-XXX') already provides strong XSS protection, making localStorage reasonably safe
Workaround
Local patch (entrypoint sed):
sed -i 's|sessionStorage.getItem(VIEWER_TOKEN|localStorage.getItem(VIEWER_TOKEN|g' viewer/index.html
sed -i 's|sessionStorage.setItem(VIEWER_TOKEN|localStorage.setItem(VIEWER_TOKEN|g' viewer/index.html
sed -i 's|sessionStorage.removeItem(VIEWER_TOKEN|localStorage.removeItem(VIEWER_TOKEN|g' viewer/index.html
Tested on v0.9.27.
Summary
The viewer stores the
AGENTMEMORY_SECRETbearer token insessionStorageinstead oflocalStorage. SincesessionStorageis per-tab and cleared when the tab closes, users must re-enter the token every time they open a new tab or restart their browser.Affected code
src/viewer/index.html(around line 1207–1212 on v0.9.27):Notably, the theme preference already uses
localStorage(line 1070):So the less-sensitive setting persists, but the auth token does not.
Impact
Suggested fix
Use
localStorageinstead ofsessionStoragefor the token. If there are XSS concerns withlocalStorage, consider:script-src 'nonce-XXX') already provides strong XSS protection, makinglocalStoragereasonably safeWorkaround
Local patch (entrypoint sed):
Tested on v0.9.27.