SlideShare uma empresa Scribd logo
1 de 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

Mais conteúdo relacionado

Mais procurados

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ı
 

Mais procurados (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
 

Destaque

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
 

Destaque (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
 

Semelhante a 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
 

Semelhante a 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...
 

Mais de 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
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

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
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
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...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 

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

Notas do Editor

  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,