Skip to content

Pre-existing: rand() in cf-agent is effectively seeded with time(NULL) only #33

Open

Description

@djbclark

Found by the Fable review of #27, verified by running.

RandomSeed() (libpromises/crypto.c) runs from CryptoInitialize() inside GenericAgentInitialize(). That happens before SetReferenceTime() sets CFSTARTTIME and before VFQNAME is known, so the intended pid/start-time/fqdn mixing collapses to the current second. Any rand()-derived name is predictable.

--simulate-json no longer relies on it; it now uses RAND_bytes(). libpromises/override_fsattrs.c uses the same <file>.<rand>.cfnew idiom and inherits the weakness, although it unlinks first. To do: reseed after SetReferenceTime(), or move override_fsattrs.c to RAND_bytes().

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions