1. Homepage
  2. Exam
  3. [2019] INFR11098 SECURE PROGRAMMING - Final Exam - Q2m Perl Script Vulnerability

[2019] INFR11098 SECURE PROGRAMMING - Final Exam - Q2m Perl Script Vulnerability

This question has been solved
Engage in a Conversation

2. Figure 1 on page 4 shows a Perl web CGI script along with a form to invoke it. The script displays information about a user using the Unix finger program. It could be used, for example, in a web hosting environment with a Virtual Private Server, when several users may be permitted to login to the system and work on different web sites. An example invocation gives output like this: CourseNana.COM

  CourseNana.COM

Finger User CourseNana.COM

Login name: bod Real name: Bod Idley CourseNana.COM

On since Feb 19 23:37:16 on pts/7 from domain237.btinternet.com CourseNana.COM

42 seconds Idle Time CourseNana.COM

  CourseNana.COM

(a) The developer of the script has followed an FAQ entry given by the web hosting provider which states: CourseNana.COM

  CourseNana.COM

Put “use CGI::Carp qw(fatalsToBrowser);” into the second line of your script. This will make perl print the error instead of the “500 Internal Server Error” page, and will allow you to find out where your script is breaking. [Exerpt from https://www.123-reg.co. CourseNana.COM

uk/support/hosting/debugging-your-perl-scripts/] CourseNana.COM

  CourseNana.COM

i. Explain the reasoning behind this recommendation and why adding the extra line might constitute a security vulnerability. [2 marks] CourseNana.COM

ii. Exploiting this vulnerability, what might an attacker be able to do? [2 marks] CourseNana.COM

iii. Explain carefully some additional advice you would propose to be added to this FAQ entry. [2 marks] CourseNana.COM

  CourseNana.COM

(b) Unfortunately, the code contains a second, more serious vulnerability. CourseNana.COM

i. Identify and explain the critical vulnerability in the code, giving an example exploit and its result. [3 marks] CourseNana.COM

ii. Give a fix for the vulnerability you identified, which does not cause errors in the script execution or the client browser. (Hint: you might use the Perl regular expression match test, written “<str> ~= <regexp>”. Syntax doesn’t need to be perfect; code showing the right intention will gain full marks.) [3 marks] CourseNana.COM

  CourseNana.COM

(c) The developer realises the script may reveal information about more users than wanted; it would be better to offer a drop-down list using a form with <select>...<option>... to choose from users bod, flo, and barley. Explain a (secure) way to do this. [4 marks] CourseNana.COM

  CourseNana.COM

(d) Considering how a hosting provider such as 123 Reg can minimise risks associated with vulnerable web sites they host, give two examples of risks affecting the hosting provider and corresponding mitigations. CourseNana.COM

  CourseNana.COM

1 #!/usr/bin/perl CourseNana.COM

2 # finger.cgi - finger CGI script using Perl5 CGI module CourseNana.COM

3 CourseNana.COM

4 use CGI; CourseNana.COM

5 use CGI::Carp qw(fatalsToBrowser); CourseNana.COM

6 $q = new CGI; CourseNana.COM

7 CourseNana.COM

8 # display HTML header CourseNana.COM

9 print $q->header, CourseNana.COM

10 $q->start_html(’Finger User’), CourseNana.COM

11 $q->h1(’Finger User’); CourseNana.COM

12 CourseNana.COM

13 # get name of user and display finger information CourseNana.COM

14 $user = $q->param("user"); CourseNana.COM

15 print ‘/usr/bin/finger -sh $user‘; CourseNana.COM

16 CourseNana.COM

17 # display HTML footer CourseNana.COM

18 print "</pre>"; CourseNana.COM

19 print $q->end_html; CourseNana.COM

20 exit(0); CourseNana.COM

  CourseNana.COM

1 <html><head><title>Finger User</title></head> CourseNana.COM

2 <body><h1>Finger User</h1> CourseNana.COM

3 <form method=post action="finger.cgi"> CourseNana.COM

4 <b>Username to finger:</b> <input type=text name=user value=""> CourseNana.COM

5 <p><input type=submit value="Finger User"> CourseNana.COM

6 </form> CourseNana.COM

7 </body> CourseNana.COM

8 </html> CourseNana.COM

  CourseNana.COM

Figure 1: The Perl CGI script finger.cgi and a web form invoking it CourseNana.COM

  CourseNana.COM

(e) Webmin is a web-based administration tool for Unix systems. CourseNana.COM

In August 2019, year-old backdoors were revealed inWebmin’s password_change.cgi script. Surreptitious changes were found on the build server used to make official Sourceforge releases (master Github sources were not affected). CourseNana.COM

One modification was: CourseNana.COM

< $enc eq $wuser->{’pass’} || &pass_error($text{’password_eold’}); CourseNana.COM

--- CourseNana.COM

> $enc eq $wuser->{’pass’} || &pass_error($text{’password_eold’},qx/$in{’old’}/); CourseNana.COM

(the Perl qx function executes an OS command, returning the result). CourseNana.COM

i. Speculate how an attacker with knowledge of the backdoor could gain root access to a server running a vulnerable version of Webmin. [3 marks] CourseNana.COM

ii. Explain how a backdoor such as this might have arisen, and what measures could be taken to avoid it. CourseNana.COM

Get the Solution to This Question

WeChat WeChat
Whatsapp WhatsApp
UNIVERSITY OF EDINBURGH代写,INFR11098代写,SECURE PROGRAMMING代写,Perl代写,UNIVERSITY OF EDINBURGH代编,INFR11098代编,SECURE PROGRAMMING代编,Perl代编,UNIVERSITY OF EDINBURGH代考,INFR11098代考,SECURE PROGRAMMING代考,Perl代考,UNIVERSITY OF EDINBURGHhelp,INFR11098help,SECURE PROGRAMMINGhelp,Perlhelp,UNIVERSITY OF EDINBURGH作业代写,INFR11098作业代写,SECURE PROGRAMMING作业代写,Perl作业代写,UNIVERSITY OF EDINBURGH编程代写,INFR11098编程代写,SECURE PROGRAMMING编程代写,Perl编程代写,UNIVERSITY OF EDINBURGHprogramming help,INFR11098programming help,SECURE PROGRAMMINGprogramming help,Perlprogramming help,UNIVERSITY OF EDINBURGHassignment help,INFR11098assignment help,SECURE PROGRAMMINGassignment help,Perlassignment help,UNIVERSITY OF EDINBURGHsolution,INFR11098solution,SECURE PROGRAMMINGsolution,Perlsolution,