Skip to content

fix: resolve websocket auth token exposure and ensure transaction#616

Open
Ankush-ai wants to merge 2 commits into
viru0909-dev:mainfrom
Ankush-ai:fix-notification-token-issue
Open

fix: resolve websocket auth token exposure and ensure transaction#616
Ankush-ai wants to merge 2 commits into
viru0909-dev:mainfrom
Ankush-ai:fix-notification-token-issue

Conversation

@Ankush-ai
Copy link
Copy Markdown

Pull Request

Description

Closes #594

This Pull Request resolves a critical security vulnerability where the JWT authentication token was exposed as a query parameter in the WebSocket connection URL string.

Both frontend and backend architectures have been upgraded to pass the token securely in-band via JSON text frames immediately following connection initialization. Additionally, an event-driven mechanism has been implemented on the backend to eliminate dual-write side effects during database transaction rollbacks.

Changes Made

  • Frontend (NotificationService.js): Removed the sensitive token parameter from the core WebSocket URL. Added an onopen hook to safely transmit the token inside a structured AUTH JSON frame. Handled application routing states for AUTH_SUCCESS and AUTH_ERROR.
  • Backend Handler (NotificationWebSocketHandler.java): Transitioned session registry keys from transient socket session IDs to explicit database Long user identities. Implemented a 5-second connection sandboxing window that auto-evicts unauthenticated channels with Close Status 1008.
  • Backend Service & Events: Completely decoupled the business logic layer from the transport layer using Spring's ApplicationEventPublisher. Created a lightweight NotificationCreatedEvent and a transaction-aware NotificationWebSocketEventListener listening strictly on the AFTER_COMMIT phase with REQUIRES_NEW propagation.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes
Screenshot 2026-05-25 025211

@Ankush-ai Ankush-ai requested a review from viru0909-dev as a code owner May 24, 2026 21:40
@vercel
Copy link
Copy Markdown

vercel Bot commented May 24, 2026

@Ankush-ai is attempting to deploy a commit to the CodeBlooded's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Ankush-ai
Copy link
Copy Markdown
Author

@viru0909-dev I have made the Changes and Fixes , everything works as expected, kindly merge the PR .
Thanks

@vercel
Copy link
Copy Markdown

vercel Bot commented May 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nyaysetu Error Error May 25, 2026 4:51am

@Mohitswamii
Copy link
Copy Markdown
Contributor

Hi @viru0909-dev,

I noticed this issue currently has an open PR linked to it. If any additional improvements, testing, frontend integration, or fixes are still needed, I would be happy to contribute under GSSoC 2026.

Please let me know if I can work on this. Thank you!

@Ankush-ai
Copy link
Copy Markdown
Author

Ankush-ai commented May 25, 2026 via email

@Ankush-ai
Copy link
Copy Markdown
Author

Ankush-ai commented May 29, 2026 via email

@viru0909-dev
Copy link
Copy Markdown
Owner

viru0909-dev commented May 29, 2026

@Ankush-ai Sorry for the delay in reviewing this PR.

My health has not been good recently, so I will need another 2–3 days to properly review it. I apologize for the wait and understand that it can be frustrating when a PR remains unreviewed for a long time.

From my initial review, I noticed that the CI/CD checks are currently failing, and the Vercel deployment is also not passing. It would be helpful if you could take a look at those issues in the meantime.

Thank you for your patience and understanding. If you face any issues or need to discuss anything regarding this PR, feel free to contact me via LinkedIn

@Ankush-ai
Copy link
Copy Markdown
Author

Ankush-ai commented May 29, 2026 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SECURITY]: Auth Token Leakage via WebSocket Query Parameters (Priority: HIGH 🟠)

3 participants