Commit c5371ab
authored
Merge commit from fork
* Add SSH host key verification for git+ssh:// mirrors
Motivation:
- `SshGitMirror`'s SSH client unconditionally accepted any host key presented
by the remote server (CWE-322), allowing on-path attackers to intercept
mirrored repository contents or inject malicious commits.
Modifications:
- Add `acceptedHostKeys` field to `SshKeyCredential` for per-credential
host key pinning using SHA-256 fingerprints.
- Add `trustedHostKeys` (hostname → fingerprints map) to
`MirroringServicePluginConfig` for server-wide host key configuration.
- Replace the accept-all `ServerKeyVerifier` lambda in
`SshGitMirror.createSshClient()` with a verifier that computes the
SHA-256 fingerprint of the presented key and compares it against the
merged set of per-credential and global trusted keys using
constant-time comparison.
- Reject non-`SshKeyCredential` types (PASSWORD, ACCESS_TOKEN, NONE,
null) at `SshGitMirror` construction time.
- Remove the unused `PasswordCredential` code path from `SshGitMirror`
(`sshRemoteUri()`, `configureCredential()`, `getAcceptedHostKeys()`).
Result:
- Every outbound SSH mirror connection now verifies the remote server's
host key against an explicit allowlist before proceeding to
authentication.
* Address the comment from @ikhoon1 parent a38baa1 commit c5371ab
18 files changed
Lines changed: 424 additions & 64 deletions
File tree
- server-mirror-git/src
- main/java/com/linecorp/centraldogma/server/internal/mirror
- test/java/com/linecorp/centraldogma/server/internal/mirror
- server/src
- main/java/com/linecorp/centraldogma/server
- internal
- mirror
- storage
- project
- repository
- mirror
- test/java/com/linecorp/centraldogma/server/internal
- api/auth
- credential
- storage
- site/src/sphinx
- testing-internal/src/main/java/com/linecorp/centraldogma/testing/internal
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
| 53 | + | |
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| |||
server-mirror-git/src/main/java/com/linecorp/centraldogma/server/internal/mirror/SshGitMirror.java
Lines changed: 67 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| 29 | + | |
27 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
28 | 36 | | |
29 | 37 | | |
30 | 38 | | |
31 | 39 | | |
32 | 40 | | |
33 | 41 | | |
34 | 42 | | |
| 43 | + | |
35 | 44 | | |
36 | 45 | | |
37 | 46 | | |
| 47 | + | |
38 | 48 | | |
39 | 49 | | |
40 | 50 | | |
| |||
53 | 63 | | |
54 | 64 | | |
55 | 65 | | |
| 66 | + | |
56 | 67 | | |
57 | 68 | | |
58 | 69 | | |
59 | 70 | | |
60 | | - | |
61 | 71 | | |
62 | 72 | | |
63 | 73 | | |
| |||
68 | 78 | | |
69 | 79 | | |
70 | 80 | | |
| 81 | + | |
71 | 82 | | |
72 | 83 | | |
73 | 84 | | |
| |||
81 | 92 | | |
82 | 93 | | |
83 | 94 | | |
| 95 | + | |
| 96 | + | |
84 | 97 | | |
85 | 98 | | |
86 | | - | |
| 99 | + | |
| 100 | + | |
87 | 101 | | |
88 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
89 | 108 | | |
90 | 109 | | |
91 | 110 | | |
| |||
121 | 140 | | |
122 | 141 | | |
123 | 142 | | |
124 | | - | |
125 | | - | |
126 | | - | |
| 143 | + | |
127 | 144 | | |
128 | 145 | | |
129 | 146 | | |
| |||
145 | 162 | | |
146 | 163 | | |
147 | 164 | | |
148 | | - | |
149 | | - | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
150 | 184 | | |
151 | 185 | | |
152 | 186 | | |
| |||
159 | 193 | | |
160 | 194 | | |
161 | 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 | + | |
162 | 220 | | |
163 | 221 | | |
164 | 222 | | |
| |||
189 | 247 | | |
190 | 248 | | |
191 | 249 | | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
| 250 | + | |
| 251 | + | |
196 | 252 | | |
197 | 253 | | |
198 | 254 | | |
| |||
Lines changed: 19 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
202 | 202 | | |
203 | 203 | | |
204 | 204 | | |
205 | | - | |
| 205 | + | |
206 | 206 | | |
207 | | - | |
| 207 | + | |
208 | 208 | | |
209 | | - | |
210 | | - | |
| 209 | + | |
| 210 | + | |
211 | 211 | | |
212 | 212 | | |
213 | | - | |
214 | 213 | | |
215 | | - | |
216 | 214 | | |
217 | 215 | | |
218 | 216 | | |
| |||
243 | 241 | | |
244 | 242 | | |
245 | 243 | | |
246 | | - | |
247 | | - | |
| 244 | + | |
| 245 | + | |
248 | 246 | | |
249 | 247 | | |
250 | 248 | | |
| |||
257 | 255 | | |
258 | 256 | | |
259 | 257 | | |
| 258 | + | |
260 | 259 | | |
261 | 260 | | |
262 | 261 | | |
263 | 262 | | |
264 | 263 | | |
265 | | - | |
| 264 | + | |
266 | 265 | | |
267 | | - | |
| 266 | + | |
| 267 | + | |
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
273 | | - | |
| 273 | + | |
274 | 274 | | |
275 | | - | |
| 275 | + | |
| 276 | + | |
276 | 277 | | |
277 | 278 | | |
278 | 279 | | |
279 | 280 | | |
| 281 | + | |
280 | 282 | | |
281 | | - | |
282 | | - | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
283 | 287 | | |
284 | 288 | | |
Lines changed: 5 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
58 | | - | |
| 59 | + | |
| 60 | + | |
59 | 61 | | |
60 | 62 | | |
61 | 63 | | |
| |||
73 | 75 | | |
74 | 76 | | |
75 | 77 | | |
76 | | - | |
| 78 | + | |
| 79 | + | |
77 | 80 | | |
78 | 81 | | |
79 | 82 | | |
| |||
0 commit comments