Skip to content

Fix Weak JWT Signing Key - #53

Open
JBHook wants to merge 1 commit into
OWASP-CTF:dc34-ctffrom
JBHook:fix/weak-jwt-signing-key
Open

JBHook wants to merge 1 commit into
OWASP-CTF:dc34-ctffrom
JBHook:fix/weak-jwt-signing-key

Conversation

@JBHook

@JBHook JBHook commented Aug 9, 2026

Copy link
Copy Markdown

Summary

The JWT signing secret was hardcoded to the literal string "random" - trivially guessable, letting an attacker forge arbitrary valid tokens (including admin) entirely offline. Replaced with a securely random 256-bit key generated at process start (with an optional SECRET_KEY env var override).

Test plan

  • Booted the app locally and validated live: normal login/auth still works; a token forged with the old hardcoded secret "random" for the admin user is now rejected with "Invalid token. Please log in again."

The JWT signing secret was hardcoded to the literal string "random" -
a trivially guessable/brute-forceable key, letting an attacker forge
arbitrary valid auth tokens (including for the admin account) entirely
offline, without ever needing valid credentials.

Replaced it with a securely random 256-bit key generated via
secrets.token_hex(32) at process start, with an optional SECRET_KEY
environment variable override for deployments that want to pin a
fixed key (e.g. across multiple app instances).

Verified live: normal login/auth still works end-to-end (login as
"name1", use the returned token against /me). Forged a token signed
with the old hardcoded secret "random" for the admin user using
PyJWT directly - the app now rejects it with "Invalid token. Please
log in again." instead of accepting it as a valid admin session.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown

🏆 VAmPI — CTF Patch Score

████░░░░░░░░░░░░░░░░  3 / 16 pts  (19%)

1 / 9 challenges patched

Per-challenge detail is withheld — it would reveal the rubric.

Commit: fb57c47 · scoring run

🎉 Your result is on the leaderboard — see where you rank! 🏆

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