Skip to content

🔒 [security fix] Restrict overly permissive CORS configuration#68

Merged
PelleNybe merged 1 commit intomainfrom
fix-cors-security-10579433568742318875
Apr 12, 2026
Merged

🔒 [security fix] Restrict overly permissive CORS configuration#68
PelleNybe merged 1 commit intomainfrom
fix-cors-security-10579433568742318875

Conversation

@PelleNybe
Copy link
Copy Markdown
Owner

🎯 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.

⚠️ Risk: Previously, the server allowed any origin (*) 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:

  • Replaced app.use(cors()) with a configured version that checks the Origin header against a whitelist.
  • Configured Socket.io with the same restricted CORS settings.
  • Introduced a new environment variable ALLOWED_ORIGINS (comma-separated list) to allow flexible configuration.
  • Provided sensible defaults for local development (localhost:5173, 127.0.0.1:5173, etc.) to maintain ease of use while remaining "secure by default".
  • Added a standalone test suite tests/cors_logic_test.js to verify the origin-checking logic.
  • Updated documentation in .env.example and gui/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

- 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
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@PelleNybe PelleNybe merged commit a801484 into main Apr 12, 2026
@PelleNybe PelleNybe deleted the fix-cors-security-10579433568742318875 branch April 12, 2026 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant