Common Pitfalls in Cryptography for Software Developers. OWASP AppSec Israel July 2006. The OWASP Foundation http://www.owasp.org/



Similar documents
Cryptography & Network Security

Chapter 11 Security+ Guide to Network Security Fundamentals, Third Edition Basic Cryptography

CIS433/533 - Computer and Network Security Cryptography

CIS 6930 Emerging Topics in Network Security. Topic 2. Network Security Primitives

Overview of Cryptographic Tools for Data Security. Murat Kantarcioglu

How To Understand And Understand The History Of Cryptography

IT Networks & Security CERT Luncheon Series: Cryptography

Network Security. Computer Networking Lecture 08. March 19, HKU SPACE Community College. HKU SPACE CC CN Lecture 08 1/23

Dr. Jinyuan (Stella) Sun Dept. of Electrical Engineering and Computer Science University of Tennessee Fall 2010

CSCE 465 Computer & Network Security

Message Authentication Codes

Cryptography: Motivation. Data Structures and Algorithms Cryptography. Secret Writing Methods. Many areas have sensitive information, e.g.

Network Security CS 5490/6490 Fall 2015 Lecture Notes 8/26/2015

How To Understand Cryptanalysis

Part I. Universität Klagenfurt - IWAS Multimedia Kommunikation (VK) M. Euchner; Mai Siemens AG 2001, ICN M NT

Savitribai Phule Pune University

Lecture 6 - Cryptography

CPSC 467b: Cryptography and Computer Security

Network Security Technology Network Management

Content Teaching Academy at James Madison University

Effective Secure Encryption Scheme [One Time Pad] Using Complement Approach Sharad Patil 1 Ajay Kumar 2

CSE331: Introduction to Networks and Security. Lecture 20 Fall 2006

Lecture 9: Application of Cryptography

Cryptography Exercises

CS 758: Cryptography / Network Security

Outline. Computer Science 418. Digital Signatures: Observations. Digital Signatures: Definition. Definition 1 (Digital signature) Digital Signatures

The Misuse of RC4 in Microsoft Word and Excel

The Mathematics of the RSA Public-Key Cryptosystem

Cryptography and Network Security

Cryptography and Network Security Prof. D. Mukhopadhyay Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Cryptographic Hash Functions Message Authentication Digital Signatures

Cryptography & Network Security. Introduction. Chester Rebeiro IIT Madras

Table of Contents. Bibliografische Informationen digitalisiert durch

How To Encrypt With A 64 Bit Block Cipher

Lecture 9 - Network Security TDTS (ht1)

Modes of Operation of Block Ciphers

CRYPTOGRAPHY IN NETWORK SECURITY

Network Security. HIT Shimrit Tzur-David

Computer Security: Principles and Practice

Textbooks: Matt Bishop, Introduction to Computer Security, Addison-Wesley, November 5, 2004, ISBN

Network Security. Security Attacks. Normal flow: Interruption: 孫 宏 民 Phone: 國 立 清 華 大 學 資 訊 工 程 系 資 訊 安 全 實 驗 室

Client Server Registration Protocol

Chapter 23. Database Security. Security Issues. Database Security

Cryptography and Network Security Department of Computer Science and Engineering Indian Institute of Technology Kharagpur

SAMPLE EXAM QUESTIONS MODULE EE5552 NETWORK SECURITY AND ENCRYPTION ECE, SCHOOL OF ENGINEERING AND DESIGN BRUNEL UNIVERSITY UXBRIDGE MIDDLESEX, UK

Secure Network Communications FIPS Non Proprietary Security Policy

Forward Secrecy: How to Secure SSL from Attacks by Government Agencies

Archived NIST Technical Series Publication

CSE/EE 461 Lecture 23

Final Exam. IT 4823 Information Security Administration. Rescheduling Final Exams. Kerberos. Idea. Ticket

Insight Guide. Encryption: A Guide

Security. Contents. S Wireless Personal, Local, Metropolitan, and Wide Area Networks 1

Introduction to Encryption

Network Security. Gaurav Naik Gus Anderson. College of Engineering. Drexel University, Philadelphia, PA. Drexel University. College of Engineering

Secure Network Communication Part II II Public Key Cryptography. Public Key Cryptography

Cryptography & Digital Signatures

SECURITY IMPROVMENTS TO THE DIFFIE-HELLMAN SCHEMES

Lecture Note 8 ATTACKS ON CRYPTOSYSTEMS I. Sourav Mukhopadhyay

Lecture 4 Data Encryption Standard (DES)

Cryptographic hash functions and MACs Solved Exercises for Cryptographic Hash Functions and MACs

Transitions: Recommendation for Transitioning the Use of Cryptographic Algorithms and Key Lengths

Chapter 10. Network Security

Network Security: Cryptography CS/SS G513 S.K. Sahay

Chapter 7: Network security

Fundamentals of Computer Security

CS Computer Security Third topic: Crypto Support Sys

Network Security. Modes of Operation. Steven M. Bellovin February 3,

EXAM questions for the course TTM Information Security May Part 1

AC76/AT76 CRYPTOGRAPHY & NETWORK SECURITY DEC 2014

Evaluation of the RC4 Algorithm for Data Encryption

An Introduction to Cryptography as Applied to the Smart Grid

Center for Internet Security. INTEGRATED INTELLIGENCE CENTER Technical White Paper William F. Pelgrin, CIS President and CEO

CS 348: Computer Networks. - Security; 30 th - 31 st Oct Instructor: Sridhar Iyer IIT Bombay

Security in Distributed Systems. Network Security

Ky Vu DeVry University, Atlanta Georgia College of Arts & Science

7! Cryptographic Techniques! A Brief Introduction

Homework 2. A 4*4 image with 16 pixels Borders unaltered. Color of B2 = Average color of (B1,A2,B3,C2) A1 A2 A3 A4 B1 B2 B3 B4 C1 C2 C3 C4 D1 D2 D3 D4

Cryptography and Network Security Chapter 9


12/3/08. Security in Wireless LANs and Mobile Networks. Wireless Magnifies Exposure Vulnerability. Mobility Makes it Difficult to Establish Trust

Cryptosystems. Bob wants to send a message M to Alice. Symmetric ciphers: Bob and Alice both share a secret key, K.

Princeton University Computer Science COS 432: Information Security (Fall 2013)

RSA Attacks. By Abdulaziz Alrasheed and Fatima

CS155. Cryptography Overview

First Semester Examinations 2011/12 INTERNET PRINCIPLES

Chapter 23. Database Security. Security Issues. Database Security

Safeguarding Data Using Encryption. Matthew Scholl & Andrew Regenscheid Computer Security Division, ITL, NIST

Network Security. Abusayeed Saifullah. CS 5600 Computer Networks. These slides are adapted from Kurose and Ross 8-1

Computer Networks. Network Security 1. Professor Richard Harris School of Engineering and Advanced Technology

CSCI-E46: Applied Network Security. Class 1: Introduction Cryptography Primer 1/26/16 CSCI-E46: APPLIED NETWORK SECURITY, SPRING

Symmetric Key cryptosystem

Chapter 8. Network Security

Network Security (2) CPSC 441 Department of Computer Science University of Calgary

CrypTool Claudia Eckert / Thorsten Clausius Bernd Esslinger / Jörg Schneider / Henrik Koy

CSCE 465 Computer & Network Security

SECURITY IN NETWORKS

Network Security. Chapter 3 Symmetric Cryptography. Symmetric Encryption. Modes of Encryption. Symmetric Block Ciphers - Modes of Encryption ECB (1)

Cryptography and Network Security

Transcription:

Common Pitfalls in Cryptography for Software Developers OWASP AppSec Israel July 2006 Shay Zalalichin, CISSP AppSec Division Manager, Comsec Consulting shayz@comsecglobal.com Copyright 2006 - The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License. The OWASP Foundation http://www.owasp.org/

Agenda Demonstrating Crypto Failures Common Crypto Terminology The Top 10 Crypto Pitfalls Conclusions 2

Example #1 The Cesar Cipher Earliest known Substitution Cipher Invented by Julius Caesar, 49 BC Used to communicate with his army officers and keep the messages secure Replaces each letter by 3rd letter on example: MEET ME AFTER OWASP LECTURE PHHW PH DIWHU RZDVS OHFWXUH 3

Cryptanalysis of the Cesar Cipher Only have 26 possible ciphers A maps to A,B,..Z Could simply try each in turn using a Brute Force Search Given Ciphertext, just try all shifts of letters Do need to recognize when have plaintext 4

Cryptanalysis of the Cesar Cipher 5

Example #2 Using Complex Substitution Cipher Example: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z D E F G H I J K L M N O P Q R S T U V W X Y Z A B C 6

