fix: resolve CodeQL security issues for URL redirects and CORS - #81
Merged
Merged
Conversation
- Add isLocalUrl validation utility to prevent open redirect vulnerabilities - Validate req.originalUrl before directory trailing slash redirects - Validate req.path before legacy endpoint redirects (create-folder, search) - Fix permissive CORS configuration when whitelist is empty - Add security warnings for rejected redirects and CORS misconfigurations Resolves 4 CodeQL security findings: - Server-side URL redirect at routes/fileServer.js:231 - Server-side URL redirect at routes/fileServer.js:1082 - Server-side URL redirect at routes/fileServer.js:1086 - Permissive CORS configuration at app.js:72
🤖 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.
fix: resolve CodeQL security issues for URL redirects and CORS
Summary
This PR addresses 4 CodeQL security findings by implementing URL validation for redirects and fixing permissive CORS configuration:
isLocalUrl()function inconfig/paths.jsthat validates URLs stay on the same originroutes/fileServer.js:app.js: Whenallow_origin: trueis set with an empty whitelist, now defaults to blocking all CORS requests instead of allowing all originsAll redirects now validate the target URL before redirecting, and CORS configuration properly enforces whitelisting.
Review & Testing Checklist for Human
🔴 High Priority (3 items)
/some/folder) and verify it still redirects to/some/folder/correctlyisLocalUrl()function useshttps://localhostas the base - confirm this approach works correctly with your actual domain setup in productionNotes
allow_origin: truenow fail secure (block all) rather than allow all origins?action=create-folder,?action=search) continue to work but with validationLink to Devin run: https://app.devin.ai/sessions/7854353c8b2c43edb12a9967e5c7cdb5
Requested by: @MarkProminic (mark.gilbert@prominic.net)