Commit b8c44b3
authored
fix(gui): expire single-use GUI intent tokens after 30s (#54612)
### What does this PR do?
Gives the single-use GUI "intent token" (used by `agent launch-gui` and the systray Configure action to bootstrap a GUI session) a 30 second TTL instead of letting it stay valid indefinitely until first use.
### Motivation
Security finding [VULN-92705](https://datadoghq.atlassian.net/browse/VULN-92705): `launch-gui` (and the Windows systray Configure path) pass the intent token to the OS URL-opener (`xdg-open`/`open`/`rundll32`) as part of a URL query string. That URL lands in the opener's argv, and via the browser process it spawns can remain visible there for a much longer time — readable by any co-resident local user via `/proc/<pid>/cmdline` on hosts where `hidepid` isn't set. `/auth?intent=` performs no caller-identity check, so whoever presents a valid intent token first is granted the (by default never-expiring) `accessToken` session cookie.
Intent tokens previously had no expiration and remained valid in memory until first use, leaving an unbounded window for this argv-leak race. This change bounds that window to 30 seconds, which is generous for normal browser-launch latency while meaningfully limiting the exploitable exposure. (The token remains single-use regardless of outcome — an expired token is still consumed on presentation, closing any residual re-use race.)
### Describe how you validated your changes
- Added unit tests in `comp/core/gui/impl/gui_test.go` covering: valid unexpired token grants access, expired token is rejected *and* consumed, a token cannot be redeemed twice, and expired entries are purged from the map when a new token is issued.
- `dda inv test --targets=./comp/core/gui/impl/...` and `bazel test //comp/core/gui/impl:impl_test` pass.
- `dda inv linter.go --targets=./comp/core/gui/impl/...` passes.
- Built the agent locally (`dda inv agent.build`) to confirm `launch-gui` still compiles end-to-end.
### Additional Notes
No release note: this is an internal hardening change with no user-facing behavior change (the GUI login flow is unaffected under normal use; only the far edge case of a stale, un-redeemed launch attempt now expires after 30s instead of forever).
[VULN-92705]: https://datadoghq.atlassian.net/browse/VULN-92705?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
Co-authored-by: louis.coquerelle <louis.coquerelle@datadoghq.com>1 parent 2ffb147 commit b8c44b3
3 files changed
Lines changed: 114 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
44 | 50 | | |
45 | 51 | | |
46 | 52 | | |
| |||
49 | 55 | | |
50 | 56 | | |
51 | 57 | | |
52 | | - | |
| 58 | + | |
53 | 59 | | |
54 | 60 | | |
55 | 61 | | |
| |||
112 | 118 | | |
113 | 119 | | |
114 | 120 | | |
115 | | - | |
| 121 | + | |
116 | 122 | | |
117 | 123 | | |
118 | 124 | | |
| |||
195 | 201 | | |
196 | 202 | | |
197 | 203 | | |
198 | | - | |
| 204 | + | |
| 205 | + | |
199 | 206 | | |
200 | 207 | | |
201 | 208 | | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
202 | 219 | | |
203 | 220 | | |
204 | 221 | | |
| |||
270 | 287 | | |
271 | 288 | | |
272 | 289 | | |
273 | | - | |
274 | | - | |
275 | | - | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
276 | 295 | | |
277 | 296 | | |
278 | 297 | | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | 298 | | |
283 | 299 | | |
284 | 300 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
0 commit comments