Add CORS recommendation for browser-based clients (section 2)#14
Add CORS recommendation for browser-based clients (section 2)#14mwiesen wants to merge 1 commit into
Conversation
SPXP servers SHOULD send Access-Control-Allow-Origin: * to allow browser-based clients to access SPXP endpoints without a server-side proxy. Closes #12
Security Analysis: CORS and AuthenticationSince there have been questions about whether enabling CORS could open up security vulnerabilities, here's a structured analysis of the relevant scenarios. Preliminary: CORS vs. CSRFThe concern that a malicious website could use existing browser credentials to perform actions on behalf of a user is a classic CSRF (Cross-Site Request Forgery) attack — not a direct consequence of CORS. The two are related but distinct:
A critical detail: Block 1: Read access — public endpoints
Takeaway: CORS never protects against server-to-server access. Anyone who wants to scrape public data doesn't need CORS. Block 2: Read access — authenticated / private content
Block 3: Write access — management endpoints
Block 4: Preflight and header control
Block 5: Edge cases
Conclusion
Furthermore, if management requests are cryptographically signed (as in SPXP), the entire threat model is inherently immune to CSRF: without the private key, no attacker can produce a valid signed request regardless of CORS configuration. |
Closes #12
Summary
Adds a SHOULD-level recommendation for SPXP servers to include the
Access-Control-Allow-Origin: *HTTP response header on all endpoints.Motivation
Browser-based SPXP clients (e.g. web viewers, web UIs) cannot access SPXP endpoints cross-origin without CORS headers. Currently, such clients must route all requests through a server-side proxy — a significant barrier that contradicts the protocol's design goal of direct client-server communication.
Adding this as a SHOULD (not MUST) keeps existing server implementations valid while signalling best practice for new implementations and hosting providers.
Changes
SPXP-Spec.md, section 2 (Communication protocols): Added one sentence recommendingAccess-Control-Allow-Origin: *on all SPXP endpoints.