Task endpoints missing session validation - users can access any user's data
Describe the bug Task endpoints accept user credentials from query params without checking if the user is actually logged in. Anyone can access/modify tasks for any user if they know their email, UUID, and encryption secret.
To Reproduce Steps to reproduce the behavior:
- Login as any user and check network tab for task API calls
- Copy the email, UUID, and encryptionSecret from the request
- Logout or use incognito browser
- Make direct API call:
GET /[email protected]&UUID=victim-uuid&encryptionSecret=victim-secret - See that you can access the victim's tasks without being logged in
Expected behavior
- Should check if user has valid session before allowing task operations
- Should return 401 if not logged in
- Should only allow users to access their own tasks
Screenshots Not applicable - this is a backend security issue
Current code issue
In backend/controllers/get_tasks.go:
email := r.URL.Query().Get("email") // No session check
UUID := r.URL.Query().Get("UUID") // Direct parameter trust
Hey @its-me-abhishek, I found this critical security issue while working on the backend. Since I'm already familiar with the task controllers and session handling from my previous work, I'd like to tackle this one. Can you assign it to me?
@Hell1213 since we do not actually use any auth in mobile app, and since this API can be a wrapper for TW based applications, we need not have auth based check. We do have a session based check already which will expire after a while and allows us to have a multi user setup. Please migrate this Get Tasks to use Header based Parameters instead of URL based Queries, and that will fix this. I have tested the backend using that approach earlier and it works.
This can be used inside get_tasks.go
email := r.Header.Get("X-User-Email")
encryptionSecret := r.Header.Get("X-Encryption-Secret")
UUID := r.Header.Get("X-User-UUID")
origin := os.Getenv("CONTAINER_ORIGIN")
Also update the Swagger and Frontend accordingly
Will open an issue for the App once this is merged
EDIT: Added more context
Fixed by this commit