Skip to content

Validate token storage keys before Redis reads/deletes - #451

Open
quentinmayo wants to merge 2 commits into
pinterest:masterfrom
quentinmayo:fix/token-storage-key-validation-clean
Open

Validate token storage keys before Redis reads/deletes#451
quentinmayo wants to merge 2 commits into
pinterest:masterfrom
quentinmayo:fix/token-storage-key-validation-clean

Conversation

@quentinmayo

Copy link
Copy Markdown
Contributor

Summary

  • validate token-derived Redis storage keys before any exists/get/delete operation
  • reject tokens that do not match SnapPass key format (REDIS_PREFIX + 32 hex chars)
  • add regression tests to ensure non-SnapPass keys (e.g. session:42) cannot be used as an existence oracle or read/delete target

Test plan

  • MOCK_REDIS=1 .venv/bin/pytest -q tests.py
  • MOCK_REDIS=1 .venv/bin/pytest -q tests.py -k "non_snappass or rejects_non_snappass or get_password or password_exists or retrieve_password_api_v2 or check_password_api_v2"

Reject tokens that do not match SnapPass key format so arbitrary Redis keys cannot be probed, read, or deleted via password retrieval endpoints.
The throwaway `_` shadowed the gettext `_` imported from flask_babel,
which flake8 flags as F811 and failed the lint (build 3.10) job. Restore
the original descriptive `decryption_key` name.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

2 participants