Lock down CORS and add rate limiting on the chat endpoints#68
Open
n33levo wants to merge 1 commit into
Open
Conversation
50cc7e3 to
335e2d8
Compare
0f84e2f to
df80dcf
Compare
marcelobarreto
left a comment
Member
There was a problem hiding this comment.
Review assisted by pair-review
df80dcf to
103b801
Compare
335e2d8 to
030dddd
Compare
103b801 to
92f86f5
Compare
Author
|
Follow-up audit after re-reading the stack end-to-end: I pushed The extra #68 fix is in the widget: it now checks non-OK chat responses before reading the response body as SSE, so HTTP 429 JSON responses surface as the busy message instead of being parsed as stream frames. Re-verified top of stack: |
n33levo
commented
Jun 9, 2026
n33levo
left a comment
Author
There was a problem hiding this comment.
Review assisted by pair-review
n33levo
commented
Jun 9, 2026
n33levo
left a comment
Author
There was a problem hiding this comment.
Review assisted by pair-review
92f86f5 to
7db6511
Compare
b50b09f to
8881405
Compare
We were echoing back any Origin (with credentials), so any site could read chat responses cross-origin. Now we only allow origins from ALLOWED_ORIGINS (plus localhost in dev). Also added a small in-memory rate limiter on the chat, history, and token-status routes to slow down brute-force guessing.
7db6511 to
e88c87e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this fixes
This follows the IDOR fix in #67 and closes the cross-origin / brute-force pieces called out in Shopify/consumer-agent#1826.
What changed
ALLOWED_ORIGINSare echoed back; localhost browser clients are allowed in development.Vary: Origin..env.examplenow calls out that Shopify storefront origins are required in every environment.X-Forwarded-Forinto a sharedunknownbucket.text/event-streamfor JSON bodies.CustomerToken, so it no longer answers questions about rawconversation_idvalues.X-Shopify-Shop-Idwhen polling token status.Stack
Verification
node --test— 28 passing, 5 Vite-backed route tests skipped locally because dependencies are not installed in this checkout.node --check.git diff --check.