RUSTSEC-2022-0034

Source
https://rustsec.org/advisories/RUSTSEC-2022-0034
Import Source
https://github.com/rustsec/advisory-db/blob/osv/crates/RUSTSEC-2022-0034.json
JSON Data
https://api.osv.dev/v1/vulns/RUSTSEC-2022-0034
Published
2022-07-22T12:00:00Z
Modified
2022-07-25T17:19:15Z
Summary
Safety issues in `pkcs11`
Details

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

Database specific
{
    "license": "CC0-1.0"
}
References

Affected packages

crates.io / pkcs11

Package

Affected ranges

Type
SEMVER
Events
Introduced
0.0.0-0

Ecosystem specific

{
    "affected_functions": null,
    "affects": {
        "os": [],
        "functions": [],
        "arch": []
    }
}

Database specific

{
    "cvss": null,
    "informational": "unsound",
    "categories": [
        "code-execution",
        "memory-corruption",
        "crypto-failure"
    ]
}