SlideShare a Scribd company logo
1 of 37
Speaking with Cryptographic Oracles Daniel “unicornFurnace” Crowley Application Security Consultant, Trustwave - Spiderlabs
The Speaker and the Presentation A quick introduction and a few distinctions
The Speaker Daniel Crowley Web application security d00d IANAC (I am not a cryptographer) dcrowley@trustwave.com @dan_crowley
The Presentation Topic Finding and exploiting: Encryption Oracles Decryption Oracles Padding Oracles With little to no cryptographic knowledge More crypto knowledge, more useful attacks
NOT the Presentation Topic The Oracle We are not being harvested for energy by robot overlords Maybe ORACLE If you Google “<any crypto word> oracle” it’s all you find Google, the Internet Oracle While awesome, not what we’re talking about
NOT the Presentation Topic Crypto g00r00s like Adi Shamir While also awesome and totally related, not the topic New attacks on old crypto Mistakes are easy enough to make in implementation How Padding Oracle attacks work Too much time to explain Too many good resources
DEFCON Drinking Game 0-day APT iPad APT China, cyber-war Cloud mobile botnet Cloud cloud Cyber-Twilight APT Sun Tzu RSA HBGary botnet PCI SCADA in the cloud Cyber-war? LulzSec??? APT China cyber-war weeaboo, WikiLeaks mobile LulzSec.
A Primer on Cryptographic Terms Basic cryptographic terms, concepts and mistakes
Very Basic Terms Cipher A system for scrambling and unscrambling data to protect it Key A variable used to permute the cipher Initialization Vector (IV) A second variable used to randomize the cipher Plaintext	 The data in readable form Ciphertext The data in unreadable form Encryption Turning something you can read into something you can’t Decryption Turning something you can’t read into something you can
Stream and Block Ciphers Block Encrypt X characters at a time X is the block size Key is used to directly transform plaintext to ciphertext Stream Encrypt one character at a time Key is used to generate pseudo-random numbers Those numbers are used to transform plaintext to ciphertext
Very Basic Mistakes Using a keyless cipher Completely insecure if cipher is ever discovered Reusing keys and/or IVs Makes Oracle attacks far more dangerous IV reuse can seriously weaken stream ciphers Think WEP Leaking data from crypto operations Foundation for Oracle attacks Flickr Creative Commons - Rosino
What is an Oracle? A system which takes queries and provides answers Queries might be Plaintext Ciphertext Answers might be Corresponding plaintext Corresponding ciphertext Info about operation Sample from PRNG Picture by D Sharon Pruitt – Creative Commons
Seek the Oracle How to identify cryptographic Oracles From a black-box perspective
Decryption Oracles: Identify Input Identify where encrypted input occurs Identify all points of user input For Web apps: GET, POST, URL, Cookie, headers Identify those which may be encrypted Encrypted data is generally encoded Base64 ASCII hex URL encoding Decoded data is likely encrypted if seemingly random Modification of values may result in decryption-related errors
Decryption Oracles: Find Decrypted Output May be reflected Normal output Error May be given in later response May be inferred from modified output May be stored and not shown Additional vulnerabilities may reveal output
Decryption Oracles: An Example Scenario Consider “GetPage.php?file=<encrypted_stuff>” Opens a file to be included based on encrypted input Allows for quick page additions Prevents file inclusion attacks…? Assumes properly encrypted input is sanitary Errors are verbose Usage Feed the script some ciphertext Record the “file” the error tells you wasn’t found
Encryption Oracles: Find Encrypted Data Often found in Cookies Hidden variables Databases File resident data Flickr Creative Commons – Gideon van der Stelt
Encryption Oracles: Determine Point of Entry Frequently encrypted data Client-side state variables Passwords Financial data Anything sufficiently sensitive Being encrypted is not enough We need to be able to manipulate it And see the ciphertext
Encryption Oracles: An Example Scenario Consider “auth” cookie, encrypted Username + “:” + password_hash + “:” + timestamp Assume usernames can’t contain “:” character No delimiter injection  Timestamp to control expiration Usage Register with any username, log in Copy cookie value and replace any encrypted input with it Can’t use colons or control suffix Might not matter
Padding Oracles Input must be encrypted Must be a padded block cipher Valid vs. invalid padding is distinguishable This is the essence of a padding Oracle Padding Oracles can be used as decryption Oracles Using the CBC-R technique they are also encryption Oracles May be limited in that the first block will be garbled
Exploiting Cryptographic Oracles Breaking bad crypto and bad crypto usage
Converting One Oracle Into Another Padding Oracles only tell you whether padding is valid This information can be used to decrypt data In some circumstances, it can also be used to encrypt Decryption Oracles Can be converted to encryption Oracles using brute force Far more effective with stream ciphers Encryption Oracles Can be converted to decryption Oracles using brute force Again, more effective with stream ciphers
Attack 0: Crypto Recon Check for static key, IV, and deterministic cipher Encrypt the same plaintext twice Check to see if they are identical Check for stream vs. block ciphers Encrypt plaintexts of various sizes Compare plaintext size to ciphertext size Check for ECB block cipher mode Encrypt repeating plaintext blocks Look for repetitive ciphertext Check for stream cipher feedback ,[object Object]
Change the first byte
Observe whether the following bytes change,[object Object]
And they’re not cryptographers
And it doesn’t end wellReal homespun crypto seen in the wild: “hello” might become “KqIKefKPrPKPrPKuJXK”
Attack 1: Bad Algorithms Is there substitution? Submit “AAAA” : Get “KLoKLoKLoKLoK” ,[object Object]
We can already see patterns, tooIs there transposition? Submit “AABB” : Get “KLoKLoKaBeKaBeK” ,[object Object]
We can see more patterns
The “K” seems to be a delimeter
Substitution doesn’t change on position
One replacement per letter,[object Object]
The Oracle tells us what each maps to,[object Object]
Attack 1.75: Bride of Bad Algorithms For some simple ciphers like xor Encryption = Decryption THUS Encryption Oracle = Decryption Oracle THUS Such ciphers are made completely useless by leaking output THUS For God’s sake stop using xor
Attack 1: Bad Algorithms DEMO
Attack 2: Trusted Encrypted Input People tend to reuse keys and IVs If we can encrypt arbitrary data in one place It may work in another If devs don’t think you can mess with input They probably won’t sanitize it Encrypted inputs with MAC aren’t totally tamper-proof

More Related Content

What's hot

Crypto failures every developer should avoid
Crypto failures every developer should avoidCrypto failures every developer should avoid
Crypto failures every developer should avoid
Filip Šebesta
 
Google Hacking for Cryptographic Secrets
Google Hacking for Cryptographic SecretsGoogle Hacking for Cryptographic Secrets
Google Hacking for Cryptographic Secrets
Dr. Emin İslam Tatlı
 

What's hot (14)

php[world] 2016 - Tales From the Crypto: A Cryptography Primer
php[world] 2016 - Tales From the Crypto: A Cryptography Primerphp[world] 2016 - Tales From the Crypto: A Cryptography Primer
php[world] 2016 - Tales From the Crypto: A Cryptography Primer
 
Crypto failures every developer should avoid
Crypto failures every developer should avoidCrypto failures every developer should avoid
Crypto failures every developer should avoid
 
Cryptography and PKI
Cryptography and PKICryptography and PKI
Cryptography and PKI
 
Beyond Automated Testing - RVAsec 2016
Beyond Automated Testing - RVAsec 2016Beyond Automated Testing - RVAsec 2016
Beyond Automated Testing - RVAsec 2016
 
OSINT for Attack and Defense
OSINT for Attack and DefenseOSINT for Attack and Defense
OSINT for Attack and Defense
 
HITCON 2015 - DGAs, DNS and Threat Intelligence
HITCON 2015 - DGAs, DNS and Threat IntelligenceHITCON 2015 - DGAs, DNS and Threat Intelligence
HITCON 2015 - DGAs, DNS and Threat Intelligence
 
BSidesDC 2016 Beyond Automated Testing
BSidesDC 2016 Beyond Automated TestingBSidesDC 2016 Beyond Automated Testing
BSidesDC 2016 Beyond Automated Testing
 
Google Hacking for Cryptographic Secrets
Google Hacking for Cryptographic SecretsGoogle Hacking for Cryptographic Secrets
Google Hacking for Cryptographic Secrets
 
Cryptography by gaurav singh
Cryptography by gaurav singhCryptography by gaurav singh
Cryptography by gaurav singh
 
THOTCON 0x6: Going Kinetic on Electronic Crime Networks
THOTCON 0x6: Going Kinetic on Electronic Crime NetworksTHOTCON 0x6: Going Kinetic on Electronic Crime Networks
THOTCON 0x6: Going Kinetic on Electronic Crime Networks
 
The Good News on Cryptography
The Good News on CryptographyThe Good News on Cryptography
The Good News on Cryptography
 
My Bro The ELK
My Bro The ELKMy Bro The ELK
My Bro The ELK
 
The Dirty Little Secrets They Didn’t Teach You In Pentesting Class
The Dirty Little Secrets They Didn’t Teach You In Pentesting Class The Dirty Little Secrets They Didn’t Teach You In Pentesting Class
The Dirty Little Secrets They Didn’t Teach You In Pentesting Class
 
Cryptography and Encryptions,Network Security,Caesar Cipher
Cryptography and Encryptions,Network Security,Caesar CipherCryptography and Encryptions,Network Security,Caesar Cipher
Cryptography and Encryptions,Network Security,Caesar Cipher
 

Viewers also liked

Oracle Transparent Data Encription
Oracle Transparent Data EncriptionOracle Transparent Data Encription
Oracle Transparent Data Encription
rohit3033
 
Encryption oracle
Encryption oracleEncryption oracle
Encryption oracle
manong007
 
Introduction à la sécurité des WebServices
Introduction à la sécurité des WebServicesIntroduction à la sécurité des WebServices
Introduction à la sécurité des WebServices
ConFoo
 
“Secure Password Managers” and “Military-Grade Encryption” on Smartphones:...
“Secure Password Managers” and   “Military-Grade Encryption” on  Smartphones:...“Secure Password Managers” and   “Military-Grade Encryption” on  Smartphones:...
“Secure Password Managers” and “Military-Grade Encryption” on Smartphones:...
Positive Hack Days
 
What is a Token Service Provider?
What is a Token Service Provider?What is a Token Service Provider?
What is a Token Service Provider?
Rambus Inc
 
What is Payment Tokenization?
What is Payment Tokenization?What is Payment Tokenization?
What is Payment Tokenization?
Rambus Inc
 

Viewers also liked (14)

Oracle Transparent Data Encription
Oracle Transparent Data EncriptionOracle Transparent Data Encription
Oracle Transparent Data Encription
 
venture lab project 02
venture lab project 02venture lab project 02
venture lab project 02
 
Encryption oracle
Encryption oracleEncryption oracle
Encryption oracle
 
Jack of all Formats
Jack of all FormatsJack of all Formats
Jack of all Formats
 
Oracle Key Vault Data Subsetting and Masking
Oracle Key Vault Data Subsetting and MaskingOracle Key Vault Data Subsetting and Masking
Oracle Key Vault Data Subsetting and Masking
 
Modified MD5 Algorithm for Password Encryption
Modified MD5 Algorithm for Password EncryptionModified MD5 Algorithm for Password Encryption
Modified MD5 Algorithm for Password Encryption
 
Introduction à la sécurité des WebServices
Introduction à la sécurité des WebServicesIntroduction à la sécurité des WebServices
Introduction à la sécurité des WebServices
 
“Secure Password Managers” and “Military-Grade Encryption” on Smartphones:...
“Secure Password Managers” and   “Military-Grade Encryption” on  Smartphones:...“Secure Password Managers” and   “Military-Grade Encryption” on  Smartphones:...
“Secure Password Managers” and “Military-Grade Encryption” on Smartphones:...
 
Oracle Transparent Data Encryption (TDE) 12c
Oracle Transparent Data Encryption (TDE) 12cOracle Transparent Data Encryption (TDE) 12c
Oracle Transparent Data Encryption (TDE) 12c
 
Introduction to Tokenization
Introduction to TokenizationIntroduction to Tokenization
Introduction to Tokenization
 
What is a Token Service Provider?
What is a Token Service Provider?What is a Token Service Provider?
What is a Token Service Provider?
 
What is Payment Tokenization?
What is Payment Tokenization?What is Payment Tokenization?
What is Payment Tokenization?
 
Oracle database 12c advanced security guide
Oracle database 12c advanced security guideOracle database 12c advanced security guide
Oracle database 12c advanced security guide
 
Oracle database 12c 2 day + security guide
Oracle database 12c 2 day + security guideOracle database 12c 2 day + security guide
Oracle database 12c 2 day + security guide
 

Similar to Daniel Crowley - Speaking with Cryptographic Oracles

aacyberessential3cryptography-131067585699078884.pptx
aacyberessential3cryptography-131067585699078884.pptxaacyberessential3cryptography-131067585699078884.pptx
aacyberessential3cryptography-131067585699078884.pptx
ImXaib
 
Discussion Question Contrast file encryption and volume encryptio.docx
Discussion Question Contrast file encryption and volume encryptio.docxDiscussion Question Contrast file encryption and volume encryptio.docx
Discussion Question Contrast file encryption and volume encryptio.docx
JeniceStuckeyoo
 

Similar to Daniel Crowley - Speaking with Cryptographic Oracles (20)

Encryption
EncryptionEncryption
Encryption
 
aacyberessential3cryptography-131067585699078884.pptx
aacyberessential3cryptography-131067585699078884.pptxaacyberessential3cryptography-131067585699078884.pptx
aacyberessential3cryptography-131067585699078884.pptx
 
Crypto failures every developer should avoid
Crypto failures every developer should avoidCrypto failures every developer should avoid
Crypto failures every developer should avoid
 
Cracking the crypto
Cracking the cryptoCracking the crypto
Cracking the crypto
 
Cyber Security Workshop GDSC-BITW
Cyber Security Workshop GDSC-BITWCyber Security Workshop GDSC-BITW
Cyber Security Workshop GDSC-BITW
 
Java Hurdling: Obstacles and Techniques in Java Client Penetration-Testing
Java Hurdling: Obstacles and Techniques in Java Client Penetration-TestingJava Hurdling: Obstacles and Techniques in Java Client Penetration-Testing
Java Hurdling: Obstacles and Techniques in Java Client Penetration-Testing
 
BCS_PKI_part1.ppt
BCS_PKI_part1.pptBCS_PKI_part1.ppt
BCS_PKI_part1.ppt
 
amer-network-sihubconferances-security.ppt
amer-network-sihubconferances-security.pptamer-network-sihubconferances-security.ppt
amer-network-sihubconferances-security.ppt
 
paper9.pdf
paper9.pdfpaper9.pdf
paper9.pdf
 
sheet2.pdf
sheet2.pdfsheet2.pdf
sheet2.pdf
 
doc2.pdf
doc2.pdfdoc2.pdf
doc2.pdf
 
paper2.pdf
paper2.pdfpaper2.pdf
paper2.pdf
 
lecture1.pdf
lecture1.pdflecture1.pdf
lecture1.pdf
 
Secure Coding 101 - OWASP University of Ottawa Workshop
Secure Coding 101 - OWASP University of Ottawa WorkshopSecure Coding 101 - OWASP University of Ottawa Workshop
Secure Coding 101 - OWASP University of Ottawa Workshop
 
Discussion Question Contrast file encryption and volume encryptio.docx
Discussion Question Contrast file encryption and volume encryptio.docxDiscussion Question Contrast file encryption and volume encryptio.docx
Discussion Question Contrast file encryption and volume encryptio.docx
 
Information Security
Information SecurityInformation Security
Information Security
 
Eliminating Secret Sprawl in the Cloud with HashiCorp Vault - 07.11.2018
Eliminating Secret Sprawl in the Cloud with HashiCorp Vault - 07.11.2018Eliminating Secret Sprawl in the Cloud with HashiCorp Vault - 07.11.2018
Eliminating Secret Sprawl in the Cloud with HashiCorp Vault - 07.11.2018
 
Introduction To PKI Technology
Introduction To PKI TechnologyIntroduction To PKI Technology
Introduction To PKI Technology
 
The Anatomy of Java Vulnerabilities
The Anatomy of Java VulnerabilitiesThe Anatomy of Java Vulnerabilities
The Anatomy of Java Vulnerabilities
 
How to Use Cryptography Properly: Common Mistakes People Make When Using Cry...
How to Use Cryptography Properly:  Common Mistakes People Make When Using Cry...How to Use Cryptography Properly:  Common Mistakes People Make When Using Cry...
How to Use Cryptography Properly: Common Mistakes People Make When Using Cry...
 

More from BaronZor (6)

The Patsy Proxy
The Patsy ProxyThe Patsy Proxy
The Patsy Proxy
 
No-Knowledge Crypto Attacks
No-Knowledge Crypto AttacksNo-Knowledge Crypto Attacks
No-Knowledge Crypto Attacks
 
Home Invasion 2.0 - DEF CON 21 - 2013
Home Invasion 2.0 - DEF CON 21 - 2013Home Invasion 2.0 - DEF CON 21 - 2013
Home Invasion 2.0 - DEF CON 21 - 2013
 
Why UPnP is awesome and terrifying
Why UPnP is awesome and terrifyingWhy UPnP is awesome and terrifying
Why UPnP is awesome and terrifying
 
Advanced SQL Injection with SQLol
Advanced SQL Injection with SQLolAdvanced SQL Injection with SQLol
Advanced SQL Injection with SQLol
 
Windows File Pseudonyms
Windows File PseudonymsWindows File Pseudonyms
Windows File Pseudonyms
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Recently uploaded (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

Daniel Crowley - Speaking with Cryptographic Oracles

  • 1. Speaking with Cryptographic Oracles Daniel “unicornFurnace” Crowley Application Security Consultant, Trustwave - Spiderlabs
  • 2. The Speaker and the Presentation A quick introduction and a few distinctions
  • 3. The Speaker Daniel Crowley Web application security d00d IANAC (I am not a cryptographer) dcrowley@trustwave.com @dan_crowley
  • 4. The Presentation Topic Finding and exploiting: Encryption Oracles Decryption Oracles Padding Oracles With little to no cryptographic knowledge More crypto knowledge, more useful attacks
  • 5. NOT the Presentation Topic The Oracle We are not being harvested for energy by robot overlords Maybe ORACLE If you Google “<any crypto word> oracle” it’s all you find Google, the Internet Oracle While awesome, not what we’re talking about
  • 6. NOT the Presentation Topic Crypto g00r00s like Adi Shamir While also awesome and totally related, not the topic New attacks on old crypto Mistakes are easy enough to make in implementation How Padding Oracle attacks work Too much time to explain Too many good resources
  • 7. DEFCON Drinking Game 0-day APT iPad APT China, cyber-war Cloud mobile botnet Cloud cloud Cyber-Twilight APT Sun Tzu RSA HBGary botnet PCI SCADA in the cloud Cyber-war? LulzSec??? APT China cyber-war weeaboo, WikiLeaks mobile LulzSec.
  • 8. A Primer on Cryptographic Terms Basic cryptographic terms, concepts and mistakes
  • 9. Very Basic Terms Cipher A system for scrambling and unscrambling data to protect it Key A variable used to permute the cipher Initialization Vector (IV) A second variable used to randomize the cipher Plaintext The data in readable form Ciphertext The data in unreadable form Encryption Turning something you can read into something you can’t Decryption Turning something you can’t read into something you can
  • 10. Stream and Block Ciphers Block Encrypt X characters at a time X is the block size Key is used to directly transform plaintext to ciphertext Stream Encrypt one character at a time Key is used to generate pseudo-random numbers Those numbers are used to transform plaintext to ciphertext
  • 11. Very Basic Mistakes Using a keyless cipher Completely insecure if cipher is ever discovered Reusing keys and/or IVs Makes Oracle attacks far more dangerous IV reuse can seriously weaken stream ciphers Think WEP Leaking data from crypto operations Foundation for Oracle attacks Flickr Creative Commons - Rosino
  • 12. What is an Oracle? A system which takes queries and provides answers Queries might be Plaintext Ciphertext Answers might be Corresponding plaintext Corresponding ciphertext Info about operation Sample from PRNG Picture by D Sharon Pruitt – Creative Commons
  • 13. Seek the Oracle How to identify cryptographic Oracles From a black-box perspective
  • 14. Decryption Oracles: Identify Input Identify where encrypted input occurs Identify all points of user input For Web apps: GET, POST, URL, Cookie, headers Identify those which may be encrypted Encrypted data is generally encoded Base64 ASCII hex URL encoding Decoded data is likely encrypted if seemingly random Modification of values may result in decryption-related errors
  • 15. Decryption Oracles: Find Decrypted Output May be reflected Normal output Error May be given in later response May be inferred from modified output May be stored and not shown Additional vulnerabilities may reveal output
  • 16. Decryption Oracles: An Example Scenario Consider “GetPage.php?file=<encrypted_stuff>” Opens a file to be included based on encrypted input Allows for quick page additions Prevents file inclusion attacks…? Assumes properly encrypted input is sanitary Errors are verbose Usage Feed the script some ciphertext Record the “file” the error tells you wasn’t found
  • 17. Encryption Oracles: Find Encrypted Data Often found in Cookies Hidden variables Databases File resident data Flickr Creative Commons – Gideon van der Stelt
  • 18. Encryption Oracles: Determine Point of Entry Frequently encrypted data Client-side state variables Passwords Financial data Anything sufficiently sensitive Being encrypted is not enough We need to be able to manipulate it And see the ciphertext
  • 19. Encryption Oracles: An Example Scenario Consider “auth” cookie, encrypted Username + “:” + password_hash + “:” + timestamp Assume usernames can’t contain “:” character No delimiter injection  Timestamp to control expiration Usage Register with any username, log in Copy cookie value and replace any encrypted input with it Can’t use colons or control suffix Might not matter
  • 20. Padding Oracles Input must be encrypted Must be a padded block cipher Valid vs. invalid padding is distinguishable This is the essence of a padding Oracle Padding Oracles can be used as decryption Oracles Using the CBC-R technique they are also encryption Oracles May be limited in that the first block will be garbled
  • 21. Exploiting Cryptographic Oracles Breaking bad crypto and bad crypto usage
  • 22. Converting One Oracle Into Another Padding Oracles only tell you whether padding is valid This information can be used to decrypt data In some circumstances, it can also be used to encrypt Decryption Oracles Can be converted to encryption Oracles using brute force Far more effective with stream ciphers Encryption Oracles Can be converted to decryption Oracles using brute force Again, more effective with stream ciphers
  • 23.
  • 25.
  • 26. And they’re not cryptographers
  • 27. And it doesn’t end wellReal homespun crypto seen in the wild: “hello” might become “KqIKefKPrPKPrPKuJXK”
  • 28.
  • 29.
  • 30. We can see more patterns
  • 31. The “K” seems to be a delimeter
  • 33.
  • 34.
  • 35. Attack 1.75: Bride of Bad Algorithms For some simple ciphers like xor Encryption = Decryption THUS Encryption Oracle = Decryption Oracle THUS Such ciphers are made completely useless by leaking output THUS For God’s sake stop using xor
  • 36. Attack 1: Bad Algorithms DEMO
  • 37. Attack 2: Trusted Encrypted Input People tend to reuse keys and IVs If we can encrypt arbitrary data in one place It may work in another If devs don’t think you can mess with input They probably won’t sanitize it Encrypted inputs with MAC aren’t totally tamper-proof
  • 38. Attack 2: Trusted Encrypted Input Encrypted password with MAC in cookie Checked against database on each request needing auth Find encryption Oracle with the same keys & IV Use encryption Oracle to encrypt ‘ or 1=1-- Plug resulting value into cookie Laugh all the way to the bank
  • 39. Attack 2: Trusted Encrypted Input DEMO
  • 40. Attack 3: Let the client have it, it’s encrypted Find a decryption Oracle Find encrypted data Decrypt that sucka ????? PROFIT!!! This attack also relies on key/IV reuse
  • 41. Attack 3: Let the client have it, it’s encrypted DEMO
  • 42. What encryption? If you can find An encryption Oracle A decryption Oracle You can encrypt or decrypt any data As long as keys and IVs are reused Algorithm doesn’t matter Padding doesn’t matter Cipher mode doesn’t matter All encryption which uses the same key and IV is now useless
  • 43. How Can I Fix My Code? Avoid giving away information about crypto operations Output Not always plausible Success/Failure Suppress or generalize errors Timing Make code take the same time to finish no matter what happens Authenticate your crypto Encrypt-then-MAC MAC-then-Encrypt still allows for padding oracle attacks
  • 44. Questions? Daniel Crowley Trustwave– SpiderLabs @dan_crowley dcrowley@trustwave.com

Editor's Notes

  1. The first step is to identify where encrypted user input occurs. From a black box perspective, we first need to identify all of the user inputs, then determine which of them may be encrypted,