SlideShare a Scribd company logo
Cache on delivery
     mining memcached



    marco@sensepost.com
Cache on Delivery
The need for caching
• Large percentage of data remains relatively
  constant
  • Wikipedia page contents
  • Youtube video links
  • FB Profile data
• Poorly designed solutions regenerate data
  on each request
• Don’t regenerate, rather regurgitate
The need for caching
• Large percentage of data remains relatively
  constant
  • Wikipedia page contents
  • Youtube video links
  • FB Profile data
• Poorly designed solutions regenerate data
  on each request
• Don’t regenerate, rather regurgitate
Memcached
• memcached.org
• Written for LJ (2003) by Brad
  Fitzpatrick
• Non-persistent network-based KV
  store
• Why do we care? Mom&pop don’t
  need the cache.
Memcached
• memcached.org
• Written for LJ (2003) by Brad
  Fitzpatrick
• Non-persistent network-based KV
  store
• Why do we care? Mom&pop don’t
  need the cache.
Basic KV




• Slabs are fixed size • Users don’t care about slabs
• Dstvalue size
  by
      slab determined • Miners care about slabs
Trivial protocol
•   ASCII-based
•   Long-lived
•   Tiny command set

•   set
•   get
•   stats
•   ...
•   ????


    Binary and UDP protocols also
    exist, these were not touched.
Trivial protocol
•   ASCII-based
•   Long-lived
•   Tiny command set

•   set
•   get
•   stats
•   ...
•   ????


    Binary and UDP protocols also
    exist, these were not touched.
Trivial protocol
•   ASCII-based
•   Long-lived
•   Tiny command set

•   set
•   get
•   stats
•   ...
•   ????


    Binary and UDP protocols also
    exist, these were not touched.
Trivial protocol
•   ASCII-based
•   Long-lived
•   Tiny command set

•   set
•   get
•   stats
•   ...
•   ????


    Binary and UDP protocols also
    exist, these were not touched.
Trivial protocol
•   ASCII-based
•   Long-lived
•   Tiny command set

•   set
•   get
•   stats
•   ...
•   ????


    Binary and UDP protocols also
    exist, these were not touched.
1998


       •   Blank ‘sa’

       •   Anonymous ftp

       •   system/manager
Goals

•   Connect to memcached

•   Find all slabs

•   Retrieve keynames from each slab

•   Retrieve each key
Lies, damn lies, and
                stats
                                   stats slabs
                                   STAT 1:chunk_size   80


•
                                   <...>
    stats cmd has subcmds          STAT 2:chunk_size   104
                                   <...>
                                   STAT 3:chunk_size   136

    •   items                      <...>
                                   STAT 4:chunk_size
                                   <...>
                                                       176


    •   slabs
                                   STAT 6:chunk_size
                                   <...>
                                   STAT 8:chunk_size
                                                       280

                                                       440


    •
                                   <...>
        ...                        STAT 9:chunk_size   552
                                   <...>
                                   STAT 9:cas_badval   0
                                   STAT active_slabs   7




                This gets us the slabs_ids
Retrieving key names


Rely on two
{poorly|un}
documented
features
Retrieving key names


Feature #1:

Remote enabling of
debug mode
Retrieving key names


Feature #2:

“stats cachedump”
Retrieving key names


Feature #2:

“stats cachedump”
Retrieving key names


Feature #2:

“stats cachedump”

                    Slabs ID
Retrieving key names


Feature #2:

“stats cachedump”

                    Key limit
Retrieving key names


Feature #2:

“stats cachedump”

                    Key list
Retrieving key names


Feature #2:

“stats cachedump”




          This gets us key names
And this gets us?
•   No need for complex hacks. Memcached serves up
    all its data for us.
•   What to do in an exposed cache?
    •   Mine
        •   SQLi is too hard for me
    •   Overwrite
        •   Client-side
        •   Server-side
Mining the cache
• go-derper.rb – memcached miner
 • Retrieves up to k keys from each slab and
    their contents, store on disk
 • Applies regexes and filters matches in a
    hits file
 • Supports easy overwriting of cache
    entries
• [demo]
Two issues
Two issues

• Finding caches
 • Again with the
    simple approach
 • Pick a cloud
    network, scan for
    memcacheds on
    port 11211 with
    a mod’ed .nse
Two issues

                                                            •   Linking apps to
                                                                caches
                                                                •   Who’s %$!#ing
                                                                    cache is this?
                                                                •   Cached high scores
                                                                    suck. Where’s the
                                                                    good stuff?
                                                                •   Is it live?
http://www.rhythm.com/~keith/autoStereoGrams/vortexas.gif
Results #1
     IPs scanned          2^16
 # of caches found        229
   Retrieved Items       7.3GB
   Average uptime       ~50days
Total bandwidth used      9PB
  Total entry count    288 million
 Total Bytes stored      136TB

 Highest bandwidth       247TB
Highest entry count    133 million
Highest Bytes Stored    19.3GB
Results #2
• HTML              • Objects found
• JavaScript         • Serialized Java
• Data               • Pickled Python
 • Email             • Ruby ActiveRecord
 • Passwords         • .Net Object
   (clear-text,
   crypt’ed, MD5)    • JSON
Globworld
Globworld
Globworld
Globworld
Gowalla
Gowalla
Gowalla
Gowalla
Gowalla
Gowalla
Bit.ly Pro
Bit.ly Pro
Bit.ly Pro
PBS
PBS
PBS
PBS
Sidebar: serialized objs
• Python’s pickle intentionally insecure
• But they’re exposed!
• Pickle shellcode
  cos
  system
  (S'echo hostname'
  tR.

• [demo]
Cache on Delivery
Cache on Delivery
Sidebar: serialized objs
• Python’s pickle intentionally insecure
• But they’re exposed!
• Pickle shellcode
  cos
  system
  (S'echo hostname'
  tR.

• [demo]
Fixes?
•   FW. FW. FW. FW. FW. FW. FW. FW. FW. FW. FW. FW.
    FW. FW. FW. FW. FW. FW. FW. FW. FW. FW. FW. FW.
    FW. FW. FW. FW. FW. FW. FW. FW. FW. FW. FW. FW.
    (VPC)
•   Hack code to disable stats facility (but doesn’t prevent
    key brute-force)
•   Hack code to disable remote enabling of debug features
•   Switch to SASL
    •  Requires binary protocol
    •  Not supported by a number of memcached libs
•   Salt your passwords with a proper scheme (PHK’s MD5
    or Bcrypt)
•   Also, FW.
Random thoughts
• This can’t be new
• Inject tracker images / strings
 • Trace Refers / hit Google
• Key guessing or prediction
• Your data ends up in places you never
  expected.
Places to keep looking

• Improve data detection/sifting/filtering
• Spread the search past a single provider
• Caching providers (?!?!)
• Other cache software
• Other infrastructure software
Questions?

www.sensepost.com/labs/tools/poc/go-derper

More Related Content

PPT
Oracle 10g Performance: chapter 10 libc
PDF
Terracotta's OffHeap Explained
PDF
Ehcache 3: JSR-107 on steroids at Devoxx Morocco
KEY
Introduction to Riak - Red Dirt Ruby Conf Training
KEY
Riak Training Session — Surge 2011
PDF
Redis memcached pdf
PPTX
Coding with Riak (from Velocity 2015)
PDF
Relational Databases to Riak
Oracle 10g Performance: chapter 10 libc
Terracotta's OffHeap Explained
Ehcache 3: JSR-107 on steroids at Devoxx Morocco
Introduction to Riak - Red Dirt Ruby Conf Training
Riak Training Session — Surge 2011
Redis memcached pdf
Coding with Riak (from Velocity 2015)
Relational Databases to Riak

What's hot (20)

PPTX
HiveServer2
PDF
Memcached Code Camp 2009
PDF
Australian OpenStack User Group August 2012: Chef for OpenStack
PDF
Hadoop - Lessons Learned
PPTX
PLNOG 18 - Paweł Małachowski - Spy hard czyli regexpem po pakietach
PDF
Boosting Machine Learning with Redis Modules and Spark
PDF
Lessons learned while building Omroep.nl
KEY
Introducing Riak
KEY
Scaling php applications with redis
PDF
Lessons learned while building Omroep.nl
PDF
Mysteries of the binary log
PDF
Apache HBaseの現在 - 火山と呼ばれたHBaseは今どうなっているのか
PPT
Hadoop 24/7
PDF
Python Utilities for Managing MySQL Databases
PDF
Deployment de Rails
PPTX
Cassandra Troubleshooting (for 2.0 and earlier)
PPT
Deploying Grid Services Using Apache Hadoop
PPTX
Redis and it's data types
PDF
The Wix Microservice Stack
PDF
Moxi - Memcached Proxy
HiveServer2
Memcached Code Camp 2009
Australian OpenStack User Group August 2012: Chef for OpenStack
Hadoop - Lessons Learned
PLNOG 18 - Paweł Małachowski - Spy hard czyli regexpem po pakietach
Boosting Machine Learning with Redis Modules and Spark
Lessons learned while building Omroep.nl
Introducing Riak
Scaling php applications with redis
Lessons learned while building Omroep.nl
Mysteries of the binary log
Apache HBaseの現在 - 火山と呼ばれたHBaseは今どうなっているのか
Hadoop 24/7
Python Utilities for Managing MySQL Databases
Deployment de Rails
Cassandra Troubleshooting (for 2.0 and earlier)
Deploying Grid Services Using Apache Hadoop
Redis and it's data types
The Wix Microservice Stack
Moxi - Memcached Proxy
Ad

Similar to Cache on Delivery (20)

KEY
London devops logging
PDF
Fixing twitter
PDF
Fixing_Twitter
PDF
Fixing Twitter Improving The Performance And Scalability Of The Worlds Most ...
PDF
Fixing Twitter Improving The Performance And Scalability Of The Worlds Most ...
PDF
Riak at Posterous
PDF
Ruby and Distributed Storage Systems
PDF
[DLHacks]Introduction to ChainerCV
PDF
Rooting your internals - Exploiting Internal Network Vulns via the Browser Us...
PDF
Caching reboot: javax.cache & Ehcache 3
PDF
Ben Coverston - The Apache Cassandra Project
PDF
Where Django Caching Bust at the Seams
PDF
Play Framework and Activator
PDF
Breaking vaults: Stealing Lastpass protected secrets
PPTX
Игорь Фесенко "Direction of C# as a High-Performance Language"
PPTX
HotSpotコトハジメ
KEY
Inside Of Mbga Open Platform
PDF
DEF CON 27 - CHRISTOPHER ROBERTS - firmware slap
PDF
CBOR - The Better JSON
PDF
Ecos基础应用介绍
London devops logging
Fixing twitter
Fixing_Twitter
Fixing Twitter Improving The Performance And Scalability Of The Worlds Most ...
Fixing Twitter Improving The Performance And Scalability Of The Worlds Most ...
Riak at Posterous
Ruby and Distributed Storage Systems
[DLHacks]Introduction to ChainerCV
Rooting your internals - Exploiting Internal Network Vulns via the Browser Us...
Caching reboot: javax.cache & Ehcache 3
Ben Coverston - The Apache Cassandra Project
Where Django Caching Bust at the Seams
Play Framework and Activator
Breaking vaults: Stealing Lastpass protected secrets
Игорь Фесенко "Direction of C# as a High-Performance Language"
HotSpotコトハジメ
Inside Of Mbga Open Platform
DEF CON 27 - CHRISTOPHER ROBERTS - firmware slap
CBOR - The Better JSON
Ecos基础应用介绍
Ad

More from SensePost (20)

PDF
objection - runtime mobile exploration
PPTX
Vulnerabilities in TN3270 based Application
PDF
Ruler and Liniaal @ Troopers 17
PDF
Introducing (DET) the Data Exfiltration Toolkit
PPTX
ZaCon 2015 - Zombie Mana Attacks
PPTX
Improvement in Rogue Access Points - SensePost Defcon 22
PDF
Heartbleed Overview
PDF
Botconf 2013 - DNS-based Botnet C2 Server Detection
PPTX
Rat a-tat-tat
PDF
Hacking Z-Wave Home Automation Systems
PPTX
Offence oriented Defence
PPTX
Threats to machine clouds
PPTX
Inside .NET Smart Card Operating System
PDF
SNMP : Simple Network Mediated (Cisco) Pwnage
PPT
Its Ok To Get Hacked
PPT
Web Application Hacking
PDF
Putting the tea back into cyber terrorism
PPT
Major global information security trends - a summary
PPT
Attacks and Defences
PDF
Corporate Threat Modeling v2
objection - runtime mobile exploration
Vulnerabilities in TN3270 based Application
Ruler and Liniaal @ Troopers 17
Introducing (DET) the Data Exfiltration Toolkit
ZaCon 2015 - Zombie Mana Attacks
Improvement in Rogue Access Points - SensePost Defcon 22
Heartbleed Overview
Botconf 2013 - DNS-based Botnet C2 Server Detection
Rat a-tat-tat
Hacking Z-Wave Home Automation Systems
Offence oriented Defence
Threats to machine clouds
Inside .NET Smart Card Operating System
SNMP : Simple Network Mediated (Cisco) Pwnage
Its Ok To Get Hacked
Web Application Hacking
Putting the tea back into cyber terrorism
Major global information security trends - a summary
Attacks and Defences
Corporate Threat Modeling v2

Recently uploaded (20)

PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
A Presentation on Artificial Intelligence
PDF
Encapsulation_ Review paper, used for researhc scholars
PPT
Teaching material agriculture food technology
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
TLE Review Electricity (Electricity).pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Encapsulation theory and applications.pdf
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
A comparative analysis of optical character recognition models for extracting...
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Approach and Philosophy of On baking technology
PPTX
1. Introduction to Computer Programming.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Getting Started with Data Integration: FME Form 101
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
August Patch Tuesday
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
A Presentation on Artificial Intelligence
Encapsulation_ Review paper, used for researhc scholars
Teaching material agriculture food technology
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
TLE Review Electricity (Electricity).pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Encapsulation theory and applications.pdf
Accuracy of neural networks in brain wave diagnosis of schizophrenia
A comparative analysis of optical character recognition models for extracting...
SOPHOS-XG Firewall Administrator PPT.pptx
Approach and Philosophy of On baking technology
1. Introduction to Computer Programming.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Building Integrated photovoltaic BIPV_UPV.pdf
Getting Started with Data Integration: FME Form 101
Group 1 Presentation -Planning and Decision Making .pptx
August Patch Tuesday

Cache on Delivery

  • 1. Cache on delivery mining memcached marco@sensepost.com
  • 3. The need for caching • Large percentage of data remains relatively constant • Wikipedia page contents • Youtube video links • FB Profile data • Poorly designed solutions regenerate data on each request • Don’t regenerate, rather regurgitate
  • 4. The need for caching • Large percentage of data remains relatively constant • Wikipedia page contents • Youtube video links • FB Profile data • Poorly designed solutions regenerate data on each request • Don’t regenerate, rather regurgitate
  • 5. Memcached • memcached.org • Written for LJ (2003) by Brad Fitzpatrick • Non-persistent network-based KV store • Why do we care? Mom&pop don’t need the cache.
  • 6. Memcached • memcached.org • Written for LJ (2003) by Brad Fitzpatrick • Non-persistent network-based KV store • Why do we care? Mom&pop don’t need the cache.
  • 7. Basic KV • Slabs are fixed size • Users don’t care about slabs • Dstvalue size by slab determined • Miners care about slabs
  • 8. Trivial protocol • ASCII-based • Long-lived • Tiny command set • set • get • stats • ... • ???? Binary and UDP protocols also exist, these were not touched.
  • 9. Trivial protocol • ASCII-based • Long-lived • Tiny command set • set • get • stats • ... • ???? Binary and UDP protocols also exist, these were not touched.
  • 10. Trivial protocol • ASCII-based • Long-lived • Tiny command set • set • get • stats • ... • ???? Binary and UDP protocols also exist, these were not touched.
  • 11. Trivial protocol • ASCII-based • Long-lived • Tiny command set • set • get • stats • ... • ???? Binary and UDP protocols also exist, these were not touched.
  • 12. Trivial protocol • ASCII-based • Long-lived • Tiny command set • set • get • stats • ... • ???? Binary and UDP protocols also exist, these were not touched.
  • 13. 1998 • Blank ‘sa’ • Anonymous ftp • system/manager
  • 14. Goals • Connect to memcached • Find all slabs • Retrieve keynames from each slab • Retrieve each key
  • 15. Lies, damn lies, and stats stats slabs STAT 1:chunk_size 80 • <...> stats cmd has subcmds STAT 2:chunk_size 104 <...> STAT 3:chunk_size 136 • items <...> STAT 4:chunk_size <...> 176 • slabs STAT 6:chunk_size <...> STAT 8:chunk_size 280 440 • <...> ... STAT 9:chunk_size 552 <...> STAT 9:cas_badval 0 STAT active_slabs 7 This gets us the slabs_ids
  • 16. Retrieving key names Rely on two {poorly|un} documented features
  • 17. Retrieving key names Feature #1: Remote enabling of debug mode
  • 18. Retrieving key names Feature #2: “stats cachedump”
  • 19. Retrieving key names Feature #2: “stats cachedump”
  • 20. Retrieving key names Feature #2: “stats cachedump” Slabs ID
  • 21. Retrieving key names Feature #2: “stats cachedump” Key limit
  • 22. Retrieving key names Feature #2: “stats cachedump” Key list
  • 23. Retrieving key names Feature #2: “stats cachedump” This gets us key names
  • 24. And this gets us? • No need for complex hacks. Memcached serves up all its data for us. • What to do in an exposed cache? • Mine • SQLi is too hard for me • Overwrite • Client-side • Server-side
  • 25. Mining the cache • go-derper.rb – memcached miner • Retrieves up to k keys from each slab and their contents, store on disk • Applies regexes and filters matches in a hits file • Supports easy overwriting of cache entries • [demo]
  • 27. Two issues • Finding caches • Again with the simple approach • Pick a cloud network, scan for memcacheds on port 11211 with a mod’ed .nse
  • 28. Two issues • Linking apps to caches • Who’s %$!#ing cache is this? • Cached high scores suck. Where’s the good stuff? • Is it live? http://www.rhythm.com/~keith/autoStereoGrams/vortexas.gif
  • 29. Results #1 IPs scanned 2^16 # of caches found 229 Retrieved Items 7.3GB Average uptime ~50days Total bandwidth used 9PB Total entry count 288 million Total Bytes stored 136TB Highest bandwidth 247TB Highest entry count 133 million Highest Bytes Stored 19.3GB
  • 30. Results #2 • HTML • Objects found • JavaScript • Serialized Java • Data • Pickled Python • Email • Ruby ActiveRecord • Passwords • .Net Object (clear-text, crypt’ed, MD5) • JSON
  • 44. PBS
  • 45. PBS
  • 46. PBS
  • 47. PBS
  • 48. Sidebar: serialized objs • Python’s pickle intentionally insecure • But they’re exposed! • Pickle shellcode cos system (S'echo hostname' tR. • [demo]
  • 51. Sidebar: serialized objs • Python’s pickle intentionally insecure • But they’re exposed! • Pickle shellcode cos system (S'echo hostname' tR. • [demo]
  • 52. Fixes? • FW. FW. FW. FW. FW. FW. FW. FW. FW. FW. FW. FW. FW. FW. FW. FW. FW. FW. FW. FW. FW. FW. FW. FW. FW. FW. FW. FW. FW. FW. FW. FW. FW. FW. FW. FW. (VPC) • Hack code to disable stats facility (but doesn’t prevent key brute-force) • Hack code to disable remote enabling of debug features • Switch to SASL • Requires binary protocol • Not supported by a number of memcached libs • Salt your passwords with a proper scheme (PHK’s MD5 or Bcrypt) • Also, FW.
  • 53. Random thoughts • This can’t be new • Inject tracker images / strings • Trace Refers / hit Google • Key guessing or prediction • Your data ends up in places you never expected.
  • 54. Places to keep looking • Improve data detection/sifting/filtering • Spread the search past a single provider • Caching providers (?!?!) • Other cache software • Other infrastructure software