diff --git a/lib/gitlab/github_import/markdown/attachment.rb b/lib/gitlab/github_import/markdown/attachment.rb
index a5cf5ffa60e466181cf846b67fc5f2c2af7d90b5..1c814e34a397ef8106fe69377f0411cae83709c5 100644
--- a/lib/gitlab/github_import/markdown/attachment.rb
+++ b/lib/gitlab/github_import/markdown/attachment.rb
@@ -28,6 +28,7 @@ def from_markdown(markdown_node)
           def from_markdown_image(markdown_node)
             url = markdown_node.url
 
+            return unless url
             return unless github_url?(url, media: true)
             return unless whitelisted_type?(url, media: true)
 
@@ -37,6 +38,7 @@ def from_markdown_image(markdown_node)
           def from_markdown_link(markdown_node)
             url = markdown_node.url
 
+            return unless url
             return unless github_url?(url, docs: true)
             return unless whitelisted_type?(url, docs: true)
 
@@ -46,7 +48,7 @@ def from_markdown_link(markdown_node)
           def from_inline_html(markdown_node)
             img = Nokogiri::HTML.parse(markdown_node.string_content).xpath('//img')[0]
 
-            return unless img
+            return if img.nil? || img[:src].blank?
             return unless github_url?(img[:src], media: true)
             return unless whitelisted_type?(img[:src], media: true)
 
diff --git a/spec/lib/gitlab/github_import/markdown/attachment_spec.rb b/spec/lib/gitlab/github_import/markdown/attachment_spec.rb
index 5d29de3414165d84c25d96b3bc6545ad9e6fe086..588a3076f59cad8fc27b4eeec1a113dcdb3d1a27 100644
--- a/spec/lib/gitlab/github_import/markdown/attachment_spec.rb
+++ b/spec/lib/gitlab/github_import/markdown/attachment_spec.rb
@@ -35,6 +35,12 @@
 
         it { expect(described_class.from_markdown(markdown_node)).to eq nil }
       end
+
+      context 'when URL is blank' do
+        let(:url) { nil }
+
+        it { expect(described_class.from_markdown(markdown_node)).to eq nil }
+      end
     end
 
     context "when it's an image attachment" do
@@ -63,6 +69,12 @@
 
         it { expect(described_class.from_markdown(markdown_node)).to eq nil }
       end
+
+      context 'when URL is blank' do
+        let(:url) { nil }
+
+        it { expect(described_class.from_markdown(markdown_node)).to eq nil }
+      end
     end
 
     context "when it's an inline html node" do
@@ -80,6 +92,12 @@
         expect(attachment.name).to eq name
         expect(attachment.url).to eq url
       end
+
+      context 'when image src is not present' do
+        let(:img) { "<img width=\"248\" alt=\"#{name}\">" }
+
+        it { expect(described_class.from_markdown(markdown_node)).to eq nil }
+      end
     end
   end