The normal review, with one generalist agent. Judge: Claude Opus 5.5.
Gold bugs found
1 of 30
Comments published
4
Comments matching a bug
1
Comments not matching
3
Cost of this PR
$0.552
Published comments (4)
mediumbugapp/views/embed/best.html.erb:6
Invalid `end if` in ERB causes SyntaxError — The stray `if` makes the template fail to compile, so the embed page breaks for every topic that already has an embedded discussion. Remove it so the block closes with `<%- end %>`.
mediumsecurityapp/models/post.rb:130-137
Raw HTML cook method bypasses sanitization and enables stored XSS — Externally controlled RSS/Readability HTML can execute as script on the Discourse origin because `embed/best.html.erb` renders `<%= raw post.cooked %>` without sanitization. Sanitize the imported HTML before storing it as `cooked`.
mediumbugapp/jobs/scheduled/poll_feed.rb:31-36
Missing nil guard for i.content.scrub aborts feed polling — A feed item without a content/description element makes `i.content` nil and `scrub` raises NoMethodError, aborting the whole hourly poll. Guard with a nil/blank check, falling back to `i.summary` or `i.description`, before scrubbing.
mediumbugapp/models/topic_embed.rb:15-29
Concurrent imports of same URL raise uncaught unique violation — A concurrent import of the same URL can pass the `embed.blank?` check and then hit the unique index on `embed_url`, raising an uncaught exception that aborts a `retry: false` job. Rescue `ActiveRecord::RecordNotUnique` and roll back, or use atomic find-or-create.
Gold bugs found (1)
highPollFeed reads i.content.scrub for every feed item, so items without a content element (common in RSS feeds that only have description) raise NoMethodError and abort the import of the remaining items.
Gold bugs missed (29)
mediumThe postMessage handler in embed.js checks the sender with discourseUrl.indexOf(e.origin), a substring test instead of exact origin equality, so a page on an origin that is a substring of the Discourse URL can send forged discourse-resize messages to the embedding page.
highThe referer and embed_url host checks compare against SiteSetting.embeddable_host case-sensitively, so a host differing only in case is rejected even though hostnames are case-insensitive.
criticalTopicEmbed.import appends a footer that interpolates the URL unescaped into an <a href='...'> tag in raw HTML that is later rendered unsanitized, so a crafted URL can inject markup; it also appends to contents with << without handling nil.
highWhen the embedded post has been deleted, TopicEmbed.import's update path passes a nil embed.post to PostRevisor and crashes on every later import of that URL.
mediumClaims import_remote crashes on unparseable pages (nil content) and dead URLs because it does no nil check or network error handling around open(url).read.
mediumabsolutize_urls only handles root-relative paths: protocol-relative URLs like //cdn.example.com/x.png are rewritten to http://host/cdn.example.com/x.png and path-relative links are left unresolved, breaking links and images in imported posts.
lowThe embed view formats post dates with a hard-coded strftime pattern, so users in non-English locales see English month names and a fixed order while the rest of the view is translated.
highThe Disqus importer now creates topics through TopicEmbed.import_remote, dropping the thread's created_at and the category option and requiring a live HTTP fetch per thread, so imported topics get wrong dates/categories and a dead link aborts the import.
mediumEvery retrieval of an article not yet embedded synchronously polls and imports the entire RSS feed, and since throttling is per URL, many different article requests repeat the full feed download and processing.
mediumThe 'is 404 without an embed_url' spec never sets an embeddable host, so the request is rejected by ensure_embeddable before the embed_url check runs, and the test would pass even without that check.
mediumThe 'requires feed_polling_url' and 'requires embed_by_username' specs leave feed_polling_enabled at its false default, so they never reach the condition they name and would pass with those checks deleted.
mediumembed_url is a varchar(255) column, so importing/embedding a URL longer than 255 characters fails on insert and that page can never get its discussion topic.
mediumPostMover#copy recreates the first post via PostCreator without passing cook_method, so a moved raw_html (embedded/imported) first post is re-cooked through the markdown pipeline and its content changes.
mediumEmbedController#best renders the 'loading' placeholder and still calls discourse_expires_in 1.minute, so the anonymous cache stores the placeholder under the embed URL and visitors keep seeing 'Loading Discussion...' for up to a minute after the topic exists.
mediumTopicEmbed.import wraps PostCreator#create in Topic.transaction, so PostCreator's post-transaction job enqueueing (process_post, feature_topic_users, etc.) runs before the outer transaction commits, and a worker that picks up ProcessPost early finds no post and skips post-processing for the imported topic.
high`import_remote` fetches the embed URL with open-uri, which follows redirects, so the embeddable-host check on the initial URL can be bypassed to reach internal services (SSRF).
mediumTopicEmbed.import_remote fetches the embed URL with open(url).read and no timeout or size limit, so a slow or huge remote page can block the background job and exhaust memory.
mediumThe retrieve throttle is keyed by the full embed URL, so an anonymous client can vary the query string on the embeddable host to bypass it and make the server create an unbounded number of topics.
mediumThe "requires feed_polling_enabled?" spec leaves feed_polling_url and embed_by_username at their blank defaults, so poll_feed is skipped regardless and the test would pass even without the enabled check.
highThe embed layout references the 'embed' stylesheet and embed.js, but neither is in config.assets.precompile, so with precompiled assets in production the embed page fails to load them.
highThe embed layout writes the full request.referer into the page, and the page is anon-cached for a minute under a key without the referer. One embedding page's full URL, including query secrets, can be served to other visitors.
mediumTopicEmbed.import checks post.present? after PostCreator#create, but PostCreator returns an unsaved post when it rolls back on host spam. TopicEmbed.create! then runs with nil ids and raises, which aborts the import.
mediumabsolutize_urls calls URI(url) without a rescue, so a malformed URL that passes the http regex raises URI::InvalidURIError and aborts the PollFeed import.
mediumtopic_id_for_embed returns the stored topic_id even after the topic is deleted, and topic_embeds rows are never removed. /embed/best errors permanently for that URL, and TopicRetriever never re-creates the topic.
highPollFeed always HTML-unescapes item content, so feeds that already carry literal HTML (CDATA) get their escaped entities decoded a second time. Escaped code samples become live markup in the raw_html post.
mediumEmbedController#best's anonymous cache key leaves out the referer. Within the cache window, a request from a non-embeddable or missing referer gets the cached page, including X-Frame-Options ALLOWALL, without ensure_embeddable running.
mediumTopicRetriever#perform_retrieve runs PollFeed inline without a rescue, so a failing or malformed feed raises and aborts retrieval before the fetch_http fallback runs.
highPollFeed fetches feed_polling_url with Kernel#open, so a setting value starting with '|' runs a shell command on the job server. Anyone who can edit site settings gets command execution.
mediumPost#cook returns self.raw for raw_html posts and ignores the text it is given. Callers that cook different text, such as add_topic_to_quotes.rake, store cooked output that does not match the new raw.