Skip to content

πŸ› Bug Report: Wildcard CORS Configuration Exposes Backend to Security RisksΒ #285

@manurajgoel

Description

@manurajgoel

πŸ“œ Description

In server.js, CORS is configured with a wildcard '*', which allows any origin to make requests to the backend β€” including malicious websites.

// Current (vulnerable)
app.use(cors('*'));

This is a serious security risk for an authenticated app that uses express-session and passport. With wildcard CORS:

  • Credentials/cookies may be exposed to untrusted origins
  • Any third-party site can make API calls to the backend
  • Session hijacking attacks become easier

Expected Behavior:
CORS should only allow requests from the known frontend origin (e.g., http://localhost:5173 in dev, and the deployed frontend URL in production), configured via an environment variable.

Suggested Fix:

// After fix in server.js
app.use(cors({
  origin: process.env.ALLOWED_ORIGIN || 'http://localhost:5173',
  credentials: true
}));

What browsers are you seeing the problem on?

No response

πŸ“ƒ Relevant Screenshots (Links)

No response

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions