1) (20 pts) Please explain the common vulnerabilities/problems associated with each of the following and discuss how to identify vulnerable code through the use of code auditing. a) Metacharacters b)...

1 answer below »

1) (20 pts) Please explain the common vulnerabilities/problems associated with each of the following and discuss how to identify vulnerable code through the use of code auditing.




a) Metacharacters


b) Network Protocols with Length Identifiers in Headers


c) File Permission Check TOCTOU (Race) conditions


d) Symbolic Links


e) Insecure default






2) (20 pts) Please provide definitions for each of the following terms and discuss how they are related to software vulnerability analysis




a) Security Policy


A:


b) Authentication


c) Static Analyzers


d) Fuzzing


e) SETUID Program






3) (30 pts)




a) Please describe code auditing and black box testing. What are the pros and cons of each of them? How do you choose which one to use?


b) Summarize the concepts and process of application review.


c) Describe the process of threat modeling.


d) Summarize the concepts and process of auditing function use.


e) Give one example of operational vulnerability and discuss how to prevent it.




4) (15 pts) Define and give examples of each of the follow


a) Design Vulnerabilities


b) Implementation Vulnerabilities


c) Operational Vulnerabilities




5) (15 pts) Answer ONE of the following




a) With respect to code auditing, the process you would use to look for file access vulnerabilities. Specifically include opening files, library functions for checking file status, and evaluating path names.




-OR-




b) Explain fuzzing, discuss the different types of fuzzing, and how fuzzing can be used as an aid to software vulnerability analysis.




6) (30 pts) Each of the following pieces of C code has an error in it. Please identify and explain the vulnerability and discuss
how to fix it.




a)









1. function readFile($filename){


2. $user = getCurrentUser();


3.


4. //resolve file if its a symbolic link


5. if(is_link($filename)){


6. $filename = readlink($filename);


7. }


8.


9. if(fileowner($filename) == $user){


10. echo file_get_contents($realFile);


11. return;


12. } else {


13. echo 'Access denied';


14. return false;


15. }


16. }







b)









1. /* Initial UIDS: real = 1000 effective = 0 saved = 0 */


2. /* 1. Usual call to temporarily drop privileges */


3.


4. orig_euid = geteuid();


5. if (seteuid(geteuid() = = -1)


6. errExit(“seteuid error”);


7.


8. /* UIDs change to: real=1000 effective = 1000 saved = 0 */


9. /* Now permanently drop privileges */


10.


11. if (setuid(getuid)) == -1)


12. errExit(“setuid error”);


13. …


14. /* process rest of code */





c)









1. unsigned int readdata () {


2. int amount = 0;


3. ...


4. if (result == ERROR)


5. amount = -1;


6. ...


7. return amount;


8. }





d)









1. int processMessageFromNetwork(int socket) {


2. int successFlag;


3.


4. char buffer[BUFFER_SIZE];


5. char message[MESSAGE_SIZE];


6.


7. // get message from network socket and store into buffer



8.

// For this exam assume message fits in buffer


9. if (getMessage(socket, buffer, BUFFER_SIZE) > 0) {


10.


11. // put contents of buffer into message structure


12. ExMessage *msg = recastBuffer(buffer);


13.


14. // copy message body into message string for processing


15. int index;


16. for (index = 0; index < msg-="">msgLength; index++) {


17. message[index] = msg->msgBody[index];


18. }


19. message[index] = '\0';


20. // process received message


21. success = processMessage(message);


22. }


23. return success;


24. }





e)









1. class A{


2. void foo(bool);


3. };


4.


5. void A::foo(bool heap) {


6. int localArray[2] = { 11,22 };


7. int *p = localArray;


8.


9. if (heap){


10. p = new int[2];


11. }


12. delete[] p;


13. }











7) (20 points) Multiple choice (Circle the correct answer).




a) Which technique
cannot
be used guard against buffer overflow attacks?


i) Address space layout randomization


ii) Signed software


iii) Stack canaries


iv) Non-executable stack memory


A:






b) Operational vulnerabilities can result from failure to use the security mechanisms provided by the platform.


i) True


ii) False


A:






c) Pathological code paths describe functions with many small and nonterminating branches.


i) True


ii) False


A:






d) Uninitialized local variables are stored in:


i) bss segment


ii) data segment


iii) text segment


iv) stack segment


v) heap segment


A:






e) Overflowing which region in a function's stack frame may transfer the control to somewhere else.


i) function arguments region


ii) return address region


iii) Previous frame pointer region


iv) local variables region


A:






f) Which type conversion is value preserving conversion?


i) convert between signed and unsigned types of the same width


ii) convert from a narrower unsigned type to a wider unsigned type


iii) convert from a narrower signed type to a wider unsigned type


iv) convert from a wider type to a narrower type


A:




g) Which of the following set of operators are always executed in the order they appear in an expression:


i) &, |, <,>


ii) &&, ||, <,>>


iii) &&, ||


iv) All of the above. Modern compilers understand operators so this is not a problem.


A:






h) Consider the following macro and code: What is the output of the code


#define y 3


#define MAC2(x) (x*y+x-y)



printf("%d\n",MAC2(3+4));




i) 25


ii) 19


iii) Compiler error


iv) Undefined, compiler may choose to evaluate 3+4 first OR not, order of operations is not guaranteed.


A: 19






i) When auditing functions, the auditing log usually contains


i) Function description


ii) Cross references


iii) Return value


iv) All of the above


A: All of the Above






j) Which of the following functions behaves differently under different version of Unix


i) initgroups()


ii) mktemp()


iii) open()


iv) setuid()


v) all of the above


A:










8) (20 pts)
CS 504 Only.
Describe a homework assignment that would have been good for this course. Write up the instructions for the assignment, you do not have to include any source code, but you should explain what it will contain.


A:




1) (20 pts) Please explain the common vulnerabilities/problems associated with each of the following and discuss how to identify vulnerable code through the use of code auditing.




a) Metacharacters


b) Network Protocols with Length Identifiers in Headers


c) File Permission Check TOCTOU (Race) conditions


d) Symbolic Links


e) Insecure default






2) (20 pts) Please provide definitions for each of the following terms and discuss how they are related to software vulnerability analysis




a) Security Policy


A:


b) Authentication


c) Static Analyzers


d) Fuzzing


e) SETUID Program






3) (30 pts)




a) Please describe code auditing and black box testing. What are the pros and cons of each of them? How do you choose which one to use?


b) Summarize the concepts and process of application review.


c) Describe the process of threat modeling.


d) Summarize the concepts and process of auditing function use.


e) Give one example of operational vulnerability and discuss how to prevent it.




4) (15 pts) Define and give examples of each of the follow


a) Design Vulnerabilities


b) Implementation Vulnerabilities


c) Operational Vulnerabilities




5) (15 pts) Answer ONE of the following




a) With respect to code auditing, the process you would use to look for file access vulnerabilities. Specifically include opening files, library functions for checking file status, and evaluating path names.




-OR-




b) Explain fuzzing, discuss the different types of fuzzing, and how fuzzing can be used as an aid to software vulnerability analysis.




6) (30 pts) Each of the following pieces of C code has an error in it. Please identify and explain the vulnerability and discuss
how to fix it.




a)









1. function readFile($filename){


2. $user = getCurrentUser();


3.


4. //resolve file if its a symbolic link


5. if(is_link($filename)){


6. $filename = readlink($filename);


7. }


8.


9. if(fileowner($filename) == $user){


10. echo file_get_contents($realFile);


11. return;


12. } else {


13. echo 'Access denied';


14. return false;


15. }


16. }







b)









1. /* Initial UIDS: real = 1000 effective = 0 saved = 0 */


2. /* 1. Usual call to temporarily drop privileges */


3.


4. orig_euid = geteuid();


5. if (seteuid(geteuid() = = -1)


6. errExit(“seteuid error”);


7.


8. /* UIDs change to: real=1000 effective = 1000 saved = 0 */


9. /* Now permanently drop privileges */


10.


11. if (setuid(getuid)) == -1)


12. errExit(“setuid error”);


13. …


14. /* process rest of code */





c)









1. unsigned int readdata () {


2. int amount = 0;


3. ...


4. if (result == ERROR)


5. amount = -1;


6. ...


7. return amount;


8. }





d)









1. int processMessageFromNetwork(int socket) {


2. int successFlag;


3.


4. char buffer[BUFFER_SIZE];


5. char message[MESSAGE_SIZE];


6.


7. // get message from network socket and store into buffer



8.

// For this exam assume message fits in buffer


9. if (getMessage(socket, buffer, BUFFER_SIZE) > 0) {


10.


11. // put contents of buffer into message structure


12. ExMessage *msg = recastBuffer(buffer);


13.


14. // copy message body into message string for processing


15. int index;


16. for (index = 0; index < msg-="">msgLength; index++) {


17. message[index] = msg->msgBody[index];


18. }


19. message[index] = '\0';


20. // process received message


21. success = processMessage(message);


22. }


23. return success;


24. }





e)









1. class A{


2. void foo(bool);


3. };


4.


5. void A::foo(bool heap) {


6. int localArray[2] = { 11,22 };


7. int *p = localArray;


8.


9. if (heap){


10. p = new int[2];


11. }


12. delete[] p;


13. }











7) (20 points) Multiple choice (Circle the correct answer).




a) Which technique
cannot
be used guard against buffer overflow attacks?


i) Address space layout randomization


ii) Signed software


iii) Stack canaries


iv) Non-executable stack memory


A:






b) Operational vulnerabilities can result from failure to use the security mechanisms provided by the platform.


i) True


ii) False


A:






c) Pathological code paths describe functions with many small and nonterminating branches.


i) True


ii) False


A:






d) Uninitialized local variables are stored in:


i) bss segment


ii) data segment


iii) text segment


iv) stack segment


v) heap segment


A:






e) Overflowing which region in a function's stack frame may transfer the control to somewhere else.


i) function arguments region


ii) return address region


iii) Previous frame pointer region


iv) local variables region


A:






f) Which type conversion is value preserving conversion?


i) convert between signed and unsigned types of the same width


ii) convert from a narrower unsigned type to a wider unsigned type


iii) convert from a narrower signed type to a wider unsigned type


iv) convert from a wider type to a narrower type


A:




g) Which of the following set of operators are always executed in the order they appear in an expression:


i) &, |, <,>


ii) &&, ||, <,>>


iii) &&, ||


iv) All of the above. Modern compilers understand operators so this is not a problem.


A:






h) Consider the following macro and code: What is the output of the code


#define y 3


#define MAC2(x) (x*y+x-y)



printf("%d\n",MAC2(3+4));




i) 25


ii) 19


iii) Compiler error


iv) Undefined, compiler may choose to evaluate 3+4 first OR not, order of operations is not guaranteed.


A: 19






i) When auditing functions, the auditing log usually contains


i) Function description


ii) Cross references


iii) Return value


iv) All of the above


A: All of the Above






j) Which of the following functions behaves differently under different version of Unix


i) initgroups()


ii) mktemp()


iii) open()


iv) setuid()


v) all of the above


A:










8) (20 pts)
CS 504 Only.
Describe a homework assignment that would have been good for this course. Write up the instructions for the assignment, you do not have to include any source code, but you should explain what it will contain.


A:




1) (20 pts) Please explain the common vulnerabilities/problems associated with each of the following and discuss how to identify vulnerable code through the use of code auditing.




a) Metacharacters


b) Network Protocols with Length Identifiers in Headers


c) File Permission Check TOCTOU (Race) conditions


d) Symbolic Links


e) Insecure default






2) (20 pts) Please provide definitions for each of the following terms and discuss how they are related to software vulnerability analysis




a) Security Policy


A:


b) Authentication


c) Static Analyzers


d) Fuzzing


e) SETUID Program






3) (30 pts)




a) Please describe code auditing and black box testing. What are the pros and cons of each of them? How do you choose which one to use?


b) Summarize the concepts and process of application review.


c) Describe the process of threat modeling.


d) Summarize the concepts and process of auditing function use.


e) Give one example of operational vulnerability and discuss how to prevent it.




4) (15 pts) Define and give examples of each of the follow


a) Design Vulnerabilities


b) Implementation Vulnerabilities


c) Operational Vulnerabilities




5) (15 pts) Answer ONE of the following




a) With respect to code auditing, the process you would use to look for file access vulnerabilities. Specifically include opening files, library functions for checking file status, and evaluating path names.




-OR-




b) Explain fuzzing, discuss the different types of fuzzing, and how fuzzing can be used as an aid to software vulnerability analysis.




6) (30 pts) Each of the following pieces of C code has an error in it. Please identify and explain the vulnerability and discuss
how to fix it.




a)









1. function readFile($filename){


2. $user = getCurrentUser();


3.


4. //resolve file if its a symbolic link


5. if(is_link($filename)){


6. $filename = readlink($filename);


7. }


8.


9. if(fileowner($filename) == $user){


10. echo file_get_contents($realFile);


11. return;


12. } else {


13. echo 'Access denied';


14. return false;


15. }


16. }







b)









1. /* Initial UIDS: real = 1000 effective = 0 saved = 0 */


2. /* 1. Usual call to temporarily drop privileges */


3.


4. orig_euid = geteuid();


5. if (seteuid(geteuid() = = -1)


6. errExit(“seteuid error”);


7.


8. /* UIDs change to: real=1000 effective = 1000 saved = 0 */


9. /* Now permanently drop privileges */


10.


11. if (setuid(getuid)) == -1)


12. errExit(“setuid error”);


13. …


14. /* process rest of code */





c)









1. unsigned int readdata () {


2. int amount = 0;


3. ...


4. if (result == ERROR)


5. amount = -1;


6. ...


7. return amount;


8. }





d)









1. int processMessageFromNetwork(int socket) {


2. int successFlag;


3.


4. char buffer[BUFFER_SIZE];


5. char message[MESSAGE_SIZE];


6.


7. // get message from network socket and store into buffer



8.

// For this exam assume message fits in buffer


9. if (getMessage(socket, buffer, BUFFER_SIZE) > 0) {


10.


11. // put contents of buffer into message structure


12. ExMessage *msg = recastBuffer(buffer);


13.


14. // copy message body into message string for processing


15. int index;


16. for (index = 0; index < msg-="">msgLength; index++) {


17. message[index] = msg->msgBody[index];


18. }


19. message[index] = '\0';


20. // process received message


21. success = processMessage(message);


22. }


23. return success;


24. }





e)









1. class A{


2. void foo(bool);


3. };


4.


5. void A::foo(bool heap) {


6. int localArray[2] = { 11,22 };


7. int *p = localArray;


8.


9. if (heap){


10. p = new int[2];


11. }


12. delete[] p;


13. }











7) (20 points) Multiple choice (Circle the correct answer).




a) Which technique
cannot
be used guard against buffer overflow attacks?


i) Address space layout randomization


ii) Signed software


iii) Stack canaries


iv) Non-executable stack memory


A:






b) Operational vulnerabilities can result from failure to use the security mechanisms provided by the platform.


i) True


ii) False


A:






c) Pathological code paths describe functions with many small and nonterminating branches.


i) True


ii) False


A:






d) Uninitialized local variables are stored in:


i) bss segment


ii) data segment


iii) text segment


iv) stack segment


v) heap segment


A:






e) Overflowing which region in a function's stack frame may transfer the control to somewhere else.


i) function arguments region


ii) return address region


iii) Previous frame pointer region


iv) local variables region


A:






f) Which type conversion is value preserving conversion?


i) convert between signed and unsigned types of the same width


ii) convert from a narrower unsigned type to a wider unsigned type


iii) convert from a narrower signed type to a wider unsigned type


iv) convert from a wider type to a narrower type


A:




g) Which of the following set of operators are always executed in the order they appear in an expression:


i) &, |, <,>


ii) &&, ||, <,>>


iii) &&, ||


iv) All of the above. Modern compilers understand operators so this is not a problem.


A:






h) Consider the following macro and code: What is the output of the code


#define y 3


#define MAC2(x) (x*y+x-y)



