Skip to content

SWRDKV-5447: ocdm-widevine defect fix.#25

Open
jianwang-brcm wants to merge 4 commits into
rdkcentral:developfrom
jianwang-brcm:feature/BCM-2076
Open

SWRDKV-5447: ocdm-widevine defect fix.#25
jianwang-brcm wants to merge 4 commits into
rdkcentral:developfrom
jianwang-brcm:feature/BCM-2076

Conversation

@jianwang-brcm

Copy link
Copy Markdown

What it does: clamps the IV memcpy length to sizeof(iv) (16) so an attacker-supplied sampleInfo->ivLength cannot overflow the stack buffer.

@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

Copilot AI review requested due to automatic review settings June 29, 2026 15:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the MediaKeySession decryption/notification paths in the Widevine OCDM integration, primarily addressing memory-safety risks from client-controlled inputs.

Changes:

  • Clamp the IV memcpy length to the IV buffer size to prevent stack overflow in MediaKeySession::Decrypt.
  • Add m_piCallback initialization and null-guards before invoking callback methods.
  • Add SVP in-band header size validation and a token-size guard to prevent out-of-bounds copies when handling secure buffers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread MediaSession.cpp
Comment on lines 720 to +722
memset(iv,0,16);
memcpy(iv,(char*)sampleInfo->iv, sampleInfo->ivLength);
size_t ivCopyLen = (sampleInfo->ivLength > sizeof(iv)) ? sizeof(iv) : sampleInfo->ivLength;
memcpy(iv,(char*)sampleInfo->iv, ivCopyLen);
Comment thread MediaSession.cpp
Comment on lines +298 to 300
if (m_piCallback == nullptr)
return;
m_piCallback->OnKeyMessage((const uint8_t*) message.c_str(), message.size(), (char*) destUrl.c_str());
Comment thread MediaSession.cpp
Comment on lines +755 to +762
// The SVP header arrives in-band from the IPC client. Reject a dataSize
// that exceeds the bytes the client actually delivered, otherwise
// svp_allocate_secure_buffers() memcpy()s past the end of inData.
uint32_t svpHeaderLen = static_cast<uint32_t>(static_cast<const uint8_t*>(pEncryptedDataStart) - inData);
if (svpHeaderLen > inDataLength || actualEncDataLength > inDataLength - svpHeaderLen) {
fprintf(stderr, "[%s:%d] SVP header dataSize %u exceeds inDataLength %u\n", __FUNCTION__, __LINE__, actualEncDataLength, inDataLength);
goto ErrorExit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants