Fix security issues in generated templates and CLI subprocess calls - #1
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
Fix security issues in generated templates and CLI subprocess calls#1devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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.
Checklist
Description of Changes
Security scan of the CLI and the
_templatefiles it copies into generated projects. Template issues matter most: every generated project inherits them.Mass assignment / MongoDB operator injection in the generated users API (
_template/plugins/mongoose/app/api/users/**)The routes passed the raw parsed body straight to Mongoose:
Now both go through a whitelist that accepts only string
first_name/last_name, so$-prefixed keys and unknown fields are rejected with 400. Also added:ObjectId.isValid(id)checks before querying, 404 (not 400) when a document doesn't exist,deletedCountcheck in DELETE instead of truthiness of the always-truthy result object, try/catch aroundreq.json(), and removed the raw Mongooseerrorobject from the POST response body (leaked schema/validator internals to clients).Unauthenticated API routes when the Kinde auth plugin is installed (
_template/plugins/kinde/middleware.ts)Matcher was
['/dashboard/:path*'], so the generated/api/usersCRUD endpoints were world-writable even in a project that opted into auth. Now['/dashboard/:path*', '/api/((?!auth).*)']— all API routes protected, Kinde's own/api/auth/**handler excluded.Shell interpolation in CLI subprocess calls
git clone ${githubUrl} ${projectName}andnpm install ${pkg}ran through a shell. Replaced withexecFile/execFileSyncargv form (newsrc/utils/exec-file-async.ts; the now-unusedexec-async.tsshell helper is deleted). Currently reachable only with hardcoded values, but it removes the injection sink for future templates/plugins.Other
encodeURIComponenton the MongoDB password substituted into the connection URL — an unencoded@///:in the password otherwise corrupts the URI or misroutes the credential.npm audit fix: 25 vulnerabilities (16 high) → 1 low. Lockfile only, nopackage.jsonrange changes; notablyinquirer's transitivetmppath-traversal advisories..gitignorehad# .envcommented out, so a stray.env/.env.localin the repo root was committable. Now ignored (.env.examplestill allowed).Not changed: no hardcoded secrets or credentials found anywhere in the tree or in template files; no SQL usage; no CORS configuration; no debug/diagnostic endpoints. The generated
/test-databasepage is a plain form, not a debug endpoint, and relies on the API validation added here.Verified with
npm run build,npx tsc --noEmit, andnpm run lint -- src. The one Prettier warning onselectGitHubTemplate.tspredates this branch (confirmed againstHEAD) and is left alone.Related Issues
None
Link to Devin session: https://app.devin.ai/sessions/799e228e489d4679a22c8701a758dc3b
Requested by: @lox-bot