Investigating how attackers are exploiting GitHub Pages' free hosting for malicious purposes, creating security and DNS risks.
Image Source: Picsum

Key Takeaways

Attackers are abusing GitHub Pages for phishing and malware by exploiting its free hosting and custom domain features. This creates security risks, impacting search rankings and user trust, and strains the infrastructure supporting legitimate users.

  • Attackers use GitHub Pages to host phishing sites and malware, masquerading as legitimate services by leveraging custom domains or the free *.github.io subdomains.
  • The ease of deployment and free hosting make GitHub Pages an attractive target for attackers, often leading to its inclusion in botnets or as a redirector for malicious campaigns.
  • Lack of stringent upfront verification for domain usage or content can allow these malicious sites to persist, impacting search engine rankings and user trust.
  • The reliance on DNS and certificate authorities for these compromised sites can have cascading effects, potentially leading to the blacklisting of legitimate IPs or domains associated with GitHub infrastructure.

The Phantom Subdomain Menace: When Wildcards Turn GitHub Pages into a Phishing Farm

The allure of free, managed static hosting is strong. GitHub Pages, with its tight integration into the developer workflow, offers a compelling proposition for project documentation, personal portfolios, and even marketing sites. But beneath the surface of convenience lies a subtle, yet potent, security vulnerability. Attackers are not just targeting *.github.io domains; the real exploit targets custom domains pointed to GitHub Pages’ infrastructure via a wildcard DNS entry. This misconfiguration, coupled with GitHub’s relaxed subdomain ownership verification for such setups, creates a fertile ground for phishing and malware distribution, turning a free service into a significant liability.

DNS Wildcards: A Backdoor to Your Domain

The core of the problem isn’t with GitHub’s *.github.io domains themselves, but how legitimate domain owners configure their custom domains. When a domain owner sets up a wildcard DNS record, like *.example.com, to point to GitHub Pages’ IP addresses (185.199.108.153, 185.199.109.153, 185.199.110.153, 185.199.111.153 for IPv4, and their IPv6 counterparts), they are effectively telling the internet: “Any subdomain I haven’t explicitly defined elsewhere under example.com should be resolved by GitHub Pages.” This is a powerful directive, but one that attackers can readily exploit.

GitHub Pages serves content based on a CNAME file found in the root of a repository. This file simply lists the custom domain it should respond to, e.g., www.example.com. The critical oversight occurs when an attacker creates a repository and, within its CNAME file, specifies a subdomain that exists within a wildcard-configured domain – say, phishing.example.com. Because the legitimate domain owner has a wildcard record pointing to GitHub Pages, GitHub’s servers receive the request for phishing.example.com. GitHub’s internal routing logic then looks for a repository configured to serve phishing.example.com. If the attacker’s repository is the only one configured for that specific subdomain, or if it’s configured first, GitHub will happily serve the attacker’s malicious content. The platform does not enforce stringent ownership validation for all subdomains when a wildcard DNS record is in play, even if the apex domain (example.com) has been verified.

This contrasts with how individual subdomains are typically handled. For a subdomain like blog.example.com, one would typically create a specific CNAME or A record for blog.example.com in their DNS zone. If GitHub Pages receives a request for blog.example.com and the legitimate domain owner’s DNS points it there, GitHub would expect a repository to be configured for blog.example.com. If it finds one associated with the verified domain, all is well. But the wildcard removes this specificity.

The Dangers of Delegation: Beyond Wildcards

While wildcard DNS records represent a direct route for subdomain takeover, a related vulnerability, often conflated, involves “dangling DNS” records. This occurs when a DNS record (usually a CNAME) for a subdomain correctly points to an external service like GitHub Pages, but the repository or account that was supposed to host content for that subdomain has since been deleted or was never properly set up. Tools like can-i-take-over-xyz are designed to scan for these abandoned CNAME targets. An attacker can then register the abandoned resource on the target service and effectively claim ownership of the subdomain. Imagine a company deprecating a old project page at dev.example.com. If the CNAME record for dev.example.com still points to a non-existent GitHub Pages deployment, an attacker could potentially create a new repository on GitHub, configure it for dev.example.com (if they can trick GitHub into thinking they own it, or if GitHub’s verification is lax), and host their own content.

GitHub’s Insufficient Safeguards: Warnings Unheeded

GitHub is not entirely silent on this issue. Their documentation “strongly recommend[s] that you do not use wildcard DNS records, such as *.example.com” and explicitly states this practice poses an “immediate risk of domain takeovers.” This is a clear warning. However, the mechanism for preventing such takeovers is largely opt-in and, critically, not enforced for every subdomain.

