Evaluate the potential security risks of using C

Assignment Help Programming Languages
Reference no: EM132294724

THE ASSIGNMENT TASK:

In this assignment students are required to

1. Identify the security vulnerabilities in given programming codes.
2. Write secure programming code and appreciate secure practices in coding.

LEARNING OUTCOMES

Knowledge and understanding of
1. Security requirements, threats and countermeasures
2. Tools and techniques which may be used to enhance or break system security.

And should be able to
1. Identify and evaluate a selection of key concepts and methods employed by adversaries to break into insecure systems and/or within Malware scenarios;
2. Select, deploy, and evaluate appropriate techniques to write more secure code, both in theory and practice.

Coursework: Secure Programming

Question 1:

The following program reads two strings in1 and in2 and concatenates them to produce the string out.

1.  int main( void ) {

2.       char[YourNumber] in = gets();

3.       char[YourNumber] in2 = gets();

4.       char[2*YourNumber-1] out;

5.       strcpy(out,in);

6.       int index = strlen(in);

7.       while(index < 2*YourNumber-1) {

8.              out[index] = in2[index-strlen(in)];

9.              index = index + 1;

10.        }

11.        return 0;

12.     }

Which lines have buffer length checking errors? Fix each line. (10 marks)

Question 2:

Write a C program to:

• Write on the screen: ``Please enter a positive number less than YourNumber: ''.
• Accept a number from the user.
• Keep prompting for more numbers until -1 is entered
• Output the sum of all entered numbers excluding -1.
• Output the integer part of the average of all entered numbers excluding -1.

The program should properly check all input provided by the user and fail appropriately if bad input is given. The user should not be able to induce a segmentation fault or unintended behaviour from the program. You may use your own notes.

Your program should satisfy the following.

• Program compiles
• Program accepts input from the user
• Program exits when -1 is input
• Program correctly outputs results
• Program can't fail if the user enters too many numbers
• Program can't fail if the user enters long strings
• Program can't fall if the user enters zero numbers
• Program can't fall if the user enters a very big number
• Program is generally well written

Question 3:

The program below uses dynamic memory allocation to accept arguments from a user.

1. #include <stdlib.h>
2. #include <string.h>
3. int main(int argc, char *argv[]) {
4. char *first, *second, *third;
5. first = malloc(YourNumber);
6. second = malloc(22);
7. third = malloc(22);
8. strcpy(first, argv[1]);
9. strcpy(second, argv[2]);
10 free(first);
11 free(second);
12 free(third);
13 return(0);
14 }

Explain in detail how an attacker can exploit this program using the unlink technique. Your explanations should ideally include
• Vulnerabilities in the program's memory allocation
• Malicious argument that may be used by the attacker in unlink technique

• Suggestions of any defences to this kind of attack

Question 4

A user has a picture file. A program runs as the user root and hence is allowed to see all files. The program creates a symbolic link called mylink pointing to the picture file. It checks that the user of the program is allowed to view the picture file before creating the symbolic link. After use, the link is deleted. In a normal program run, the link only appears for a fraction of a second. Unfortunately the program is written carelessly and contains a mistake.

In more detail, what is happening is:

Directory A has a subdirectory B which in turn has a subdirectory C. The symbolic link mylink is in directory B. In the example below it points to the file funny.jpeg.

Output of running ls -l from within directory A:

drwxr-xr-x 2 alice alice 192 Sep 25 17:56 B

Output of running ls -l from within directory B during the brief time that mylink exists:

drwxr-xr-x 2 root root 192 Sep 25 17:56 C
-rw-r--r-- 1 alice alice 491 Sep 25 17:46 funny.jpeg
lrwx------ 1 root root 8 Sep 26 01:42 mylink -> funny.jpeg

Output of running ls -l from within directory C:

-rw------- 1 root root 491 Sep 25 17:46 secret_records

The user is not allowed to view the file secret_records in directory C.

(a) A user has found a way to view the file secret_records. What might the author of the program have done wrong?

(b) Explain in detail how an attacker might exploit this situation.

(c) Assuming the author of the program wishes to create the symbolic link. What could the program author have done to avoid the problem?

Question 5

You are hired by ACME Systems Software Ltd who plan to write much of their software in the language C. The software will be exposed to the Internet and will allow access to various users of different privileges.

When answering the following two questions take into account:

• What are the security risks?
• How might they be exploited?
• What precautions could be taken to reduce any security risks?
In all cases illustrate your points with examples.

(a) Your task is to evaluate the potential security risks of using C. Your work should be split into the following sections (max 200 words per section).
• Integers
• Management of memory
• Evaluation of standard libraries (Are they appropriate. Are better alternatives available and in what way are they better?)
• General robustness of the language (Does the language help the programmer to find/avoid mistakes?)
• Other

(b) Based on your analysis for each make a recommendation of software systems, coding conventions and software process changes that ACME should implement. You should consider the following step-by-step security practises (max 200 words per section).

• Systems Quality Requirements Engineering
• Threat Modeling
• Use/Misuse Cases
• Architecture and Design
• Other

Reference no: EM132294724

Questions Cloud

Current level of output : 1. At the current level of output, the following data exists:
Why would a manager need to know about product : Why would a manager need to know about product and input pricing, such as wages, in the industry (market) of the firm he or she manages?
Fixed exchange rate rather than a floating exchange rate : Briefly list five variables that explain why a country would choose to have a fixed exchange rate rather than a floating exchange rate
How is the economy-community working towards : In Canada, how is the economy/ community working towards living better and working better within the climate change boundary
Evaluate the potential security risks of using C : 7COM1028 - Secure Systems Programming - UNIVERSITY OF HERTFORDSHIRE - SSP Practical Secure Programming - Explain in detail how an attacker can exploit program
Implications of analysis for business managers : Explain how interest rates and inflation rates influence exchange rates and explain the implications of your analysis for business managers.
Estimated regression equation : Suppose the chief marketing officer of Disney used multiple regression analysis to predict gross revenue (y) as a function of television advertising
Determining the consumer surplus : Suppose supply of a good is perfectly elastic at a price of $5. The market demand curve for this good is linear, with zero quantity demanded
Concept and general requirements of theory : Briefly describe the concept and general requirements of theory.

Reviews

len2294724

4/27/2019 4:39:04 AM

This is assignment is to be submitted and marked anonymously. Students should ONLY use their student ID number to identify themselves on their work. Work submitted via StudyNet for anonymous marking will automatically have an anonymity number allocated to it. Student should complete a coursework containing five questions on secure programming offline in their own time and submit the coursework through StudyNet. The coursework is composed of C/C++ programs and case studies. Students should attempt all questions to achieve a full mark. The completed coursework should include: Q1: Your solutions and the new program with fixed errors. Q2: Your solutions and your program. Q3: Your solutions and your program. Q4: Your solutions. Q5: Your solutions. The submission should made via StudyNet and contain (1) ONE.pdf file containing all the solutions to all questions. (2) Separate program file for Q1, Q2 and Q3.

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd