Skip to content

Commit 2ac1323

Browse files
TMHSDigitalclaude
andcommitted
Add Lab 10: a dangling CNAME (#450)
The labs had no exercise for the most common finding, a CNAME to a deleted app on a hosting provider. lab10-dangling-cname.zone has two such aliases (Heroku, GitHub Pages), one to a gone host on no known provider, and one working alias, so -type A,CNAME shows dangling:<provider>, plain dangling and no hint side by side. Register it in the -simulate-zone help, README, the site flag table and unreleased.yml, write its docs/labs.md section with an answer key, and add a CLI test. Built-in scenarios are now sorted by lab number, so lab10 follows lab9 in listings. Drop the leftover unreleased tags of values v0.12.0 shipped (lab7-lab9, type=SRV, type=HTTPS), which the tag check flags once the values list is not empty. Fixes #450 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 933ad25 commit 2ac1323

11 files changed

Lines changed: 120 additions & 9 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
- Lab 10, a dangling CNAME (`-simulate-zone lab10`): two aliases for deleted apps on Heroku and GitHub Pages are flagged `dangling:heroku` and `dangling:github-pages` with `-type A,CNAME`, a third to a gone host on no known provider is plain `dangling`, and a working alias has no hint. Built-in scenarios are now listed by lab number (#450).
12+
1013
### Changed
1114
- The GitHub Action installs the release that matches it by default: the tag it is pinned to (`uses: TMHSDigital/subenum@v0.12.0`), or for a commit SHA or branch the release its `action.yml` shipped with, instead of the newest release, so a pinned action no longer runs against a binary it was never tested with. `version: latest` still installs the newest release when set (#462).
1215

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ This table describes `main`, which can be ahead of the latest release: a release
313313
| `-simulate` | `false` | Simulation mode: no real DNS queries |
314314
| `-hit-rate <n>` | `15` | Simulated resolution rate, percent (1-100), applied uniformly to every name |
315315
| `-seed <n>` | `0` | Simulation seed; the same seed reproduces the same results (line order can vary unless `-t 1`). `0` picks a random seed and prints it |
316-
| `-simulate-zone <file>` | n/a | Lab mode: answer every query from a scenario file, or a built-in scenario such as `lab1` (`lab1`-`lab9`, with their own wordlist when `-w` is not given), via a local DNS server on `127.0.0.1`; no traffic leaves the machine. See [Labs](docs/labs.md) |
316+
| `-simulate-zone <file>` | n/a | Lab mode: answer every query from a scenario file, or a built-in scenario such as `lab1` (`lab1`-`lab10`, with their own wordlist when `-w` is not given), via a local DNS server on `127.0.0.1`; no traffic leaves the machine. See [Labs](docs/labs.md) |
317317
| **Modes** | | |
318318
| `-tui` | `false` | Launch the interactive Terminal UI |
319319
| `-dry-run` | `false` | Print the plan without scanning: candidates after dedupe and `-exclude`, query and duration estimates (at `-rate`, or `-rate-per-resolver` times the `-r` pool size when that is lower), and the resolver preflight (its only DNS query, also sent once to each `-r` pool resolver, paced by `-rate` and skipped for a target `-exclude` rules out; a failing pool resolver is reported but does not fail the run), then exit; JSON with `-format json` or `jsonl` |

‎docs/_data/unreleased.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
commands: []
88
flags: []
99
# new values of a flag that is itself released, as flag=VALUE (#306)
10-
values: []
10+
values:
11+
- simulate-zone=lab10
1112
# action.yml inputs and outputs
1213
action: []
1314
# pkg/subenum identifiers

‎docs/_includes/flags.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
| `-show-records` | - | In text format, append each result's records (TYPE=value) |
4747
| `-silent` | - | Pipeline mode: bare result names on stdout, and only errors (and a simulation warning) on stderr |
4848
| `-simulate` | - | Run in simulation mode without actual DNS queries (for testing) |
49-
| `-simulate-zone <string>` | - | Lab mode: answer every query from this scenario file, or a built-in scenario such as lab1 (lab1-lab6, lab7, lab8, lab9), via a local DNS server, so no traffic leaves the machine (see the Labs page) |
49+
| `-simulate-zone <string>` | - | Lab mode: answer every query from this scenario file, or a built-in scenario such as lab1 (lab1-lab6, lab7, lab8, lab9, lab10), via a local DNS server, so no traffic leaves the machine (see the Labs page) lab10: {% include unreleased.html value="simulate-zone=lab10" %} |
5050
| `-sources <string>` | - | Comma-separated keyless passive sources whose names become candidates and -permute seeds: ct (Certificate Transparency, crt.sh), wayback (Wayback Machine), certspotter (Certificate Transparency, SSLMate Cert Spotter; up to 10 pages, set CERTSPOTTER\_API\_KEY for a higher quota); one HTTPS request per source and target |
5151
| `-srv` | - | Also look up a built-in list of about 50 service names (\_sip.\_tcp, \_autodiscover.\_tcp, \_ldap.\_tcp, ...) under each target; needs SRV in -type |
5252
| `-state <string>` | subenum-resume.json | Where a run that was interrupted, ran out of -max-duration or was aborted saves its state for -resume |

‎docs/labs.md‎

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ subenum -simulate-zone lab6 -type AAAA -show-records lab.example
201201

202202
</details>
203203

204-
## Lab 7: a zone transfer{% include unreleased.html value="simulate-zone=lab7" %}
204+
## Lab 7: a zone transfer
205205

206206
```bash
207207
subenum -simulate-zone lab7 -format jsonl lab.example
@@ -233,7 +233,7 @@ server, never to the name server's real address.
233233

234234
</details>
235235

236-
## Lab 8: an NSEC walk{% include unreleased.html value="simulate-zone=lab8" %}
236+
## Lab 8: an NSEC walk
237237

238238
```bash
239239
subenum -simulate-zone lab8 -format jsonl lab.example
@@ -266,7 +266,7 @@ the walk goes to the lab server.
266266

267267
</details>
268268

269-
## Lab 9: a dangling delegation{% include unreleased.html value="simulate-zone=lab9" %}
269+
## Lab 9: a dangling delegation
270270

271271
```bash
272272
subenum -simulate-zone lab9 -format jsonl lab.example
@@ -300,6 +300,43 @@ server.
300300

301301
</details>
302302

303+
## Lab 10: a dangling CNAME{% include unreleased.html value="simulate-zone=lab10" %}
304+
305+
```bash
306+
subenum -simulate-zone lab10 -format jsonl lab.example
307+
subenum -simulate-zone lab10 -type A,CNAME -format jsonl lab.example
308+
```
309+
310+
`shop` and `docs` are aliases for apps on two hosting providers, Heroku and
311+
GitHub Pages, and both apps were deleted: the alias targets no longer exist.
312+
Whoever creates an app with the same name on the provider would serve those
313+
names, which is a subdomain takeover. `old` points at a host that is gone too,
314+
but on no provider subenum knows. `blog` is an alias that still works. In lab
315+
mode every name outside `lab.example` is NXDOMAIN, so the deleted apps behave
316+
as they would on the real providers.
317+
318+
1. Which names does the first run report, and why not the others?
319+
2. What does each name get as `takeover_candidate` in the second run?
320+
3. Why is `blog` not marked, although it is a CNAME too?
321+
322+
<details markdown="1">
323+
<summary>Answers</summary>
324+
325+
1. `www`, `mail` and `blog`. Without `CNAME` in `-type`, a name counts as
326+
found only when its A or AAAA lookup answers, and the A lookups of `shop`,
327+
`docs` and `old` follow the alias to a target that does not exist, so they
328+
end NXDOMAIN like a name that was never there.
329+
2. `shop` is `dangling:heroku` and `docs` is `dangling:github-pages`: the
330+
target does not exist and its suffix (`.herokudns.com`, `.github.io`)
331+
belongs to a provider where an unclaimed name can be registered. `old` is
332+
plain `dangling`: worth cleaning up, but there is no known provider to claim
333+
it on. The run-quality report counts all three in `takeover_candidates`.
334+
3. Its target, `www.lab.example`, exists, so there is nothing to claim. A CNAME
335+
to a provider whose target does exist is marked `provider:<name>` instead,
336+
a lead to check by hand rather than a finding.
337+
338+
</details>
339+
303340
## Writing your own scenario
304341

305342
A scenario is a plain text file. Names are relative to the domain you scan,

‎docs/library.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ These queries go to the domain's own name servers, not to `Resolver`, and they a
123123
| `Timeout` | `1s` | Bound on one lookup of one record type. |
124124
| `Attempts` | `1` | Tries per name. Only failures are retried, never NXDOMAIN. |
125125
| `Rate` | unlimited | Queries per second on the wire, counting every type, retry and probe. |
126-
| `Types` | `A`, `AAAA` | Record types: `A`, `AAAA`, `CNAME`, `NS`, `MX`, `TXT`, `SRV`{% include unreleased.html value="type=SRV" %} and `HTTPS`{% include unreleased.html value="type=HTTPS" %}. `CNAME`, `NS`, `SRV` and `HTTPS` (an AliasMode target) populate `Result.Takeover`. |
126+
| `Types` | `A`, `AAAA` | Record types: `A`, `AAAA`, `CNAME`, `NS`, `MX`, `TXT`, `SRV` and `HTTPS`. `CNAME`, `NS`, `SRV` and `HTTPS` (an AliasMode target) populate `Result.Takeover`. |
127127
| `Recursive`, `Depth` | off, `1` | Enumerate again under each name found. |
128128
| `MaxQueries` | unlimited | Cap on candidate names tested. |
129129
| `MaxDuration`{% include unreleased.html library="MaxDuration" %} | unlimited | Time budget from the start of `Run`, not counting the preflight and wildcard probes sent before the first candidate lookup, so `Run` can take longer. Then no new names are tested and the rest are counted in `Stats.Skipped`, with `Stats.Expired` set. |

‎docs/output.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ A test fails when a field is added to the code but not to these files, so they s
3535

3636
A run's results all carry the same time, taken when the run starts. Pass each run's JSONL or CSV file to the next run's `-diff` (as the [GitHub Action](monitoring.html) does with its baseline) and `first_seen` carries forward, so a takeover candidate or an internal address shows how long it has been there.
3737

38-
A record's `type` is `A`, `AAAA`, `CNAME`, `NS`, `MX`, `TXT`, `SRV`{% include unreleased.html value="type=SRV" %} or `HTTPS`{% include unreleased.html value="type=HTTPS" %}. Its `value` is an address, a host name (`CNAME`, `NS`), `<preference> <host>` (`MX`), the text (`TXT`), with a backslash and non-printable bytes written as `\DDD`, `<priority> <weight> <port> <target>` (`SRV`), or `<priority> <target>` followed by the `alpn` and `port` parameters, if any (`HTTPS`, such as `1 . alpn=h2,h3 port=443`; a target of `.` names no other host, and an AliasMode record, priority `0`, has no parameters).
38+
A record's `type` is `A`, `AAAA`, `CNAME`, `NS`, `MX`, `TXT`, `SRV` or `HTTPS`. Its `value` is an address, a host name (`CNAME`, `NS`), `<preference> <host>` (`MX`), the text (`TXT`), with a backslash and non-printable bytes written as `\DDD`, `<priority> <weight> <port> <target>` (`SRV`), or `<priority> <target>` followed by the `alpn` and `port` parameters, if any (`HTTPS`, such as `1 . alpn=h2,h3 port=443`; a target of `.` names no other host, and an AliasMode record, priority `0`, has no parameters).
3939

4040
## Results: CSV
4141

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Lab 10: a dangling CNAME. shop and docs are aliases for apps on hosting
2+
# providers (Heroku, GitHub Pages) that were deleted, so the alias targets no
3+
# longer exist: whoever claims the same app name on the provider would serve
4+
# shop.lab.example and docs.lab.example. old points at a host that is gone
5+
# but on no known provider; blog is an alias that still works. Run:
6+
# subenum -simulate-zone lab10 -type A,CNAME -format jsonl lab.example
7+
# Then run it again without -type and compare.
8+
@ A 192.0.2.1
9+
www A 192.0.2.10
10+
mail A 192.0.2.25
11+
blog CNAME www
12+
shop CNAME lab-shop.herokudns.com.
13+
docs CNAME lab-docs.github.io.
14+
old CNAME old-app.retired-host.example.

‎internal/cli/cli.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ func parseFlagsWith(args []string, applyDefaults func(*flag.FlagSet) error, stde
243243
fs.BoolVar(&f.testMode, "simulate", false, "Run in simulation mode without actual DNS queries (for testing)")
244244
fs.IntVar(&f.testHitRate, "hit-rate", scan.DefaultHitRate, "In simulation mode, percentage of names that resolve (1-100)")
245245
fs.Uint64Var(&f.seed, "seed", 0, "In simulation mode, seed for reproducible results (0 = random; the seed used is printed)")
246-
fs.StringVar(&f.simZone, "simulate-zone", "", "Lab mode: answer every query from this scenario file, or a built-in scenario such as lab1 (lab1-lab6, lab7, lab8, lab9), via a local DNS server, so no traffic leaves the machine (see the Labs page)")
246+
fs.StringVar(&f.simZone, "simulate-zone", "", "Lab mode: answer every query from this scenario file, or a built-in scenario such as lab1 (lab1-lab6, lab7, lab8, lab9, lab10), via a local DNS server, so no traffic leaves the machine (see the Labs page)")
247247
fs.Var(&f.outputs, "o", "Write results to `file` (in addition to stdout); repeat for several files, each in -format or in the format named as a prefix, format:path (jsonl:results.jsonl)")
248248
fs.IntVar(&f.attempts, "attempts", 0, "Total DNS resolution attempts per subdomain, 1 = no retry (default 1)")
249249
fs.IntVar(&f.retries, "retries", 0, "Deprecated: use -attempts instead")

‎internal/cli/delegation_test.go‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,46 @@ func TestE2ELabDanglingDelegation(t *testing.T) {
4242
t.Errorf("without NS: parent_checks %d, other %d; want 0 and 1", tg.ParentChecks, tg.Outcomes.Other)
4343
}
4444
}
45+
46+
// TestE2ELabDanglingCNAME covers #450 on the built-in Lab 10: with CNAME in
47+
// -type, shop and docs point at deleted apps on known providers and are
48+
// flagged dangling:<provider>, old points at a gone host on no provider and
49+
// is plain dangling, and blog, whose target exists, has no hint. Without
50+
// CNAME the three dangling names end NXDOMAIN and are not reported.
51+
func TestE2ELabDanglingCNAME(t *testing.T) {
52+
t.Parallel()
53+
wl := writeFile(t, "w.txt", "www\nblog\nshop\ndocs\nold\n")
54+
stats := filepath.Join(t.TempDir(), "run.json")
55+
args := append([]string{"-simulate-zone", "lab10", "-w", wl, "-format", "jsonl", "-progress=false", "-rate", "200", "-stats", stats}, labTimingArgs...)
56+
code, out := runCLIMerged(t, append(args, "-type", "A,CNAME", "lab.example")...)
57+
got := seenResults(t, lastJSONLines(out))
58+
want := map[string]string{
59+
"shop.lab.example": "dangling:heroku",
60+
"docs.lab.example": "dangling:github-pages",
61+
"old.lab.example": "dangling",
62+
"blog.lab.example": "",
63+
"www.lab.example": "",
64+
}
65+
for name, hint := range want {
66+
if r, ok := got[name]; !ok || r.Takeover != hint {
67+
t.Errorf("%s = %+v (found %v), want takeover_candidate %q", name, r, ok, hint)
68+
}
69+
}
70+
if code != exitOK || len(got) != len(want) {
71+
t.Fatalf("exit %d, %d results, want %d\n%s", code, len(got), len(want), out)
72+
}
73+
if tg := axfrSummary(t, stats).Targets[0]; tg.Takeover != 3 {
74+
t.Errorf("report: takeover_candidates %d, want 3", tg.Takeover)
75+
}
76+
77+
code, out = runCLIMerged(t, append(args, "lab.example")...)
78+
got = seenResults(t, lastJSONLines(out))
79+
for _, name := range []string{"shop.lab.example", "docs.lab.example", "old.lab.example"} {
80+
if _, ok := got[name]; ok {
81+
t.Errorf("without CNAME: %s reported, want it NXDOMAIN", name)
82+
}
83+
}
84+
if _, ok := got["blog.lab.example"]; code != exitOK || !ok {
85+
t.Errorf("without CNAME: exit %d, blog reported %v, want it found through its alias", code, ok)
86+
}
87+
}

0 commit comments

Comments
 (0)