Skip to content

feat(builtins): $SRANDOM, uuidgen, openssl rand - #2533

Merged
chaliy merged 1 commit into
mainfrom
claude/fidelity-random
Oct 7, 2026
Merged

chaliy merged 1 commit into
mainfrom
claude/fidelity-random

Conversation

@chaliy

@chaliy chaliy commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Requested by Михайло · project thread

What changed

The usual ways to make random numbers, IDs and secrets now work:

  • $SRANDOM (bash 5.1): a fresh 32-bit value per read. Assigning to it is ignored, as in bash.
  • uuidgen (and -r): random v4 UUIDs.
  • openssl rand [-hex|-base64] [-out FILE] NUM. Other openssl subcommands fail with openssl's own Invalid command message, so scripts can fall back.

All three read from the OS CSPRNG (getrandom, the same source as /dev/urandom), never from the $RANDOM LCG.

Why

Agents generate tokens and passwords with openssl rand -hex 32, uuidgen and $SRANDOM. All three were "command not found" or empty.

Before / After

Before: uuidgen/openssl → command not found; $SRANDOM → empty.
After:

$ echo $SRANDOM; uuidgen; openssl rand -hex 16; openssl rand -base64 24; openssl dgst
2555198831
7e9ca848-6557-4662-9c99-5ad9ad1fa223
bb024b248c8615fbef71296e62f3a025
tf2JLm86JbSnRlviYP1TZN90vz1tmUOH
Invalid command 'dgst'; type "help" for a list.

random.test.sh checks the output shapes against real bash and openssl.

Risk

  • Low
  • command -v openssl now succeeds, but only rand works (L-RAND-001). openssl rand refuses requests over 1 MiB (TM-DOS-123).

Checklist

  • Tests added or updated
  • Backward compatibility considered

https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA


Generated by Claude Code

@chaliy chaliy self-assigned this Oct 7, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit 22dc42e Commit Preview URL

Branch Preview URL
Oct 07 2026, 03:56 AM

Secret generators backed by the OS CSPRNG (same source as /dev/urandom).
openssl implements only rand, capped at 1 MiB (TM-DOS-123); uuidgen
emits v4 only (L-RAND-001).

Claude-Session: https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA
@chaliy
chaliy force-pushed the claude/fidelity-random branch from 2a0b6ff to 22dc42e Compare October 7, 2026 03:55
@chaliy
chaliy merged commit 42058a6 into main Oct 7, 2026
47 checks passed
@chaliy
chaliy deleted the claude/fidelity-random branch October 7, 2026 04:21
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.

1 participant