Skip to content

fix: enforce minimum strength for learning-path tokens (issue #1874) - #1908

Open
ionfwsrijan wants to merge 1 commit into
komalharshita:mainfrom
ionfwsrijan:fix/1874-learning-path-token-strength
Open

fix: enforce minimum strength for learning-path tokens (issue #1874)#1908
ionfwsrijan wants to merge 1 commit into
komalharshita:mainfrom
ionfwsrijan:fix/1874-learning-path-token-strength

Conversation

@ionfwsrijan

Copy link
Copy Markdown
Contributor

Problem

The learning-path APIs used the client-chosen X-Learning-Path-Token as the only authorization secret but accepted any non-empty token. The route docstring only advised callers to use "a random UUID or similar"; there was no server-side length/entropy requirement, so trivially guessable tokens (e.g. "test", "1234") gave full read/write access to a user's learning-path state.

Fix

  • Enforce a minimum token length of 16 characters in _validate_token (src/utils/learning_path.py). Since create_learning_path, get_learning_path, and update_learning_path all validate the token, every learning-path route (create/read/update/analytics) now rejects weak tokens with HTTP 400 via the existing ValueError handling — no per-route changes needed.
  • Updated the create/read/update/analytics route docstrings to document that the token must be at least 16 characters (a random UUID or equivalent high-entropy value) and that short tokens are rejected.

Files changed

  • src/utils/learning_path.py_MIN_TOKEN_LENGTH = 16; _validate_token rejects tokens shorter than 16 characters with a clear message.
  • src/routes/main_routes.py — docstrings for the four learning-path endpoints now state the enforced requirement (was advisory only).
  • tests/test_learning_path.py — new TestWeakTokenRejection class with route-level tests asserting weak tokens on POST/GET/PUT return 400.

Testing

Closes #1874

@vercel

vercel Bot commented Aug 11, 2026

Copy link
Copy Markdown

@ionfwsrijan is attempting to deploy a commit to the komalsony234-1530's projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

security: learning-path APIs accept trivially weak client-chosen tokens (length/entropy only advisory in docstring)

1 participant