cloudflare / cloudflare/cloudflare-os
OAuth error callback reflects parameters without explicit Content-Type header
- Dominant language
- TypeScript
- Stars
- 9.9k
- Forks
- 1.2k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 107
Description
## Summary
The OAuth error callback handler in `packages/gatekeeper-cloudflare/src/cloudflare.ts` (L124-127) reflects `error` and `error_description` query parameters directly into the response body without an explicit Content-Type header.
## Affected Code
```typescript
const error = url.searchParams.get("error");
if (error) {
return new Response(`${error}: ${url.searchParams.get("error_description")}`);
}
```
The default Content-Type for `new Response(string)` is `text/plain` in modern runtimes, which mitigates XSS in current browsers. However, explicitly setting the header is defensive practice and prevents issues if the response is ever proxied or consumed by a component that infers content type differently.
## Suggested Fix
Set an explicit Content-Type header:
```typescript
return new Response(`${error}: ${url.searchParams.get("error_description")}`, {
headers: { "Content-Type": "text/plain; charset=utf-8" },
});
```
## Severity
Low. This is a hardening measure rather than an active vulnerability.
Previously submitted as part of PR #66 (closed per contributing guidelines).
Contributor guide
Research direction
Read packages/gatekeeper-cloudflare/src/cloudflare.ts at lines 124-127 and inspect the OAuth error callback response path. Done means responses containing the error parameters explicitly declare text/plain; charset=utf-8 while preserving the existing callback behavior; no specific test is named in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- authentication, security
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 82/100