Skip to content

V2Ray 对 X-Forwarded-For 的处理存在问题 #1037

@AkinoKaede

Description

@AkinoKaede

首先特别感谢 @rhjdvsgsgks

你正在使用哪个版本的 V2Ray?

v4.38.3

你看到的异常现象是什么?

V2Ray 优先使用 X-Forwarded-For 中的第一个值作为 WebSocket 和 HTTP/2 传输层入站的来源 IP,且无法关闭。客户端可以任意伪造 X-Forwarded-For

测试配置

服务端配置:

{
    "log": {
        "loglevel": "warning"
    },
    "inbounds": [
        {
            "listen": "127.0.0.1",
            "port": 12456,
            "protocol": "vless",
            "settings": {
                "clients": [
                    {
                        "id": "1587873b-edf6-4f43-bfdc-ba5311b4978a",
                        "level": 1,
                        "email": "[email protected]"
                    }
                ],
                "decryption": "none"
            },
            "streamSettings": {
                "network": "ws",
                "wsSettings": {
                    "path": "/"
                }
            }
        }
    ],
    "outbounds": [
        {
            "protocol": "freedom"
        }
    ]
}

客户端配置:

{
    "log": {
        "loglevel": "warning"
    },
    "inbounds": [
        {
            "listen": "127.0.0.1",
            "port": "10800",
            "protocol": "socks",
            "settings": {
                "auth": "noauth",
                "udp": true,
                "ip": "127.0.0.1"
            }
        }
    ],
    "outbounds": [
        {
            "protocol": "vless",
            "settings": {
                "vnext": [
                    {
                        "address": "127.0.0.1",
                        "port": 12456,
                        "users": [
                            {
                                "id": "1587873b-edf6-4f43-bfdc-ba5311b4978a",
                                "encryption": "none",
                                "level": 0
                            }
                        ]
                    }
                ]
            },
            "streamSettings": {
                "network": "ws",
                "wsSettings": {
                    "path": "/",
                    "headers": {
                        "Host": "test.com",
                        "X-Forwarded-For": "8.8.8.8"
                    }
                }
            },
            "tag": "proxy"
        },
        {
            "protocol": "freedom",
            "tag": "direct"
        }
    ]
}

请附上出错时软件输出的错误日志

服务器端错误日志:

2021/05/26 13:08:55 8.8.8.8:0 accepted tcp:www.google.com:443 email: [email protected]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions