Skip to content

Imported public keys leak token session objects #739

Description

@bukka

Describe the bug

When a public key is stored, a new session object is created (C_CreateObject), but that object is never destroyed when the P11PROV_OBJ is freed. Under workloads that repeatedly import distinct public keys that get later stored (in my case TLS server side client certificate verification), this leaks one session object per unique key on the long-lived login session, which is never closed.

The freeing logic in p11prov_obj_free when only cache handle is released makes so private keys as the handle should not be destroyed but it doesn't make that much sense for imported objects as far as I see (correct me if I'm missing anything important).

To Reproduce

To reproduce, the code needs to store public key object repeatedly. In my case, it can be reproduced with client verification.

Expected behavior

The imported object handle should be destroyed - calling C_DestroyObject

Operating environment (please complete the following information):

  • OS: Linux but shouldn't matter

Token and application used (please complete the following information):

  • Device: SoftHSMv2 but shouldn't matter

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions