Commit b65ef0e
committed
fix(security): replace insecure TrustManager with default JVM trust validation
HIGH-severity TLS validation bypass (CWE-295, code-scanning alert #8).
The previous HttpClientFactory honored AxonFlowConfig.insecureSkipVerify(true)
as a single-flag opt-in to a permissive X509TrustManager whose
checkClientTrusted / checkServerTrusted methods returned void and whose
getAcceptedIssuers returned an empty array. With the flag set, the SDK
trusted ANY server certificate over HTTPS, including attacker-presented
certs in MITM scenarios.
Fix: double-gate the insecure path so it activates only when BOTH
- AxonFlowConfig#insecureSkipVerify(true) is set on the builder, AND
- AXONFLOW_INSECURE_TLS is set to "true" (case-insensitive) or "1" in
the runtime environment
are present. Otherwise the JVM's default TrustManager (validating against
the system + JDK trust store) is used. When the builder flag is set but
the env var is not, the SDK logs a warning at client construction time
and keeps verification enabled. When the insecure path actually
activates, a loud *** SECURITY WARNING *** is logged.
Rationale for keeping a development carve-out: AxonFlow demos and
self-hosted local stacks ship with self-signed agent certs in some
configurations; teams need a way to opt in for local dev without a
DIY trust-store override. The double-gate makes accidental production
bypass much harder: a stray builder flag in app code is no longer
sufficient.
Tests: HttpClientFactoryTest gains two assertions. The first verifies
that with insecureSkipVerify(true) but no env var, the resulting
OkHttpClient retains OkHttp's default OkHostnameVerifier (not the
permissive (h, s) -> true verifier). The second verifies the env-var
gate helper returns false when AXONFLOW_INSECURE_TLS is unset, which
is the default in CI and dev shells.
Default behavior in production: standard TLS validation against the
JDK + system trust store. No regressions in the existing 1224-test
suite (mvn test).
Resolves code-scanning alert #8.1 parent fa27583 commit b65ef0e
4 files changed
Lines changed: 84 additions & 11 deletions
File tree
- src
- main/java/com/getaxonflow/sdk
- util
- test/java/com/getaxonflow/sdk/util
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
18 | 22 | | |
19 | 23 | | |
20 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
463 | 463 | | |
464 | 464 | | |
465 | 465 | | |
466 | | - | |
| 466 | + | |
467 | 467 | | |
468 | | - | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
469 | 473 | | |
470 | | - | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
471 | 482 | | |
472 | 483 | | |
473 | 484 | | |
| |||
Lines changed: 43 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
34 | 43 | | |
35 | 44 | | |
36 | 45 | | |
37 | 46 | | |
38 | 47 | | |
39 | 48 | | |
40 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
41 | 55 | | |
42 | 56 | | |
43 | 57 | | |
| |||
50 | 64 | | |
51 | 65 | | |
52 | 66 | | |
53 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
54 | 78 | | |
55 | 79 | | |
56 | 80 | | |
| |||
111 | 135 | | |
112 | 136 | | |
113 | 137 | | |
114 | | - | |
115 | | - | |
116 | | - | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
117 | 144 | | |
118 | 145 | | |
119 | 146 | | |
120 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
121 | 160 | | |
Lines changed: 23 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
74 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
75 | 78 | | |
76 | 79 | | |
77 | 80 | | |
78 | 81 | | |
79 | 82 | | |
80 | 83 | | |
81 | | - | |
82 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
83 | 102 | | |
84 | 103 | | |
0 commit comments