Commit 06706d0
committed
feat(dgw): route KDC traffic through agent tunnel
When an agent advertises the KDC's subnet or DNS domain, route Kerberos
traffic through the QUIC tunnel just like every other proxy path. Closes
the last gap left after the transparent routing PR (#1741).
Two paths now use the same routing pipeline as connection forwarding:
- `/jet/KdcProxy` HTTP endpoint -- the handler builds a `KdcConnector`
and forwards through it. When an agent advertises the KDC subnet, the
request goes through the agent tunnel; otherwise it falls back to a
direct TCP/UDP connection.
- RDP CredSSP/NLA -- `rdp_proxy.rs::send_network_request` previously
hard-coded `None` for the agent handle. `RdpProxy` now carries a
`KdcConnector` field that the CredSSP machinery
(`perform_credssp_as_*` -> `resolve_*_generator` -> `send_network_request`)
uses for every Kerberos sub-request. The same change reaches the
credential-injection clean path (`rd_clean_path.rs`).
`KdcConnector` (new `src/kdc_connector.rs`) bundles the three inputs the
routing pipeline needs (`session_id`, `explicit_agent_id`,
`agent_tunnel_handle`) into a single value and always defers the
routing decision to `agent_tunnel::routing::try_route`. Callers never
pre-decide "direct" vs "via tunnel": the routing pipeline does, and
its existing `explicit_agent_id` enforcement (pin without tunnel handle
must error, never silently fall back to direct) is preserved end-to-end.
Session correlation:
- RDP CredSSP callers pass the parent association's `claims.jet_aid`
as `session_id`, so KDC sub-traffic ties back to its parent RDP
session in agent-side logs.
- The HTTP `/jet/KdcProxy` handler passes the KDC token's own `jti`,
the most persistent identifier available without a parent
association. `KdcTokenClaims` now exposes `jti` through its serde
helper, matching how every other `*TokenClaims` type surfaces `jti`.
Explicit-agent routing (matches every other proxy path):
- The parent association's `jet_agent_id`, when set, is forwarded to
`try_route`. KDC traffic must route via that agent or fail -- never
silently fall back to a different agent or to direct connect. The
HTTP handler passes `None` (no parent association).
- A new UDP-via-agent guard rejects `udp://` KDC targets whenever the
routing pipeline selects an agent. Without it, an explicit
`jet_agent_id` pin could be downgraded to direct UDP, since the
agent tunnel currently carries only TCP.
Hardening (came along since they share the file):
- 64 KiB `MAX_KDC_REPLY_MESSAGE_LEN` DoS cap on the announced TCP-framed
KDC reply length, with overflow-safe length math.
- UDP scheme guard at the direct-connect branch (preserved).
Tests:
- `kdc_connector` unit tests cover the two cases that don't need a live
`AgentTunnelHandle`: pin-without-tunnel must error, no-pin-no-tunnel
falls through to direct. The remaining cases (pin-with-missing-agent,
no-match-falls-back, tunnel success, UDP-via-agent guard) need an
integration-style listener fixture and are left as a follow-up.
Issue: DGW-3841 parent b50e5d0 commit 06706d0
9 files changed
Lines changed: 365 additions & 143 deletions
File tree
- devolutions-gateway/src
- api
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | 1 | | |
4 | 2 | | |
5 | | - | |
6 | 3 | | |
7 | 4 | | |
8 | | - | |
9 | | - | |
| 5 | + | |
10 | 6 | | |
11 | 7 | | |
12 | 8 | | |
13 | 9 | | |
14 | 10 | | |
15 | 11 | | |
16 | 12 | | |
17 | | - | |
| 13 | + | |
| 14 | + | |
18 | 15 | | |
19 | 16 | | |
20 | 17 | | |
| |||
26 | 23 | | |
27 | 24 | | |
28 | 25 | | |
| 26 | + | |
29 | 27 | | |
30 | 28 | | |
31 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
70 | 71 | | |
71 | 72 | | |
72 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
73 | 81 | | |
74 | 82 | | |
75 | 83 | | |
76 | 84 | | |
77 | 85 | | |
78 | 86 | | |
79 | 87 | | |
| 88 | + | |
80 | 89 | | |
81 | 90 | | |
82 | 91 | | |
| |||
107 | 116 | | |
108 | 117 | | |
109 | 118 | | |
| 119 | + | |
110 | 120 | | |
111 | 121 | | |
112 | 122 | | |
| |||
120 | 130 | | |
121 | 131 | | |
122 | 132 | | |
123 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
124 | 136 | | |
125 | 137 | | |
126 | 138 | | |
| |||
130 | 142 | | |
131 | 143 | | |
132 | 144 | | |
133 | | - | |
| 145 | + | |
134 | 146 | | |
135 | 147 | | |
136 | 148 | | |
| |||
165 | 177 | | |
166 | 178 | | |
167 | 179 | | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | 180 | | |
267 | 181 | | |
268 | 182 | | |
| |||
288 | 202 | | |
289 | 203 | | |
290 | 204 | | |
291 | | - | |
| 205 | + | |
292 | 206 | | |
293 | 207 | | |
294 | 208 | | |
295 | 209 | | |
296 | | - | |
| 210 | + | |
297 | 211 | | |
298 | 212 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
390 | 390 | | |
391 | 391 | | |
392 | 392 | | |
| 393 | + | |
393 | 394 | | |
394 | 395 | | |
395 | 396 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
166 | 172 | | |
167 | 173 | | |
168 | 174 | | |
| |||
177 | 183 | | |
178 | 184 | | |
179 | 185 | | |
| 186 | + | |
180 | 187 | | |
181 | 188 | | |
182 | 189 | | |
| |||
0 commit comments