Skip to content

Security: Fix X-Forwarded-For IP spoofing in fleet detection (RIP-201) #525

@Scottcjn

Description

@Scottcjn

Summary

Fixed a critical IP spoofing vulnerability where 10 locations in the server code trusted the client-supplied X-Forwarded-For header instead of nginx's X-Real-IP header. This allowed fleet operators to evade fleet detection by making all fleet miners appear from different IPs.

Vulnerability

Affected: rustchain_v2_integrated_v2.2.1_rip200.py (10 locations)

The vulnerable pattern:

client_ip = request.headers.get("X-Forwarded-For", request.remote_addr)
if client_ip and "," in client_ip:
    client_ip = client_ip.split(",")[0].strip()

X-Forwarded-For leftmost value is client-supplied — an attacker sets it to any IP. X-Real-IP is set by nginx from the actual TCP connection.

Fix Applied

1. Centralized get_client_ip() function

def get_client_ip():
    """Extract real client IP - trusts nginx X-Real-IP, NOT client-supplied X-Forwarded-For."""
    return request.headers.get("X-Real-IP") or request.remote_addr

2. Replaced all 10 X-Forwarded-For references

All request.headers.get("X-Forwarded-For", ...) calls replaced with get_client_ip().

3. Fleet timing window widened (30s → 300s)

In fleet_immune_system.py: FLEET_TIMING_WINDOW_S changed from 30 to 300 seconds. The original 30-second window was too narrow — fleet operators could trivially space attestations 31 seconds apart to evade timing correlation.

Deployment Status

Node Status
Node 1 (50.28.86.131) ✅ Deployed, service restarted
Node 3 (76.8.228.245) ⏳ Pending — VM unreachable

Credit

Vulnerability identified via RIP-201 bypass PoC analysis (PR #514 by @liu971227-sys, 200 RTC bounty paid).

Metadata

Metadata

Assignees

No one assigned

    Labels

    RIParea: apiAPI or backend service surfacehelp wantedExtra attention is neededneeds strong contributorRequires repo familiarity or higher-risk changessecuritySecurity-related changeseverity: criticalMust be handled immediatelytype: securitySecurity-sensitive issue

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions