Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 2024-05-18 - Weak Random Generation in IDs
**Vulnerability:** The codebase was using the standard `random` module for generating session tokens and identifiers (`helpers/guids.py`).
**Learning:** The `random` module is not cryptographically secure and predictable, which could compromise generated IDs.
**Prevention:** Always use the `secrets` module (e.g., `secrets.choice`) for generating random strings where security or unpredictability is needed.
4 changes: 2 additions & 2 deletions helpers/guids.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import random, string
import secrets, string

def generate_id(length: int = 8) -> str:
return "".join(random.choices(string.ascii_letters + string.digits, k=length))
return "".join(secrets.choice(string.ascii_letters + string.digits) for _ in range(length))