Skip to content

SSRF detection fails open on malformed punycode hostnames (UnicodeError in get_hostname_options) #703

Description

@MaiDormo

Testing aikido_zen 1.2.35 I noticed that get_hostname_options() decodes the hostname as IDNA without guarding the call:

punycode_decoded = raw_hostname.encode("ascii", errors="").decode("idna")

A hostname containing an invalid punycode label (for example xn--a.attacker.com, which is fine at DNS level under an attacker-owned domain) raises UnicodeError at this line. The exception propagates through find_hostname_in_context() and is swallowed by the catch-all in run_vulnerability_scan(), so the entire SSRF scan is skipped and the outgoing request to a private IP goes through unblocked.

Repro (Python 3.12, AIKIDO_BLOCK=true, Flask endpoint that fetches a user-supplied URL, both test hostnames resolving to 127.0.0.1):

  • http://attacker.com/ -> blocked with AikidoSSRF (expected)
  • http://xn--a.attacker.com/ -> not blocked, response returned

Suggested fix: catch UnicodeError from the idna decode and fall back to the ASCII/punycode form for input matching, or treat hosts that fail IDNA validation as suspicious. The scan should not abort silently.

Happy to share a small PoC script if useful.

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