⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 236256 in webkit


Ignore:
Timestamp:
Sep 20, 2018, 4:22:00 AM (8 years ago)
Author:
commit-queue@webkit.org
Message:

[EME] Add WebM sanitization
​https://bugs.webkit.org/show_bug.cgi?id=189740

Patch by Yacine Bandou <​yacine.bandou@softathome.com> on 2018-09-20
Reviewed by Xabier Rodriguez-Calvar.

This patch adds support for sanitizing the WebM initialization data,
ensures there are no bogus values.
See ​https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-generaterequest.

Tests: imported/w3c/web-platform-tests/encrypted-media/clearkey-generate-request-disallowed-input.https.html

  • Modules/encryptedmedia/InitDataRegistry.cpp:

(WebCore::sanitizeWebM): Added implementation, check if the initialization data doesn't empty and its size
should be less than 64KB, return the buffer copy if it is ok, otherwise a nullptr.
(WebCore::extractKeyIDsWebM): Added implementation.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r236255 r236256  
     12018-09-20  Yacine Bandou  <yacine.bandou@softathome.com>
     2
     3        [EME] Add WebM sanitization
     4        https://bugs.webkit.org/show_bug.cgi?id=189740
     5
     6        Reviewed by Xabier Rodriguez-Calvar.
     7
     8        This patch adds support for sanitizing the WebM initialization data,
     9        ensures there are no bogus values.
     10        See https://www.w3.org/TR/encrypted-media/#dom-mediakeysession-generaterequest.
     11
     12        Tests: imported/w3c/web-platform-tests/encrypted-media/clearkey-generate-request-disallowed-input.https.html
     13
     14        * Modules/encryptedmedia/InitDataRegistry.cpp:
     15        (WebCore::sanitizeWebM): Added implementation, check if the initialization data doesn't empty and its size
     16        should be less than 64KB, return the buffer copy if it is ok, otherwise a nullptr.
     17        (WebCore::extractKeyIDsWebM): Added implementation.
     18
    1192018-09-20  Philippe Normand  <pnormand@igalia.com>
    220
  • trunk/Source/WebCore/Modules/encryptedmedia/InitDataRegistry.cpp

    r234689 r236256  
    4242namespace {
    4343    const uint32_t kCencMaxBoxSize = 64 * KB;
     44    // ContentEncKeyID has this EBML code [47][E2] in WebM,
     45    // as per spec the size of the ContentEncKeyID is encoded on 16 bits.
     46    // https://matroska.org/technical/specs/index.html#ContentEncKeyID/
     47    const uint32_t kWebMMaxContentEncKeyIDSize = 64 * KB; // 2^16
    4448}
    4549
    … …  
    140144static RefPtr<SharedBuffer> sanitizeWebM(const SharedBuffer& buffer)
    141145{
     146    // Check if the buffer is a valid WebM initData.
     147    // The WebM initData is the ContentEncKeyID, so should be less than kWebMMaxContentEncKeyIDSize.
     148    if (buffer.isEmpty() || buffer.size() > kWebMMaxContentEncKeyIDSize)
     149        return nullptr;
     150
     151    return buffer.copy();
     152}
     153
     154static std::optional<Vector<Ref<SharedBuffer>>> extractKeyIDsWebM(const SharedBuffer& buffer)
     155{
     156    Vector<Ref<SharedBuffer>> keyIDs;
     157    RefPtr<SharedBuffer> sanitazedBuffer = sanitizeWebM(buffer);
     158    if (!sanitazedBuffer)
     159        return std::nullopt;
     160
    142161    // 1. Format
    143162    // https://w3c.github.io/encrypted-media/format-registry/initdata/webm.html#format
    144     notImplemented();
    145     return buffer.copy();
    146 }
    147 
    148 static std::optional<Vector<Ref<SharedBuffer>>> extractKeyIDsWebM(const SharedBuffer&)
    149 {
    150     // 1. Format
    151     // https://w3c.github.io/encrypted-media/format-registry/initdata/webm.html#format
    152     notImplemented();
    153     return std::nullopt;
     163    keyIDs.append(sanitazedBuffer.releaseNonNull());
     164    return keyIDs;
    154165}
    155166
Note: See TracChangeset for help on using the changeset viewer.