Fix cross-origin policy accepts any origin in SolidStart

The CORS configuration accepts requests from any origin. Combined with credentials this lets any site a logged-in user visits make authenticated calls to the API and read the responses. Without credentials it may be intentional for a public API - the finding says which case it found.

medium likely SolidStart CWE-942 / OWASP A05:2021

The vulnerable pattern in SolidStart

MEDIUM likely Cross-origin policy accepts any origin A05:2021 src/middleware.ts:5:7 3 │ (event: { response: { headers: Headers } }) => { 4 │ // cors-permissive: wildcard origin AND credentials, hand-rolled. 5 │ event.response.headers.set('access-control-allow-origin', '*') │ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ accepts requests from any origin 6 │ event.response.headers.set('access-control-allow-credentials', 'true') 7 │ },

This finding comes from the SolidStart fixture in the owlwarden test suite. Any origin may call this API and read the response. That is a deliberate choice for a public endpoint and a mistake for anything behind a session - nothing in the source says which this is, so it is reported for you to decide.

The corrected handler

Name the origins in middleware rather than reflecting whatever arrived.

const ALLOWED = new Set(['https://app.example.com'])
const origin = event.request.headers.get('origin') ?? ''
if (ALLOWED.has(origin)) {
  event.response.headers.set('Access-Control-Allow-Origin', origin)
  event.response.headers.append('Vary', 'Origin')
}

If you are not using SolidStart

Replace the wildcard with the origins that actually need access, and only send credentials to those.

Check your own repository

npx owlwarden scan
npx owlwarden explain cors-permissive

Runs on your machine. No account, no telemetry, no network unless you ask. In CI, SARIF uploads to code scanning and the exit code is the gate.

Other SolidStart checks

Rules with a tested SolidStart example.

cors-permissive for every framework / All rules / owlwarden