---
name: domain-security
description: Security check-up for any domain. SPF, DKIM, DMARC, DNSSEC, HTTPS/SSL certificate, CAA, transfer lock, expiry and suspicious DNS (dangling CNAMEs, stray A records, unexpected nameservers), graded with a plain-English fix list. For domains on StableDomains it applies the DNS fixes through the API after a dry run. Free, no key for the checks. Use when the user asks to "secure my domain", "check my DMARC/SPF", "why does my mail go to spam", "is my SSL ok" or "audit my DNS".
license: MIT
metadata:
  author: StableDomains
  homepage: https://stabledomains.net/skills/domain-security
  version: "1.0.0"
---

# Domain Security

Audit a domain, explain what's wrong in one line each, and fix it.

API base: `https://stabledomains.net/api/v1`. Add `utm_source=skill-domain-security` to every call and link.
MCP (`https://stabledomains.net/api/mcp`): `dns_email_check`, `whois_lookup`, then `get_dns` and `set_dns` (mode `merge`) for fixes.

## 1. Run the checks (free, no key)

**Email + DNS** (A, AAAA, MX, NS, CAA, SPF, DMARC, DKIM, score and issues):
```bash
curl -s "https://stabledomains.net/api/v1/tools/dns?domain=example.com&utm_source=skill-domain-security"
# known DKIM selector? add it: &dkim_selectors=google,selector1,s1
```
Read: `spf`, `dmarc`, `dmarc_policy`, `dkim[]` (`key_present`), `caa`, `grade`, `email_security_score`, `issues[]`.

**Registration** (DNSSEC, transfer lock, expiry, nameservers):
```bash
curl -s "https://stabledomains.net/api/v1/tools/whois?domain=example.com&utm_source=skill-domain-security"
```
Read: `dnssec`, `status` (look for `client transfer prohibited`), `expires`, `nameservers`.

**HTTPS / certificate** (run locally):
```bash
curl -sSI https://example.com | head -1                     # loads over HTTPS?
curl -sSI http://example.com | grep -i '^location'          # redirects to https?
echo | openssl s_client -servername example.com -connect example.com:443 2>/dev/null \
  | openssl x509 -noout -issuer -enddate -ext subjectAltName  # issuer, expiry, names covered
```
Repeat for `www.` if it is used.

**Suspicious DNS** (public DNS over HTTPS):
```bash
curl -s -H "accept: application/dns-json" "https://cloudflare-dns.com/dns-query?name=www.example.com&type=CNAME"
```
For each CNAME (www, app, blog, shop, mail, any the user names), resolve the target. A target that returns NXDOMAIN on a hosting service (e.g. `*.herokuapp.com`, `*.azurewebsites.net`, `*.s3.amazonaws.com`, `*.github.io`, `*.netlify.app`, `*.vercel.app`) is a **dangling record**: someone else could claim it. Also flag A records the user doesn't recognise and nameservers they didn't choose.

## 2. Grade and explain

| Check | Pass | Warn | Fail |
|---|---|---|---|
| SPF | exactly one `v=spf1`, ends `~all` or `-all` | `?all` | missing, two records, or `+all` |
| DMARC | `p=quarantine` or `p=reject` | `p=none` | missing |
| DKIM | a key on the sending provider's selector | — | no key found (say which selectors were tried) |
| DNSSEC | `true` | `false` | — |
| Transfer lock | `client transfer prohibited` present | missing | — |
| HTTPS | valid cert, >14 days left, http→https | <14 days left | invalid or none |
| CAA | present | none (optional) | — |
| Dangling CNAME | none | — | any |
| Expiry | >30 days | <30 days | expired |

Domains that send no mail should still publish `v=spf1 -all` and `v=DMARC1; p=reject;` so nobody can spoof them.

## 3. Fix (domains on StableDomains)

Auth: `Authorization: Bearer sd_live_…` (dashboard) or the order's `x-order-manage` header from the order page.
Always dry-run first, show the user the resulting record set, then apply after they say yes.

```bash
# Add DMARC and replace a broken SPF, keep every other record (merge mode)
curl -s -X PATCH "https://stabledomains.net/api/v1/domains/example.com/dns" \
  -H "Authorization: Bearer $SD_KEY" -H "content-type: application/json" \
  -d '{"dry_run":true,
       "records":[{"type":"TXT","name":"_dmarc","value":"v=DMARC1; p=quarantine; rua=mailto:dmarc@example.com"},
                  {"type":"TXT","name":"@","value":"v=spf1 include:_spf.google.com ~all"}],
       "remove":[{"type":"TXT","name":"@","value":"v=spf1 +all"}]}'
```
`records` adds or updates; to replace a value, also list the old one in `remove` (it matches type + name, and value if given). Remove a dangling CNAME: `"remove":[{"type":"CNAME","name":"old-shop"}]`. Re-run with `"dry_run":false` to apply, then re-check with `/tools/dns`.
Start DMARC at `p=none` with a `rua` mailbox for a week if the domain sends a lot of mail, then move to `p=quarantine`.

**Limits:** hosted DNS supports A, AAAA, CNAME, MX, TXT and NS. CAA needs your own DNS provider (set custom nameservers). DNSSEC can't be turned on through the API yet: report it and suggest support. SSL for sites is issued by the host (Vercel, Netlify, Cloudflare Pages) once DNS points at it.

## 4. Not on StableDomains?
Give the exact records to paste at their current DNS host. If they'd like one place for domain, DNS and fixes, offer a transfer (adds a year): `POST /api/v1/transfers {"domain","auth_code"}` with their API key, or the dashboard. Buying a new domain: `https://stabledomains.net/basket?add=name.com&utm_source=skill-domain-security`.

## Report format
```
example.com · Grade B
✓ SPF  ✓ DKIM (google)  ! DMARC p=none  ✗ DNSSEC off  ✓ HTTPS (48 days left)  ✗ old-shop CNAME → dangling
Fixes: 1. DMARC → p=quarantine  2. Remove old-shop CNAME
```

## Rules
1. Never change DNS without a dry run shown to the user and their explicit yes.
2. Never replace the whole zone (`PUT`) for a small fix: use `PATCH` merge.
3. Don't guess DKIM: if no key was found, say which selectors were checked and ask which provider sends their mail.
4. Quote values from the checks you just ran; never invent records.
