🔒 [security fix] Restrict overly permissive CORS configuration#68
🔒 [security fix] Restrict overly permissive CORS configuration#68
Conversation
- Modified gui/backend/server.js to implement restricted CORS for Express and Socket.io - Added ALLOWED_ORIGINS environment variable support with secure defaults - Updated .env.example and gui/backend/.env.example - Added tests/cors_logic_test.js for verification - Verified with existing order validation and MCP tests
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
🎯 What: This PR fixes an overly permissive CORS configuration in the Node.js backend (
gui/backend/server.js) that affected both the Express REST API and the Socket.io real-time server.*) to make requests. This could potentially allow malicious websites to perform actions or leak data if a user visits them while authenticated with the dashboard, bypassing browser-level cross-origin protections.🛡️ Solution:
app.use(cors())with a configured version that checks theOriginheader against a whitelist.ALLOWED_ORIGINS(comma-separated list) to allow flexible configuration.localhost:5173,127.0.0.1:5173, etc.) to maintain ease of use while remaining "secure by default".tests/cors_logic_test.jsto verify the origin-checking logic..env.exampleandgui/backend/.env.example.All tests, including existing order validation and CCXT MCP tests, have passed.
PR created automatically by Jules for task 10579433568742318875 started by @PelleNybe