• No results found

Internet Programming. Security

N/A
N/A
Protected

Academic year: 2021

Share "Internet Programming. Security"

Copied!
25
0
0

Loading.... (view fulltext now)

Full text

(1)

Internet Programming

(2)
(3)

3

Spyros Voulgaris - Vrije Universiteit

Internet Programming - Period 1 17/10/2015

Security Issues in Internet Applications

A distributed application can run inside a LAN

Only a few users have access to the application

Network infrastructures are handled by one organizationSecurity is not a huge threat (in general)

When you deploy an application over the Internet

You cannot control who your users are

You cannot control the network infrastructuresThere may be attacks to your application

(4)

4

Spyros Voulgaris - Vrije Universiteit

Internet Programming - Period 1 17/10/2015

What is Security? [1/2]

Confidentiality

Prevent unauthorized disclosure of the informationAn attacker cannot “spy” on you

Integrity

Prevent unauthorized modification of the informationAn attacker cannot modify your information

Authentication

Prove your identity to the system

An attacker cannot pretend to be an authorized user

Authorization

(5)

5

Spyros Voulgaris - Vrije Universiteit

Internet Programming - Period 1 17/10/2015

What is Security? [2/2]

Non Repudiation

To prevent false denial of a contract

A user cannot pretend he did not sign some statement

Auditing

To securely record evidence of performed actions

Availability

Guarantee access to the information

An attacker cannot prevent you from accessing your information

Fault Tolerance

(6)
(7)

7

Spyros Voulgaris - Vrije Universiteit

Internet Programming - Period 1 17/10/2015

Encryption / Decryption

Encryption provides confidentiality

Symmetric key encryption (e.g., DES)

The same key is used for encryption and decryptionBut how do you distribute the key to your partners?

You need to communicate over a secure channel!E.g., give it by hand, by post, by other means

Asymmetric key encryption (e.g., RSA)

Keys are created in pairs

Public key: You can announce it to everyone  Used to ENCRYPT

Private key: You should keep it strictly for yourself  Used to DECRYPT

 You encrypt your messages with the recipient’s public key

(8)

8

Spyros Voulgaris - Vrije Universiteit

Internet Programming - Period 1 17/10/2015

Digital Signatures

Digital signatures provide integrity

You attach a signature to each message

Only you can attach a correct signature to a message

 An attacker can modify the message but cannot forge a correct signature to pretend the message comes from you

Digital signatures are usually realized by asymmetric keys

The same pairs of keys as for asymmetric encryption!  You sign the message  Encrypt it with your private key

 The recipient can check the signature without knowing the secret key  It is “impossible” (read: computationally infeasible) to create a correct

signature without knowing the secret key

If you want both integrity and confidentiality, use both encryption and

(9)

9

Spyros Voulgaris - Vrije Universiteit

Internet Programming - Period 1 17/10/2015

Hash Functions

Hash functions

provide

integrity

as well

Hash functions are the same as signatures, but without a key

You compute a signature (or hash) of your message

You transmit it in a secure way

It is very hard to create another message whose hash will be the sameAnyone can compute the hash of the received message and check

whether it matches the expected value 

Example: md5

$ md5sum slides.tex 05aa72cd3c0b238b6228e295fd203e73 slides.tex $ echo >> slides.tex $ md5sum slides.tex 185d85f4932265d68958c5e708f09c6f slides.tex $

(10)

10

Spyros Voulgaris - Vrije Universiteit

Internet Programming - Period 1 17/10/2015

Secure Protocols

Basic security tools are not enough

 How do you use them?

 How do you react when something happens?

Secure protocols define how basic tools are used

They provide higher levels of security by merging the strengths of several basic security tools

 They provide simple security mechanisms  The provide standards

Examples:

PGP: Pretty Good Privacy

Encryption / decryption / signatures

SSL: Secure Socket LayerSSH: Secure SHell

(11)
(12)

12

Spyros Voulgaris - Vrije Universiteit

Internet Programming - Period 1 17/10/2015

GPG

GPG: GNU Privacy Guard

GPG is primarily meant for securing email

But you can also use it to encrypt / decrypt / sign any messageIt is a free alternative to PGP

It is available at http://www.gnupg.org/

GPG allows you to

Create public/private key pairsEncrypt/decrypt messages

(13)

13

Spyros Voulgaris - Vrije Universiteit

Internet Programming - Period 1 17/10/2015

GPG Usage

To create your own public/private key pair:

You will be asked several questions: which kind of key you want,

which size, which expiration date, a username, your email address,

etc.

Unless you have a good reason to do so, keep the default values

Then it will ask you a passphrase

Type any passphrase

Your private key will be encrypted with this passphrase before being stored on disk

GPG will ask you for your passphrase each time it needs to access your private key

(14)

14

Spyros Voulgaris - Vrije Universiteit

Internet Programming - Period 1 17/10/2015

Disseminating your Public Key

You can give your public key to anyone

In particular, to anyone who may want to communicate with you using GPG

Never give your private key to anyone!

You can get your public key with:

You can import somebody else’s public key to your “keyring” with:

You can list the keys contained in your keyring:

gpg –-export –armor <Your_Name>

gpg –-import <filename>

(15)

15

Spyros Voulgaris - Vrije Universiteit

Internet Programming - Period 1 17/10/2015

Encryption / Decryption with GPG

To

encrypt

a file, you must specify the recipient of your message

The message will be encrypted with the recipient’s public key

Of course, the recipient’s public key must be in your keyring

To

decrypt

a file

GPG will use your private key to decrypt a file sent to youSo you will be asked to type your passphrase

gpg –-encrypt –r <recipient> < <file_to_encrypt>

(16)

16

Spyros Voulgaris - Vrije Universiteit

Internet Programming - Period 1 17/10/2015

Signatures with GPG

To sign a message:

You will be asked for your passphrase

To check a signature

You can encrypt and sign a document

To decrypt and check:

gpg –-output <output_file> --clearsign <document>

gpg –-verify <document>

gpg –-armor –-sign –-encrypt –r [email protected] < document

(17)

17

Spyros Voulgaris - Vrije Universiteit

Internet Programming - Period 1 17/10/2015

Public Key Authentication Problem

PROBLEM!

How do you make sure a public key actually belongs to your partner?An attacker may create a key pair and tell you that the public key

belongs to your partner

He can then successfully intercept your messages to your partner

PKI: Public Key Infrastructure

Provides authentication

(18)

18

Spyros Voulgaris - Vrije Universiteit

Internet Programming - Period 1 17/10/2015

Public Key Infrastructure

A

Certification Authority (CA)

authenticates public keys

Everybody trusts the CA

Everybody knows the public key of the CAThe CA issues messages saying

“I certify that key X belongs to person Y”

The message is signed by the CA, so everybody can check that it has been issued indeed by the CA

(19)

19

Spyros Voulgaris - Vrije Universiteit

Internet Programming - Period 1 17/10/2015

Public Key Infrastructure

Steps (1) and (2) are done only once!

Clients check the validity of messages, without bothering the CA

Client ---pubCA Server ---pubCA pubServer privServer CA ---pubCA privCA 5: OK, you are Server!

3: Who are you?

4:[“pubServer belongs to Server”]

signed by CA

2: [“pubServer belongs to Server”]

signed by CA

(20)

20

Spyros Voulgaris - Vrije Universiteit

Internet Programming - Period 1 17/10/2015

CA delegation

Often, one public authority is not enough

You want

delegation

: I will be the new CA for cs.vu.nl

The “root CA” certifies the “local CA”

The “local CA” can issue certificates

A key is authenticated if there is a

chain of certifications

from the

(21)
(22)

22

Spyros Voulgaris - Vrije Universiteit

Internet Programming - Period 1 17/10/2015

SSL

SSL: Secure Socket Layer

SSL is a communication protocol

It provides a higher layer of abstraction than normal sockets

 Server authentication

 Client authentication

 Encryption

Secure sockets

SSL uses normal sockets as a base, and adds lots of crypto to it

There are many implementations of SSL

There is an open-source implementation: OpenSSLIt is quite difficult to use!

(23)

23

Spyros Voulgaris - Vrije Universiteit

Internet Programming - Period 1 17/10/2015

Bird-Eye View of OpenSSL

You start by initializing SSL

 Get yourself a key pair

 Get a CA’s certification for your key pair  Initialize the library

 Create an “SSL context”

Load your key in the context, define the list of CAs that you trust

Create a normal TCP connection

Create an SSL connection (which uses the TCP connection)

 Attach the SSL connection to the TCP connection

 A number of checks are realized (e.g., the server key must be certified)  Use the SSL connection to transfer data

(24)

24

Spyros Voulgaris - Vrije Universiteit

Internet Programming - Period 1 17/10/2015

stunnel: An SSL Tunnel

What if you want to use SSL with an existing application?

stunnel allows you to use SSL without messing with the original codeAvailable from http://www.stunnel.org/

stunnel creates a daemon which

converts regular TCP connections

(25)

25

Spyros Voulgaris - Vrije Universiteit

Internet Programming - Period 1 17/10/2015

SSH tunnel

You can use ssh in a similar way:

-f: work in the background

-N: do Not execute a task, just establish a tunnel-L: the tunnel origin and destination address

Then, by accessing localhost:9090, ssh automatically

tunnels

the

TCP connection to localhost:3500 on acropolis.cs.vu.nl

References

Related documents

  Business (BU) BU105 Management Principles  

특히 근무연수 5년 이하의 군에서는 높은 직무 요구도만이 요통발생 위험도를 증가시킨 것으로 나타났는 데, 높은 직무 요구도는 높은 노동강도를 반영한다고 할

Наукова новизна та теоретичне значення дослідження полягає у тому, що вперше досліджено організаційно-методичні засади професійної підготовки фахівців

study, including auditors, data safety monitoring boards etc. {List other agencies as appropriate}. The following people and organizations will have access to the de-identified PHI:

(k) If application is made on or before 120 days from the effective date of this Rule, applicants for Restricted Limited Plumbing Contractor license who present a current

Electron vortex beams in field-free space have a cylindrically symmetric wave function and maintain a constant orbital angular momentum in the direction of propagation [2].. Based

We may share all of the information we collect (including Sensitive Information) with any successor to all or part of our business in connection with a transaction involving a

Wolfgang Amadeus Mozart. Copyright © 2005