Safeguard
Security Guides•

How do you limit DNS credentials for ACME DNS-01 validation?

Keep full DNS API keys off your web servers. Delegate the _acme-challenge name with a CNAME, scope credentials narrowly, or validate from a separate host.

Safeguard Security Team
3 min read

Do not put full DNS API credentials on a web server. Delegate the _acme-challenge name to a separate zone with a CNAME, use credentials limited to that zone, or run validation on a separate host and copy the certificate out. Then a hacked web server cannot rewrite your whole DNS.

The risk

DNS-01 proves control by writing a TXT record, so the ACME client needs a way to edit DNS. If that is a general API token on the same machine that serves traffic, an attacker who compromises the web server can change any record: mail, web, verification entries. Let's Encrypt's documentation says this significantly increases the impact of a compromise and recommends narrowly scoped credentials, or validating from a separate server.

Three safer patterns

PatternHow it worksTrade-off
Scoped tokenCredential can edit just the needed zone or recordsDepends on your DNS provider supporting scopes
CNAME delegation_acme-challenge points to a zone built for validationOne time DNS change, then a small zone to manage
Separate validator hostA host with the token gets the certificate and distributes itMore moving parts to deploy

CNAME delegation, step by step

Let's Encrypt follows DNS standards when it looks up the challenge TXT record, so a CNAME or NS record can hand the answering to another zone.

  1. Create a small dedicated zone, for example acme.example.net, at a provider with an API.
  2. In your main zone, create the record that points the challenge name at it:
_acme-challenge.app.example.com.  CNAME  app.acme.example.net.
  1. Give your ACME client credentials for the dedicated zone alone.
  2. Configure the client to write the TXT record there, following your client's documentation for delegated validation.
  3. Test it against staging. See staging.

The same trick helps when your main provider is slow to update. You can delegate to a quicker server.

Operating it

  • Propagation. Providers vary, and some need a wait of up to an hour unless their API reports when a change is live.
  • Cleanup. Multiple TXT records for one name are allowed, for example for a wildcard and a non-wildcard certificate together, but remove old ones, since an oversized response is rejected.
  • Failure counts. Typos in the CNAME are a frequent cause of failed authorizations. See rate limits.
  • Review. Treat the token like any production secret: rotate it, store it in a secret manager, and list who can read it.

Why it matters more soon

Shorter certificate lifetimes and shorter authorization reuse mean validation runs more often, which means credentials get used more often. See ARI and renewal timing.

Where Safeguard fits

Safeguard scans dependencies and SBOMs for known vulnerabilities, including those in the TLS and crypto libraries your projects pull in, and you can try it with the free scan at gold.safeguard.sh/scan.

Quick check

Can a CNAME really answer a DNS-01 challenge?

Yes. Let's Encrypt follows standard DNS lookups, so CNAME and NS records can delegate the challenge name.

Do I still need DNS-01 for wildcards?

Yes. Wildcard certificates require DNS-01.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.