Safari FairPlay HLS: CDN token expiry bypasses Shaka network filters — request ownership investigation

GitHub source

Inferred. This page is generated from GitHub Issue #43; GitHub remains the canonical authoring and discussion source.

Local reproduction and solution — 18 November 2026#

Status: Native request ownership reproduced; concrete app-level renewal helper supplied.

Source and evidence#

Upstream case · local report and evidence · portable reproduction instructions

Observed results are Reproduced only within the stated seam. Implementation explanations remain Inferred, not Apple Confirmed.

Reconstruct the scene#

Execute the actual v4.3.3 routing and onSrcEquals_ methods. The native path assigns mediaElement.src and invokes no NetworkingEngine media request; the MSE flag only selects MSE when capabilities permit it.

The actual-method ownership checks pass. The supplied proactive URL-renewal helper passes 10 deterministic checks: authoritative expiry, same-asset fresh URL, deduplication, VOD/paused intent and bounded live-offset handling, and stopping on failure.

Solution / guideline#

Native playlist/segment fetches bypass Shaka request filters; license requests are a separate path. Where the app has signer-provided expiresAt and a compatible refresh API, opt into proactive reload renewal with the supplied helper. MSE is an alternative only after provider compatibility is established; the original Verimatrix warning remains relevant.

Renewal helper · 10 checks

Limits / remaining work#

Helper tests are not a real Safari signed-CDN410 recovery, native interception or seamless renewal demonstration. Reload may interrupt playback.

This update supersedes earlier no-local-run statements below only within the stated scope. Historical source reports are retained; no unresolved issue is closed by this publication.


Earlier investigation and source history

Safari FairPlay HLS: CDN token expires but Shaka network filters never fire#

Source incident: shaka-project/shaka-player#6932 (opened 2024-06-27; maintainer discussion through July 2024). Status: public API/ownership explanation supported; the reporter's exact playback path and a working token-refresh fix were not independently verified.

Symptom and observed evidence#

Shaka Player 4.3.3 on Safari 16.3/macOS Ventura plays FairPlay HLS with expiring CDN query-token URLs. A playlist is fetched roughly every six seconds; after expiry the server returns HTTP 410. The reporter's registerRequestFilter and registerResponseFilter are never invoked for the playlist requests, although playback state events still fire. The first maintainer suggestion (streaming.useNativeHlsOnSafari = false) was corrected to streaming.useNativeHlsForFairPlay = false; the maintainer explained that in native src= mode the browser, not Shaka's NetworkingEngine, fetches media resources. The reporter believed that invoking player.load(url) meant MSE was in use; this does not prove the effective pipeline. The maintainer warned that the reported Verimatrix integration might not support the desired MSE configuration. These statements are observations/maintainer assessments, not device-level proof of the reporter's exact mode.

Causal model and first diagnostic boundary#

Shaka Player.load(HLS URL)
  ├─ Native HLS / HTMLMediaElement src=
  │    └─ Safari media stack → playlist GET → 410 on expired CDN token
  │         └─ Shaka NetworkingEngine filters do not own this request
  └─ MSE-managed HLS (if selected and supported)
       └─ Shaka NetworkingEngine → request/response filters → HTTP fetch → SourceBuffer
FairPlay license requests are a SEPARATE request class from HLS playlist/segment requests.

Established design boundary: Shaka request filters cannot rewrite native-browser playlist requests that do not traverse its NetworkingEngine. Not established: whether the reporter actually selected native mode, why the alternative failed, or whether any provider-specific MSE/DRM limitation was decisive.

Evidence hierarchy#

  1. Authoritative: Apple AVFoundation HLS/resource-loading documentation, Shaka's public configuration/networking contracts, HLS/HTTP specifications, and identified maintainer statements. Apple describes HLS as HTTP-based media delivery and AVAssetResourceLoaderDelegate as a resource-loading assistance API; neither is proof that arbitrary native segment requests can be rewritten by an application.
  2. Implementation: pinned Shaka v4.3.3 source and relevant WebKit source (repository, SHA, path, function and lines required before asserting implementation details). WebKit is not native AVPlayer.
  3. Experiments: Safari network capture, effective Shaka configuration, request filter invocation counts, token expiry timestamps, final HTTP statuses, FairPlay license traffic (metadata only), and device A/B tests.
  4. Hypotheses: clearly labeled; never claim a root cause solely from a 410 or missing callback.

Reproduction and decisive experiments#

  1. Record exact Safari/macOS, Shaka build hash, player.getConfiguration() and effective useNativeHlsForFairPlay, and distinguish video.src vs MediaSource / SourceBuffer presence. Calling player.load is insufficient.
  2. Install Shaka filters that count MANIFEST, SEGMENT, and LICENSE requests separately; correlate with browser Network panel and CDN access logs using sanitized path, session and time.
  3. Run A: native HLS with token TTL 30s; B: verified MSE mode with a compatible authorized DRM integration; C: long-lived token baseline; D: refresh token before expiry. Keep media bytes constant.
  4. At first 410, compare playlist URI token version, actual request owner, last successful playlist response, buffered media duration, AVPlayerItem.errorLog (native app control only), and whether a new signed URL can be introduced without restarting the session.
  5. Validate both live playlist and nested variant/segment URL token propagation; refreshing only the top-level manifest may leave expired signed child URIs.
  6. Repeat ≥20 sessions per condition, recording first 410, first missing media, recovery, and playback interruption. A network log showing 410 is evidence of an expired URL response, not automatically the first causal failure.

Client-only mitigation candidates#

  • If verified MSE is supported with this DRM integration: renew signed URLs before expiry through the player-owned request path; validate manifest/segment filters and 410 recovery.
  • If native HLS is required: design the client around token lifetime and controlled stream reload/reinitialization with playback-position recovery. This is a candidate workaround, not guaranteed seamless continuity; avoid assuming a Shaka request filter or AVAssetResourceLoaderDelegate can rewrite native segment GETs.
  • Separate CDN/origin proposals (not client-enforceable): longer-lived media tokens, token renewal/redirect contract, or signing strategy that permits uninterrupted live playlist polling. Evaluate security and cache impact independently.

Evidence ledger#

Claim Level Status
Reporter saw 410 after token expiry and no Shaka filter calls Original incident Reported, not independently reproduced
Native src= requests bypass Shaka NetworkingEngine Shaka maintainer/API ownership Supported
Reporter was definitely in native mode Hypothesis Unverified
Switching to MSE fixes Verimatrix integration Hypothesis Unverified
Token-refresh/reload can preserve uninterrupted playback Hypothesis Requires device tests

Publishable insight#

Before debugging CDN token refresh in FairPlay HLS, establish which component owns the media HTTP requests. A Shaka networking callback cannot intercept traffic owned by Safari's native HLS pipeline. Distinguish media playlist/segment authorization from FairPlay SPC/CKC licensing, and do not confuse playback state events with network interception.

Sources#

Second-AI investigation prompt (copy/paste)#

Act as a senior iOS/tvOS reverse engineer, AVFoundation/CoreMedia engineer, WebKit media-pipeline investigator, HLS protocol expert and FairPlay DRM security specialist.

INCIDENT: https://github.com/shaka-project/shaka-player/issues/6932. On Safari 16.3/macOS Ventura with Shaka 4.3.3 and FairPlay/Verimatrix, live HLS playlist requests recur ~6s. A signed CDN query token expires, server responds 410, and Shaka NetworkingEngine request/response filters do not fire. Determine the FIRST PROVEN causal divergence and a verified client-side mitigation.

EVIDENCE HIERARCHY (strict): (1) official Apple Developer docs, Apple HLS Authoring Specification, FairPlay SDK, RFCs, Shaka documented contracts and identified maintainer statements; (2) pinned Shaka and WebKit source with URL, commit SHA, file/function/line range, symbolicated AVFoundation/CoreMedia/CFNetwork traces, peer-reviewed or verified security research; (3) reproducible physical-device tests, manifest captures, HTTP logs and authorized KSM metadata; (4) explicitly labeled hypotheses. Never present tier 4 as fact. WebKit does not prove native AVPlayer internals.

TRACE: Player.load → actual native src= or MSE selection → owner of manifest/segment HTTP requests → token validity → request/response filters → 410 → playlist update → buffering/stall. Separately trace EXT-X-KEY → SKD/KID → SPC → KSM → CKC only if DRM evidence indicates a license failure. Do not confuse CDN access tokens with FairPlay licenses.

VERIFY: exact Shaka 4.3.3 code and configuration, effective useNativeHlsForFairPlay, MediaSource/SourceBuffer presence, request-filter counts by MANIFEST/SEGMENT/LICENSE, browser network waterfall, redacted URL-token generation, 410 status, segment availability, and recovery. Compare native HLS vs verified MSE with authorized compatible DRM; short vs long token TTL; proactive renewal vs expiration; and identical media bytes. Include an independent native AVPlayer control and note client-only limitations. Never assume AVAssetResourceLoaderDelegate intercepts native segments.

For each major claim provide source, evidence tier, counterevidence, confidence and falsification test. Root cause requires reproducibility, first divergence, successful controlled intervention and elimination of alternatives. Do not invent experiments or expose keys, SPC/CKC payloads, certificates or credentials.

DELIVER: executive finding, ownership diagram, timestamped working/failing traces, exact source audit, competing hypotheses, test matrix with actual results or NOT RUN, client-only mitigation, separately labeled CDN proposals, remaining unknowns and publication-ready article.