Skip to content

[Security] SSE getClientIp trusts client X-Forwarded-For, letting attackers bypass the per-IP SSE connection limit (DoS) #817

Description

@grantfox-oss

Telegram (ask questions / claim the issue here first): https://t.me/+DOylgFv1jyJlNzM0

Why this matters

sse.controller.ts:15-26 getClientIp reads req.headers['x-forwarded-for'] unconditionally and returns its first entry as sourceIp; that value feeds sseService.checkCapacity(sourceIp) and addClient(...,sourceIp). Express never sets trust proxy, so this header is fully attacker-controlled - a client rotating a fake X-Forwarded-For per request opens unlimited SSE connections, defeating the per-IP connection cap and exhausting connection slots.

Acceptance criteria

  • Derive the client IP from req.ip after configuring a correct trust proxy setting, not directly from the raw X-Forwarded-For header
  • When trust proxy is not enabled, ignore X-Forwarded-For and use req.socket.remoteAddress
  • Add a test proving two connections with different spoofed X-Forwarded-For values from the same socket still count against one per-IP bucket

Files to touch

  • backend/src/controllers/sse.controller.ts
  • backend/src/services/sse.service.ts

Out of scope

  • Changing the per-IP limit value
  • Redis-backed SSE fan-out

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave programbackendBackend related tasksbugSomething isn't workingcriticalsecuritySecurity related tasks

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions