Commit e9205f98 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'security-include-directive-allows-ssrf-requests' into 'master'

[Master]: - Ensures SSRF requests are not allowed by include directive

See merge request gitlab/gitlab-ee!625
parents 57fab4c6 b9d00365
---
title: Fixes include directive to not allow SSRF requests
merge_request:
author:
type: security
...@@ -11,8 +11,8 @@ module Gitlab ...@@ -11,8 +11,8 @@ module Gitlab
@content = strong_memoize(:content) do @content = strong_memoize(:content) do
begin begin
Gitlab::HTTP.get(location, allow_local_requests: true) Gitlab::HTTP.get(location)
rescue Gitlab::HTTP::Error, Timeout::Error, SocketError rescue Gitlab::HTTP::Error, Timeout::Error, SocketError, Gitlab::HTTP::BlockedUrlError
nil nil
end end
end end
......
...@@ -50,6 +50,14 @@ describe Gitlab::Ci::External::File::Remote do ...@@ -50,6 +50,14 @@ describe Gitlab::Ci::External::File::Remote do
expect(remote_file.valid?).to be_falsy expect(remote_file.valid?).to be_falsy
end end
end end
context 'with an internal url' do
let(:location) { 'http://localhost:8080' }
it 'should be falsy' do
expect(remote_file.valid?).to be_falsy
end
end
end end
describe "#content" do describe "#content" do
...@@ -84,6 +92,14 @@ describe Gitlab::Ci::External::File::Remote do ...@@ -84,6 +92,14 @@ describe Gitlab::Ci::External::File::Remote do
expect(remote_file.content).to be_nil expect(remote_file.content).to be_nil
end end
end end
context 'with an internal url' do
let(:location) { 'http://localhost:8080' }
it 'should be nil' do
expect(remote_file.content).to be_nil
end
end
end end
describe "#error_message" do describe "#error_message" do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment