关键词 > COMPSCI5104/5093

COMPSCI5104/5093: Assessed Exercise 1 2021

发布时间:2022-02-08

Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit


COMPSCI5104/5093: Assessed Exercise 1

Secured Software Engineering

2021


Introduction

One objective of this course is to provide you with an understanding of how static analysers work and in turn, allow you to investigate and provide a risk assessment on a code-base. The aim of this assessed exercise is to test your understanding of static analysis by asking you to investigate some code examples, generate constraints and solve the constraints to determine whether the resulting solutions are considered legal or not. This work will count for 20% of your overall course mark for Secured Software Engineering.


Marking Scheme

There are two tasks to this assessment which is worth a total of 10 marks. Tasks 1 and 2 are both worth 5 marks respectively. You will be awarded marks based on the evidence you provide in your answers. I strongly encourage you to be explicit when answering these questions. You are not being asked to com-ment on code quality, efficiency or feasibility in this assessment.

Being able to address all of the points in the following list for both tasks 1 and 2 will lead you to attaining the available marks in this assessment.

1. Appropriate use of qualifiers.

2. Identifying information flow paths.

3. Identifying constraints with qualifiers.

4. Correctly identifying contradictions when solving constraints (explicit and implicit illegal flows/so- lutions).

5. Providing a correct conclusion to the task question.


Note

You do not have to illustrate all possible code execution paths in this assessment to get full marks.  I appreciate that this can be a tedious activity. If there is a path involving implicit or explicit illegal flow,

illustrate one possible path in detail and discuss why there is segregation between the sinks and tainted


Deliverable Instructions

You are to submit a pdf via the Moodle coursework submission link. You may annotate this document if you wish, or create a new document from scratch if you prefer. You are free to use whatever software/tools

the format "sse_1_".



Deadline

Your submission is due on 14-02-2022 at 16:30. In accordance with the university Code of Assessment Policy, late submissions will be accepted. However, any late submissions will be penalised by 2 bands for each additional day up to 5 working days; Any late submission after 5 working days will receive the grade

monitoring system.


Task 1 (5 Marks)

Below is some arbitrary code that acts as a sanitising function for some input data. It will first take

is required. Otherwise, the data is updated. In the event it is updated, a check occurs to determine if the data is empty, if so then null is returned. Otherwise, an administrator is prompted to input an override which is then returned. Proper handling of the scanner is not illustrated for brevity.


Question 1: Is the returned String from the sanitize function tainted?

Task 1 - Source Code


//   ’ data ’   assumed   untainted ,   return   type   assumed   untainted public   String   sanitize ( String   data )  {

if   (! validate ( data ))

data  =  override ( data );

return   data ;

}

public   String   override ( String  badData )  {

if   ( badData . isEmpty ())

return  null ;

else  {

Scanner   s  =  new   Scanner (System . in);        System . out . println ( " enter_override : " ); return   s . nextLine ();

}

}



public




}


boolean   validate (String if   ( inputData . length ()

return   false ;

else

return  true ;


inputData )  {

%  2   !=  0)


Task 2 (5 Marks)

Below is a second arbitrary example of code. Here, an application has a map, pairing a user profile string to an alias. Further there is an array of strings used for guest accounts. The code will initially check to see if the supplied user profile exists within the hash-map. If it is then the associated value

the same check is performed on the now instantiated array and if a match is made, a concatenated



Question 2: Is it correct to assume the returned value of ’loadProfile’ is untainted?


Task 2 - Source Code


//   assumed   untainted   and   instantiated

private  HashMap < String , String >  users ;

//   assumed   declared   only   ( not   instantiated )

private   String []  guests ;

//   ’ user ’   assumed   tainted ,   return   type   assumed   untainted public   String   loadProfile ( String  user )  {

String  target  =  null ;

for   ( String  profile   :  users . keySet ())  {

if   ( profile . equals ( user ))

return  users . get ( user );

}

guests  =  loadGuests ();

for ( String  profile :  guests )  {

if ( user . equals ( profile ))

return   " GUEST :   " + profile ;

}

return   " Unknown " ;

}



//   assumed   instantiated

String   fileName ;

private   String []   loadGuests ()  { try  {

FileInputStream   file Ob j e c tInpu tStream   in


=  new  FileInputStream ( fileName ); =  new   Ob j e c tInpu tStream ( file );


guests  =   ( String [])   in . readObject ();

in . close ();

file . close ();

}   catch   ( Exception  e )  {

System . err . println ( " something  went  wrong " ); }

return   guests ;

}