auth: validate URL-supplied token before persisting + tighten guards to require populated user #36
Labels
No labels
app:activities
app:chat
app:events
app:forum
app:libra
app:market
app:restaurant
app:tasks
app:wallet
app:webapp
bug
enhancement
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
aiolabs/webapp#36
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Pre-#11 auth hardening that closes a concrete access-control gap discovered when an unauthenticated tester reached
/market/dashboard("My Store") on the demo standalone.Risk: HIGH — both findings combined produced an actual bypass.
Background
The standalone app shells call
acceptTokenFromUrl()synchronously at boot in every per-appapp.ts:Files:
src/market-app/app.ts:17-29,src/wallet-app/app.ts:22-33,src/chat-app/app.ts,src/forum-app/app.ts,src/tasks-app/app.ts,src/activities-app/app.ts:22-33,src/accounting-app/app.ts:24-36.LnbitsAPIconstructor (src/lib/api/lnbits.ts:80) readslnbits_access_tokenfrom localStorage at instantiation.lnbitsAPI.isAuthenticated()(:194-196) returns!!this.accessToken— token presence only, no server confirmation.The router guards in
src/lib/router-helpers.tsonly checkauth.isAuthenticated.value:Combined: any string in
?token=…becomes a "valid" session as far as the guard is concerned, untilauth.initialize()makes a server round-trip and the API rejects it. There's a window in which guards permit navigation with no real user context.Repro
Open in a clean browser. Until the first failing API call, the dashboard route is reachable and
auth.isAuthenticated.value === true.Acceptance criteria
1. Validate URL-supplied tokens server-side before persisting
acceptTokenFromUrl()MUST NOT write directly tolnbits_access_token. Suggested approach:lnbits_pending_token) and strip it from the URL.auth.initialize(), iflnbits_pending_tokenexists:getCurrentUser()using that tokenlnbits_access_token, populateuser.valueapp.tsshells.2. Guards require BOTH
isAuthenticatedAND a populated user objectinstallStrictAuthGuardandinstallLenientAuthGuardinsrc/lib/router-helpers.tsshould compute:and use that everywhere they currently use
auth.isAuthenticated.value. TheAuthLiketype needscurrentUseradded.3. Per-route auth gate inside dashboards (defence in depth)
MarketDashboard.vueand any other auth-gated view should also check at mount time and route-redirect to/loginif the auth state isn't fully populated. Belt-and-suspenders against future guard regressions.Out of scope
Notes
misc-docs/SECURITY_AUDIT_PRVKEY.md).