printf("%d\n",MAC2(3+4));




i) 25


ii) 19


iii) Compiler error


iv) Undefined, compiler may choose to evaluate 3+4 first OR not, order of operations is not guaranteed.


A: 19






i) When auditing functions, the auditing log usually contains


i) Function description


ii) Cross references


iii) Return value


iv) All of the above


A: All of the Above






j) Which of the following functions behaves differently under different version of Unix


i) initgroups()


ii) mktemp()


iii) open()


iv) setuid()


v) all of the above


A:










8) (20 pts)
CS 504 Only.
Describe a homework assignment that would have been good for this course. Write up the instructions for the assignment, you do not have to include any source code, but you should explain what it will contain.


A:


Answered Same DayMay 11, 2021

Answer To: 1) (20 pts) Please explain the common vulnerabilities/problems associated with each of the following...

Sandeep Kumar answered on May 13 2021
151 Votes
1) A) The easiest case of metacharacter vulnerabilities occur when users can embed delimiter characters used to denote the end of a field. Susceptibilities of this nature are caused by inadequately prepared user input combined into a formatted string. For example, say you have a data file containing username and password pairs, with each line in the file in the format username:password. The NUL terminator character. However, there are a variety of in-band representations that are common in textual data formats. For example, a slash (/) metacharacter in a filename indicates the beginning or end of a path segment, a dot (.) metacharacter in a hostname indicates a subdomain, and a space metacharacter in an ASCII-based protocol often denotes the end of an input token this could be used to identify vulnerable code.
B) As a packet header might be valid or invalid at numerous different levels, we must audit packet headers at each level of the protocol stack. An example of this would be an invalid UDP packet encapsulated by a valid IP packet and valid Ethernet frame. While the UDP packet will be discarded at the UDP layer, the IP packet header will be processed and might represent an attack. Furthermore, if we wait until the packet has reached the top of the stack to audit its encapsulating headers, a lower-level header may already have exploited a vulnerability and crashed the system. In this case, the audit mechanism with race condition involving the checking of the state of a part of a system (such as a security credential) and the use of the results of that check.
C) A TOCTOU (time-of-check, time-of-use) race condition occurs when two or more concurrent processes are operating on a shared file system. Usually, the first access is a check to verify some attribute of the file, followed by a call to use the file, this can lead to vulnerability. For example, an attacker can change the file between the two accesses, or even replace the file with a soft or hard link to a different file. These TOCTOU conditions can become a vulnerability and be exploited when a program does two or more file operations on the same file or path name.
Also, a program that performs two or more than two file operations on a single file or path name establishes a race window between the two file operations. This race window comes from the assumption that the file name or path name refers to the same resource both times. If an attacker modifies the contents of the file, removes it, or replaces it with some other file, then it can cause serious damage
D) Symbolic links can be created by any user or user group under some object directories, but by themselves are not sufficient to successfully intensify exclusions. However, combining them with a different object, such as the NTFS junction point, just might do the trick. A junction is an object that maps a directory into a different directory. There are two requirements for creating a junction i.e. having a write-permission over the chosen directory and having the ability to delete all files inside the directory. For example, a malicious user can create a symbolic or soft link to a file inaccessible to them. When the authorized user or program creates a file of the same name as the soft link, it actually ends up creating the linked-to the file instead, which can possibly let the malicious user insert malicious content to it.
E) Many systems include inherently insecure default settings and behaviors, including empty default passwords, permissive default access control lists, network ports open by default, and so on. Such behavior is very likely to result in real security threats, usually when exhibited by packaged software products, which are often installed by users who are not familiar with it. Ensuring secure default behavior makes a real contribution to practical systems security.
2) a) There are the appearances of errors that violate security policies, which occur in every phase of the software life cycle, including requirement analysis, design, coding, testing as well as operation phases. Such vulnerabilities are the origin causes of software security problems. If these vulnerabilities cannot be discovered in time and reside in software until later phases of software development cycle, the normal operation of software systems will be faced with great threats. A software vulnerability is an instance of an error in the specification, development, or configuration of software such that its execution can violate the...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here