Title: [207775] trunk/Source/WebCore
Revision
207775
Author
[email protected]
Date
2016-10-24 13:47:04 -0700 (Mon, 24 Oct 2016)

Log Message

[Win] AVCF based media engine does not block cross-site/cross-domain loads.
https://bugs.webkit.org/show_bug.cgi?id=163783

Reviewed by Brent Fulgham.

Prevent cross-site/cross-domain loads by setting appropriate AVCF options.

No new tests; covered by media/video-canvas-source.html. Media tests are
currently skipped on Windows.

* platform/graphics/avfoundation/cf/AVFoundationCFSoftLinking.h:
* platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
(WebCore::MediaPlayerPrivateAVFoundationCF::resolvedURL):
(WebCore::MediaPlayerPrivateAVFoundationCF::hasSingleSecurityOrigin):
(WebCore::AVFWrapper::createAssetForURL):
* platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (207774 => 207775)


--- trunk/Source/WebCore/ChangeLog	2016-10-24 20:42:48 UTC (rev 207774)
+++ trunk/Source/WebCore/ChangeLog	2016-10-24 20:47:04 UTC (rev 207775)
@@ -1,3 +1,22 @@
+2016-10-24  Per Arne Vollan  <[email protected]>
+
+        [Win] AVCF based media engine does not block cross-site/cross-domain loads.
+        https://bugs.webkit.org/show_bug.cgi?id=163783
+
+        Reviewed by Brent Fulgham.
+
+        Prevent cross-site/cross-domain loads by setting appropriate AVCF options.
+
+        No new tests; covered by media/video-canvas-source.html. Media tests are
+        currently skipped on Windows.
+
+        * platform/graphics/avfoundation/cf/AVFoundationCFSoftLinking.h:
+        * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
+        (WebCore::MediaPlayerPrivateAVFoundationCF::resolvedURL):
+        (WebCore::MediaPlayerPrivateAVFoundationCF::hasSingleSecurityOrigin):
+        (WebCore::AVFWrapper::createAssetForURL):
+        * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h:
+
 2016-10-24  Anders Carlsson  <[email protected]>
 
         Fix build with newer versions of clang

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/cf/AVFoundationCFSoftLinking.h (207774 => 207775)


--- trunk/Source/WebCore/platform/graphics/avfoundation/cf/AVFoundationCFSoftLinking.h	2016-10-24 20:42:48 UTC (rev 207774)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/cf/AVFoundationCFSoftLinking.h	2016-10-24 20:47:04 UTC (rev 207775)
@@ -225,6 +225,9 @@
 SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFURLAssetCreateWithURLAndOptions, AVCFURLAssetRef, __cdecl, (CFAllocatorRef allocator, CFURLRef URL, CFDictionaryRef options, dispatch_queue_t notificationQueue), (allocator, URL, options, notificationQueue))
 #define AVCFURLAssetCreateWithURLAndOptions softLink_AVCFURLAssetCreateWithURLAndOptions
 
+SOFT_LINK_DLL_IMPORT(AVFoundationCF, AVCFAssetCopyResolvedURL, CFURLRef, __cdecl, (AVCFAssetRef asset), (asset));
+#define AVCFAssetCopyResolvedURL softLink_AVCFAssetCopyResolvedURL
+
 SOFT_LINK_DLL_IMPORT_OPTIONAL(AVFoundationCF, AVCFPlayerSetDirect3DDevice, void, __cdecl, (AVCFPlayerRef player, IDirect3DDevice9* d3dDevice))
 #define AVCFPlayerSetDirect3DDevice softLink_AVCFPlayerSetDirect3DDevice
 
@@ -397,6 +400,9 @@
 SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFURLAssetInheritURIQueryComponentFromReferencingURIKey, const CFStringRef);
 #define AVCFURLAssetInheritURIQueryComponentFromReferencingURIKey  getAVCFURLAssetInheritURIQueryComponentFromReferencingURIKey()
 
+SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFURLAssetReferenceRestrictionsKey, const CFStringRef);
+#define AVCFURLAssetReferenceRestrictionsKey getAVCFURLAssetReferenceRestrictionsKey()
+
 SOFT_LINK_VARIABLE_DLL_IMPORT(AVFoundationCF, AVCFMediaCharacteristicEasyToRead, const CFStringRef);
 #define AVCFMediaCharacteristicEasyToRead getAVCFMediaCharacteristicEasyToRead()
 

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp (207774 => 207775)


--- trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp	2016-10-24 20:42:48 UTC (rev 207774)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp	2016-10-24 20:47:04 UTC (rev 207775)
@@ -83,6 +83,11 @@
 #pragma comment(lib, "libdispatch.lib")
 #endif
 
+enum {
+    AVAssetReferenceRestrictionForbidRemoteReferenceToLocal = (1UL << 0),
+    AVAssetReferenceRestrictionForbidLocalReferenceToRemote = (1UL << 1)
+};
+
 using namespace std;
 
 namespace WebCore {
@@ -1333,6 +1338,26 @@
         m_avfWrapper->setVideoLayerNeedsCommit();
 }
 
+URL MediaPlayerPrivateAVFoundationCF::resolvedURL() const
+{
+    if (!m_avfWrapper || !m_avfWrapper->avAsset())
+        return URL();
+
+    auto resolvedURL = adoptCF(AVCFAssetCopyResolvedURL(m_avfWrapper->avAsset()));
+
+    return URL(resolvedURL.get());
+}
+
+bool MediaPlayerPrivateAVFoundationCF::hasSingleSecurityOrigin() const
+{
+    if (!m_avfWrapper || !m_avfWrapper->avAsset())
+        return false;
+
+    Ref<SecurityOrigin> resolvedOrigin(SecurityOrigin::create(resolvedURL()));
+    Ref<SecurityOrigin> requestedOrigin(SecurityOrigin::createFromString(assetURL()));
+    return resolvedOrigin.get().isSameSchemeHostPort(&requestedOrigin.get());
+}
+
 AVFWrapper::AVFWrapper(MediaPlayerPrivateAVFoundationCF* owner)
     : m_owner(owner)
     , m_objectID(s_nextAVFWrapperObjectID++)
@@ -1492,6 +1517,11 @@
     if (inheritURI)
         CFDictionarySetValue(optionsRef.get(), AVCFURLAssetInheritURIQueryComponentFromReferencingURIKey, kCFBooleanTrue);
 
+    const int restrictions = AVAssetReferenceRestrictionForbidRemoteReferenceToLocal | AVAssetReferenceRestrictionForbidLocalReferenceToRemote;
+    auto cfRestrictions = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &restrictions));
+
+    CFDictionarySetValue(optionsRef.get(), AVCFURLAssetReferenceRestrictionsKey, cfRestrictions.get());
+
     m_avAsset = adoptCF(AVCFURLAssetCreateWithURLAndOptions(kCFAllocatorDefault, urlRef.get(), optionsRef.get(), m_notificationQueue));
 
 #if HAVE(AVFOUNDATION_LOADER_DELEGATE)

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h (207774 => 207775)


--- trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h	2016-10-24 20:42:48 UTC (rev 207774)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h	2016-10-24 20:47:04 UTC (rev 207775)
@@ -116,6 +116,10 @@
 
     virtual void contentsNeedsDisplay();
 
+    URL resolvedURL() const override;
+
+    bool hasSingleSecurityOrigin() const override;
+
 #if ENABLE(LEGACY_ENCRYPTED_MEDIA)
     std::unique_ptr<CDMSession> createSession(const String&, CDMSessionClient*) override;
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to