Skip to content

SWRDKV-5447: ocdm-playready defect fix.#14

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

SWRDKV-5447: ocdm-playready defect fix.#14
jianwang-brcm wants to merge 3 commits into
rdkcentral:developfrom
jianwang-brcm:feature/BCM-2076

Conversation

@jianwang-brcm

Copy link
Copy Markdown

What it does: Replaces the assert(ivLength>0) with a runtime check that sampleInfo->ivLength is exactly EXPECTED_AES_CTR_IVDATA_SIZE (8) or EXPECTED_AES_CBC_IVDATA_SIZE (16) — returning CDMi_S_FALSE otherwise — and additionally clamps the Netflix-path memcpy to sizeof(iv_vector).

@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 16:23

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 addresses stability issues in the PlayReady CDMi integration by hardening IV handling in decrypt, adding additional bounds checks around secure-token operations, and introducing session tracking to prevent resetting/freeing the shared PlayReady app context while sessions still reference it.

Changes:

  • Replaced assert(ivLength > 0) with a runtime validation that ivLength is exactly 8 (CTR) or 16 (CBC), and clamped a Netflix-path IV memcpy.
  • Added additional safety checks in the decrypt path to avoid buffer overruns (SVP token size, decrypted length vs. encrypted length).
  • Introduced m_sessionCount plus additional locking around app-context usage and lifecycle operations.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
MediaSystem.cpp Adds session counting and additional locking to prevent app-context reset/uninit while sessions exist.
MediaSession.cpp Adds runtime IV length validation, clamps IV copy, adds several mutex guards, and adds extra length checks in decrypt paths.

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

Comment thread MediaSystem.cpp
Comment on lines 153 to 166
bool isNetflixPlayready = (strstr(keySystem.c_str(), "netflix") != nullptr);
if (isNetflixPlayready) {
SafeCriticalSection systemLock(drmAppContextMutex_);
if(!m_isAppCtxInitialized)
{
InitializeAppCtx();
}
}
*f_ppiMediaKeySession = new CDMi::MediaKeySession(f_pbInitData, f_cbInitData, m_poAppContext.get(), !isNetflixPlayready);
} else {
*f_ppiMediaKeySession = new CDMi::MediaKeySession(f_pbInitData, f_cbInitData, f_pbCDMData, f_cbCDMData, m_poAppContext.get(), !isNetflixPlayready);
}
return CDMi_SUCCESS;
++m_sessionCount;
return CDMi_SUCCESS;
}
Comment thread MediaSystem.cpp
Comment on lines +258 to 264
SafeCriticalSection systemLock(drmAppContextMutex_);
bool isNetflixPlayready = (strstr(keySystem.c_str(), "netflix") != nullptr);
printf("\n [TEL ELXSI] isNetflixPlayready is %d",&isNetflixPlayready);
*session = new CDMi::MediaKeySession(drmHeader, drmHeaderLength, m_poAppContext.get(), !isNetflixPlayready);
++m_sessionCount;

return CDMi_SUCCESS;
Comment thread MediaSystem.cpp
Comment on lines 269 to 273
SafeCriticalSection systemLock(drmAppContextMutex_);
delete f_piMediaKeySession;
if (m_sessionCount > 0) --m_sessionCount;
return CDMi_SUCCESS;
}
Comment thread MediaSystem.cpp
Comment on lines 211 to 213
delete f_piMediaKeySession;
if (m_sessionCount > 0) --m_sessionCount;
}
Comment thread MediaSystem.cpp
Comment on lines +623 to +628
if (m_sessionCount > 0)
{
/* Existing MediaKeySession(s) hold a raw alias of m_poAppContext.get(); freeing here is a UAF. */
fprintf(stderr, "[%s:%d] UninitializeAppCtx refused: %u session(s) still hold m_poAppContext\n",__FUNCTION__,__LINE__,m_sessionCount);
return CDMi_S_FALSE;
}
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