fix: wallet-based rate limiting to prevent IP-spoofing bypass (SECURITY)#1698
fix: wallet-based rate limiting to prevent IP-spoofing bypass (SECURITY)#1698jujujuda wants to merge 1 commit intoScottcjn:mainfrom
Conversation
Fixes rate limit bypass via X-Forwarded-For header spoofing. Vulnerability: Attacker controlling a reverse proxy could spoof any IP via X-Forwarded-For, bypassing IP-based rate limits. Fix: Add wallet-based rate limiting as primary defense. Attacker cannot bypass wallet-based limit without rotating wallets, which is more expensive than rotating IPs. Also improved X-Forwarded-For validation: only trust it when present and properly formatted (a legitimate reverse proxy always sets it). Addresses: rustchain-bounties#2246
|
Welcome to RustChain! Thanks for your first pull request. Before we review, please make sure:
Bounty tiers: Micro (1-10 RTC) | Standard (20-50) | Major (75-100) | Critical (100-150) A maintainer will review your PR soon. Thanks for contributing! |
|
Good security fix — we want to merge this. But it has merge conflicts with main. Could you rebase on main and force-push? We'll merge once conflicts are resolved. Thanks @jujujuda! |
|
Review: Request Changes 🔧 Wallet-based rate limiting is the right concept. Two bugs to fix:
Fix these = 20 RTC. @jujujuda |
|
Good concept — wallet-based rate limiting addresses a real vulnerability. Two things needed before merge:
Fix those and this is mergeable. 🔒 |
Security Fix: Faucet Rate Limit Bypass via X-Forwarded-For Spoofing
Vulnerability Summary
Reported in rustchain-bounties#2246.
The faucet (
faucet.py) used IP-based rate limiting only. An attacker who controls or exploits a misconfigured reverse proxy could set arbitraryX-Forwarded-Forvalues, bypassing the IP-based rate limit.Fix Applied
Primary Defense: Wallet-based rate limiting
X-Forwarded-For Validation
Changes
get_client_ip(): Improved XFF validationcan_drip_by_wallet(): New — wallet-based rate limitcan_drip_by_ip(): Existing IP-based check (secondary)drip()endpoint: Now checks both wallet AND IP limitsBounty payment wallet
RTC2fe3c33c77666ff76a1cd0999fd4466ee81250ff