System Security Implementation

Diomidis Spinellis
Department of Management Science and Technology
Athens University of Economics and Business
Athens, Greece
dds@aueb.gr

System Security Roadmap

Welcome

System Security Implementation

Schedule

Παρασκευή 5 Νοεμβρίου 2004

Σάββατο 6 Νοεμβρίου 2004

Overview

Notes

Security Infrastructure

Security Infrastructure Investment

Getting the management commitment

Management Errors

The 7 Top Management Errors that Lead to Computer Security Vulnerabilities

As determined by the 1,850 computer security experts and managers meeting at the SANS99 and Federal Computer Security Conferences held in Baltimore May 7-14, 1999
From http://www.sans.org/newlook/resources/errors.htm (http://www.sans.org/newlook/resources/errors.htm)

Security Mission Statement

The security mission statement is determined by a number of factors:

Security Awareness Training

Example of a CERT Advisory

Subject: CERT Summary CS-2002-02
Date: Tue, 28 May 2002 14:50:15 -0400 (EDT)
From: CERT Advisory <cert-advisory@cert.org>
Organization: CERT(R) Coordination Center - +1 412-268-7090
To: cert-advisory@cert.org

CERT Summary CS-2002-02

   May 28, 2002

   Each  quarter, the CERT Coordination Center (CERT/CC) issues the CERT
   summary  to  draw  attention  to  the types of attacks reported to our
   incident  response  team,  as  well  as  other noteworthy incident and
   vulnerability information. The summary includes pointers to sources of
   information for dealing with the problems.

   Past CERT summaries are available at http://www.cert.org/summaries/.
   ______________________________________________________________________

Recent Activity

   Since  the  last  regularly scheduled CERT summary, issued in February
   2002  (CS-2002-01),  we  have  released  several advisories addressing
   vulnerabilties   in   Microsoft's  IIS  server,  Oracle  Database  and
   Application  Servers, Sun Solaris cachefsd, and MSN Instant Messenger.
   In  addition,  we  have  published statistics for the first quarter of
   2002,  numerous  white  papers,  and  a collection of frequently asked
   questions about the OCTAVE Method.

   For  more  current  information  on  activity  being  reported  to the
   CERT/CC,  please  visit the CERT/CC Current Activity page. The Current
   Activity  page  is  a  regularly updated summary of the most frequent,
   high-impact  types  of  security  incidents  and vulnerabilities being
   reported  to the CERT/CC. The information on the Current Activity page
   is reviewed and updated as reporting trends change.

    1. Exploitation of Vulnerabilities in Microsoft SQL Server

       The  CERT/CC  has  received  reports  of systems being compromised
       through  the  automated  exploitation  of  null or weak default sa
       passwords  in Microsoft SQL Server and Microsoft Data Engine. This
       activity  is  accompanied by high volumes of scanning, and appears
       to  be  related  to recently discovered self-propagating malicious
       code,  referred  to  by  various  sources  as Spida, SQLsnake, and
       Digispid.

       CERT Incident Note IN-2002-04:
       Exploitation of Vulnerabilities in Microsoft SQL Server
       http://www.cert.org/incident_notes/IN-2002-04.html

[...]

Security Support Personnel Duties

Security log example

Subject: istlab.dmst.aueb.gr security check output
Date: Sat, 15 Jun 2002 03:01:02 +0300 (EEST)
From: Charlie Root <root@istlab.dmst.aueb.gr>
To: undisclosed-recipients:;

Checking setuid files and devices:


Checking for uids 

Checking setuid files and devices:


Checking for uids of 0:
root 0
toor 0


Checking for passwordless accounts:


istlab.dmst.aueb.gr kernel log messages:
> Jun 14 17:21:29 istlab su: dds to root on /dev/ttyp0
> Jun 14 23:30:02 istlab sendmail[65649]: g5EKU1a65648: Truncated MIME Content-Disposition header due to field size (length = 23) (possible attack)


istlab.dmst.aueb.gr login failures:


