Skip to content

A platform for community discussion. Free, open, simple.

SECURITY: Remove bypass for base_url (#19995)

Bianca Nenciucd7c8861ae87
diff --git a/app/models/embeddable_host.rb b/app/models/embeddable_host.rb
index 721faed2b61..285c6fd1b79 100644
--- a/app/models/embeddable_host.rb
+++ b/app/models/embeddable_host.rb
@@ -45,9 +45,6 @@ class EmbeddableHost < ActiveRecord::Base
def self.url_allowed?(url)
return false if url.nil?
- # 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) && EmbeddableHost.exists?
-
uri =
begin
URI(UrlHelper.normalized_encode(url))
diff --git a/spec/models/embeddable_host_spec.rb b/spec/models/embeddable_host_spec.rb
index 68871b9402d..a72c577be89 100644
--- a/spec/models/embeddable_host_spec.rb
+++ b/spec/models/embeddable_host_spec.rb
@@ -88,8 +88,8 @@ RSpec.describe EmbeddableHost do
expect(EmbeddableHost.url_allowed?("http://discourse.org")).to eq(true)
end
- it "always allow forum own URL" do
- expect(EmbeddableHost.url_allowed?(Discourse.base_url)).to eq(true)
+ it "does not allow forum own URL" do
+ expect(EmbeddableHost.url_allowed?(Discourse.base_url)).to eq(false)
end
end