Skip to content

Commit

Permalink
uploads: do not use Origin header in fetchDoc
Browse files Browse the repository at this point in the history
The `Origin` header is produced by `getTransitiveHeaders` but we don't
need it here, as this is only for an internal request where no
cross-origin attacks are possible.
  • Loading branch information
jordigh committed Apr 10, 2024
1 parent 17ea97d commit 400937f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/server/lib/uploads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,12 @@ export async function fetchDoc(server: GristServer, docId: string, req: Request,
// Prepare headers that preserve credentials of current user.
const headers = getTransitiveHeaders(req);

// Passing the Origin header would serve no purpose here, as we are
// constructing an internal request to fetch from our own doc worker
// URL. Indeed, it may interfere, as it could incur a CORS check in
// `trustOrigin`, which we do not need.
delete headers.Origin;

// Find the doc worker responsible for the document we wish to copy.
// The backend needs to be well configured for this to work.
const homeUrl = server.getHomeUrl(req);
Expand Down

0 comments on commit 400937f

Please sign in to comment.