Commit 04a6c83
fix(security): close still-valid Copilot review concerns from merged PRs
Triage of Copilot comments on PRs #38–#43 (merged) identified seven
items where the concern is still valid in main. Bundled here rather
than split into separate per-finding PRs.
Dashboard (gearbox/):
- login.go: isSafeReturnURL now rejects ASCII control characters
(< 0x20, 0x7F). Without this, %0d%0a-encoded paths and embedded tabs
could survive the open-redirect allowlist and feed into downstream
header-injection attempts (P0-4 follow-up from PR #39).
- security_headers.go: validCSPDirective now allows base64 chars
(`+`, `=`) so nonce-... / sha256/384/512-... source expressions
aren't silently dropped. Both sanitizers now use a shared
cspContainsForbidden helper that rejects ALL ASCII control chars
and any non-ASCII rune, catching form-feed and unicode whitespace
that the previous hand-curated ContainsAny lists missed
(P1-4 follow-up from PR #43).
Agent (gearbox-agent/):
- parser.go: sanitizeName output is now capped at 25 chars so the
default backend name {app}_{service}_backend stays inside
validBackendName's 63-char limit. A long app or service directory
name would otherwise build a default that fails validation and
silently drops the whole backend (P0-1 follow-up from PR #39).
- websocket.go: canonicalHost uses net.SplitHostPort instead of
strings.Index(":"), which corrupted IPv6 host parsing
("[::1]:8405" was treated as host="[" / port=":1]:8405").
(P1-5 follow-up from PR #42).
- backoff.go: NewBackoffTracker now clamps zero/negative window,
baseDelay, threshold to safe minimums. cleanupLoop's
time.NewTicker would otherwise panic on a zero window
(P1-7 follow-up from PR #42).
- ratelimit.go: "map at capacity" warn log is throttled to one per
minute. Without throttling, a distributed scan that fills the
client map drove a log-write per denied IP, turning the
structured-log pipeline into a secondary disk/ingest DoS surface
(P1-6 follow-up from PR #42).
- fail2ban.go: comment said "unit argument" but the code handles
fail2ban jails — wording drift left over from copy/paste of a
systemctl-related comment (P1-3 follow-up from PR #41).
Skipped (not material in this deployment):
- APIKeyAuth using its own IP extractor rather than the rate limiter's
(only diverges behind a trusted proxy; we're not).
- Retry-After hardcoded to 60 (UX nit, not security).
- Fork-PR handling in claude-security-review workflow (no fork PRs in
this repo).
- Historical "recommended fix order" wording in 2026-05-findings.md
(the section is explicitly retrospective).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent c174f39 commit 04a6c83
7 files changed
Lines changed: 102 additions & 16 deletions
File tree
- gearbox-agent/internal
- api
- framework
- middleware
- services/compose
- gears/security
- gearbox/internal/framework
- handler
- middleware
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
53 | 59 | | |
54 | 60 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
63 | 70 | | |
64 | | - | |
| 71 | + | |
65 | 72 | | |
66 | 73 | | |
67 | 74 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
50 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
51 | 68 | | |
52 | 69 | | |
53 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
39 | 45 | | |
40 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
41 | 52 | | |
42 | 53 | | |
43 | 54 | | |
| |||
90 | 101 | | |
91 | 102 | | |
92 | 103 | | |
93 | | - | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
94 | 111 | | |
95 | 112 | | |
96 | 113 | | |
| 114 | + | |
97 | 115 | | |
| 116 | + | |
98 | 117 | | |
99 | 118 | | |
100 | 119 | | |
| |||
Lines changed: 16 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
384 | 384 | | |
385 | 385 | | |
386 | 386 | | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
387 | 394 | | |
| 395 | + | |
388 | 396 | | |
389 | 397 | | |
390 | 398 | | |
391 | 399 | | |
392 | 400 | | |
393 | 401 | | |
394 | 402 | | |
395 | | - | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
396 | 411 | | |
397 | 412 | | |
398 | 413 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
161 | | - | |
| 161 | + | |
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
38 | 46 | | |
39 | 47 | | |
40 | 48 | | |
| |||
Lines changed: 23 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
22 | 27 | | |
23 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
24 | 44 | | |
25 | 45 | | |
26 | 46 | | |
| |||
33 | 53 | | |
34 | 54 | | |
35 | 55 | | |
36 | | - | |
| 56 | + | |
37 | 57 | | |
38 | 58 | | |
39 | 59 | | |
| |||
52 | 72 | | |
53 | 73 | | |
54 | 74 | | |
55 | | - | |
| 75 | + | |
56 | 76 | | |
57 | 77 | | |
58 | 78 | | |
| |||
0 commit comments