Skip to content

Reject non-loopback Host headers for loopback ADK web servers #5288

Closed

Description

@petrmarinec

Summary

When the ADK web server is bound to loopback, such as the default 127.0.0.1, it should not accept requests with non-loopback Host header values.

The current origin check derives the request origin from the incoming Host header and then compares it with the Origin header. A DNS-rebound request can therefore use a non-loopback hostname in both headers, for example Host: rebind.attacker.example:8000 and Origin: http://rebind.attacker.example:8000, causing the request to be treated as same-origin even though the hostname is not a loopback host.

Impact

If an external page can reach a victim's running local ADK server through DNS rebinding, it may be able to send requests to local ADK APIs as if it were the local server origin. Depending on enabled routes and local agent configuration, this can allow the page to create or modify local eval inputs, trigger local agent runs, or read local API responses.

Expected behavior

When ADK is bound to a loopback host, the server should only accept loopback Host header values such as localhost, 127.0.0.1, and ::1. Non-loopback hostnames should be rejected before the origin comparison.

Validation

I have a PR prepared that:

  • rejects non-loopback Host headers when the server is bound to loopback
  • keeps the existing origin checks for allowed/cross-origin behavior
  • adds a regression test for the DNS-rebound Host/Origin shape
  • reproduces the unsafe behavior on clean origin/main: the rebound request returns 200 true
  • verifies the patch returns 403 Forbidden: host not allowed
  • passes tests/unittests/cli/test_fast_api.py in Linux Docker: 63 passed

Activity

  1. added
    web[Component] This issue will be transferred to adk-web
    on Apr 11, 2026
  2. added theissue type on Apr 11, 2026
  3. added
    needs review[Status] The PR/issue is awaiting review from the maintainer
    on Apr 16, 2026
  4. removed
    needs review[Status] The PR/issue is awaiting review from the maintainer
    on Apr 16, 2026
  5. klateefa commented on Apr 16, 2026

    @klateefa

    @petrmarinec Thanks for reporting!
    The server trusts the Host header, which attackers can fake using DNS rebinding.Check the Host header first. If the server is running on loopback, only allow localhost, 127.0.0.1, or ::1. Reject anything else with a 403 error.This blocks fake domains from bypassing security checks.Can you try this and let me know if the issue persists?

  6. petrmarinec commented on Apr 16, 2026

    @petrmarinec
    ContributorAuthor

    Hi @klateefa,

    PR #5289 implements this mitigation by checking the Host header before the origin comparison when the server is bound to loopback. In that mode it only allows loopback host values such as localhost, 127.0.0.1, and ::1; a DNS-rebound shape like:

    Host: rebind.attacker.example:8000
    Origin: http://rebind.attacker.example:8000

    is rejected with 403 Forbidden: host not allowed.

  7. llalitkumarrr commented on Jun 22, 2026

    @llalitkumarrr
    Collaborator

    Hello @petrmarinec ,

    Thank you for your contribution. Your PR is currently under review and we will reach out if any additional details are required. In the meantime, we appreciate your patience.

  8. added
    needs review[Status] The PR/issue is awaiting review from the maintainer
    on Jun 22, 2026
  9. removed
    needs review[Status] The PR/issue is awaiting review from the maintainer
    on Jul 22, 2026
  10. sasha-gitg commented on Aug 11, 2026

    @sasha-gitg
    Collaborator

    Fixed here: #6227

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

web[Component] This issue will be transferred to adk-web

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions