Skip to content

Commit d26b3e6

Browse files
rfayclaudestasadev
authored
blog: ddev-hostname and security, fixes #384 (#397)
Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Stanislav Zhuk <stasadev@gmail.com>
1 parent fbc7819 commit d26b3e6

File tree

4 files changed

+111
-12
lines changed

4 files changed

+111
-12
lines changed

CLAUDE.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ Blog posts require:
7070
- pubDate as Date object
7171
- Optional featureImage with alt text
7272

73+
### Content Linking
74+
75+
- **Internal blog links**: Use markdown filename references (e.g., `[link text](filename.md)`) for links between blog posts. Astro automatically resolves these to proper URLs.
76+
- **Other internal links**: Use root-relative paths (e.g., `[Contact](/contact)`) for links to other site pages
77+
- **External links**: Use full URLs for links outside the site
78+
7379
### GitHub Integration
7480

7581
The site fetches dynamic data from GitHub API:
119 KB
Loading
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
title: "Enhanced Security with DDEV's New `ddev-hostname` Binary"
3+
pubDate: 2025-07-22
4+
summary: "DDEV v1.24.7 introduces a new dedicated `ddev-hostname` binary that improves security by minimizing elevated privileges and simplifies WSL2 setup with the new ddev-wsl2 package."
5+
author: Randy Fay
6+
featureImage:
7+
src: /img/blog/2025/07/ddev-hostname-security.jpg
8+
alt: DDEV v1.24.7 introduces enhanced security with the dedicated ddev-hostname binary
9+
caption: "DDEV v1.24.7 introduces enhanced security with the dedicated ddev-hostname binary"
10+
categories:
11+
- Announcements
12+
- DevOps
13+
---
14+
15+
> **TL;DR**: The new binary `ddev-hostname` shipped with DDEV now takes care of `hosts` file editing when needed. `hosts` editing only happens when you use a non-`ddev.site` URL.
16+
17+
One of the core principles of secure software development is the **principle of least privilege**: give a program only the minimal permissions it needs to do its job. With DDEV v1.24.7, we've taken a significant step forward in applying this principle to how DDEV manages hostname resolution on your development machine.
18+
19+
**If you don't use an alternate top-level-domain (TLD) or custom FQDNs, you won't notice any changes here.** Read on, but DDEV will continue to work as it always has for most users.
20+
21+
## Why DDEV Sometimes Needs Elevated Privileges
22+
23+
Most of the time, DDEV projects work seamlessly with URLs like `https://yourproject.ddev.site` without any special setup. That's because DDEV maintains DNS records for `ddev.site` and all its subdomains that resolve to `127.0.0.1` (your local machine). As long as you have an internet connection, your browser can look up these hostnames automatically.
24+
25+
However, there are situations where DDEV needs to edit your system's `hosts` file (`/etc/hosts` on Linux/macOS or `C:\Windows\System32\drivers\etc\hosts` on Windows):
26+
27+
- When you don't have an internet connection
28+
- When your DNS is broken or blocks `127.0.0.1` resolution (DNS rebinding protection)
29+
- When you use custom hostnames with `additional_fqdns` that aren't under `ddev.site`
30+
- When you've configured a `project_tld` other than the default `ddev.site` or disabled DNS with `use_dns_when_possible: false`
31+
32+
For a deeper dive into how DDEV hostname resolution works, see our detailed guide on [DDEV name resolution and wildcards](ddev-name-resolution-wildcards.md).
33+
34+
## The Security Challenge: Minimal Elevated Access
35+
36+
When DDEV does need to edit the `hosts` file, it requires elevated permissions (root on Linux/macOS, Administrator on Windows). This is the **only** thing DDEV does with elevated privileges—but from a security perspective, how we handle that elevation matters a lot.
37+
38+
Previously, the main DDEV binary—which handles containers, databases, files, and many other tasks—also had to manage hostname editing with elevated permissions. When you elevate privileges for one specific task (editing `hosts` files), you want to minimize what else that elevated process can do. The old approach meant a larger binary with more dependencies running with elevated permissions, increasing the potential attack surface.
39+
40+
## The Solution: Meet ddev-hostname
41+
42+
DDEV v1.24.7 introduces a new dedicated `ddev-hostname` (and `ddev-hostname.exe` for Windows and WSL2) binary that handles hostname management exclusively. This specialized tool follows the security principle of least privilege in several important ways:
43+
44+
### Minimal Capabilities
45+
46+
The `ddev-hostname` binary has been stripped down to do exactly one thing: manage hostname entries in your system's `hosts` file. It doesn't include Docker utilities, global configuration management, or the dozens of other features that the main DDEV binary provides.
47+
48+
### Reduced Attack Surface
49+
50+
By removing unnecessary dependencies, we shrunk the `ddev-hostname` binary significantly. More important, though, we eliminated dependencies on several libraries that were previously included in the main DDEV binary but aren't needed for hostname management.
51+
52+
Each removed dependency is one less potential entry point for security vulnerabilities in the elevated binary.
53+
54+
### Platform-Specific Security
55+
56+
The new implementation provides native elevation techniques for each platform instead of relying on third-party tools like `gsudo.exe` on Windows. This reduces external dependencies and gives us better control over the security model.
57+
58+
## Special Benefits for WSL2 Users
59+
60+
If you're using DDEV with Windows WSL2, you'll especially appreciate another improvement that comes with these changes. The new `ddev-wsl2` package provides the Windows-side binaries you need, including `ddev-hostname.exe` and `mkcert.exe`, directly within your Linux distro.
61+
62+
This means **you no longer need to install DDEV on the Windows side** when using WSL2. The `ddev-wsl2` package gives you everything you need for proper WSL2 integration with Windows hostname and certificate management.
63+
64+
To install it:
65+
66+
```bash
67+
sudo apt-get update && sudo apt-get install ddev-wsl2
68+
# or sudo dnf install --refresh ddev-wsl2
69+
```
70+
71+
This streamlines the WSL2 setup process significantly and ensures you always have the correct versions of these critical utilities.
72+
73+
## What This Means for You
74+
75+
As a DDEV user, these changes are largely transparent—your development workflow remains the same. But under the hood, you're now benefiting from:
76+
77+
1. **Better security**: Elevated processes now have minimal capabilities and smaller attack surfaces.
78+
2. **Simpler WSL2 setup**: No need for Windows-side DDEV installation.
79+
3. **More reliable hostname management**: Native platform elevation instead of third-party tools.
80+
81+
## The Bigger Picture
82+
83+
These improvements reflect our ongoing commitment to making DDEV not just powerful and easy to use, but also secure by design. By applying established security principles like least privilege and minimal attack surface, we're building a development tool that you can trust with your local environment.
84+
85+
## Getting Started
86+
87+
DDEV v1.24.7 with these security improvements is [available now](https://github.com/ddev/ddev/releases). If you're using WSL2, install the new `ddev-wsl2` package.
88+
89+
As always, we'd love to hear your feedback on these changes. Join us on [Discord](/s/discord) to share your experience or ask questions about the new hostname management approach.
90+
91+
---
92+
93+
_Follow our [blog](https://ddev.com/blog/), [LinkedIn](https://www.linkedin.com/company/ddev-foundation), [Mastodon](https://fosstodon.org/@ddev), and join us on [Discord](/s/discord). And we'd love to have you sign up for the [monthly newsletter](/newsletter)._

src/content/blog/ddev-name-resolution-wildcards.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Hostnames and Wildcards and DDEV, Oh My!"
33
pubDate: 2024-03-28
4-
modifiedDate: 2024-03-29
4+
modifiedDate: 2025-07-21
55
summary: How hostname name resolution works in a DDEV environment, including how wildcards work and how DNS is involved
66
author: Randy Fay
77
featureImage:
@@ -16,7 +16,7 @@ A very cool thing about DDEV is that most of the time you don’t have to worry
1616

1717
**Most of you will never need to understand anything in this article.**
1818

19-
This article attempts to unwind what DDEV does for you in name resolution, and what to do when things require a bit more effort.
19+
This article attempts to unwind what DDEV does for you in name resolution, and what to do when things require a bit more effort. People who use `ddev.site` URLs and have working DNS will never think about any of these things.
2020

2121
## Name resolution for browsers and URLs
2222

@@ -34,7 +34,7 @@ DDEV's `ddev-router` uses the hostname in the URL to determine which project wil
3434

3535
## How DDEV hostnames get resolved
3636

37-
DDEV URLs have to have a hostname that a browser is able to resolve. How do we accomplish that? How can we get a URL like `https://something.ddev.site`?
37+
DDEV URLs have to have a hostname that a browser is able to resolve. How do we achieve that? How can we get a URL like `https://something.ddev.site`?
3838

3939
When a browser tries to resolve `https://something.ddev.site` it looks up the hostname `something.ddev.site`. That is usually a lookup in the Domain Name System (DNS). You don't have to know about DNS to understand that. The browser asks the internet "What does `something.ddev.site` resolve to, and the internet DNS system says "Oh, anything with `ddev.site` has the IP address `127.0.0.1`". So the browser knows how to reach and connect to your local machine - that is what `127.0.0.1` or `localhost` always stands for. This process is invisible to you, and works because the DDEV project maintains the DNS records for `ddev.site` on the internet. You don't have to know it and you don't have to think about it.
4040

@@ -44,9 +44,9 @@ Your domain `ddev.site` as well as every subdomain, like `you.ddev.site` and `so
4444

4545
## What happens when you don't have an internet connection?
4646

47-
When no internet connection available, or the DNS name resolution is broken, as a fallback DDEV tries to add the hostname to your `hosts` file during startup (`ddev start`). This is `/etc/hosts` on a Linux or macOS based machine and `C:\Windows\system32\drivers\etc\hosts` on a Windows based one. This is one of the very few times that DDEV will ever try to change the configuration of your local workstation. In general, the philosophy is never to do that. DDEV knows how to edit the hosts file properly and does it when you give it permission with your `sudo` password.
47+
When no internet connection available, or the DNS name resolution is broken, as a fallback DDEV tries to add the hostname to your `hosts` file during startup (`ddev start`). This is `/etc/hosts` on a Linux or macOS based machine and `C:\Windows\system32\drivers\etc\hosts` on a Windows based one. This is one of the very few times that DDEV will ever try to change the configuration of your local workstation. In general, the philosophy is never to do that. DDEV knows how to edit the `hosts` file properly and does it when you give it permission with your `sudo` password.
4848

49-
If you _lose_ your internet connection after `ddev start`, then your browser is going to struggle because it doesn't have a way to resolve the hostname. This can happen when you are, for example, working on a project and get on a plane. `ddev restart` will force the update of the hosts file, `ddev hostname` can do that directly, or you can manually edit the hosts file.
49+
If you _lose_ your internet connection after `ddev start`, then your browser is going to struggle because it doesn't have a way to resolve the hostname. This can happen when you are, for example, working on a project and get on a plane. `ddev restart` will force the update of the `hosts` file, `ddev hostname` can do that directly, or you can manually edit the `hosts` file.
5050

5151
## Why does my project use `ddev.site` anyway?
5252

@@ -63,7 +63,7 @@ However, wildcards don't work in `/etc/hosts` so DDEV has no way to provide a re
6363
Of course. There are two easy ways:
6464

6565
1. Turn off the use of DNS in your `.ddev/config.yaml` by adding `use_dns_when_possible: false`
66-
2. Use a different `project_tld`. If you are using for example `project_tld: example.site` then DDEV will try to use `<projectname>.example.site` for your projects. Since that is not resolvable, DDEV will resort to using hosts file manipulation.
66+
2. Use a different `project_tld`. If you are using, for example, `project_tld: example.site` then DDEV will try to use `<projectname>.example.site` for your projects. Since that is not resolvable, DDEV will resort to using `hosts` file manipulation.
6767

6868
## Can I use my own local-machine DNS?
6969

@@ -79,24 +79,24 @@ Yes, if you have the ability to configure an internet DNS zone, you can set it u
7979

8080
## What happens on WSL2 and why do I have to take action on the Windows side?
8181

82-
On WSL2, when you don't have internet, or your DNS is broken, or you're using a hostname that can't be looked up in DNS, DDEV has to request the hosts file change from the Windows side of things, because your _browser_ is almost always running on Windows, so editing the hosts file on the Windows side is what has to happen. The way DDEV currently does this is requests a **Windows** version of `ddev.exe` to escalate and edit the hosts file. That's why WSL2 installations also ask you to install Windows DDEV using `choco install -y ddev`.
82+
On WSL2, when you don't have internet, or your DNS is broken, or you're using a hostname that can't be looked up in DNS, DDEV has to request the `hosts` file change from the Windows side of things, because your _browser_ is almost always running on Windows, so editing the `hosts` file on the Windows side is what has to happen. The way DDEV does this is to invoke `ddev-hostname.exe`, a small **Windows** binary, to escalate and edit the `hosts` file. `ddev-hostname.exe` is normally part of the extra `ddev-wsl2` package. See [Enhanced Security with DDEV's New `ddev-hostname` Binary](ddev-hostname-security-improvements.md) for more information.
8383

84-
## No matter what, DDEV always wants to edit my hosts file (No DNS Rebinding)
84+
## No matter what, DDEV always wants to edit my `hosts` file (No DNS Rebinding)
8585

8686
There is one DNS server configuration that disallows looking up any hostname that resolves to `127.0.0.1`. It's called preventing [DNS Rebinding](https://en.wikipedia.org/wiki/DNS_rebinding), and it happens most often to European users who have Fritzbox routers. The fix for this is covered in the [DDEV Docs](https://ddev.readthedocs.io/en/stable/users/usage/troubleshooting/#dns-rebinding-prohibited-mostly-on-fritzbox-routers) and it's easy and will make your life much easier.
8787

88-
However, if you don't have control over your router, there's another easy fix, and that is to use a trusted DNS server outside your network. To do this, you would change your DNS server on your computer to `1.1.1.1` for Cloudflare's public DNS server, or `8.8.8.8` for Google's public DNS. Those will both do ordinary DNS resolution. There are lots of articles on the internet explaining how to change your computer's DNS servers, [here's one of them](https://www.hellotech.com/guide/for/how-to-change-dns-server-windows-mac). Unless you're on a corporate network with private DNS, this is unlikely to cause you any trouble and may resolve other difficulties, like removing some advertisements.
88+
However, if you don't have control over your router, there's another easy fix, and that is to use a trusted DNS server outside your network. To do this, change the DNS server configuration on your computer to `1.1.1.1` for Cloudflare's public DNS server, or `8.8.8.8` for Google's public DNS. Those will both do ordinary DNS resolution. There are lots of articles on the internet explaining how to change your computer's DNS servers, [here's one of them](https://www.hellotech.com/guide/for/how-to-change-dns-server-windows-mac). Unless you're on a corporate network with private DNS, this is unlikely to cause you any trouble and may resolve other difficulties, like removing some advertisements.
8989

9090
## How can I tell if `ddev.site` name resolution is broken?
9191

9292
Try `ping -c 1 test.ddev.site`. If it doesn't ping `127.0.0.1`, it is broken. Please see the [above](#no-matter-what-ddev-always-wants-to-edit-my-hosts-file-no-dns-rebinding) for troubleshooting and resolution.
9393

9494
## What about using `additional_fqdns` in DDEV configuration?
9595

96-
DDEV provides `additional_hostnames`, which works nicely most of the time, but there is also `additional_fqdns`. With a setting like `additional_fqdns: [one.two.example.com]` a DDEV project will respond to `https://one.two.example.com`, but DDEV will need to add `one.two.example.com` to the hosts file for it to work. The [docs](https://ddev.readthedocs.io/en/stable/users/configuration/config/#additional_hostnames) explain how to use it and what the consequences are.
96+
DDEV provides `additional_hostnames`, which works nicely most of the time, but there is also `additional_fqdns`. With a setting like `additional_fqdns: [one.two.example.com]` a DDEV project will respond to `https://one.two.example.com`, but DDEV will need to add `one.two.example.com` to the `hosts` file for it to work. The [docs](https://ddev.readthedocs.io/en/stable/users/configuration/config/#additional_hostnames) explain how to use it and what the consequences are.
9797

98-
Be exceptionally careful with "masking" real sites this way. It can be really confusing to add for example `additional_fqdns: [www.google.com]` to your configuration, because DDEV will then put `www.google.com` into your hosts file and you'll no longer be able to reach Google.
98+
Be exceptionally careful with "masking" real sites this way. It can be really confusing to add for example `additional_fqdns: [www.google.com]` to your configuration, because DDEV will then put `www.google.com` into your `hosts` file and you'll no longer be able to reach Google.
9999

100100
## Keep in touch!
101101

102-
I'd love to hear your experience. Join us in [Discord](/s/discord) or [open an issue](https://github.com/ddev/ddev/issues) or send [an email](mailto:support%40ddev.com) if you have success (or failure 😀). We're always trying to make DDEV better for you.
102+
I'd love to hear your experience. Join us in [Discord](/s/discord) or [open an issue](https://github.com/ddev/ddev/issues) if you have success (or failure 😀). We're always trying to make DDEV better for you.

0 commit comments

Comments
 (0)