Skip to content

fix: audit expert vault unlock failures - #3

Merged
CyberSunil merged 4 commits into
CyberSunil:mainfrom
luojiyin1987:fix/local-only-docker-and-unlock-audit
Sep 21, 2026
Merged

CyberSunil merged 4 commits into
CyberSunil:mainfrom
luojiyin1987:fix/local-only-docker-and-unlock-audit

Conversation

@luojiyin1987

@luojiyin1987 luojiyin1987 commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

What changed

  • Treat only Fernet authentication failures as invalid Expert Access Keys.
  • Verify both the encrypted vault and its metadata against release-maintained SHA-256 digests before JSON parsing or PBKDF2 work.
  • Configure root logging to emit INFO audit events to stderr under Gunicorn.
  • Audit successful, invalid-key, and loading-error unlock outcomes without recording access keys or player names.
  • Add tests for vault failures, valid metadata tampering, audit events, and secret redaction.

Why

The previous broad exception handler converted operational vault failures into an indistinguishable invalid-key response, which concealed deployment faults and left no unlock-attempt audit trail. Fernet intentionally uses InvalidToken for both wrong keys and invalid tokens, so independent integrity anchors are required to distinguish vault corruption before key derivation and decryption.

Validation

  • python3 -m py_compile app.py challenges/expert_vault.py tests/test_expert_unlock.py
  • pytest -q — 13 passed
  • git diff --check

Closes #2

@luojiyin1987
luojiyin1987 marked this pull request as ready for review July 17, 2026 10:35
@CyberSunil CyberSunil added the bug Something isn't working label Sep 17, 2026
@CyberSunil

Copy link
Copy Markdown
Owner

Sorry for the long delay on this — thanks for the thorough writeup and for the tests, the integrity-anchor approach is the right call. You're correct that InvalidToken can't distinguish a wrong key from a corrupt vault, so checking the digests before key derivation is the only clean way to separate them.

Two things before I can merge: the branch has a conflict in app.py against current main, and the three required CI checks are blocked behind it. Could you rebase on main?

@luojiyin1987

Copy link
Copy Markdown
Contributor Author

I fixed the code conflict.

@CyberSunil
CyberSunil merged commit 653b82d into CyberSunil:main Sep 21, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: distinguish expert vault failures from invalid keys

2 participants