Email me

Rust advisories / pkcs11

UnsoundRUSTSEC-2022-0034 · pkcs11

RUSTSEC-2022-0034: Safety issues in `pkcs11`

Short answerpkcs11 has an API that can cause undefined behaviour from safe code: Safety issues in `pkcs11`. No fixed version yet.

Cratepkcs11
TypeUnsound (code-execution, memory-corruption, crypto-failure)
Affected versionsEvery version.
Fixed innone
Severitynot scored
Published2022-07-22
Last changed2022-07-25
Also known asnone

What to do

  1. Find who pulls it in: cargo tree -i pkcs11.
  2. Avoid the affected API, or replace the crate.

Details from the advisory

Impact

The interface of pkcs11 is subject to a number of safety issues, mainly related to handling of raw pointers. Despite presenting a safe interface, many of the functions and methods that rely on inputs which contain pointers (attributes and mechanisms in particular) can lead to segmentation faults and undefined behaviour when those pointers get dereferenced. For more details see the issues referenced below.

Other problems that have been identified by the community include use-after-free (mheese/rust-pkcs11#53) and unsound uses of transmute_copy (mheese/rust-pkcs11#55).

Workarounds

Users of the crate need to be _extremely_ careful in all the calls made to avoid segmentation faults and undefined behaviour due to use of stale pointers. Whenever a pointer is derived from a value and passed to the library, that value's lifetime must be guaranteed to outlast all calls that rely on the pointer. For example, users should **avoid** creating or converting values within a separate scope (say, in a dedicated function), deriving a pointer, then extracting the pointer from that scope leaving the value to get dropped before passing the pointer to pkcs11.

References

References

From the RustSec Advisory Database (CC0-1.0) via the OSV export, downloaded Oct 24, 2026. Severity score computed from the published CVSS vector.

Up next

Are you affected?Check your whole dependency treePaste Cargo.lock: every advisory, for your exact versions.Read it next →

Did this answer your question?

Get the receipts by email.

What my AI agents tried this week, with the real numbers: what worked, what flopped, what made money. One email when there is something worth reading.

No spam, never sold. Every email has a one-click unsubscribe.

Popular in the shop

All 124 tools →

Browse: Bundles and kitsHome, family and schoolMoney and businessAI toolsSports and fitnessMaking and hobbiesFood and drinkIndie dev and launchTrading and quant

Free: Landing page teardown iPhone app cost calculator LLM API cost calculator Paid online: $49 Launch Check App builds Articles FAQ