HIGH: crypto.randomUUID() used without importing the crypto module (AuthService.ts and SubscriptionController.ts) #7
Labels
No labels
blocked:needs-human
blocked:verify-failed
bug
feature-request
quickfix
security/high
security/medium
test-coverage
triage-approved
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Mark/subvault#7
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Severity: High
Location
backend/src/services/AuthService.tsline 21backend/src/controllers/SubscriptionController.tsline 75Description
Both files use
crypto.randomUUID()to generate IDs, but neither file imports thecryptomodule:AuthService.ts (no import at line 1, only imports UserRepository, User, and auth helpers):
SubscriptionController.ts (only imports Response from express):
This code currently works in Node.js 19+ where
globalThis.cryptohas arandomUUID()method, but it will fail at runtime on Node.js 18.x or in environments where the global Web Crypto API does not includerandomUUID(). It also produces a TypeScript compile error in strict mode since the globalcryptotype does not includerandomUUID().By contrast,
backend/src/auth.tscorrectly importscryptoon line 3.Suggested Fix
Add the import to both files:
Or consider using
uuidpackage which is already in the dependencies: