Skip to content

urlapi: deny hostnames with more than one trailing dot#21622

Closed
bagder wants to merge 4 commits into
masterfrom
bagder/double-dot
Closed

urlapi: deny hostnames with more than one trailing dot#21622
bagder wants to merge 4 commits into
masterfrom
bagder/double-dot

Conversation

@bagder

@bagder bagder commented May 15, 2026

Copy link
Copy Markdown
Member

Or if the host name is just a single dot.

Such names cannot be resolved with DNS.

While they can still be resolved with /etc/hosts or --resolve tricks, they easily cause internal problems because their trailing dots.

Let's not allow them anymore.

Such names cannot be resolved with DNS.

While they *can* still be resolved with /etc/hosts or --resolve tricks,
they easily cause internal problems because their trailing dots.

Let's not allow them anymore.
@bagder bagder added the URL label May 15, 2026
@github-actions github-actions Bot added the tests label May 15, 2026
@bagder bagder marked this pull request as ready for review May 15, 2026 08:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Rejects URLs whose hostname is just a single dot or ends in two or more dots, since such names are not resolvable via DNS and cause internal issues.

Changes:

  • Add hostname validation in hostname_check() to return CURLUE_BAD_HOSTNAME for hostnames that are a single . or end with ...
  • Update lib1560 test cases (single dot, multiple trailing dots) and add new URL-roundtrip tests that expect CURLUE_BAD_HOSTNAME.
  • Update test_17_04_double_dot to expect curl to exit with code 3 (malformed URL) instead of TLS-level failures.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
lib/urlapi.c Reject hostnames that are a single dot or have 2+ trailing dots
tests/libtest/lib1560.c Update existing cases and add new URL tests for the new rule
tests/http/test_17_ssl_use.py Adjust SSL trailing-dot test to expect curl exit code 3

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/libtest/lib1560.c Outdated
comment language

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@bagder bagder closed this in 9135294 May 15, 2026
@bagder bagder deleted the bagder/double-dot branch May 15, 2026 09:44
outcast36 pushed a commit to greearb/curl that referenced this pull request Jun 3, 2026
Or consisting of just a single dot.

Such names cannot be resolved with DNS.

While they *can* still be resolved with /etc/hosts or --resolve tricks,
they easily cause internal problems because their trailing dots.

Let's not allow them anymore.

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

Development

Successfully merging this pull request may close these issues.

2 participants