Cryptanalysis of Complex Substitution Cipher The key space for the English Alphabet is very large: 26! 4 x 10 26 It can be, however, broken easily, especially if the message space has known structure. For example, in English texts the letter E is the most used letter. Hence, if one performs a frequency count on the ciphers, then the most frequent letter can be assumed to be E Other letters are fairly rare (e.g. Z,J,K,Q,X) Have also tables of single, double & triple letter frequencies 7

Cryptanalysis of Complex Substitution Cipher 8

Cryptanalysis of Complex Substitution Cipher Demo. 9

Example #3 Data Encryption Standard US encryption standard [NIST 1993] 56-bit symmetric key, 64 bit plaintext input How secure is DES? In 1977, Diffie and Hellman proposed a machine costing an estimated US$20 million which could find a DES key in a single day By 1993, Wiener had proposed a key-search machine costing US$1 million which would find a key within 7 hours In 1998 the EFF built Deep Crack which costs $250,000 and decrypted DES in 56 hours of work In 1999 (Six months later) in collaboration with Distributed.net, Deep Crack decrypted DES in 22 hours and 15 minutes less then a day! 10

Example #3 Enhancing DES What if we want to enhance its strength beyond of 2^56? We might consider enhancing the algorithm to perform Double Encryption with two different 56-bit Keys C = Ek1(Ek2(M)) Total strength is considered to be: 2^112 (twice as strong as the original DES) 11

Example #3 Breaking the Enhancement However Time & Memory tradeoff attack called Meet-in-the- Middle (from Diffie & Hellman) can be performed against the improved algorithm breaking it in only 2^57 guesses Attack includes: Using know P, C Computing Ek1(P) for all k1 Computing Dk2(C) for all k2 Checking if Ek1(P) = Dk2(C) and if so, the key was found! 12

Example #4 Using Public Key Mechanism Alice generates Ea & Da Alice sends Bob Ea Bob generates Eb & Db Bob sends Alice Eb Alice sends Bob encrypted messages using Eb and decrypts incoming messages using Da Bob sends Alice encrypted messages using Ea and decrypts incoming messages using Db What can go wrong? 13

Common Pitfalls Introduction Covers the popular mistakes & pitfalls that software developers do while using crypto within their applications Based on a few hundred security audits that Comsec performed over the last 6 years The list is not bound to any technology / application infrastructure or programming language Note: This list is far from being complete but serves its purpose to describe common mistakes 14

The Top 10 List of Crypto Pitfalls 1. Security by Obscurity 2. Using Traditional Cryptography 3. Using Proprietary Cryptography 4. Using Insecure Random Generators 5. Hiding Secrets 6. Using Weak Keys 7. Memory Protection 8. Not Using Salted Hash 9. Using MAC Insecurely 10. Insecure Initialization 15

#1: Security by Obscurity One of the basic security principles that every software developer / designer should follow when writing secure applications In the crypto context, usually related to: Hiding the Crypto algorithms / protocols being used Hiding the Crypto keys generation algorithms Hiding the Crypto keys Hiding initialization parameters Etc. Simply does not work Once revealed, usually results in total breakdown of the system security model Side effect is the prevention of other-eyes from inspecting / reviewing the algorithms being used for potential weaknesses that can be fixed 16

#2: Using Traditional Crypto Traditional or Classical Cryptography covers algorithms and techniques used to perform cryptographic operations in the old-days Popular examples include: Shift Cipher (e.g. Caesar / C3) Substitution Cipher Affine Cipher Vigenere Cipher Etc. Effective Cryptanalysis techniques / tools are considered common knowledge and usually result in the total breakdown of these algorithms 17

#3: Using Proprietary Crypto Includes the modification of standard crypto algorithms or the usage of proprietary new crypto algorithms Usually combined with #1 (Security by Obscurity) In most cases standard algorithms / methods cover most aspects needed by software developers Unless you have vast experience and significant resources to invest in the cryptanalysis research of the new algorithm usually results in poor algorithm that can be easily broken 18

#4: Using Insecure Random Generators Usually Random Generators are not truly random but rather Pseudo Random algorithms Common usage of the random generators in the crypto context usually includes a generation of: One-time-passwords Access codes Crypto keys Session identifiers Etc. 19

#4: Using Insecure Random Generators (Cont.) Some of the generators were planned to support statistical requirements (e.g. uniformly distribution) and not to provide secure unpredictable values Some of the generators are required to be initialized by using SEED value. Usage of the same SEED provides the same sequence causing the choosing of the SEED to be critical for security Using random generators that are considered insecure or the insecure initialization of these generators usually results in the ability of an attacker in predict other values that were generated by the random generator 20

#5: Hiding Secrets Secure systems need to handle secrets These secrets are usually access credentials to other systems (e.g. DBMS) or crypto keys (sometimes even to protect those access credentials) In many cases, to protect those secrets developers hides them in several places such as: Application source code Configuration files Windows Registry 21

#5: Hiding Secrets (Cont.) It is common belief that since application code is compiled into binary executable it would be hard to extract them The fact is that extracting those secrets from application compiled code is eventually not as hard as it seems and can be done using various tools and techniques Some programming languages (e.g. Java,.NET) do not produce true binary making the extraction job even easier 22

#5: Hiding Secrets (Cont.) Additional problems with hard-coded secrets are that they are hard to maintain and expose these secrets to developers or to less secure environments (e.g. Testing, Integration, Source Control) As for hiding the secrets in external resources (e.g. files), plenty of available tools can be easily used to discover the resource used for storage and easily recover the secret 23

#6: Using Weak Keys Systems that use crypto must use crypto keys to perform various crypto activities (e.g. for encryption, decryption, MAC) These crypto keys are sometime based on chosen passwords that might seem long & hard but when used as keys are weak Other cases include key generation using an insecure generator (e.g. pseudo random generator or other obscured techniques) 24

#6: Using Weak Keys (Cont.) The strength of the entire crypto scheme is heavily dependent upon keys strength It is important to notice that strength is not always equal to length Example: 8 char alpha numeric passwords strength is not equal to 64- bit crypto key but rather to 40-bit crypto key! Secure crypto schemes (e.g. AES, RSA) are almost useless and can be easily defeated when used with weak keys 25

#7: Memory Protection In most cases sensitive crypto data is stored in the host s memory Most of the time this information is stored unprotected (without any Encryption) Many times this information is stored for a longer period than actually needed (enlarging the attack window) Many times the memory is not specifically overwritten to perform the actual removal of the sensitive information from memory 26

#7: Memory Protection (Cont.) In some programming languages the information is even stored (usually due to insufficient knowledge) within a mutable object preventing it from being specifically erased Insufficient memory protection jeopardizes the sensitive information (usually crypto Keys) to be leaked out to an unauthorized attacker causing direct risk to the entire cryptosystem 27

#8: Not Using Salted Hash Crypto Hash Functions are sometimes used to store one-way version of Passwords (or other credentials that needs to be authenticated) Popular implementation includes a simple replacement of the Password field with the Hashed version and the performance of the checks against it Not using any Salt on the stored Hash Values exposes this scheme to Dictionary Attack that can totally break this scheme! 28

#9: Using MAC Insecurely MAC is used to secure the integrity of the message and to authenticate the sender by using a Shared Secret Popular MAC implementations are based on unkeyed Hashes operated on the data combined with the Shared Secret The Data + Shared Secret combination is usually the concatenation operation 29

#9: Using MAC Insecurely (Cont.) Due to its mathematical operation of the iterative Hash function, if not carefully built, data can be altered and a matching MAC can be calculated without knowing the Shared Secret! 30

#10: Insecure Initialization Standard crypto algorithms and mechanisms are based on several parameters, most of them are defined during initialization Examples include: Symmetric block encryption modes of operation (e.g. ECB) Asymmetric encryption (e.g. Modulus in RSA) RSA Padding mode These parameters define the way the algorithms work and therefore have a direct impact on the algorithm security level Failure to choose them carefully may weaken the algorithm exposing it to different types of attacks (e.g. MITM, Existential Forgery) 31

#10: Insecure Initialization Example Usage of Shared Modulus in RSA results in total breakdown of the entire cryptosystem If Bob has (N, Eb) & (N, Db) And Alice has (N, Ea) & (N, Da) Bob can factor N and then calculate Da from Ea 32

Conclusions And if you can only take a few thing from this presentation: Know what you are doing Do not rely on Obscurity Do not try to Hide secrets Do not re-invent the wheel Generate Strong Keys and Protect them Use only strong & standard Ciphersuites 33

Questions? OWASP AppSec Israel July 2006 Shay Zalalichin, CISSP AppSec Division Manager, Comsec Consulting shayz@comsecglobal.com Copyright 2006 - The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License. The OWASP Foundation http://www.owasp.org/