Heuristic:1jehuang Jcode No CORS No Echo
| Knowledge Sources | |
|---|---|
| Domains | Security, API_Design |
| Last Updated | 2026-10-18 00:00 GMT |
Overview
OAuth account endpoints forbid browser access (no CORS) and never echo database errors, payloads, or email addresses, preventing account-membership oracle attacks.
Description
The No_CORS_No_Echo heuristic ensures that the OAuth account tracking endpoints (/v1/oauth-account and /v1/oauth-account/check) reject any request with an Origin header (HTTP 403 Forbidden), preventing browser-based access. The UUID is a correlation identifier, not authentication — browser access would allow cross-origin attacks. Additionally, the endpoints never echo database errors, payloads, email addresses, or private digests. If a database error occurs, a generic "Account storage unavailable" (HTTP 503) is returned instead. Insertion/dedup status is not exposed as an account-membership oracle — the endpoint always returns { ok: true } on success, regardless of whether the account was newly inserted or already existed.
Usage
Use this heuristic when designing endpoints that handle account identifiers or credentials. Reject browser-originated requests by checking for the Origin header. Never echo internal errors, user data, or insertion status, as these can be used as oracles to probe for account existence.
The Insight (Rule of Thumb)
- Action: Return HTTP 403 if
request.headers.has("Origin"); return generic errors (503) on database failures; always return{ ok: true }regardless of insertion/dedup status. - Value: No CORS on OAuth endpoints; no error echoing; no insertion-status oracle.
- Trade-off: Browser-based tools cannot call these endpoints directly; all access must be from non-browser clients (CLI, server).
- Compatibility: The main telemetry beacon (
/v1/event) keeps permissive CORS (ALLOWED_ORIGIN = "*") since telemetry is anonymous and unauthed.
Reasoning
If the OAuth account endpoint allowed browser access (CORS), a malicious website could probe whether a visitor's email/UUID is in the jcode account database by observing insertion vs. dedup responses. By forbidding browser access and never revealing insertion status, the endpoint cannot be used as an account-membership oracle. Echoing database errors could leak schema details or confirm/deny account existence through error messages.
Code Evidence
No browser CORS from telemetry-worker/src/oauth-account.js:14-16:
export async function oauthAccount(request, env, check) {
// No browser CORS access: a UUID is a correlation identifier, not authentication.
if (request.headers.has("Origin")) return reply({ error: "Forbidden" }, 403);
No error echoing from telemetry-worker/src/oauth-account.js:88-92:
// Do not expose insertion/dedup status as an account-membership oracle.
return reply({ ok: true });
} catch {
// Never echo database errors, payloads, email addresses, or private digests.
return reply({ error: "Account storage unavailable" }, 503);
}
Contrast with main beacon CORS from telemetry-worker/src/worker.js:65-68:
// Origins the website beacon posts from. The default CORS policy stays the
// permissive ALLOWED_ORIGIN var ("*", telemetry is anonymous and unauthed);