Skip to content

Hosting & Infrastructure

DNS-01 automation without giving away your DNS account: least-privilege patterns

A token that can rewrite MX is the wrong token for ACME. Scope the write to the challenge name.

sslcertificates.io Engineering & Editorial · Published 25 August 2026 · Updated 22 September 2026 · 11 min read

DNS-01 automation without giving away your DNS account: least-privilege patterns — original technical illustration

The current problem

DNS-01 is the ACME challenge that proves control of a DNS zone by placing a TXT record at _acme-challenge.<name>. RFC 8555 requires it for wildcard certificates. It is also the challenge you use when port 80 will never answer, when a firewall will never allow a CA to your origin, or when you want to issue before a listener exists.

The failure mode is not the TXT record. The failure mode is the credential that creates it. Teams hand an ACME client a cloud account that can delete hosted zones, rewrite MX, change NS, or create email-forwarding records, because the first tutorial used AdministratorAccess or a Global API key and the certificate came back in thirty seconds. That credential lives in a CI variable, a Kubernetes Secret, or a panel integration. When it leaks, the attacker does not need your private key. They have your zone.

Shorter public lifetimes make the credential more active. From 15 March 2026 domain-control evidence may be reused for at most 200 days; from 15 March 2027, 100 days; from 15 March 2029, 10 days. DNS-01 writes will happen more often. A sloppy token that was used twice a year will be used weekly. The blast radius does not shrink with the certificate.

Why it matters

DNS is load-bearing for more than TLS. MX, SPF, DKIM, NS, and CDN records sit in the same zone object as _acme-challenge. A token scoped to “edit this zone” can take mail offline, redirect the website, or change CAA so a hostile CA becomes the only CA that will issue. Certificate automation should not be the path by which an organization grants that power to a cron job.

Least privilege is also how you survive vendor incidents and former contractors. An ACME-specific credential can be rotated without a war room. A global key cannot.

There is a third reason: cleanup. Clients that create TXT records and never delete them leave a growing set of stale challenges. Clients that delete “all TXT at _acme-challenge” will race a second issuance and will delete records they did not create. Privilege and cleanup are the same design: write only what you created, delete only what you created.

Technical background

The record. For a name app.example.com, HTTP-01 is unused; DNS-01 places a TXT at _acme-challenge.app.example.com. For a wildcard *.example.com, the TXT is at _acme-challenge.example.com — the same name as the apex challenge. RFC 8555 computes the TXT value as the base64url SHA-256 of the key authorization. The CA resolves the name from multiple vantage points and compares. Your laptop’s dig is not the CA.

CNAME delegation. _acme-challenge.app.example.com may be a CNAME to a name in a zone you do control, for example _acme-challenge.app.example.com. CNAME app.example.com.acme.example-ops.net.. The CA follows the CNAME (unless a broken resolver or DNSSEC configuration gets in the way). This is the standard way to avoid giving an ACME client write access to the production zone. The production zone is edited once, by a human or a tightly reviewed change, to create the CNAME. Ongoing writes happen in the dedicated zone.

CAA. CAA on the zone restricts which CAs may issue. A DNS-01 token that can edit CAA can relax that restriction. If the ACME credential can change CAA, it is not a challenge credential; it is a CA-policy credential.

DNSSEC. Signatures have to cover the TXT. Providers that automatically resign on record change are fine. Providers that require a separate sign step will fail validation in ways that look like “propagation.” Test with the same provider you will use in production.

Propagation. There is no Internet-wide TTL of 60 seconds. The CA’s resolvers may see a cached NXDOMAIN or an old TXT for minutes to hours. Your client should present the record, wait, then trigger validation — or retry on the CA’s error. Sleeping a constant two seconds is not a design.

Multi-perspective issuance checking. CAs are required, on a tightening schedule, to see the same challenge from more than one network. Split-horizon DNS that shows the TXT only to “the Internet” from one region, or only on IPv4, will fail. The least-privilege token does not fix that; the zone data must be consistent.

Provider APIs are not equal. Some APIs can scope a token to one zone and to DNS-record edit. Some can scope to a record-name prefix. Some can only scope to a project or account. The pattern is the same — ask for the narrowest write that can create and delete the challenge TXT — but the implementation is vendor-specific.

