Skip to content

Commit ad24e80

Browse files
fujimotosxmcqueen
authored andcommitted
out_forward: always initialize salt with random numbers (fluent#2575)
There is an initialization bug that leaves the shared key salt being uninitialized when SSL is not enabled. This might allow attackers to guess the shared key by looking at the hash. Let's always initialize the salt buffer securely using flb_randombytes(). Signed-off-by: Fujimoto Seiji <fujimoto@ceptord.net>
1 parent 4da40d5 commit ad24e80

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

plugins/out_forward/forward.c

+6-3
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,6 @@ static int secure_forward_init(struct flb_forward *ctx,
6565
secure_forward_tls_error(ctx, ret);
6666
return -1;
6767
}
68-
69-
/* Gernerate shared key salt */
70-
mbedtls_ctr_drbg_random(&fc->tls_ctr_drbg, fc->shared_key_salt, 16);
7168
return 0;
7269
}
7370
#endif
@@ -520,6 +517,12 @@ static int forward_config_init(struct flb_forward_config *fc,
520517
}
521518
#endif
522519

520+
/* Generate the shared key salt */
521+
if (flb_randombytes(fc->shared_key_salt, 16)) {
522+
flb_plg_error(ctx->ins, "cannot generate shared key salt");
523+
return -1;
524+
}
525+
523526
mk_list_add(&fc->_head, &ctx->configs);
524527
return 0;
525528
}

0 commit comments

Comments
 (0)