[PR #11451] fix: add fallback for when crypto.randomUUID is unavailable #13793

Closed
opened 2026-02-16 18:18:37 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/11451

State: closed
Merged: No


The web app uses crypto.randomUUID for generating an ID of every file attachment. Unfortunately, crypto.randomUUID is only available in "secure contexts" (https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID). This prevents users from uploading files in opencode when running inside internal networks, over HTTP. The security concern here is very weak: this is simply an identifier for the file, and setting up SSL certificates inside the internal network is a pain.

The solution here is identical to what is already implemented elsewhere in the app: https://github.com/anomalyco/opencode/blob/f834915d3fbcf05137fc61fc51b9fa07b815e82c/packages/app/src/utils/perf.ts#L19 , and is simple: if randomUUID isn't available, we're using Math.random to generate the file ID.

Fixes #11452

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/11451 **State:** closed **Merged:** No --- The web app uses crypto.randomUUID for generating an ID of every file attachment. Unfortunately, crypto.randomUUID is only available in "secure contexts" (https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID). This prevents users from uploading files in opencode when running inside internal networks, over HTTP. The security concern here is very weak: this is simply an identifier for the file, and setting up SSL certificates inside the internal network is a pain. The solution here is identical to what is already implemented elsewhere in the app: https://github.com/anomalyco/opencode/blob/f834915d3fbcf05137fc61fc51b9fa07b815e82c/packages/app/src/utils/perf.ts#L19 , and is simple: if randomUUID isn't available, we're using Math.random to generate the file ID. Fixes #11452
yindo added the pull-request label 2026-02-16 18:18:37 -05:00
yindo closed this issue 2026-02-16 18:18:37 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13793