Commit 8dad8eb
committed
fix(dstack-ingress): verify delegated records with dnsguide, not a second checker
Challenge delegation (#104) grew its own CAA check: one DoH resolver,
`grep -F` over the rdata, refuse to start if the record is not found.
Three problems, all of which dnsguide.py already handles because
tls-alpn-01 hit them first.
Public resolvers cache *negative* answers for the zone's SOA minimum, up
to an hour, so a resolver asked before the operator created the record
keeps reporting it absent long after it exists. Combined with failing
closed, that is a container refusing to start over a record that is
there.
The failure asymmetry ran the wrong way, too: an unreachable resolver
warned and continued -- no CAA protection at all -- while a stale cache
was fatal. The cheap failure was treated as serious and the serious one
as cosmetic.
And `grep -F` only matches presentation-form rdata, which is what
dns.google returns. Adding a second resolver for the first problem would
have quietly broken it, because Cloudflare answers CAA in RFC 3597
generic hex; a literal match fails, and failing closed turns that into an
outage.
dnsguide.py queries two resolvers with union quorum, parses both wire
formats, and is unit-tested against strings real resolvers returned. Use
it. Delegation also stops printing its own record list, since printing
operator-managed records is what that tool is for.
Two additions were needed:
- `challenge-cname`, the `_acme-challenge` CNAME that makes delegation
work. It gets an exact-match check rather than the gateway CNAME's:
check_alias falls back to comparing addresses so a flattened apex ALIAS
is not rejected, but a delegation target holds only a TXT, so there is
no address and its absence would be reported as "hostname does not
resolve yet".
- `--caa-advisory`, so ALLOW_MISSING_CAA still downgrades a failing CAA
check to a warning.
Delegation gains DNS_SETUP_MODE from the same change. `wait` is the
useful one: the operator can start the container and create the records
while it waits, instead of the container failing on the first look. The
routing records are now verified *before* the first issuance rather than
after, so a first deployment no longer spends an ACME attempt on records
nobody has created yet.
Two smaller fixes in the same area:
- `unset_txt_record` returned success when the zone lookup failed, because
`get_dns_records` returns `[]` for both "no records" and "could not
look". Observed as `Error: Could not find zone` immediately followed by
`Successfully unset TXT record`, exit 0.
- `_ensure_zone_id` returned the *previously cached* zone id when a lookup
failed, so a write meant for one zone could land in another. Not
currently reachable — `dnsman.py` runs fresh per call — but delegation
is precisely the feature that makes "which zone are we writing to" a
security property.
Refs #106.1 parent ab6d7e1 commit 8dad8eb
6 files changed
Lines changed: 213 additions & 86 deletions
File tree
- custom-domain/dstack-ingress
- scripts
- dns_providers
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
176 | | - | |
177 | | - | |
178 | | - | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
| |||
193 | 193 | | |
194 | 194 | | |
195 | 195 | | |
196 | | - | |
| 196 | + | |
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
229 | 228 | | |
230 | 229 | | |
231 | 230 | | |
| |||
235 | 234 | | |
236 | 235 | | |
237 | 236 | | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
238 | 244 | | |
239 | 245 | | |
240 | 246 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | 79 | | |
90 | 80 | | |
91 | 81 | | |
| |||
105 | 95 | | |
106 | 96 | | |
107 | 97 | | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | 98 | | |
115 | 99 | | |
116 | 100 | | |
| |||
121 | 105 | | |
122 | 106 | | |
123 | 107 | | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
139 | 119 | | |
140 | 120 | | |
141 | | - | |
142 | | - | |
143 | 121 | | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
169 | 134 | | |
170 | 135 | | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
176 | 145 | | |
177 | | - | |
178 | | - | |
179 | | - | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
180 | 153 | | |
181 | 154 | | |
182 | 155 | | |
183 | 156 | | |
184 | 157 | | |
185 | | - | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
186 | 161 | | |
187 | | - | |
| 162 | + | |
188 | 163 | | |
189 | 164 | | |
190 | 165 | | |
| |||
223 | 198 | | |
224 | 199 | | |
225 | 200 | | |
226 | | - | |
227 | | - | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
228 | 213 | | |
229 | 214 | | |
230 | 215 | | |
| |||
Lines changed: 23 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
247 | 248 | | |
248 | 249 | | |
249 | 250 | | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
250 | 260 | | |
251 | 261 | | |
252 | 262 | | |
| |||
259 | 269 | | |
260 | 270 | | |
261 | 271 | | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
262 | 284 | | |
263 | | - | |
| 285 | + | |
264 | 286 | | |
265 | 287 | | |
266 | 288 | | |
| |||
Lines changed: 10 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
161 | | - | |
162 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
163 | 168 | | |
164 | 169 | | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
165 | 173 | | |
166 | 174 | | |
167 | 175 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
65 | 70 | | |
66 | 71 | | |
67 | 72 | | |
| |||
156 | 161 | | |
157 | 162 | | |
158 | 163 | | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
159 | 175 | | |
160 | 176 | | |
161 | 177 | | |
| |||
324 | 340 | | |
325 | 341 | | |
326 | 342 | | |
| 343 | + | |
327 | 344 | | |
328 | 345 | | |
329 | 346 | | |
330 | 347 | | |
331 | 348 | | |
332 | 349 | | |
333 | 350 | | |
334 | | - | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
335 | 355 | | |
336 | 356 | | |
337 | | - | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
338 | 361 | | |
339 | 362 | | |
340 | 363 | | |
| |||
359 | 382 | | |
360 | 383 | | |
361 | 384 | | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
362 | 400 | | |
363 | 401 | | |
364 | 402 | | |
| |||
385 | 423 | | |
386 | 424 | | |
387 | 425 | | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
388 | 436 | | |
389 | 437 | | |
390 | 438 | | |
| |||
401 | 449 | | |
402 | 450 | | |
403 | 451 | | |
404 | | - | |
| 452 | + | |
| 453 | + | |
405 | 454 | | |
406 | 455 | | |
407 | 456 | | |
| |||
434 | 483 | | |
435 | 484 | | |
436 | 485 | | |
437 | | - | |
| 486 | + | |
438 | 487 | | |
439 | 488 | | |
440 | 489 | | |
| |||
0 commit comments