際際滷

際際滷Share a Scribd company logo
Implementation of MITM Attack on
           HDCP-Secured Links
                         bunnie / 28c3

      Twitter your comments @bunniestudios or #28c3


December 29, 2011 28c3       bunnie
What is HDCP?
 ? High Definition Content Protection
      C Pixel-level encryption operating at the link layer
 ? Cipher structure
      C Stream cipher capable of generating 24 bits of
        pseudorandom data per clock cycle
            ? Two parallel 84-bit block functions per round
            ? LFSR-based ^key scheduler ̄ that whitens block functions at the
              beginning of each horizontal line of pixels
            ? Block functions initialized with publicly exchanged 64-bit initial
              vector (An) that evolves once during each vertical blanking
              interval

December 29, 2011 28c3                 bunnie
What is HDCP?
 ? Key management
      C Distributed private keys with sort of key revocation
      C Public key is a ^key selection vector ̄ (KSV)
            ? 40 bits (20 zeros and 20 ones)
      C Private key is a vector of 40 56-bit numbers
      C All private keys derived from a master key consisting of a
        40x40 matrix of 56-bit numbers
 ? Master key can be directly computed from a
   collection of 40 unique private keys
      C The master key was revealed in September 2010

December 29, 2011 28c3                 bunnie
Why HDCP?
 ? Encrypt video transmissions
      C Complements AACS, BD+ to create studio-to-screen
        cryptographic chain
 ? Chain was broken long ago: AACS was the weakest
   link
      C HDCP master key leak is thus largely a ^nop ̄ from the
        content access standpoint
      C Strippers based on legitimate HDCP keys have long been
        available on the market; key revocation is largely
        ineffective

December 29, 2011 28c3         bunnie
So Why Implement HDCP MITM?
 ? It¨s about control
      C Broadcasters and studios control your screen
      C DMCA and other legal tricks make it illegal for you
        to modify content C on your own screen




December 29, 2011 28c3       bunnie
So Why Implement HDCP MITM?
 ? HDCP restricts the implementation of
   legitimate content manipulation
      C Picture in picture
      C Content overlays
      C 3rd party filtering & image modification
 ? As a result, there are few HDMI video mixing
   solutions that can operate on
   broadcast/movie content
December 29, 2011 28c3        bunnie
Goal
 ? Consumer-side content remixing
      C Add web content to existing TV
      C Live comment & chat
 ? ^Over the top ̄ advertising
      C Eliminate ads
      C Or replace ads with targeted ads
 ? Interactive TV
      C Add interactive elements to broadcast TV
 ? Compatibility with any TV

December 29, 2011 28c3         bunnie
How Do We Do It?




December 29, 2011 28c3          bunnie
December 29, 2011 28c3   bunnie
A¨: Intercept and override EDID
 ? HDMI uses an I2C bus (referred to as DDC) to
   communicate between video source & sink
 ? Bus shared between two functions:
      C Monitor capability identification
      C HDCP key exchange




December 29, 2011 28c3       bunnie
Snoop & squash
 ? Snooping: intercept key exchange
 ? Squashing: force TV characteristics
      C The implementation can¨t do all HDMI standards
      C Rewrite the EDID record on the fly to reflect only
        the standards NeTV supports, e.g. no 3D, etc.




December 29, 2011 28c3         bunnie
I2C snoop & override




December 29, 2011 28c3       bunnie
I2C snoop & override




December 29, 2011 28c3       bunnie
I2C snoop & override



 ? Oversampled squash can modify data on the
   fly
      C Snoop address, and change only bits that need
        changing

December 29, 2011 28c3       bunnie
Hot Plug Override
 ? Hot plug bus has a FET on it to simulate a
   plug/unplug event
      C Hot plug is an open-drain bus, so this is a safe and
        easy thing to do
      C Used to resynchronize state when necessary
      C Used to manipulate EDID state



December 29, 2011 28c3          bunnie
December 29, 2011 28c3   bunnie
B¨, C¨, D¨: Intercept keys & sync cipher
 ? Getting An, AKSV, BKSV accomplished with
   I2C snooper listening for specific addresses
 ? Once key exchange is captured, private key
   vector and shared secret must be derived
      C Final byte write of AKSV is ^trigger ̄ to start
        authentication
      C FPGA fires interrupt to host linux system
      C udev event starts a helper program that does the
        math
December 29, 2011 28c3      bunnie
Computing Private Keys




 ? Modular inner product of master key and public key
   vectors
      C HDCP master key K is 40x40 matrix of 56-bit numbers
      C AKSV, BKSV are 40-bit numbers consisting of 20 ones and 20 zeros
      C APK, BPK are 40-element vectors of 56-bit numbers

December 29, 2011 28c3             bunnie
Computing Shared Secret
                 BKSV , APK      = Km            AKSV , BPK    = Km

                 0       APK00                   1     BPK00
                 1       APK01                   0     BPK01
                 .                               .
                 .                 Km            .               Km
                 .                               .
                 1       APK38                   1     BPK38
                 0       APK39                   1     BPK39


 ? Multiply KSVs by private keys to get 56-bit shared
   secret Km


December 29, 2011 28c3                  bunnie
Synchronize Ciphers
 ? Plug An, Km into cipher
   hardware
 ? Init key schedules
 ? Evolve cipher state
   based on:
      C   Pixclock
      C   HSYNC
      C   VSYNC
      C   Data guardband timings
      C   All in plaintext

December 29, 2011 28c3             bunnie
Pixel-by-pixel synchronization
                                              NeTV
                                         NeTV UI       Tx-synchronized
                                          video         cipher stream




                                       XOR
                                                                                                          TV
Video source                                                                              cipher stream




                                  Swap encrypted pixels for
  Encrypted video                 alternate encrypted pixels                                                   Decrypted video
                    Video cable                                             Video cable


                                                                                               XOR




  December 29, 2011 28c3                                           bunnie
Synchronize Frame Buffers
 ? Overlay pixels must be exactly timed to video
   pixels
 ? Overlay comes from /dev/fb0 of attached linux
   computer
 ? Challenges
      C linux interrupt jitter is too high (10¨s to 100¨s of us, i.e.
        thousands of pixels)
      C Local crystal oscillators drift over time (100¨s of pixels per
        frame)
      C Ultimately, overlay ^jitters ̄ and ^drifts ̄ without tight
        synchronization

December 29, 2011 28c3            bunnie
Synchronize Frame Buffers
 ? Technique #1: source graphics engine pixclock from
   video, not locally




December 29, 2011 28c3    bunnie
Synchronize Frame Buffers
 ? Technique #1: source graphics engine pixclock from
   video, not locally
 ? Technique #2: derive timing dynamically from video
   stream and set /dev/fb0 properties to match




December 29, 2011 28c3   bunnie
Synchronize Frame Buffers
 ? Technique #1: source graphics engine pixclock from
   video, not locally
 ? Technique #2: derive timing dynamically from video
   stream and set /dev/fb0 properties to match
 ? Technique #3: start LCD DMA based on VSYNC
   start from video stream



December 29, 2011 28c3   bunnie
Synchronize Frame Buffers
 ? Technique #1: source graphics engine pixclock from
   video, not locally
 ? Technique #2: derive timing dynamically from video
   stream and set /dev/fb0 properties to match
 ? Technique #3: start LCD DMA based on VSYNC
   start from video stream
 ? Technique #4: add a few video lines¨ elastic FIFO
   buffering to absorb VSYNC interrupt jitter

December 29, 2011 28c3   bunnie
Chroma Key
 ? Chroma key reserves a specific color and
   substitutes its value for ^transparent ̄
 ? In this implementation, F0,00,F0 (a shade of pink) is
   the magic color
      C A comparator within the FPGA inspects every pixel and
        switches a mux


                         +                            =

                                          Image copyright ? 2008, Blender Foundation / www.bigbuckbunny.org CC-BY-3.0

December 29, 2011 28c3           bunnie
HDMI Connector
            RGB to TMDS
              Serialize
                          bunnie
                          December 29, 2011 28c3
        TMDS to RGB
         Deserialize
HDMI Connector
Optimizations
 ? Key caching
      C Every video source/sink pair has a constant shared secret
      C Km is cached after first computation to improve system
        robustness
 ? EDID caching
      C More important because without EDID caching, users will
        see a double-blink of the screen
            ? First blink is to measure the TV¨s capabilities
            ? Then we compute the intersection of the TV capabilities and
              NeTV capabilities
            ? Second blink is to override the capabilities we don¨t support

December 29, 2011 28c3                bunnie
The Bigger System Picture




                                           HDMI Connector
              HDMI Connector




December 29, 2011 28c3         bunnie
A Complete Open Stack
              Provisioning & update server (EC2)




                                                   OpenEmbedded/
               HTML/javascript widgets (github)




                                                      buildbot
                            Webkit
                  Angstrom distro (apps/tools)
               U-boot                Linux
                            FPGA (verilog)
                                 PCB
                                Plastics
December 29, 2011 28c3               bunnie
Application Environment
 ? TV overlay apps are web pages
      C CSS configured to put ^magic pink ̄ as background
      C Apps are javascript/HTML programs
      C But you can extend to any infrastructure that can write to
        /dev/fb0 (SDL, Flash, etc.)
 ? Our demo apps are open source and stored in a github
   repo
      C Updating apps consists of doing a git pull on the client
      C Configured to pull every reboot
 ? Firmware updates served from EC2 infrastructure
      C Public AMI provided so you can make your own
      C More on this later

December 29, 2011 28c3               bunnie
HTTP API
 ? Zeroconf solution for networked interaction with TV
      C API provides method to send events to NeTV
            ? So, a smartphone can:
                  C Discover NeTV with Bonjour
                  C Send events (such as SMS) to the NeTV using HTTP GET
                  C NeTV renders these events on your TV
            ? Also provides a method for file upload to enable photosharing to the TV
      C Fast, easy integration into ^smarthome ̄ environment
      C Example call:
        http://10.0.88.1/bridge?cmd=tickerevent&message=Hello%World&
        title=Hello%20World
      C Each API call can be restricted to just localhost for security


December 29, 2011 28c3                     bunnie
Turnkey Build System
 ? Public Amazon EC2 instance with pre-built
   Angstrom distribution
      C Saves hours of effort downloading & building
        sources
      C Instance comes configured with local git repo and
        buildbot to manage builds
      C Built images configured to fetch updates from
        your own instance

December 29, 2011 28c3       bunnie
Launching an EC2 AMI




December 29, 2011 28c3      bunnie
Local cgit repo




December 29, 2011 28c3         bunnie
Auto-build triggers based on commits




December 29, 2011 28c3   bunnie
Distribute Finished Builds
 ? Image once, auto-update forever




December 29, 2011 28c3     bunnie
Hardware is Open




December 29, 2011 28c3          bunnie
Plastics are Open




December 29, 2011 28c3          bunnie
Pr0n




December 29, 2011 28c3    bunnie
Schematics




December 29, 2011 28c3       bunnie
And PCB Layout




December 29, 2011 28c3         bunnie
A Complete Open Solution to HDCP MITM
 ? Hardware
      C Schematics, PCB, industrial design, FPGA
 ? Software
      C Complete, turn-key cloud-based build
        environment
            ? Half an hour from start to production-grade
              deployment
 ? Available at adafruit.com
   (http://www.adafruit.com/products/609)
December 29, 2011 28c3            bunnie
Recap: HDCP MITM Implementation
 ? Complete HDCP MITM solution demonstrated
      C   Intercept key exchange on the fly
      C   Derive shared secrets & synchronize Tx ciphers
      C   Multiplex overlay video using chroma key
      C   Avoids decrypting data, therefore DMCA-safe
      C   Modifies EDID records to force compatibility
 ? Enables video compositing functionality
      C Enables unconnected legacy TVs to now have connected TV
        capabilities
      C Enables you to modify your video content (stop/modify ads,
        show live internet commentary, etc.)
 ? A completely open hardware/software stack

December 29, 2011 28c3               bunnie
Non-Infringing Use of HDCP Master Key!
 ? Embodiment of a bona-fide, non-infringing and
   commercially useful application of the HDCP
   master key
 ? Blurs the association of the HDCP master key with
   piracy
      C Prior to this exploit, the only application of the HDCP
        master key was to circumvent the encryption on
        copyrighted data
      C Now, there is a non-circumventing application for the
        HDCP master key

December 29, 2011 28c3           bunnie
Q&A




December 29, 2011 28c3    bunnie

More Related Content

A non-copyright circumventing application of the HDCP master key

  • 1. Implementation of MITM Attack on HDCP-Secured Links bunnie / 28c3 Twitter your comments @bunniestudios or #28c3 December 29, 2011 28c3 bunnie
  • 2. What is HDCP? ? High Definition Content Protection C Pixel-level encryption operating at the link layer ? Cipher structure C Stream cipher capable of generating 24 bits of pseudorandom data per clock cycle ? Two parallel 84-bit block functions per round ? LFSR-based ^key scheduler ̄ that whitens block functions at the beginning of each horizontal line of pixels ? Block functions initialized with publicly exchanged 64-bit initial vector (An) that evolves once during each vertical blanking interval December 29, 2011 28c3 bunnie
  • 3. What is HDCP? ? Key management C Distributed private keys with sort of key revocation C Public key is a ^key selection vector ̄ (KSV) ? 40 bits (20 zeros and 20 ones) C Private key is a vector of 40 56-bit numbers C All private keys derived from a master key consisting of a 40x40 matrix of 56-bit numbers ? Master key can be directly computed from a collection of 40 unique private keys C The master key was revealed in September 2010 December 29, 2011 28c3 bunnie
  • 4. Why HDCP? ? Encrypt video transmissions C Complements AACS, BD+ to create studio-to-screen cryptographic chain ? Chain was broken long ago: AACS was the weakest link C HDCP master key leak is thus largely a ^nop ̄ from the content access standpoint C Strippers based on legitimate HDCP keys have long been available on the market; key revocation is largely ineffective December 29, 2011 28c3 bunnie
  • 5. So Why Implement HDCP MITM? ? It¨s about control C Broadcasters and studios control your screen C DMCA and other legal tricks make it illegal for you to modify content C on your own screen December 29, 2011 28c3 bunnie
  • 6. So Why Implement HDCP MITM? ? HDCP restricts the implementation of legitimate content manipulation C Picture in picture C Content overlays C 3rd party filtering & image modification ? As a result, there are few HDMI video mixing solutions that can operate on broadcast/movie content December 29, 2011 28c3 bunnie
  • 7. Goal ? Consumer-side content remixing C Add web content to existing TV C Live comment & chat ? ^Over the top ̄ advertising C Eliminate ads C Or replace ads with targeted ads ? Interactive TV C Add interactive elements to broadcast TV ? Compatibility with any TV December 29, 2011 28c3 bunnie
  • 8. How Do We Do It? December 29, 2011 28c3 bunnie
  • 9. December 29, 2011 28c3 bunnie
  • 10. A¨: Intercept and override EDID ? HDMI uses an I2C bus (referred to as DDC) to communicate between video source & sink ? Bus shared between two functions: C Monitor capability identification C HDCP key exchange December 29, 2011 28c3 bunnie
  • 11. Snoop & squash ? Snooping: intercept key exchange ? Squashing: force TV characteristics C The implementation can¨t do all HDMI standards C Rewrite the EDID record on the fly to reflect only the standards NeTV supports, e.g. no 3D, etc. December 29, 2011 28c3 bunnie
  • 12. I2C snoop & override December 29, 2011 28c3 bunnie
  • 13. I2C snoop & override December 29, 2011 28c3 bunnie
  • 14. I2C snoop & override ? Oversampled squash can modify data on the fly C Snoop address, and change only bits that need changing December 29, 2011 28c3 bunnie
  • 15. Hot Plug Override ? Hot plug bus has a FET on it to simulate a plug/unplug event C Hot plug is an open-drain bus, so this is a safe and easy thing to do C Used to resynchronize state when necessary C Used to manipulate EDID state December 29, 2011 28c3 bunnie
  • 16. December 29, 2011 28c3 bunnie
  • 17. B¨, C¨, D¨: Intercept keys & sync cipher ? Getting An, AKSV, BKSV accomplished with I2C snooper listening for specific addresses ? Once key exchange is captured, private key vector and shared secret must be derived C Final byte write of AKSV is ^trigger ̄ to start authentication C FPGA fires interrupt to host linux system C udev event starts a helper program that does the math December 29, 2011 28c3 bunnie
  • 18. Computing Private Keys ? Modular inner product of master key and public key vectors C HDCP master key K is 40x40 matrix of 56-bit numbers C AKSV, BKSV are 40-bit numbers consisting of 20 ones and 20 zeros C APK, BPK are 40-element vectors of 56-bit numbers December 29, 2011 28c3 bunnie
  • 19. Computing Shared Secret BKSV , APK = Km AKSV , BPK = Km 0 APK00 1 BPK00 1 APK01 0 BPK01 . . . Km . Km . . 1 APK38 1 BPK38 0 APK39 1 BPK39 ? Multiply KSVs by private keys to get 56-bit shared secret Km December 29, 2011 28c3 bunnie
  • 20. Synchronize Ciphers ? Plug An, Km into cipher hardware ? Init key schedules ? Evolve cipher state based on: C Pixclock C HSYNC C VSYNC C Data guardband timings C All in plaintext December 29, 2011 28c3 bunnie
  • 21. Pixel-by-pixel synchronization NeTV NeTV UI Tx-synchronized video cipher stream XOR TV Video source cipher stream Swap encrypted pixels for Encrypted video alternate encrypted pixels Decrypted video Video cable Video cable XOR December 29, 2011 28c3 bunnie
  • 22. Synchronize Frame Buffers ? Overlay pixels must be exactly timed to video pixels ? Overlay comes from /dev/fb0 of attached linux computer ? Challenges C linux interrupt jitter is too high (10¨s to 100¨s of us, i.e. thousands of pixels) C Local crystal oscillators drift over time (100¨s of pixels per frame) C Ultimately, overlay ^jitters ̄ and ^drifts ̄ without tight synchronization December 29, 2011 28c3 bunnie
  • 23. Synchronize Frame Buffers ? Technique #1: source graphics engine pixclock from video, not locally December 29, 2011 28c3 bunnie
  • 24. Synchronize Frame Buffers ? Technique #1: source graphics engine pixclock from video, not locally ? Technique #2: derive timing dynamically from video stream and set /dev/fb0 properties to match December 29, 2011 28c3 bunnie
  • 25. Synchronize Frame Buffers ? Technique #1: source graphics engine pixclock from video, not locally ? Technique #2: derive timing dynamically from video stream and set /dev/fb0 properties to match ? Technique #3: start LCD DMA based on VSYNC start from video stream December 29, 2011 28c3 bunnie
  • 26. Synchronize Frame Buffers ? Technique #1: source graphics engine pixclock from video, not locally ? Technique #2: derive timing dynamically from video stream and set /dev/fb0 properties to match ? Technique #3: start LCD DMA based on VSYNC start from video stream ? Technique #4: add a few video lines¨ elastic FIFO buffering to absorb VSYNC interrupt jitter December 29, 2011 28c3 bunnie
  • 27. Chroma Key ? Chroma key reserves a specific color and substitutes its value for ^transparent ̄ ? In this implementation, F0,00,F0 (a shade of pink) is the magic color C A comparator within the FPGA inspects every pixel and switches a mux + = Image copyright ? 2008, Blender Foundation / www.bigbuckbunny.org CC-BY-3.0 December 29, 2011 28c3 bunnie
  • 28. HDMI Connector RGB to TMDS Serialize bunnie December 29, 2011 28c3 TMDS to RGB Deserialize HDMI Connector
  • 29. Optimizations ? Key caching C Every video source/sink pair has a constant shared secret C Km is cached after first computation to improve system robustness ? EDID caching C More important because without EDID caching, users will see a double-blink of the screen ? First blink is to measure the TV¨s capabilities ? Then we compute the intersection of the TV capabilities and NeTV capabilities ? Second blink is to override the capabilities we don¨t support December 29, 2011 28c3 bunnie
  • 30. The Bigger System Picture HDMI Connector HDMI Connector December 29, 2011 28c3 bunnie
  • 31. A Complete Open Stack Provisioning & update server (EC2) OpenEmbedded/ HTML/javascript widgets (github) buildbot Webkit Angstrom distro (apps/tools) U-boot Linux FPGA (verilog) PCB Plastics December 29, 2011 28c3 bunnie
  • 32. Application Environment ? TV overlay apps are web pages C CSS configured to put ^magic pink ̄ as background C Apps are javascript/HTML programs C But you can extend to any infrastructure that can write to /dev/fb0 (SDL, Flash, etc.) ? Our demo apps are open source and stored in a github repo C Updating apps consists of doing a git pull on the client C Configured to pull every reboot ? Firmware updates served from EC2 infrastructure C Public AMI provided so you can make your own C More on this later December 29, 2011 28c3 bunnie
  • 33. HTTP API ? Zeroconf solution for networked interaction with TV C API provides method to send events to NeTV ? So, a smartphone can: C Discover NeTV with Bonjour C Send events (such as SMS) to the NeTV using HTTP GET C NeTV renders these events on your TV ? Also provides a method for file upload to enable photosharing to the TV C Fast, easy integration into ^smarthome ̄ environment C Example call: http://10.0.88.1/bridge?cmd=tickerevent&message=Hello%World& title=Hello%20World C Each API call can be restricted to just localhost for security December 29, 2011 28c3 bunnie
  • 34. Turnkey Build System ? Public Amazon EC2 instance with pre-built Angstrom distribution C Saves hours of effort downloading & building sources C Instance comes configured with local git repo and buildbot to manage builds C Built images configured to fetch updates from your own instance December 29, 2011 28c3 bunnie
  • 35. Launching an EC2 AMI December 29, 2011 28c3 bunnie
  • 36. Local cgit repo December 29, 2011 28c3 bunnie
  • 37. Auto-build triggers based on commits December 29, 2011 28c3 bunnie
  • 38. Distribute Finished Builds ? Image once, auto-update forever December 29, 2011 28c3 bunnie
  • 39. Hardware is Open December 29, 2011 28c3 bunnie
  • 40. Plastics are Open December 29, 2011 28c3 bunnie
  • 41. Pr0n December 29, 2011 28c3 bunnie
  • 43. And PCB Layout December 29, 2011 28c3 bunnie
  • 44. A Complete Open Solution to HDCP MITM ? Hardware C Schematics, PCB, industrial design, FPGA ? Software C Complete, turn-key cloud-based build environment ? Half an hour from start to production-grade deployment ? Available at adafruit.com (http://www.adafruit.com/products/609) December 29, 2011 28c3 bunnie
  • 45. Recap: HDCP MITM Implementation ? Complete HDCP MITM solution demonstrated C Intercept key exchange on the fly C Derive shared secrets & synchronize Tx ciphers C Multiplex overlay video using chroma key C Avoids decrypting data, therefore DMCA-safe C Modifies EDID records to force compatibility ? Enables video compositing functionality C Enables unconnected legacy TVs to now have connected TV capabilities C Enables you to modify your video content (stop/modify ads, show live internet commentary, etc.) ? A completely open hardware/software stack December 29, 2011 28c3 bunnie
  • 46. Non-Infringing Use of HDCP Master Key! ? Embodiment of a bona-fide, non-infringing and commercially useful application of the HDCP master key ? Blurs the association of the HDCP master key with piracy C Prior to this exploit, the only application of the HDCP master key was to circumvent the encryption on copyrighted data C Now, there is a non-circumventing application for the HDCP master key December 29, 2011 28c3 bunnie
  • 47. Q&A December 29, 2011 28c3 bunnie