Skip to content

Commit

Permalink
Enforce a valid IP address return in /util/client_ip instead of opt…
Browse files Browse the repository at this point in the history
…ional hostname
  • Loading branch information
NeonDaniel committed Nov 14, 2024
1 parent f784590 commit d713345
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions neon_hana/app/routers/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
@util_route.get("/client_ip", response_class=PlainTextResponse)
async def api_client_ip(request: Request) -> str:
ip_addr = request.client.host if request.client else "127.0.0.1"
if len(ip_addr.split('.')) != 4:
# Reported host is a hostname, not an IP address. Return a generic
# loopback value
ip_addr = "127.0.0.1"
client_manager.validate_auth("", ip_addr)
return ip_addr

Expand Down

0 comments on commit d713345

Please sign in to comment.