Skip to content

Rate limiting can be bypassed via IP header spoofing #3784

@MrBMRBLX

Description

@MrBMRBLX

In fastchat/serve/gradio_web_server.py, get_ip() trusts x-forwarded-for and cf-connecting-ip headers without validation.

If the server isn't behind Cloudflare or a trusted proxy that overwrites these headers, users can set fake values like x-forwarded-for: 1.2.3.4 to bypass rate limiting in is_limit_reached().

def get_ip(request: gr.Request):
    if "cf-connecting-ip" in request.headers:
        ip = request.headers["cf-connecting-ip"]
    elif "x-forwarded-for" in request.headers:
        ip = request.headers["x-forwarded-for"]

Might want to add a config option to specify trusted proxy sources.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions