Skip to content

Commit 4a23b12

Browse files
snhensonmattcaswell
authored andcommitted
Fix SRP buffer overrun vulnerability.
Invalid parameters passed to the SRP code can be overrun an internal buffer. Add sanity check that g, A, B < N to SRP code. Thanks to Sean Devlin and Watson Ladd of Cryptography Services, NCC Group for reporting this issue.
1 parent 80bd7b4 commit 4a23b12

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

crypto/srp/srp_lib.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ static BIGNUM *srp_Calc_k(BIGNUM *N, BIGNUM *g)
8989
int longg ;
9090
int longN = BN_num_bytes(N);
9191

92+
if (BN_ucmp(g, N) >= 0)
93+
return NULL;
94+
9295
if ((tmp = OPENSSL_malloc(longN)) == NULL)
9396
return NULL;
9497
BN_bn2bin(N,tmp) ;
@@ -121,6 +124,9 @@ BIGNUM *SRP_Calc_u(BIGNUM *A, BIGNUM *B, BIGNUM *N)
121124
if ((A == NULL) ||(B == NULL) || (N == NULL))
122125
return NULL;
123126

127+
if (BN_ucmp(A, N) >= 0 || BN_ucmp(B, N) >= 0)
128+
return NULL;
129+
124130
longN= BN_num_bytes(N);
125131

126132
if ((cAB = OPENSSL_malloc(2*longN)) == NULL)

0 commit comments

Comments
 (0)