π Fix IP Address Spoofing via X-Forwarded-For#16
Conversation
- Moved getClientIp to a dedicated src/lib/ip.ts utility. - Updated implementation to prioritize X-Real-IP. - Changed X-Forwarded-For parsing to use the last IP in the list. - Added comprehensive unit tests in src/lib/ip.test.ts. - Updated API route to use the new utility. Co-authored-by: instax-dutta <54683866+instax-dutta@users.noreply.github.com>
|
π 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded
β How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. π¦ How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. βΉοΈ Review infoβοΈ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: π Files selected for processing (4)
β¨ Finishing Touchesπ§ͺ Generate unit tests (beta)
π Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This PR fixes a security vulnerability where an attacker could spoof their IP address by providing a custom
X-Forwarded-Forheader.The previous implementation blindly trusted the first IP in the
X-Forwarded-Forlist, which is often client-controlled. The new implementation prioritizes theX-Real-IPheader (typically set by trusted infrastructure like Vercel) and falls back to the last IP in theX-Forwarded-Forlist, which is the most reliable entry in a proxy chain.Key changes:
src/lib/ip.tsfor secure IP retrieval logic.src/app/api/paste/route.tsto use the improved utility.src/lib/ip.test.tswith 6 test cases verifying the security and robustness of the fix.src/lib/validation.ts.PR created automatically by Jules for task 8564156710181733307 started by @instax-dutta