Skip to content

Request names are not validated before they are used in Hetzner API paths #124

Closed

Description

@xhess

Summary

Record names from requests are only lowercased and stripped of trailing dots (NormalizeFQDN) before they are split (SplitFQDN), authorized and passed to the Hetzner Cloud API. They are never checked against hostname rules. hcloud-go builds the RRSet paths with fmt.Sprintf("/zones/%s/rrsets/%s/%s", ...) without escaping, so characters such as /, ?, % and .. segments in a name end up unescaped in the API request path.

This affects all endpoints that take a name from the request (plain, nic, acmedns, httpreq, directadmin and the new records endpoint from #122). It already exists on main and is not specific to #122.

Impact

Authorization only checks that the name ends with an allowed domain. A name that satisfies this check but contains path separators or dot segments can change which API path is requested. Possible consequences:

  • Requests addressing a different RRSet or zone than the one that was authorized, if the API (or anything in between) normalizes dot segments in the path. This is not verified, it depends on how the Hetzner API handles such paths.
  • At minimum, names with ?, % or / lead to wrong lookups or 500 errors instead of a clean 400.

Suggested fix

Validate the normalized name before SplitFQDN in every binder (or in SplitFQDN itself) using hostname label rules:

  • labels of 1-63 characters, total length <= 253
  • letters, digits, hyphen and underscore (underscore is needed for _acme-challenge and _service._proto names)
  • no leading or trailing hyphen, no empty labels

Invalid names are rejected with 400 (nic: the existing notfqdn token). For acmedns the check should also run after the _acme-challenge. prefix is added, since the prefix can push the name over 253 characters. Escaping the name in the API path would be an additional safety net, but validation alone already closes the problem.

Note

This was found by Claude Opus 5.5 (via Claude Code) during an AI-assisted code review of #122, and this issue was also drafted and created with Claude Opus. The analysis is based on reading the code (pkg/middleware/bind.go, hcloud-go zone_rrset.go). The path normalization behavior of the Hetzner API was not tested against the live API.

Activity

  1. self-assigned this
    on Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions