No CORS configuration — API accepts requests from any origin

Open Beginner friendly
#2 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
typescript
Domain
api, backend, security

Research direction

Start in src/main.ts at the NestFactory bootstrap and review how the Fastify adapter is configured. Check how the frontend URL is provided through environment configuration, then verify requests from the known frontend origin and an arbitrary origin. Done means only the configured frontend origin is accepted with the listed credentials and methods.

Written by the indexing model from the issue text.

Description

bug help wanted security

Description

In src/main.ts, the Fastify-based NestJS application does not configure any CORS restrictions:

const app = await NestFactory.create<NestFastifyApplication>(
  AppModule,
  new FastifyAdapter()
);

By default, Fastify/NestJS with no explicit CORS config either accepts all origins or uses the framework's permissive defaults. This means any website can make authenticated API requests to the Hub endpoints, enabling CSRF attacks and cross-origin data theft.

Steps to Reproduce

  1. From any arbitrary domain, send a CORS request to https://hub-api/api/v1/*
  2. The request succeeds without CORS preflight rejection

Expected Behavior

Only known frontend origins (the OpenLake Hub frontend domain) should be allowed to make cross-origin requests.

Suggested Fix

app.enableCors({
  origin: [process.env.FRONTEND_URL],
  credentials: true,
  methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'],
});

Affected Files

  • src/main.ts
Dominant language
TypeScript
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from OpenLake/Hub

All issues in OpenLake/Hub

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.