Skip to content

Add Domain.maybe_wildcard? to detect possible wilcard DNS records #203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 5, 2025

Conversation

TooManyBees
Copy link
Contributor

Domain#maybe_wildcard? generates a random sibling domain and queries it, then checks if it returns an answer and if it points to github pages. If so, then it's reasonable to suspect that the record which points the domain to github pages is a wildcard record.

This is worth warning about because a wildcard DNS record will allow anyone to host a pages site at a subdomain of the wildcard record. GitHub allows us to verify ownership of our domains, but it only works for the verified domain and direct subdomains (a.example.com, b.example.com), not subdomains arbitrarily many segments long (a.b.c.d.e.f.example.com).

Use a subdomain with more randomness

Return an error when a wildcard record is suspected

Some affordances for unit tests

in maybe_wildcard? also check that the wildcard leads back to GitHub

lint

Don't include wildcard warnings as an error

wildcard_warning method to generate an error
@Copilot Copilot AI review requested due to automatic review settings June 5, 2025 18:30
@TooManyBees TooManyBees requested a review from a team as a code owner June 5, 2025 18:30
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds detection for potential wildcard DNS records in custom domains, warning users when a wildcard could allow unintended Pages subdomains.

  • Introduces Domain#maybe_wildcard? and Domain#wildcard_warning to detect and surface wildcard-record risks.
  • Adds a new WildcardRecordError class and updates the total error count in specs.
  • Bumps the addressable gem dependency to ~> 2.8.7.

Reviewed Changes

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

File Description
spec/github_pages_health_check/errors_spec.rb Update expected error count to include the new wildcard error
lib/github-pages-health-check/errors/wildcard_record_error.rb Add WildcardRecordError for wildcard DNS record warnings
lib/github-pages-health-check/domain.rb Implement parent_domain, maybe_wildcard?, and wildcard_warning
github-pages-health-check.gemspec Bump addressable dependency to ~> 2.8.7
Comments suppressed due to low confidence (2)

spec/github_pages_health_check/errors_spec.rb:7

  • [nitpick] The spec currently only checks the total number of errors, which can be brittle. Consider adding a dedicated test to verify that WildcardRecordError is included and that its message is as expected.
expect(GitHubPages::HealthCheck::Errors.all.count).to eql(11)

lib/github-pages-health-check/errors/wildcard_record_error.rb:17

  • Consider using a <<~MSG heredoc instead of <<-MSG to automatically strip indentation and avoid leading whitespace in the error message.
<<-MSG

@github github deleted a comment from Copilot AI Jun 5, 2025
@maybe_wildcard = begin
wildcard_resolver = GitHubPages::HealthCheck::Resolver.new(sibling_domain, :nameservers => nameservers)

[Dnsruby::Types::A, Dnsruby::Types::AAAA].any? do |record_type|
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we also want to check for CNAME and MX? Or is that something we don't worry about because it's a Pages domain?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For this purpose, all that matters is whether the IP points to github, so just A and AAAA are sufficient.

@TooManyBees TooManyBees merged commit f41aa92 into master Jun 5, 2025
8 of 9 checks passed
@TooManyBees TooManyBees deleted the wildcard-test branch June 5, 2025 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants