Skip to content

[Bug] Normalization of hostnames #2926

@griffer

Description

@griffer

Is this a support request?

  • This is not a support request

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

First off, love Headscale, it works great!

I think I found a bug in hostname handling.

When a client reports a hostname like "My-PC!", it fails ValidateHostname() and gets replaced with "invalid-xyz". Headscales code has a NormaliseHostname() function that would sanitize this to "my-pc".

The affected code paths are:

  • ApplyHostnameFromHostInfo() hscontrol/types/node.go
  • EnsureHostname() in hscontrol/util/util.go

Both use ValidateHostname() (reject if invalid), instead of NormaliseHostname() (sanitize and accept).

This seems like an oversight? The NormaliseHostname function exists but isn't being used.

Expected Behavior

Expected: Hostname "My-PC!" → sanitized to "my-pc"
Actual: Hostname "My-PC!" → rejected, becomes "invalid-abc123"

Steps To Reproduce

  1. Register a node with hostname containing invalid characters:

On client with hostname "My-PC!"

tailscale up --login-server https://your-headscale-server

  1. List nodes on server:
    headscale nodes list

  2. Expected: Node appears as my-pc

  3. Actual: Node appears as invalid-abc123

Environment

- Headscale version: v0.27.1
- Deployment: Docker
- OS: Ubuntu 24.04.3 LTS
- Docker: 29.0.2

Runtime environment

  • Headscale is behind a (reverse) proxy
  • Headscale runs in a container

Debug information

This is a code logic issue, so dont believe debug log is useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions