Commit 2072710
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`) encapsulates the routing
decision behind a single value so callers no longer thread
`agent_tunnel_handle`, `session_id`, and `explicit_agent_id` through
every layer. CredSSP code only sees `&KdcConnector`.
Session correlation:
- RDP CredSSP callers build `KdcConnector::agent_tunnel(claims.jet_aid,
...)` so KDC sub-traffic ties back to its parent RDP session in
agent-side logs.
- The HTTP `/jet/KdcProxy` handler builds
`KdcConnector::agent_tunnel(claims.jti, ...)` so all sub-requests of
the same KDC token share a correlation ID. `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 `AgentTunnel` variant of `KdcConnector` carries an
`explicit_agent_id: Option<Uuid>`. When the parent association pins
`jet_agent_id`, 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` (it has no parent association).
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: KDC over UDP keeps going direct because the agent
tunnel only carries TCP today.
Issue: DGW-3841 parent 64777c6 commit 2072710
9 files changed
Lines changed: 331 additions & 123 deletions
File tree
- crates/agent-tunnel/src
- devolutions-gateway/src
- api
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
| |||
| 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 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
73 | 84 | | |
74 | 85 | | |
75 | 86 | | |
76 | 87 | | |
77 | 88 | | |
78 | 89 | | |
79 | 90 | | |
| 91 | + | |
80 | 92 | | |
81 | 93 | | |
82 | 94 | | |
| |||
107 | 119 | | |
108 | 120 | | |
109 | 121 | | |
| 122 | + | |
110 | 123 | | |
111 | 124 | | |
112 | 125 | | |
| |||
120 | 133 | | |
121 | 134 | | |
122 | 135 | | |
123 | | - | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
124 | 139 | | |
125 | 140 | | |
126 | 141 | | |
| |||
130 | 145 | | |
131 | 146 | | |
132 | 147 | | |
133 | | - | |
| 148 | + | |
134 | 149 | | |
135 | 150 | | |
136 | 151 | | |
| |||
165 | 180 | | |
166 | 181 | | |
167 | 182 | | |
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 | 183 | | |
267 | 184 | | |
268 | 185 | | |
| |||
288 | 205 | | |
289 | 206 | | |
290 | 207 | | |
291 | | - | |
| 208 | + | |
292 | 209 | | |
293 | 210 | | |
294 | 211 | | |
295 | 212 | | |
296 | | - | |
| 213 | + | |
297 | 214 | | |
298 | 215 | | |
| 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 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
166 | 175 | | |
167 | 176 | | |
168 | 177 | | |
| |||
177 | 186 | | |
178 | 187 | | |
179 | 188 | | |
| 189 | + | |
180 | 190 | | |
181 | 191 | | |
182 | 192 | | |
| |||
0 commit comments