istlab.dmst.aueb.gr refused connections:

Coordination with ISP

Subject: Re: Prospatheia hacking
Date: Mon, 15 Jan 2001 12:49:33 +0200
From: OTEnet Network Abuse Team <abuse@otenet.gr>
To: Diomidis Spinellis <dds@host.gr>

On Mon, Jan 15, 2001 at 11:30:06AM +0200, Diomidis Spinellis wrote:
> Ο παρακάτω χρήστης σας προσπάθησε το Σάββατο να παραβιάσει το μηχάνημα
> XXX.XXX.XXX.XXX:
> 
> Jan 13 01:28:17 inet popper[20009]: ddl@athe530-q166.otenet.gr: -ERR
> Unknown command: "close".
> Jan 13 01:28:19 inet popper[20009]: Possible probe of account ddl from
> host
> athe530-q166.otenet.gr
> Jan 13 01:28:31 inet popper[20010]: dds@athe530-q166.otenet.gr: -ERR
> Unknown command: "l".
> Jan 13 01:28:33 inet popper[20010]: dds@athe530-q166.otenet.gr: -ERR
> Unknown command: "r".
> 
> Παρακαλώ να με ενημερώσετε για τις ενέργειές σας.
> 
> Φιλικά,
> 
> Δ. Σπινέλλης

-- 
Agaphte Kyrie

Meta apo e3etash twn log files pou mas exete steilei, exoume entopisei ton
syndromhth mas ekeino, o opoios empleketai sthn en logw apopeira kai exoume 
pra3ei ta deonta prokeimenou na mhn epanalhfthoun sto mellon tetoies energeies 
apo merous tou.

OTEnet Network Abuse Team

Complaint

Subject: [Spam mail]
Date: Tue, 22 Jan 2002 12:56:20 +0200
From: XXX@yyy.gr
To: abuse@isp.gr
CC: abuse@host.gr

Aytos fainetai (me traceroute) oti pairnei grammh apo esas. Epeidh oi idioi
einai spammers sas stelnw esas to complaint.

To spam einai attached.
Eyxaristw.

-- 

[Copy of the spam mail]

Auditing

Help an organization balance resources expended against the most likely areas of weaknesses.
Audit Type Reason
New System Installation Security Audits Ensure conformance to existing policies and a standard system configuration.
Regular Automated System Audit Checks Reveal a "visitation" by an intruder or illicit activity by insiders.
Random Security Audit Checks
  • Test for conformance to security policies and standards (by finding illicit activity) ,
  • Check for the existence of a specific class of problems (e.g., the presence of a vulnerability reported by a vendor).
Nightly Audits of Critical Files
  • Assess the integrity of critical files (e.g., the password file)
  • Integrity of databases (e.g., payroll or sales and marketing information).
User Account Activity Audits Detect dormant, invalid, misused accounts.
Periodic audits and vulnerability assessments Determine overall state of your security infrastructure.

Tools

Targeted System Binaries And Directories

Internet Attack Methods

Incident Response

Incident Response Centers

CERT(sm) Coordination Center
http://www.cert.org/
email cert@cert.org or call +1 412 268-7090

GRNET-CERT

Computer Emergency Responce Team for the Greek National Research Network

E-Mail: grnet-cert@grnet.gr (mailto:grnet-cert@grnet.gr)

Network Operations Center, University of the Aegean, 30 Voulgaroktonou str, Athens 114 72, Greece

Telephone: +30 - 210 - 649 - 2056
Telefax: +30 - 210 - 649 - 2499
World Wide Web: http://cert.grnet.gr (http://cert.grnet.gr)

Network Management Center
National Technical University of Athens
Iroon Polytechnioy 9
Zografou, GR 157 80
Athens
Greece
phone [+30-210] 772.1860
fax [+30-210] 772.1866
http://www.ntua.gr/grnet-cert/grnet-cert.html (http://www.ntua.gr/grnet-cert/grnet-cert.html)

Management-related Security Problems

Software Installation Practices

