MiniMax M3 · Heavy
enhance-embed-url-handling-and-validation-system-discourse-cursor
Discourse · Ruby · M · 100–299 lines · 6 files
The generalist plus 9 specialist lens agents in parallel, then the same verify and dedup steps. Judge: Claude Haiku 5.5.
- Gold bugs found
- 2 of 12
- Comments published
- 8
- Comments matching a bug
- 2
- Comments not matching
- 6
- Cost of this PR
- $0.529
Published comments (8)
Raw request.referer interpolated into JS string breaks out of context — Raw `<%= request.referer %>` interpolation into a JS string lets an attacker with a single quote or `</script>` segment in the URL execute script in the parent page. Wrap with `j`/`json_escape` so the referer cannot break out of the JS context.
URL interpolated raw into href attribute and link text enables XSS — Wrap both occurrences in `CGI.escapeHTML(url)` and prefer double-quoted attributes.
PollFeed runs synchronously on every embed cache miss — Running `Jobs::PollFeed.new.execute({})` inline makes each cached-miss embed view pay the cost of a full RSS import. Enqueue `Jobs.enqueue(:poll_feed)` instead and only return early on the existence check.
postMessage origin check uses substring match instead of origin comparison — `discourseUrl.indexOf(e.origin) === -1` accepts any origin whose string appears inside `discourseUrl`, allowing attacker-controlled origins to resize the iframe. Compare `new URL(discourseUrl).origin === e.origin` to match only the parsed origin.
Synchronous PollFeed in embed render path — Invoking `Jobs::PollFeed.new.execute({})` inline in `perform_retrieve` blocks the embed render on a full RSS fetch and import per cache miss. Drop the synchronous call and let the scheduled `PollFeed` job reconcile topics, relying only on the embed_url existence check.
postMessage origin check uses unsafe substring match — `discourseUrl.indexOf(e.origin) === -1` matches any origin substring contained in `discourseUrl`, so attackers on a shorter matching origin can resize the iframe. Replace with `e.origin === new URL(discourseUrl).origin` for an exact parsed comparison.
"is 404 without an embed_url" test sits outside "with a host" context — Move it inside the context and stub referer so only the embed_url path is exercised.
Layout echoes full request.referer (incl. query string) into JS context — Echo only the scheme and host from `URI(request.referer)` through the `j` helper so embedding-site query secrets never reach the response.