security: decouple settings keys and sandbox game iframes#369
Open
afnan0304 wants to merge 1 commit into
Open
Conversation
Signed-off-by: afnan0304 <mhdafnan309@gmail.com>
|
@afnan0304 is attempting to deploy a commit to the kaif ansari 's projects Team on Vercel. A member of the Team first needs to authorize it. |
❌ Deploy Preview for gamehub-99999 failed.
|
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.
📝 Pull Request Template
📄 Description
This PR fixes two major security flaws where the app was leaving its keys out in the open and letting third-party game code touch sensitive user data.
Backend: Cleaned up settings.py. Instead of hardcoding the master SECRET_KEY, leaving DEBUG=True, and allowing all hosts (*), the app now uses python-dotenv to safely load these settings from a local .env file. I also added a bulletproof parser for ALLOWED_HOSTS that handles extra spaces or commas gracefully and defaults to local setup if empty.
Frontend: Locked down the game components (GamePlayPage.jsx and GameModal.jsx). I added sandbox="allow-scripts allow-forms" to the game iframes. Leaving out the allow-same-origin flag forces the browser to isolate the game completely. Even though the games run on the same domain, they are now legally blocked by the browser from sneaking into localStorage and stealing user auth tokens.
Environment Files: Created a new frontend/.env.example file to serve as a blueprint for the frontend setup, ensuring other developers know exactly how to configure their local environment keys without leaking real ones.
🔗 Related Issues
🧩 Type of Change
Select the type of change your PR introduces (check all that apply):
🐛 Bug Fix
✨ New Feature
⚡ Enhancement / Optimization
🧰 Refactoring
🧾 Documentation Update
🔧 Other (please specify): Security Patch
✅ Checklist
Before submitting your PR, please confirm the following:
💬 Additional Notes (Optional)
This completely solves the token leak and hardcoded secret bugs for GSSoC'26. Everything runs perfectly fine on local env files.