Modify default software installation to Develop standard installation guidelines for all operating systems and applications used by the organization.

Authentication Practices

Backup Practices

Port Filtering Practices

Evaluating Vulnerabilities

For each vulnerability we need to now:

Common Unix Vulnerabilities

(From the Twenty Most Critical Internet Security Vulnerabilities
2004
Copyright 2001-2004, The SANS Institute
http://www.sans.org/top20.htm (http://www.sans.org/top20.htm))

Common Windows Vulnerabilities

(From the Twenty Most Critical Internet Security Vulnerabilities
2004
Copyright 2001-2004, The SANS Institute
http://www.sans.org/top20.htm (http://www.sans.org/top20.htm))

Home-user Tips

(Excerpted from http://www.nipc.gov/warnings/computertips.htm (http://www.nipc.gov/warnings/computertips.htm))

System Administrator Best Practices

Low-cost Security Improvements

Doing it on a shoestring basis:

Free Tool Repositories

Security Web Sites

Security Books

Articles

Cryptology

Cryptology

Cryptography:
Generalized methods to hide (encrypt) and authenticate information
Cryptanalysis:
Generalized methods to expose and substitute information

Algorithm Uses and Properties

Algorithm Types

Algorithm applications

Maintaining Confidentiality

Transposition Ciphers

Example
1 2 3 4
T R A N
S P O T
I T I O
N X X X
Take-off as 2, 4, 3, 1: RPTXNTOXAOIXTSIN
Try RAYXPAIXYNSXCTLS

Transposition Cryptanalysis

Substitution Ciphers

Polyalphabetic Ciphers

Rotor Machines

The Enigma machine

The Playfair Cipher

Example:
A -> B
B -> I
O -> P
R -> U
T -> A
X -> V
L -> O
A -> I
N -> L
D -> G
I -> Y
N -> L
G -> H
X -> W

SP Networks

Example: 4 bit S-box design with a single permutation

The Data Encryption Standard (DES)

DES structure

The Advanced Encryption Standard (AES)

Operation Modes

Block ciphers can be operated in a number of different modes

Electronic Code Book (ECB)

Cipher Block Chaining (CBC)

Output Feedback Mode (OFB)

Hash Function Properties

Hash functions compress a n (abritrarily) large number of bits into a small number of bits (e.g. 512).

Properties

Common Hash Functions

Hash Function Applications

Asymmetric Ciphers

The Diffie-Hellman Protocol

Case Study: Public Key Cryptography

The following example is based on the OpenSSL (http://www.openssl.org/) open-source cryptography library and command-line tool.
#!/bin/sh

################
# Key generation

# Create Alice's key pair
openssl genrsa >alice.private
# Obtain Alice's public key
openssl rsa -pubout <alice.private >alice.public

# Create Bob's key pair
openssl genrsa >bob.private
# Obtain Bob's public key
openssl rsa -pubout <bob.private >bob.public

##########################################
# Alice sends a short confidential message

# Secret message Alice wants to send to Bob
echo "Alice loves you" >message.plain

# Alice encrypts the message using Bob's public key
openssl rsautl -encrypt -in message.plain -out message.encrypted -pubin -inkey bob.public

# Bob decrypts Alice's message using his private key
openssl rsautl -decrypt -in message.encrypted -out message.decrypted -inkey bob.private

##################################
# Bob sends a short signed message

# Message Bob wants to sign
echo "Will you marry me?" >message.plain

# Bob signs the message using his private key
openssl rsautl -sign -in message.plain -out message.signed -inkey bob.private

# Alice verifies Bob's message using his public key
openssl rsautl -verify -in message.signed -out message.verified -pubin -inkey bob.public


#####################################################
# Alice sends a large signed and confidential message

# Secret message Alice wants to send to Bob
cat  >message.plain <<EOF
                       Marital AGREEMENT

THIS AGREEMENT, made this thirteen day of June, 2004 is between Bob
and Alice

1. PURPOSE. The parties expect to be married to death do them part,
   and hear by enter into this agrement vouluntarily.

2. EFFECT OF AGREEMENT. The parties agree that if one or the other
   commits infidelity during the duration of the marriage, that the person
   guilty of said act shall in effect and wholey forsake all material
   property, assets and rights to act as a parent of any children.

3. DEFINITON OF INFEDELITY. Infedelity is defined as follows: Any
   socializing with the intent to establish a realtionship, and/or
   physical contact with other person.

4. JOINT PROPERTY, ETC. This Agreement does not restrict, prohibit
   or condition any conveyance or transfer by the parties, or either of
   them alone, of the Separate Property of either party into tenancy in
   common, joint tenancy, tenency by the entireties or any other form of
   concurrent and/or undivided estate or ownership between the parties,
   or the acquisition of any property in any such form of ownership by the
   parties. The incidents and attributes of ownership and other rights
   of the parties with respect to any property so conveyed, transferred
   or acquired shall be determined under State law and shall not be
   governed by or otherwise determined with reference to this Agreement.

5. SEPARATE PROPERTY. The parties agree that there is no seperate
   property.

6. WAIVER OF RIGHTS. Except as otherwise provided in this Agreement,
   each party hereby waives, releases and relinquishes any and all right,
   title or interest whatsoever, whether arising by common law or present
   or future statute of any jurisdiction or otherwise.

7. DISSOLUTION/SEPARATION/ANNULMENT. Except as otherwise provided in
   this Agreement, each party specifically agrees that neither shall make
   any claim for or be entitled to receive any money or property from
   the other as alimony, spousal support, or maintenance in the event
   of separation, annulment, dissolution or any other domestic relations
   proceeding of any kind or nature, and each of the parties waives and
   relinquishes any claim for alimony, spousal support or maintenance,
   including, but not limited to, any claims for services rendered,
   work performed, and labor expended by either of the parties during
   any period of cohabitation prior to the marriage and during the entire
   length of the marriage. The waiver of spousal support shall apply to
   claims both pre and post-judgment.

8. RIGHT TO CONTEST. Nothing contained herein shall limit the right
   of either party to contest any domestic relations suit between the
   parties or to file a countersuit against the other party; However,
   in any hearing on such suit, this Agreement shall be considered
   a full and complete settlement of all property rights between the
   parties. In such case, neither party shall maintain any claim or demand
   whatsoever against the other for property, suit money, attorney fees
   and costs which is either inconsistent with or not provided for in
   this Agreement.

9. INTEGRATION. This Agreement sets forth the entire agreement between
   the parties with regard to the subject matter hereof. All prior
   agreements, covenants, representations, and warranties, expressed or
   implied, oral or written, with respect to the subject matter hereof,
   are contained herein. All prior or contemporaneous conversations,
   negotiations, possible and alleged agreements, representations,
   covenants, and warranties, with respect to the subject matter hereof,
   are waived, merged, and superseded hereby. This is an integrated
   agreement.

10. BINDING ON SUCCESSORS. Each and every provision hereof shall
   inure to the benefit of and shall be binding upon the heirs, assigns,
   personal representatives, and all successors in the interest of
   the parties.

11. ACKNOWLEDGEMENTS. Each party acknowledges that he or she has
   had an adequate opportunity to read and study this Agreement, to
   consider it, to consult with attorneys individually selected by each
   party, without any form of coercion, duress or pressure. Each party
   acknowledges that he or she has examined the Agreement before signing
   it, and has been advised by independent legal counsel concerning the
   rights, liabilities and implications of this document.

12. STATE LAW. It is intended that this Agreement be valid and
   enforceable within the provisions of the State Law, and that Case
   Law that governs its interpretation. State law is considered to be
   that of California, USA.
EOF

# Alice generates a short random key to be used for encrypting the message
openssl rand 16 -out key.plain

# Alice encrypts the message with the short random key
openssl des3 -e -kfile key.plain -in message.plain -out message.encrypted

# Alice creates a message digest of the message to sign
openssl dgst -binary message.plain >message.digest

# Alice signs the digest using her private key
openssl rsautl -sign -in message.digest -out digest.signed -inkey alice.private

# Alice encrypts the random key using Bob's public key
openssl rsautl -encrypt -in key.plain -out key.encrypted -pubin -inkey bob.public

# Alice sends Bob:
# - the encrypted message
# - the encrypted key
# - the signed message digest


# Bob decrypts Alice's encrypted key using his private key
openssl rsautl -decrypt -in key.encrypted -out key.decrypted -inkey bob.private

# Bob decrypts the message using the decrypted key
openssl des3 -d -kfile key.decrypted -in message.encrypted -out message.decrypted

# Bob verifies the digest Alice has signed using her public key
openssl rsautl -verify -in digest.signed -out message.digest1 -pubin -inkey alice.public

# Bob calculates again a message digest of the message
openssl dgst -binary message.plain >message.digest2

# Bob compares the two message digests to verify Alice signed the agreement
# he has examined
diff message.digest1 message.digest2

A Simple Public Key System

  1. Create a graph with a known perfect code
  2. Simple example: fair coin tossing over the phone
  3. Public key encryption and decryption

Bibliography

Access Control, Firewalls and VPNs

Hardware-based Access Control

Operating System Access Control

Firewall Purpose

Security Strategies

Security by Obscurity

Not effective when it: Valid when it:

Firewall Limitations

A firewall can not protect against:

Firewall Technologies

How Packet Filtering Works

Evaluation of Packet Filtering

Basic Packet Filtering

Other Service Packet Filtering

IP Packet Filtering

Block:

How Proxying Works

Evaluation of Proxying

How Network Address Translation Works

NAT Example

Packets Inside the NAT

14:59:13.710291 eagle.spinellis.gr.1112 > istlab.dmst.aueb.gr.http:
 S 3678001010:3678001010(0) win 64240 <mss 1460,nop,nop,sackOK> (DF)

14:59:13.810853 istlab.dmst.aueb.gr.http > eagle.spinellis.gr.1112:
 S 881432074:881432074(0) ack 3678001011 win 57344 <mss 1460> (DF)

Packets on the Internet

14:59:13.725267 nat.spinellis.gr.1112 > istlab.dmst.aueb.gr.http:
 S 3678001010:3678001010(0) win 64240 <mss 1460,nop,nop,sackOK> (DF)

14:59:13.725285 istlab.dmst.aueb.gr.http > nat.spinellis.gr.1112:
 S 881432074:881432074(0) ack 3678001011 win 57344 <mss 1460> (DF)

Evaluation of Network Address Translation

Firewall Architectures

Screening Router

Router configuration set to drop packets.

Dual-homed Host

Host with two network adapters, routing often disabled.

Screened Host

Screened Subnet

Internal Firewall

Personal Firewall

Incident Levels

Probe

A few (random) tries to break in.

Attack

Concerted break-in attempt.

Break-in

Host has been compromised.

Maintenance: Housekeeping

Maintenance: Monitoring

Maintenance: Updating

VPN Architectures

Tunneling

Defence in Depth Example

2 Layers

  1. Firewall
  2. Host based packet filtering

5 Layers

(Increase security on the Internet side to handle DDOS attacks)
  1. Border router
  2. Network management system
  3. Intrusion detection system
  4. Firewall
  5. Host based packet filtering

8 Layers

(Increase security on the workstation side to handle internal attacks)
  1. Border router
  2. Network management system
  3. Intrusion detection system
  4. Firewall
  5. Host based packet filtering
  6. Log analysis and alert
  7. File integrity validation
  8. Cryptography

Bibliography

Web Security and Mobile Code

Web Security Requirements

User Privacy: What are we Protecting?

Data Traces

Traces are left on:

Web Server Data

Typical data available to the web server:
GET http://www.google.com/ HTTP/1.1
Host: www.google.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040113
Accept: application/x-shockwave-flash,text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1
Accept-Language: en-us,en;q=0.8,el;q=0.5,de;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: windows-1253,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Proxy-Connection: keep-alive
Cookie: PREF=ID=33a5ab74b4a12719:LD=en:CR=2:TM=1070012757:LM=1070012764:S=bEOIfrJZzBGyc5LD

Log File Contents

Normal Users

217.195.129.242 - - [23/Jun/2004:15:38:25 +0300] "GET /pubs/jrnl/2000-IST-Components/html/comp.html HTTP/1.0" 200 49099 "http://find.in.gr/results.page?data=unix+command" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Q312461)"
217.195.129.242 - - [23/Jun/2004:15:38:25 +0300] "GET /pubs/jrnl/2000-IST-Components/html/process.gif HTTP/1.0" 200 6429 "http://www.spinellis.gr/pubs/jrnl/2000-IST-Components/html/comp.html" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; Q312461)"
backport.reaktor-i.com - - [23/Jun/2004:16:00:05 +0300] "GET /sw/umlgraph/doc/index.html HTTP/1.1" 200 3317 "http://www.spinellis.gr/sw/umlgraph/" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040207 Firefox/0.8"
backport.reaktor-i.com - - [23/Jun/2004:16:00:08 +0300] "GET /sw/umlgraph/doc/cd-intro.html HTTP/1.1" 200 2188 "http://www.spinellis.gr/sw/umlgraph/doc/index.html" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040207 Firefox/0.8"

Crawler

65.197.137.37 - - [22/Jun/2004:13:33:58 +0300] "GET /robots.txt HTTP/1.1" 200 35 "-" "ZipppBot/0.25 (Zippp; http://www.zippp.net; webmaster@zippp.net)"
65.197.137.37 - - [22/Jun/2004:13:33:59 +0300] "GET /pubs/conf/1994-OOPSLA-Multipar/html/mlom.html HTTP/1.1" 200 19166 "-" "ZipppBot/0.25 (Zippp; http://www.zippp.net; webmaster@zippp.net)"

Web Server Exploitation Attempts

[Thu Jun 10 11:36:59 2004] [error] [client 148.244.150.52] script not found or unable to stat: /webdata/istlab-cgi-bin/FormMai
l.pl
[Thu Jun 10 11:37:03 2004] [error] [client 148.244.150.52] script not found or unable to stat: /webdata/istlab-cgi-bin/mail.pl
[Thu Jun 10 11:37:03 2004] [error] [client 148.244.150.52] script not found or unable to stat: /webdata/istlab-cgi-bin/Mail.pl
[Thu Jun 10 11:37:04 2004] [error] [client 148.244.150.52] script not found or unable to stat: /webdata/istlab-cgi-bin/Form.pl
[Thu Jun 10 11:37:04 2004] [error] [client 148.244.150.52] script not found or unable to stat: /webdata/istlab-cgi-bin/form.pl


[Fri Jun 18 23:05:25 2004] [error] [client 216.245.167.136] File does not exist: /webdata/spinellis/_vti_bin/owssvr.dll
[Fri Jun 18 23:05:25 2004] [error] [client 216.245.167.136] File does not exist: /webdata/spinellis/MSOffice/cltreq.asp
[Fri Jun 18 23:06:17 2004] [error] [client 216.245.167.136] File does not exist: /webdata/spinellis/_vti_bin/owssvr.dll
[Fri Jun 18 23:06:18 2004] [error] [client 216.245.167.136] File does not exist: /webdata/spinellis/MSOffice/cltreq.asp

Packet Dump Output

Web Request

02:40:27.881867 192.168.238.1.1540 > 192.168.238.5.www: P 1:485(484) ack 1 win 6
4240 (DF)
0x0000   4500 020c 5af0 4000 8006 40a3 c0a8 ee01        E...Z.@...@.....
0x0010   c0a8 ee05 0604 0050 6a19 984a 87b4 aae9        .......Pj..J....
0x0020   5018 faf0 59b7 0000 4745 5420 2f6f 7267        P...Y...GET./org
0x0030   616e 2d65 6e68 616e 6365 6d65 6e74 2e68        an-enhancement.h
0x0040   746d 6c20 4854 5450 2f31 2e31 0d0a 486f        tml.HTTP/1.1..Ho
0x0050   7374 3a20 3139 322e 3136 382e 3233 382e        st:.192.168.238.
0x0060   350d 0a55 7365 722d 4167 656e 743a 204d        5..User-Agent:.M
0x0070   6f7a 696c 6c61 2f35 2e30 2028 5769 6e64        ozilla/5.0.(Wind

Password in a Packet Dump

05:50:03.157394 seagull.spinellis.gr.1098 > www.taxisnet.gr.http: P
479:588(109) ack 1 win 16603 (DF)
0x0000 4500 0095 0654 4000 8006 7057 c0a8 880e  E....T@...pW....
0x0010 d4cd 6633 044a 0050 fdf4 e5a9 912f e6a5  ..f3.J.P...../..
0x0020 5018 40db 1033 0000 436f 6e74 656e 742d  P.@..3..Content-
0x0030 7479 7065 3a20 6170 706c 6963 6174 696f  type:.applicatio
0x0040 6e2f 782d 7777 772d 666f 726d 2d75 726c  n/x-www-form-url
0x0050 656e 636f 6465 640d 0a43 6f6e 7465 6e74  encoded..Content
0x0060 2d6c 656e 6774 683a 2033 380d 0a0d 0a70  -length:.38....p
0x0070 7764 3d73 6563 7265 7426 7573 6572 6e61  wd=secret&userna <<<
0x0080 6d65 3d74 6573 7475 7365 7226 7061 7373  me=testuser&pass <<<
0x0090 776f 7264 3d                             word=

Malicious Applets

Once malicious code gets control of the machine it can:

The Java Sandbox Model

Bytecode Verification

Bytecode verification checks that: Common problems

Policy Example

As an example the sanbox policy may prohibit:

ActiveX and Code Signing

Problems:

Javascript

Exploitation examples:

Cookies

Security problems

User Authentication

Application-layer Attacks

Server Security and Scripting

Scripting Exploitation Example

The following flawed and insecure Perl program is supposed to run the Unix "finger" command for the user given on a form's USER field:
#!/usr/bin/perl
$query = $ENV{'QUERY_STRING'};
@pairs = split(/\&/, $query);
for (@pairs) {
        ($field, $val) = split(/=/);
        $field =~ s/\+/ /g;
        $field =~ s/\%(\w\w)/sprintf("%c", hex($1))/eg;
        $val =~ s/\+/ /g;
        $val =~ s/\%(\w\w)/sprintf("%c", hex($1))/eg;
        $field{$field} = $val;
}
$|=1;
print "Content-Type: text/plain\n\n";
system "finger $field{USER}\n";
Running the program with USER having the value "dds"
http://www.host.gr/cgi-bin/pe?USER=dds
will give the following result:
Login: dds                              Name: Diomidis Spinellis
Directory: /home/dds                    Shell: /bin/bash
On since Wed Jun 30 12:18 (EET) on ttyp0
   5 minutes 49 seconds idle
Adding to the URI a semicolon (the Unix shell command separator) and the command cat /etc/shadow
http://www.host.gr/cgi-bin/pe?USER=dds;cat%20/etc/shadow
may send us the encoded contents of the system's password file after the results of the finger command.
Login: dds                              Name: Diomidis Spinellis
Directory: /home/dds                    Shell: /bin/bash
On since Wed Jun 30 12:18 (EET) on ttyp0
   5 minutes 49 seconds idle

root:XXXXXXXXXXXXX:0:0:Charlie Root:/root:/bin/bash
bin:*:1:1:bin:/bin:
daemon:*:2:2:The Devil Himself:/sbin:
adm:*:3:4:adm:/var/adm:
lp:*:4:7:lp:/var/spool/lpd:
...

Scripting Guidelines

To avoid exploitation problems:

State Variable Manipulation

Cross-site Scripting

Bibliography

Appendix A: Protecting the Internet Explorer


Information of a secure page


Page certificate information


Certification path


Basic security settings


Tailored security settings


ActiveX controls


Cookies


Downloads


Microsoft extensions


Scripting


Authentication


Security implementation

Appendix B: Protecting Mozilla

Mozilla places privacy and security and devotes a number of configuration options for this task.


Privacy categories


Cookie management


Image management


Popup window management


Form management


Password management


Master password


SSL details


Cipher options


Certificate options


Certificate authorities


Personal certificate details


Certificate validation

Appendix C: Protecting the Netscape Navigator


Executable content


Content security information


Certificate information


Secure page view


Password security


Browser settings


Mail settings


Signed executable content


Certificates and CAs


Personal Certificate


Cryptography


Cryptographic module access


Cryptographic algorithms

Software Security

Principles for Software Security

Buffer Overflows

How does a Buffer Overflow Work?

The attacker can execute code by corrupting the stack This is the stack when gets is called:
+---------------+
| envp          |	Program's environment
+---------------+
| argv          |	Argument vector
+---------------+
| argc          |	Argument count
+---------------+
| _start        |	Return address of main
+---------------+
| buff[0]       |	First byte of buffer (e.g. 'n')
+---------------+
| buff[1]       |	Second byte of buffer (e.g. 'o')
+---------------+
| buff[...]     |	More buffer bytes
+---------------+
| buff[19]      |	Last byte of buffer
+---------------+
| main+12       |	Return address of gets
+---------------+
This is the corrupted stack after an attack:
+---------------+
| envp          |	Program's environment
+---------------+
| argv          |	Argument vector
+---------------+
| argc          |	Argument count
+---------------+
| _start        |	Return address of main
+---------------+
| buff[0]       |<-+	First byte of buffer (EVIL CODE)
+---------------+  |
| buff[1]       |  |	Second byte of buffer (EVIL CODE)
+---------------+  |
| buff[...]     |  |	More buffer bytes (more EVIL CODE)
+---------------+  |
| buff[19]      |  |	Last byte of buffer
+---------------+  |
| &buff[0]      |--^	Overwritten return address
+---------------+

Buffer Overflow Defences

Unix Access Control

Example:
$ id
uid=1000(dds) gid=1000(dds) groups=1000(dds), 0(wheel), 10000(cvs), 20000(lh), 20001(dynweb), 20002(rpipe), 20003(postg), 20004(issues), 20005(dewdrop), 20006(eaware), 20007(mexpress), 20008(ivm), 20009(weblog), 20010(rng), 20011(uca)
Example:
-r-xr-xr-x   1 root  wheel   206740 Mar 27 15:42 /usr/bin/make
-r-sr-xr-x   1 man   wheel    29752 Mar 27 15:39 /usr/bin/man
-r-sr-xr-x   2 root  wheel    28828 Mar 27 15:42 /usr/bin/passwd

drwxr-xr-x  23 root  wheel  1024 Jun 15 16:38 /usr/src
drwxrwxrwt   3 root  wheel   512 Jul  4 13:24 /usr/tmp
drwxr-xr-x   2 root  wheel   512 Dec  2  2002 /usr/var
drwxr-xr-x  13 root  wheel   512 Jun 15 17:01 /usr/www

-rw-------  1 root  wheel  5291 Jul  2 12:47 /etc/master.passwd

Windows Access Control

Race Conditions

Problematic APIs

Randomness and Determinism

Applying Cryptography

Trust Management

Untrusted Input

Result Verification

Failing to check the success of the Unix system calls or the Windows API calls can result in a process running with elevated privileges.

Data and Privilege Leakage

Often consequence of discretionary access control.

Password Authentication

Database Security

Application Security

Copy protection measures: Tamperproofing: Keep in mind that the attacker has complete control of your application.

Bibliography