GitHub offers a domain verification process, typically involving adding a TXT record to your DNS zone. Verifying your apex domain, say example.com, helps secure it. GitHub does extend this verification to immediate subdomains (e.g., a.example.com is better protected if example.com is verified). However, the brief highlights a crucial gap: this verification does not extend to deeper subdomains (e.g., b.a.example.com) if a wildcard DNS record is present and pointing to GitHub Pages. An attacker can still potentially register b.a.example.com via a repository on GitHub, even if example.com is verified, provided their DNS entry is handled by the wildcard.

Furthermore, community discussions reveal frustration with GitHub’s reactive approach. Users report that even verified domains can be hijacked if the domain is associated with a repository not directly linked to the verified owner. The platform’s grace period – a seven-day window before a takeover is finalized after detection – prolongs the window of exposure. This slow remediation cycle, combined with reports of bug bounty programs marking similar issues as “Not Applicable,” suggests a persistent disconnect between the perceived severity of the vulnerability and GitHub’s implementation of defenses. Some researchers have even observed that while certain types of takeovers on [username].github.io might be difficult, this observation can distract from the more pervasive wildcard DNS vulnerability affecting custom domains.

Configuration Snippet: The Malicious CNAME

Consider a domain owner that has configured their DNS for company.com with a wildcard record:

*.company.com.  IN  A   185.199.108.153
*.company.com.  IN  A   185.199.109.153
*.company.com.  IN  A   185.199.110.153
*.company.com.  IN  A   185.199.111.153
# IPv6 counterparts also configured

Meanwhile, an attacker sets up a repository on GitHub Pages. In the root of their publishing branch, they create a file named CNAME (all caps) with the following content:

malicious-subdomain.company.com

When a user navigates to http://malicious-subdomain.company.com, their browser makes an HTTP request. The DNS system, encountering the wildcard record, resolves malicious-subdomain.company.com to one of GitHub’s Pages IP addresses. GitHub receives the request, checks its internal mapping, and finds the attacker’s repository configured for malicious-subdomain.company.com. The attacker’s malicious HTML, JavaScript, or phishing form is then served.

Bonus Perspective: The Unintended Trust Fallacy

The root cause here is a subtle but critical misapplication of trust. Domain owners, in their pursuit of convenience and cost savings, delegate broad authority to GitHub Pages via wildcard DNS. They implicitly trust that GitHub’s platform will act as a robust gatekeeper for all subdomains, regardless of explicit configuration. However, GitHub’s architecture, as evidenced by the lack of stringent ownership verification for wildcard-resolved subdomains, does not provide that level of granular protection. This creates an “unintended trust fallacy” where a feature designed for ease of use inadvertently opens a significant security aperture. The downstream consequence is not just a compromised subdomain, but the erosion of trust in the parent domain and the broader web ecosystem, as users are increasingly targeted by sophisticated phishing operations hosted on seemingly legitimate infrastructure. This issue underscores the broader challenge in supply chain security: a vulnerability in a seemingly innocuous component can propagate risks throughout the entire system, much like the concerns raised regarding GitHub Actions as a CI/CD weak link.

Opinionated Verdict: Harden Your DNS, or Pay the Price

GitHub Pages is a powerful tool, but its free tier and ease of deployment mask potential security pitfalls when custom domains are involved. The wildcard DNS vulnerability is not a theoretical edge case; it’s a documented and exploitable mechanism. If you are using GitHub Pages with a custom domain and have configured wildcard DNS records pointing to their IPs, you are actively inviting risk. The advice is stark: remove wildcard DNS records pointing to GitHub Pages. If you require subdomains, define them explicitly in your DNS configuration and ensure they are properly associated with the correct GitHub Pages repositories or your verified domain. GitHub’s own documentation issues a strong warning, yet the enforcement remains insufficient. Relying on the platform’s good graces, or an easily overlooked CNAME file, is a gamble that can lead to brand damage and user trust erosion. The cost of an explicit DNS record is negligible compared to the potential fallout of a successful subdomain takeover.

The Enterprise Oracle

The Enterprise Oracle

Enterprise Solutions Expert with expertise in AI-driven digital transformation and ERP systems.

Cellogen Therapeutics' $20M Seed Round: A Risky Bet on Unproven Cell Therapy Platforms?
Prev post

Cellogen Therapeutics' $20M Seed Round: A Risky Bet on Unproven Cell Therapy Platforms?

Next post

Beyond the Hype: Enterprise Agentic AI Platforms and the Unseen Operational Debt

Beyond the Hype: Enterprise Agentic AI Platforms and the Unseen Operational Debt