Skip to content

Commit

Permalink
SECURITY: Don't allow base_uri as embeddable host if none exist
Browse files Browse the repository at this point in the history
  • Loading branch information
eviltrout committed Sep 30, 2019
1 parent 7561044 commit d5c5ca4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/embeddable_host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def self.record_for_url(uri)

def self.url_allowed?(url)
# Work around IFRAME reload on WebKit where the referer will be set to the Forum URL
return true if url&.starts_with?(Discourse.base_url)
return true if url&.starts_with?(Discourse.base_url) && EmbeddableHost.exists?

uri = begin
URI(UrlHelper.escape_uri(url))
Expand Down
4 changes: 4 additions & 0 deletions spec/models/embeddable_host_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@
end
end

it "doesn't allow forum own URL if no hosts exist" do
expect(EmbeddableHost.url_allowed?(Discourse.base_url)).to eq(false)
end

describe "url_allowed?" do
fab!(:host) { Fabricate(:embeddable_host) }

Expand Down

3 comments on commit d5c5ca4

@darix

This comment was marked as off-topic.

@discoursereviewbot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SamSaffron posted:

I think it does, we will backport it.

@ZogStriP
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been backported to both stable and beta.

Please sign in to comment.