Skip to content

Commit d8ff2a5

Browse files
committed
PrepareUserAuthRequestEcc Missing Bounds Checks
For agent ECC public key parsing, replaced parsing the data by hand with the GetSkip() and GetStringRef() functions which do bounds checking. Affected function: PrepareUserAuthRequestEcc. Issue: F-526
1 parent 6a89725 commit d8ff2a5

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

src/internal.c

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14400,19 +14400,27 @@ static int PrepareUserAuthRequestEcc(WOLFSSH* ssh, word32* payloadSz,
1440014400
word32 idx = 0;
1440114401
#ifdef WOLFSSH_AGENT
1440214402
if (ssh->agentEnabled) {
14403-
word32 sz;
14404-
const byte* c = (const byte*)authData->sf.publicKey.publicKey;
14405-
14406-
ato32(c + idx, &sz);
14407-
idx += LENGTH_SZ + sz;
14408-
ato32(c + idx, &sz);
14409-
idx += LENGTH_SZ + sz;
14410-
ato32(c + idx, &sz);
14411-
idx += LENGTH_SZ;
14412-
c += idx;
14413-
idx = 0;
14403+
const byte* publicKey = NULL;
14404+
word32 publicKeySz;
1441414405

14415-
ret = wc_ecc_import_x963(c, sz, &keySig->ks.ecc.key);
14406+
ret = GetSkip((const byte*)authData->sf.publicKey.publicKey,
14407+
authData->sf.publicKey.publicKeySz, &idx);
14408+
if (ret == WS_SUCCESS) {
14409+
ret = GetSkip((const byte*)authData->sf.publicKey.publicKey,
14410+
authData->sf.publicKey.publicKeySz, &idx);
14411+
}
14412+
if (ret == WS_SUCCESS) {
14413+
ret = GetStringRef(&publicKeySz, &publicKey,
14414+
(const byte*)authData->sf.publicKey.publicKey,
14415+
authData->sf.publicKey.publicKeySz, &idx);
14416+
}
14417+
if (ret == WS_SUCCESS) {
14418+
ret = wc_ecc_import_x963(publicKey, publicKeySz,
14419+
&keySig->ks.ecc.key);
14420+
}
14421+
if (ret == 0) {
14422+
ret = WS_SUCCESS;
14423+
}
1441614424
}
1441714425
else
1441814426
#endif

0 commit comments

Comments
 (0)