Encryption Web Security - Computer...
Transcript of Encryption Web Security - Computer...
Web Security: EncryptionMarissa SchmidtCS401: Intro to Web Development
Topics
● Security Overview● Secure Communication● Hash Functions
Security OverviewInformation
Information Security
Defending information from unauthorized access, usage, disruption, modification or destruction.A general term that applies to various forms of data (physical, electronic, etc.)
Basic PrinciplesConfidentiality
A set of rules or an agreement that limits access or imposes restrictions on certain types of information. (I like web better, but don’t tell CS121 students)
IntegrityMaintaining the consistency and accuracy of information to ensure that it can’t be modified in an unauthorized or undetected manner. (Don’t say that I said that I like web students better)
AvailabilityThe information is accessible when needed; storage, security, and communication mediums must function correctly to ensure accessibility and prevent disruptions. (Be ready to share my secret with other web students)
Basic PrinciplesAuthenticity
Ensure that the information, and the associated transactions and communication mediums are genuine, where the involved parties are validated (to make sure they are who they claim to be). (Before sharing my secret, make sure the other person is not a web imposter!)
Non-repudiationThe ability to ensure that a party to a contract or a communication cannot deny the authenticity of their signature on a document or the sending of a message that they originated. (Should probably get my signature so I can’t deny that I said I liked web better)
Information Technology (IT) Security
Information security applied to technology.● Computing devices.
● Public and private computer networks,including the entire internet.
Also referred to as computer security or cyber security.
Web SecurityOur main focus
Web Security
The practice of defending websites, web applications, and web services from unauthorized access, usage, disruption, modification or destruction.All of the basic security principles apply:
Confidentiality Integrity Availability Authenticity Non-repudiation
Introduction and Motivation
The www can be a hostile place!Assume nothing, trust no one...It is our duty as web programmers to protect and defend web-based systems.● We must acquire knowledge and learn skills
to deal with attacks.
Introduction and Motivation
● Valuable, powerful, and applicable skillsets for many jobs and industries.
● Need to pay close attention to detail when it comes to security.○ If even one vulnerability of a public website is
overlooked, then the results can be disastrous!○ Top 10 data breaches of the last 12 months○ http://www.informationisbeautiful.
net/visualizations/worlds-biggest-data-breaches-hacks/
Introduction and MotivationEven if your website doesn’t contain sensitive data such as personal records, credit card numbers, etc., it may still be a target for an attacker.
Websites are attacked for many different reasons and it happens all the time!
Introduction and MotivationIf an attacker compromises a website, then they may: ● read private data,● modify, delete, or falsify data,● damage, deface, or shutdown the site,● harm the site’s reputation or credibility,● use the site (or the underlying server) as a platform to
launch additional attacks against other people, websites, or systems (i.e. to spread spam, viruses, trojans, key loggers, or other malware).
Secure CommunicationCryptography
CryptologyCryptography
The science of the mathematical techniques for securing messages. More generally, it is the construction, analysis, and practice of codes and protocols for secure communication in the presence of third parties (often called “adversaries”).
CryptanalysisThe science of breaking cryptography.
CryptologyThe science of both cryptography and cryptanalysis; it is a fundamental component of web security!
CryptologyDue to the time limitations of this class and that cryptology is vast discipline, we can only explore the essential basics of cryptography in web applications... but there is plenty more to learn about on this topics in other classes.
Cryptography: Basic Terminology
PlaintextInformation a sender wishes to transmit to a receiver.
CiphertextEncoded information that contains a form of the original plaintext that is unreadable by a human or computer (without the proper means to decode it).
CipherA secret or “camouflaged” method of writing, in which plaintext is transformed into ciphertext.
Cryptography: Basic Terminology
EncryptionThe process of transforming plaintext into ciphertext.
DecryptionThe reverse process of transforming ciphertext into plaintext.
Key A piece of information (a parameter) that determines the functional output of a cipher---encryption and decryption are controlled by keys.
Cryptography: Encryption Methods
Modern encryption methods can be divided into two categories.1. Private-key cryptography (symmetric key ciphers):
The same key is used for encryption and decryption.2. Public-key cryptography (asymmetric key ciphers):
Two different keys are used for encryption and decryption.
Symmetric (Private) Key Cryptography
The key is shared privately between the sender and receiver, and is kept secret from the public. In other words, only the web client and web server know the key, and this key must be securely transmitted between them.
Private Key Private Key
Asymmetric (Public) Key Cryptography
Both the sender and receiver are each assigned a pair of keys: E (a public key, known to everyone) and D (a private key, known only to the owner). In other words, the web client has a key pair and the web server has a key pair, so this key doesn’t need to be securely transmitted between them.
Symmetric vs Asymmetric Ciphers
In general, relatively faster algorithms.
Less secure. If the key is stolen, then security is lost. So the key exchange between the client and server must be done carefully and strictly controlled.
Not scalable. In the case of multiple clients, then multiple keys must be securely transmitted with each new session. (i.e. 1000 clients requires 999 keys.)
In general, relatively slower algorithms.
More secure. For the client and the server, the public keys shared to everyone and the private keys are kept secret, so there is no need to exchange the private keys.
Scalable. In the case of multiple clients, then the server and each of the clients needs only one public key and one private key. These never need to change.
Symmetric Ciphers Asymmetric Ciphers
General Session Key ExchangeAsymmetric ciphers are used to negotiate a symmetric private key for a web session between the client and the server.
● Symmetric ciphers are faster than asymmetric ciphers.● Asymmetric ciphers don’t need to share a private key.
○ Don’t need to worry about transmitting it.
General Session Key Exchange
Popular Ciphers
Popular examples of symmetric ciphers● Triple Data Encryption Standard (3-DES): accepted as standard in
1977. Older, phasing out.● Advanced Encryption Standard (AES): based on Rijndael cipher,
accepted as the new global standard in 2001.
Popular examples of asymmetric ciphers● Rivest-Shamir-Adelman (RSA): published in 1977.● El Gamal: published in 1985.
HTTPSHTTPS (or “HTTP over SSL” or “HTTP over TLS”): ● A communications protocol for secure communication over a computer
network or the Internet.● Is the result of simply layering the HTTP on top of either secure sockets
layer (SSL) or transport layer security (TLS), where TLS is the successor to SSL.
● Provides authentication of the website and server that the client is communicating with.
● Protects the privacy and integrity of the exchanged data against man-in-the-middle attacks.
HTTPSLook at a few certificates:https://www.firsttechfed.com/https://my.boisestate.edu/pages/default.aspx
One-Way Hashing
DefinitionsOne-way function
A function that’s “easy” to compute on every input, but “hard” to compute the inverse given the output. (e.g. recall the Diffe-Hellman key exchange)
Hash functionAny one-way function that can be used to map digital data of an arbitrary size to digital data of a fixed size. (e.g. HashTables)
Cryptographic hash functionA hash function that is considered to be practically impossible to invert---given the digest (or “output hash value”), it is practically impossible to recover the message (or “input value”). Are often referred to as “the workhorses of modern cryptography”.
Examples
Note: miniscule changes in the source input drastically change the resulting output.
Key FeaturesThe ideal cryptographic hash function has four key features: 1. It is easy to compute the digest for any given message.
It is computationally infeasible to: 2. modify a message without changing the digest, 3. find two different messages with the same digest, and 4. generate a message from its digest.
Well-Known ImplementationsSome examples of well-known cryptographic hash functions are:● MD4 (published in 1990 with 128-bit digest) and MD5 (published in 1991
with 128-bit digest)---both were found to have collision flaws and are considered obsolete.
● SHA-1 (published in 1995 with 160-bit digest), SHA-2 (published in 2001 with 224, 256, 384, and 512-bit digests), and SHA-3 (published in 2012 with 224, 256, 384, and 512-bit digests).
All are unsuitable for password hashing. They are fast.
BCRYPT
A hash function specifically designed for passwords.● Incorporates a salt.● Adaptive function: over time, iteration count can be increased to
make it slower. Helps prevent against brute force attacks.
Note: Preferred method of encrypting passwords.
Salting the HashBut, what if two users have the same password?
SaltRandom data that is used as an additional input to a cryptographic hash function that hashes a password.
Often, for a given username-password pair, the password is concatenated with a random, non-secret salt value before the hash function is applied. Then the salt is stored with the password hash.
Salts are used to defend against attacks such as dictionary attacks, which rely on precomputed hash values for common passwords.
Hashing Passwords in PHP
Safe Password Hashing in PHP:http://php.net/manual/en/faq.passwords.php
If we want to use password_hash (recommended) on earlier versions of PHP, usehttps://github.com/ircmaxell/password_compat
Hashing Passwords in PHPhttps://github.com/BoiseState/CS401-resources/tree/master/php/hashing
<?php$salted_digest = password_hash("password", PASSWORD_DEFAULT);password_verify("password", $salted_digest);?>
Strong Passwords
● Brute force● Single GPU optimized to process ~350
billion passwords per second.● At least eight characters long.
○ 128^8 possibilities○ Guess all passwords in < 2 days○ 128^9 -> 305 days○ 128^10 -> 106 years
More Applications for one-way hashingSome major example applications:● Message or file integrity (i.e. comparing digests before
and after transmission).
● User account authentication (i.e. store hashed passwords in database).
● Digital signature authentication (i.e. verify that a message was created by a known sender).