Repository navigation
feat(security): dynamic runtime password pepper injection from Cloudflare secrets - #133
Open
Lakshya-2440 wants to merge 2 commits into
Open
Lakshya-2440 wants to merge 2 commits into
Lakshya-2440 wants to merge 2 commits into
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR resolves the hardcoded password pepper vulnerability in
src/worker.pyby introducing dynamic runtime pepper injection from Cloudflare secrets.Previously,
_PEPPERwas statically hardcoded asb"edu-platform-cf-pepper-2024", causing all clones and deployments to share the same password-salt derivation material.Key Changes
Dynamic Pepper Resolution (
src/worker.py):get_pepper(env)with hierarchical resolution:PASSWORD_PEPPERorPEPPERbinding on the Cloudflareenvobject._ACTIVE_PEPPERinitialized duringon_fetch().os.environ["PASSWORD_PEPPER"]oros.environ["PEPPER"].ENVIRONMENTorSENTRY_ENVIRONMENTequalsproduction) and the pepper secret is missing, it raises aRuntimeErrorinstead of falling back to default values._DEFAULT_PEPPER(b"edu-platform-cf-pepper-2024").Injected into Cryptographic Routines:
_user_salt(),hash_password(), andverify_password()with optionalpepperandenvarguments.on_fetch()viainit_pepper(env).env=envintoapi_register,api_login,api_reset_password,api_change_password,seed_db, and guest checkout.Test Suite (
tests/test_password.py):TestDynamicPeppertest suite covering:envbinding andPEPPERalias.os.environ.make_envhelper intests/helpers.py.Documentation:
PASSWORD_PEPPERto setup instructions and Wrangler production secrets inREADME.md.Verification
python3 -m py_compile src/worker.pypassed with 0 errors.tests/test_password.pypass cleanly.I used gemini 3.8