Fix critical security vulnerabilities#71
Open
beta-devin-ai-integration[bot] wants to merge 1 commit into
Open
Conversation
- Replace hardcoded Stripe keys and weak JWT secret in example.env with placeholders - Fix admin password change to use findOne+save (triggers bcrypt setter) instead of updateOne (stores plaintext) - Add secure and sameSite flags to auth cookie - Fix IDOR on video re-render by adding owner check - Add NoSQL injection protection with string type validation on registration and admin user creation - Tighten CORS to only allow permissive mode when NODE_ENV=development (not just != production) - Sanitize Stripe webhook error response to not leak internal details - Remove console.log of sensitive Stripe session data - Move dotenv.config() before modules that depend on env vars Co-Authored-By: ahlback.emil+coggitgrant <me@emil.zip>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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
Security audit of the backend (
bog-api/) identified and fixes 10 issues:example.env: Replaced real Stripe test keys (sk_test_...,whsec_...) and a weak JWT secret with placeholder valuesUser.updateOne()which bypasses Mongoose schema setters — the bcrypt hash was never applied. Changed tofindOne()+.save()to trigger the settersecure(production) andsameSite: "strict"flagsowner: req.user._idfilterusername/emailfromreq.bodywere passed directly into MongoDB queries. Addedtypeof === "string"validation on registration and admin user creation!== "production"to=== "development"so CORS isn't accidentally open whenNODE_ENVis unseterr.messagefrom response andconsole.log(session)of payment datadotenv.config()before modules that readprocess.envReview & Testing Checklist for Human
sk_test_*andwhsec_*values are still in git history. They should be rotated in the Stripe dashboard immediatelysameSite: "strict"doesn't break Stripe checkout redirect — after completing payment on Stripe's hosted checkout page, the redirect back to the app relies on the auth cookie being sent.strictblocks cookies on cross-site navigations; if this breaks the flow, change to"lax"NODE_ENVvalue other than"development"(e.g.,"staging","test", or unset), CORS will now be disabled. Check that all environments that need CORS setNODE_ENV=developmentPUT /api/admin/users/:id/change-passwordare properly bcrypt-hashed in the database (not stored as plaintext)body.rerenderVideoNotes
username/emailon registration and admin user creation. Other endpoints (e.g.,/api/authlogin) also passreq.bodyfields into queries without type checks — these should be addressed in a follow-up/videosstatic file route still serves any file to any authenticated user without ownership checks — flagged in the audit but not fixed here as it requires an architectural changeLink to Devin session: https://app.beta.devin.ai/sessions/01fe4df39ecd47ed8a6c83cb255aa88a
Requested by: @FOLLGAD