Operational consequences

Mail and traffic at risk. An over-broad token is an availability and integrity risk for every record in the zone, not only for TLS.

Audit gaps. When the same cloud user that provisions VMs also writes ACME TXT records, you cannot tell a legitimate renewal from a zone takeover in the API logs.

Wildcard concentration. One DNS-01 credential for *.example.com issues a certificate that covers every one-label name in the zone. Protect that credential like the private key.

Shared hosting. A panel that stores one DNS token for all customers is a cross-tenant incident. Scope per zone or per customer.

Stale TXT records. Extra TXT values at the same name are allowed by the protocol (multiple issuances, multiple CAs). Extra values that you do not recognize are a signal. Extra values that your cleanup deleted out from under another client are an outage.

Registrar vs. DNS host. The registrar account that can change NS is a worse credential than the DNS-host token that can edit records. ACME does not need the registrar. Keep those accounts separate.

IPv6 and split views. Validation failures that “work from the office” are usually views, firewalls, or missing AAAA, not token scope. Fix the data plane before widening the token.

Affected audiences

SRE and platform teams who put a DNS token in a secret store and hoped the tutorial was conservative. It was not.

Hosting providers who offer “DNS + SSL” and store a provider key that can edit every hosted zone.

SaaS companies who asked customers for a Cloudflare global key instead of a CNAME. The customer should refuse.

MSPs who keep client registrar logins in a shared password manager and use them for ACME. That is the opposite of least privilege.

Security and IAM who should treat DNS-write credentials as production secrets with rotation, ownership, and monitoring.

Implementation options

CNAME delegation to an ACME-only zone. Best privilege story. The production zone allows a CNAME; a dedicated zone, with a dedicated token, receives the TXT. Works across providers. Works when the production DNS host has no API.

Provider token scoped to one zone and to record edit. The practical pattern on Cloudflare (a token with Zone.DNS:Edit on a specific zone, not a Global API key). Similar ideas exist on other hosts: a role that can ChangeResourceRecordSets on one hosted zone (Amazon Route 53), a role that is DNS Zone Contributor on one zone (Azure DNS), a service account that can update record sets on one project or managed zone (Google Cloud DNS). Those are IAM patterns for teams who already use those DNS hosts. They are not a claim that every certificate platform’s REST integration includes every vendor.

Record-name prefix conditions. Where the IAM language allows “only names that start with _acme-challenge,” use it. Not every provider offers this. When they do, it is the correct next tightening after “one zone.”

Manual DNS-01. A human creates the TXT. Acceptable for a one-off wildcard on a zone with no API. Incompatible with 100-day and 47-day cadence except as a listed exception.

HTTP-01 instead. If you do not need a wildcard and you can serve port 80, you may not need a DNS token at all. Least privilege includes “no DNS write.”

rfc2136 / nsupdate with a TSIG key that can only update _acme-challenge.*. The original least-privilege DNS-01, still valid on operated BIND/PowerDNS.

On a lifecycle platform, REST DNS automation today is commonly manual presentation plus a Cloudflare connection when you store a scoped token. Other DNS hosts are typically a connect-your-account or out-of-band credential workflow, not a silent default of any one cloud DNS API. Design your runbooks to that fact.

Recommended practices

Create a dedicated identity for ACME. Do not reuse the identity that opens support tickets or provisions servers.

Scope to the smallest zone set. One token per zone is better than one token per company if the vendor allows it.

Prefer CNAME delegation when the production zone is sensitive (mail, payments, NS).

Never store a Global API key, a registrar login, or AdministratorAccess for ACME.

Delete only the TXT records the automation created. Correlate by value, not only by name.

Rotate tokens on a calendar and on personnel change. A 200-day validation-reuse world is not a reason to keep a three-year-old token.

Log creates and deletes. Alert on API calls from the ACME identity that touch MX, NS, CAA, or unexpected names.

Do not put the token in a git repository, a ticket, or a screenshot of the CI settings page.

Test the token by creating and deleting a harmless TXT in Staging-oriented practice (a dedicated test name), not by issuing a Production wildcard on the first try.

If two clients share a zone, give them different delegated names or accept that TXT at the same name will have multiple values. Document which client owns which value.

