Skip to content

Modify os.urandom() to return false for no entropy - #11185

Closed
ladyada wants to merge 1 commit into
mainfrom
ladyada-patch-1
Closed

Modify os.urandom() to return false for no entropy#11185
ladyada wants to merge 1 commit into
mainfrom
ladyada-patch-1

Conversation

@ladyada

@ladyada ladyada commented Aug 7, 2026

Copy link
Copy Markdown
Member

Update os.urandom() to fail closed when no secure entropy is available.

Update os.urandom() to fail closed when no secure entropy is available.
@ladyada
ladyada requested review from dhalbert and a lite review from Copilot August 7, 2026 13:59
@dhalbert

dhalbert commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

I would rather close this in favor of #11184

@dhalbert dhalbert closed this Aug 7, 2026
@ladyada
ladyada deleted the ladyada-patch-1 branch August 7, 2026 14:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR changes the CXD56 port’s common_hal_os_urandom() implementation to fail closed when no secure entropy source is available, ensuring os.urandom() raises NotImplementedError instead of returning deterministic bytes.

Changes:

  • Replaced the previous rand()-based buffer fill with an unconditional false return to indicate no secure RNG is available.
  • Added rationale in comments explaining the security implications and intended behavior.
Suppressed comments (1)

ports/cxd56/common-hal/os/init.c:22

  • The statement "broadcom, silabs and litex ports, which also lack a hardware RNG" is potentially misleading: those ports currently return false from common_hal_os_urandom(), but that doesn’t necessarily imply the underlying silicon has no RNG. Rewording this to describe the implementation behavior (returning false) avoids over-claiming about hardware capabilities.
// rather than silently returning non-random data. This matches the broadcom,
// silabs and litex ports, which also lack a hardware RNG.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +15 to +17
// source. That is the same class of defect behind the 2026 Coldcard wallet
// key-recovery incident, where a silent PRNG fallback stood in for hardware
// entropy.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants