Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13578
bug65839b-REL1_19.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Authored By
•
bzimport
Nov 22 2014, 3:10 AM
2014-11-22 03:10:48 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
bug65839b-REL1_19.patch
View Options
From 4f78d3cf09adde74ced1dddfda7f56467b5a227d Mon Sep 17 00:00:00 2001
From: csteipp <csteipp@wikimedia.org>
Date: Wed, 28 May 2014 16:55:40 -0700
Subject: [PATCH] SECURITY: Prevent external resources in SVG files
On bug 65724, it was discovered that a user could upload SVG images
with embedded <image> elements that pulled in the resource via http.
This could allow an attacker to track all viewers of an SVG by having
the image embed another image hosted on their own server.
While testing the patch, I also identified 3 more element namespaces
that have been used on commons and seem harmless, so I added those to
the whitelist.
Change-Id: I0eb08831f8606e44d548c31e7d2bf20e51554e0c
---
includes/upload/UploadBase.php | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/includes/upload/UploadBase.php b/includes/upload/UploadBase.php
index 7903087..3028e05 100644
--- a/includes/upload/UploadBase.php
+++ b/includes/upload/UploadBase.php
@@ -1186,10 +1186,19 @@ abstract class UploadBase {
return true;
}
- # href with javascript target
- if( $stripped == 'href' && strpos( strtolower( $value ), 'javascript:' ) !== false ) {
- wfDebug( __METHOD__ . ": Found script in href attribute '$attrib'='$value' in uploaded file.\n" );
- return true;
+ # href with non-local target (don't allow http://, javascript:, etc)
+ if ( $stripped == 'href'
+ && strpos( $value, 'data:' ) !== 0
+ && strpos( $value, '#' ) !== 0
+ ) {
+ if ( !( $strippedElement === 'a'
+ && preg_match( '!^https?://!im', $value ) )
+ ) {
+ wfDebug( __METHOD__ . ": Found href attribute <$strippedElement "
+ . "'$attrib'='$value' in uploaded file.\n" );
+
+ return true;
+ }
}
# href with embeded svg as target
--
1.9.2.msysgit.0
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
13009
Default Alt Text
bug65839b-REL1_19.patch (1 KB)
Attached To
Mode
T67839: Investigate SVG's uploaded with external resources
Attached
Detach File
Event Timeline
Log In to Comment