Keep CAA in a change process that the ACME token cannot perform.

Architecture and checklist

[production zone]  _acme-challenge.app  CNAME  app.acme-deleg.ops.example.
[ACME-only zone]   app.acme-deleg.ops.example  TXT  <keyAuthorization digest>
        ^
        │  token: create/delete TXT in ACME-only zone only
        │
[ACME client / control plane]

Alternative when delegation is impossible:

[production zone]  _acme-challenge.app  TXT  <digest>
        ^
        │  token: DNS edit on this zone, ideally name-prefix conditioned

Least-privilege checklist

  • Inventory every DNS token used for ACME: owner, scopes, age, last rotation.
  • Replace global keys and administrator roles.
  • One zone (or one delegated zone) per token where the vendor allows.
  • Token cannot edit MX, NS, or CAA unless you have a written exception.
  • Cleanup deletes by record identity, not “all TXT at this name.”
  • Wildcard issuances use a credential you treat like a private key.
  • Multi-tenant systems do not share a single DNS token across customers.
  • Propagation wait is measured, not guessed.
  • CAA is set and not writable by the ACME identity.
  • Let’s Encrypt Staging (Test) is used to prove the token path before Production (Live).
  • 15 March 2027 reuse cut (100 days) is in the rotation and monitoring plan.

Cloudflare-shaped example (industry pattern)

A token limited to Zone.DNS:Edit on the one zone you intend to issue for, created from a scoped-token UI, stored encrypted, and rotatable without changing the Global key. That is sufficient for DNS-01. A Global API key is sufficient for a zone-wide incident.

Route 53 / Azure DNS / Cloud DNS (industry patterns, not a platform default)

  • Route 53: an IAM policy that allows change on record sets in one hosted-zone ARN, not AdministratorAccess.
  • Azure DNS: a service principal with DNS Zone Contributor on one zone, not Owner on the subscription.
  • Google Cloud DNS: a service account that can update resource record sets on one managed zone, not Editor on the project.

Use these patterns in the cloud you already operate. Do not assume a certificate control plane’s hosted REST integration is Route 53 unless that connection is one you configured.

How platforms and tools can help

ACME clients (lego, Certbot dns plugins, cert-manager dns01 solvers) already speak many provider APIs. The client does not choose the token scope; you do. Read the plugin’s required permissions and cut everything else.

cert-manager’s CNAME strategy and webhook solvers exist so the cluster’s credential does not need to be the production-zone credential.

A control plane that presents a TXT for you to create by hand is a valid least-privilege design. Slower, narrower, honest.

Cloudflare and other DNS hosts document token templates. Use the DNS-edit template, then remove zones you do not need.

Do not confuse “the provider appears in a directory of integrations” with “a token is already scoped.” Connection is not privilege.

Where a lifecycle platform fits

Teams that already operate reliable ACME, deployment and monitoring may not need another issuance layer. If you already have a delegated ACME zone and a scoped token, keep them. A platform is useful when it will present and clean up TXT through a connection you choose — on many products that is a manual step or a Cloudflare token you store — and when it will not demand a registrar login. sslcertificates.io follows that shape: REST DNS automation is manual or Cloudflare; other DNS hosts are a connect-your-account workflow. The least-privilege work remains yours.

What to watch next

100-day and 10-day reuse (15 March 2027, 15 March 2029). More writes, more need for narrow tokens and reliable cleanup.

dns-persist-01. A persistent authorization record, if it becomes a standard CA challenge, would change how often you write TXT. It would not change the rule that the writer should be unable to edit MX.

CAA accounturi and validationmethods. More specific CAA makes a token that can edit CAA even more dangerous.

MPIC and DNSSEC edge cases. Validation will fail closed more often. Widening the token will not be the fix.

Provider IAM language. Cloud DNS hosts occasionally add record-prefix conditions. When they do, adopt them.

Sources

Related reading

Primary sources

Related reading

When a lifecycle platform is worth it

Teams that already operate reliable ACME, deployment and monitoring workflows may not need another issuance layer. A lifecycle platform becomes more useful when central state, multi-tenant operations, deployment verification or provider abstraction become operational requirements.

Start free Read the Product hub