Open hoyong2007 opened 1 month ago
Thanks for the investigation.
Using null pointers with libckteec will only crash the Linux client application that invokes the TA. It won't affect other Linux applications neither the pkcs11 TA itsleft. So I don't thinks these can lead to DoS attacks.
We could add non-NULL pointer verification for non-zero sized buffer references but that would only help for development/debugging. For example, there is no way to check pointers are well sized. It is the responsibility of the client application to contain programming errors. That said, it should not add much complexity to test some pointer here and there.
Thanks for your reply.
I'm focusing on the bugs via NULL pointer, not non-NULL pointer. I agreed with that the client cannot check the actual buffer size of the pointer, but I believe the client should at least verify whether the pointer is null.
As far as I know, the mechanism pointer is checked in the higher-level functions, but the pointer members of the mechanism are not checked for null. I believe every pointer variable should be checked at least once before being referenced.
If you have some changes to propose, I'll be happy to review them and help.
I made PR for this issue. https://github.com/OP-TEE/optee_client/pull/392
Hi @hoyong2007, thanks. I'll posted some comments.
@etienne-lms I’ve added a few additional comments and committed the code with the comments reflected.
Commit: a5b1ffc (master) File: libckteec/src/serialize_ck.c Function: serialize_mecha_XXX()
There are lots of potential Null-Pointer deference spots in serialize_ck.c
For example, in the
serialize_mecha_rsa_oaep_param()
function,mecha->pParameter
is referenced directly without proper pointer validation.Additionally, the
params->pSourceData
pointer is also directly referenced in theserialize_buffer()
function without proper pointer validation.Directly referencing pointers without proper validation, as shown, can lead to null pointer dereference bugs, which may result in a DoS (Denial of Service).
Credit: @hoyong2007 @jch6637