2015-01-14 7 views
6

मैं 4 आवेदन मेरी रेल पर निम्न त्रुटि हो रही है:रेल 4 आवेदन में आईपी स्पूफिंग जांच को अक्षम कैसे करें?

ActionDispatch::RemoteIp::IpSpoofAttackError: IP spoofing attack?! HTTP_CLIENT_IP="xx.xx.xx.xx" HTTP_X_FORWARDED_FOR="xx.xx.xx.xx"

हम सुरक्षा जांच के इस प्रकार की जरूरत नहीं है, इसलिए कुछ चारों ओर Googling के बाद मैं इस पाया:

https://github.com/rails/rails/issues/10780

When an intermediate proxy inserts the user IP address both in the HTTP_CLIENT_IP and the HTTP_X_FORWARDED_FOR, and this address is private, ActionDispatch::RemoteIp raises an IpSpoofAttackError exception.

When an enterprise proxy includes the user's IP address in a header, this will commonly be private. Removing private IP addresses from the chain contained in HTTP_X_FORWARDED_FOR should probably be done only when the address is not an exact match of the one found in HTTP_CLIENT_IP. If it is a match, that should be the user's IP address.

This happens for example with the following environment:

HTTP_CLIENT_IP: 172.17.19.51 HTTP_X_BLUECOAT_VIA: ffffffffffffffff HTTP_X_FORWARDED_FOR: 172.17.19.51 REMOTE_ADDR: xxx.xxx.xxx.xxx (this would be a public IP address)


फिक्स यहां प्रस्तुत:

As a work-around, I've disabled this check in config/application.rb:

config.action_dispatch.ip_spoofing_check = false

हालांकि इस doens't रेल 4 में काम करने के लिए लग रहे हैं क्या नया कॉल है और मैं इसे साइट विस्तृत कैसे सेट करूँ?

उत्तर

2

config.action_dispatch.ip_spoofing_checkRemoteIp के लिए calling chain के आधार पर काम करना चाहिए।

आपको config.action_dispatch.trusted_proxies को regex matching all IPv4 addresses पर सेट करके एक ही प्रभाव प्राप्त करने में सक्षम होना चाहिए।

5

बल्कि चेतावनी को बंद करने की तुलना में, यह वास्तविक समस्या को ठीक करने के लिए बेहतर हो सकता है।

This request seems to have come through two different reverse proxies. One of them set the CLIENT_IP header to the user's IP address; the other set the X_FORWARDED_FOR header. One of those values is probably correct, the other probably contains the IP of a reverse proxy, and I have no way to tell which is which. I can't reliably determine this user's IP address, so I'm going to reject the request.

"सही" समाधान दोनों हेडर की स्थापना को रोकने के लिए है: यहाँ क्या रेल आप कह रहा है की मेरी rephrasing है। इसके लिए आपको यह पता लगाने की आवश्यकता होगी कि वे कहां से आ रहे हैं (मैं आपके ब्लूकोट डिवाइस से शुरू करूंगा) और पता लगाएं कि क्या दोनों की आवश्यकता है या नहीं। आमतौर पर आप केवल एक या दूसरे का उपयोग करेंगे।

यदि यह पता चला है कि वे दोनों आवश्यक हैं (मैंने अजनबी चीजें देखी हैं), तो आपको यह पता लगाना होगा कि कौन सा शीर्षलेख पहले सेट किया जा रहा है (माना जाता है कि श्रृंखला में दो प्रॉक्सी हैं)। फिर आप एक कस्टम मिडलवेयर लिख सकते हैं जो अन्य HTTP शीर्षलेख को हटा देता है।

कैसे अपनी खुद की मिडलवेयर बनाने के लिए पर संकेत के लिए Rails 3 middleware modify request headers देखें। रिमोटआईप मिडलवेयर से पहले इसे डालें, जो भी शीर्षलेख में "खराब" मान है, उसे साफ़ करें, और आपको अच्छा होना चाहिए।

संबंधित मुद्दे