Skip to content

πŸ›‘οΈ Sentinel: [HIGH] Fix XSS and DoS in Socket.IO handlers - #96

Draft
google-labs-jules[bot] wants to merge 1 commit into
mainfrom
sentinel/fix-socket-xss-13127777788474757747
Draft

πŸ›‘οΈ Sentinel: [HIGH] Fix XSS and DoS in Socket.IO handlers#96
google-labs-jules[bot] wants to merge 1 commit into
mainfrom
sentinel/fix-socket-xss-13127777788474757747

Conversation

@google-labs-jules

Copy link
Copy Markdown
Contributor

This PR addresses a high-severity security vulnerability in the Socket.IO event handlers where user input was not properly sanitized or validated.

Changes:

  1. Created backend/utils/security.js: Added a dedicated utility for HTML escaping to prevent XSS.
  2. Updated backend/server.js:
    • Imported the escapeHtml utility.
    • Added input validation to send_message and guild_message handlers to ensure message is a string and does not exceed 1000 characters.
    • Applied escapeHtml to the message content before emitting it to other users.
  3. Added Tests: Created backend/tests/security/socket_sanitization.test.js to verify:
    • XSS payloads (e.g., <script>) are correctly escaped.
    • Non-string inputs are rejected.
    • Oversized messages (>1000 chars) are rejected.

Verification:
Run cd backend && npm test tests/security/socket_sanitization.test.js. All tests should pass.


PR created automatically by Jules for task 13127777788474757747 started by @4444J99

🚨 Severity: HIGH
πŸ’‘ Vulnerability: Socket.IO message handlers (`send_message`, `guild_message`) lacked input validation and sanitization, allowing XSS payloads and oversized messages.
🎯 Impact: Attackers could inject scripts into other users' sessions or cause denial of service via large payloads.
πŸ”§ Fix:
- Added `backend/utils/security.js` with `escapeHtml` utility.
- Implemented strict type checking (string only) and length limits (1000 chars) in `backend/server.js`.
- Applied `escapeHtml` to message content before broadcasting.
βœ… Verification: Added `backend/tests/security/socket_sanitization.test.js` verifying XSS payloads are escaped and invalid messages are rejected.
@google-labs-jules

Copy link
Copy Markdown
Contributor Author

πŸ‘‹ Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a πŸ‘€ emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai

coderabbitai Bot commented Jan 12, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

@4444J99

4444J99 commented Jul 19, 2026

Copy link
Copy Markdown
Member

The genuine security want here has been distilled onto main and merged as #158 (bfcd3836):

  • Token-refresh privilege escalation β€” authController.refreshToken now enforces the same user.status !== 'active' gate as login, so a suspended/inactive/deleted user can no longer mint fresh access tokens.
  • Socket.IO message XSS / input validation β€” new backend/utils/sanitize.js (HTML-escape + control-char strip + length cap + type check) is wired into both the send_message and guild_message handlers.

Both are covered by tests (refreshTokenStatus.test.js, messageSanitize.test.js). Keeping this PR open per our never-close doctrine β€” the fix now lives on main. If your PR targets a distinct vector not covered above, reply here and it becomes the next distillation.

@4444J99 4444J99 added the lifecycle:blocked Fail-closed pending explicit lifecycle review label Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lifecycle:blocked Fail-closed pending explicit lifecycle review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant