Skip to content

Improve documentation about fork safety #6968

@piru

Description

@piru

libcurl Security Considerations documentation could be improved to include section about fork safety.

Currently if libcurl is used in with NSS backend, fork() will effectively clone the random generator state. Unlike openssl and friends, NSS doesn't automatically reseed the RNG when the process id changes. This means that NSS will generate same random byte stream for both forks, possibly leading to identical temporary keys and/or tokens being used. In some scenarios this could lead to security vulnerability being introduced.

At least in my testing calling SECMOD_RestartModules(PR_TRUE); in the child after fork() seemed a reliable way to reseed the RNG.

It is a bit unfortunately that such backend specific code needs to be used, but as far as I can tell there is no easy way to have this fixed in a generic way, at least if libcurl doesn't want to add some magic that tries to identify fork()ing.

Note that some arc4random() implementations might be affected in a similar manner. However, this is implementation specific. For example libbsd commonly used in linux distros appears to be fork safe. MacOS arcrandom() is safe. I didn't test iOS one, but I'd assume it's safe as well.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions