Skip to content

Fix cross-tenant notification data leak via query parameter#114

Merged
Senthil455 merged 6 commits into
mainfrom
fix/issue-41-cross-tenant-notifications
Jun 17, 2026
Merged

Fix cross-tenant notification data leak via query parameter#114
Senthil455 merged 6 commits into
mainfrom
fix/issue-41-cross-tenant-notifications

Conversation

@Senthil455

Copy link
Copy Markdown
Owner

Remove the tenant_id query parameter that took precedence over the X-Tenant-Id header, allowing any authenticated user to read any tenant's notifications. Now always uses the header value and returns 403 if missing.

Add SIGINT/SIGTERM signal handling, context-based cancellation for
background goroutines, and proper app.Shutdown() to all three Go
services to prevent connection leaks on Kubernetes pod termination.

- attendance-service: signal.Notify -> app.ShutdownWithContext
- lms-service: signal.Notify -> app.ShutdownWithContext
- notification-go-service: signal.Notify -> http.Server.Shutdown
- All background goroutines accept context.Context for clean shutdown
Wrap RabbitMQ consumer setup in an infinite reconnection loop so that
consumers automatically reconnect when the connection drops, instead of
permanently terminating the goroutine.

- attendance-service: consumeEmployeeDeletions now retries on disconnect
- notification-go-service: setupRabbitMQConsumer now retries on disconnect
- Exponential backoff from 1s to 30s max on each retry attempt
Limit total WebSocket connections (max 1000) and enforce per-IP rate
limiting (max 10 per IP) to prevent resource exhaustion attacks.

- maxClients = 1000 global limit checked before upgrade
- maxConnsPerIP = 10 limit enforced per client IP address
- canAcceptConnection/releaseConnection for tracking IP counts
- Client struct extended with clientIP field for cleanup
- Existing readPump cleanup extended to release IP count
Remove tenant_id query parameter that could bypass the X-Tenant-Id
header set by auth middleware. Always use the header value and return
403 if missing.

@Senthil455 Senthil455 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removes the insecure query parameter fallback that allowed cross-tenant notification access. Simple, targeted fix for a clear security vulnerability.

@Senthil455 Senthil455 merged commit f9a4f0b into main Jun 17, 2026
4 of 20 checks passed
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.

1 participant