logo

Crowdly

Browser

Add to Chrome

Web Security (LTAT.04.018)

Looking for Web Security (LTAT.04.018) test answers and solutions? Browse our comprehensive collection of verified answers for Web Security (LTAT.04.018) at moodle.ut.ee.

Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!

Please implement a web application in PHP that meets the following requirements:

  1. The application must be a single, self-contained .php file.
  2. When first accessed, it should display an HTML form with two input fields ("Username" and "Password") and a login button. [0.5p]
  3. When the login button is clicked, a POST request should be submitted to the application, containing the entered username and password. [0.5p]
  4. Before the form is submitted, client-side JavaScript must validate that both input fields are filled. If either is empty, the form should not be submitted, and a JavaScript alert() message should be shown to the user. [1.5p]
  5. If the submitted username is "user" and the password is "pass", the application should treat the session as authenticated and display a "Hello user!" message along with a logout button. [1.5p]

    (Tip: use $_POST, session_start().)
  6. The session cookie must use the __Host- prefix. [1p]

    (Tip: use session_name() and session_set_cookie_params().)
  7. If the username or password is incorrect, the application should display "Login incorrect!" along with the initial login form. [1p]
  8. Clicking the logout button should send a GET request with the query parameter action=logout. The application must then delete the session cookie (using the Set-Cookie header) and redirect the user (using the Location header) back to the login form. [1.5p]

    (Tip: use isset(), $_GET, setcookie() and header().)
  9. The application must only handle GET and POST methods. Any other HTTP method must result in an error response with status code 405 and a message in the response body indicating that only GET and POST are supported. [0.5p]

    (Tip: use $_SERVER["REQUEST_METHOD"] and http_response_code().)

Please submit the link to your deployed PHP website and the source code of your .php file below.

View this question

Paste a curl one-liner below that can be used to test how your web application rejects HTTP requests that are not GET or POST.

The one-liner should demonstrate (1) that a 405 Method Not Allowed status code is returned, and (2) display the error message in the HTTP response body.

View this question

On the websec.ee server, where is PHP session data stored?

Is it stored securely so that other users on the shared hosting environment cannot access it?

Please upload a screenshot as evidence to support your answer.

View this question

How should the vulnerable website https://websec.ee/web/theme/ be fixed to prevent this type of attack?

Describe below which two lines in the website's client-side code need to be modified, and explain how they should be changed to make the website secure.

View this question

What attack is possible if a cookie does not have the Domain attribute set but its name does not start with the __Host- prefix?

View this question

The website https://www.example.com/ sets a cookie as shown below:

Set-Cookie: session-id=12345; Domain=www.example.com; Path=/; Secure;

Which of the websites listed below will be able to receive this cookie?

  1. http://www.example.com/
  2. https://www.example.com/
  3. https://www.example.com:8787/
  4. https://example.com/
  5. https://mail.example.com/
  6. https://example.mail.com/
View this question

The website https://websec.ee/web/theme/ allows users to switch between light and dark themes.

The user's choice is stored in a cookie and reused on subsequent visits.

For this assignment, create a malicious webpage on your *.websec.ee domain that, when visited, forces the dark theme on https://websec.ee/web/theme/ by performing a cookie tossing attack.

Please submit the link to your malicious webpage below.

View this question

Which of the websites listed in the previous question will be able to inject the cookie?

View this question

What attack is possible if a cookie has the Secure attribute set but its name does not start with the __Secure- prefix?

View this question

A session identifier included in an authentication cookie must contain a unique value to identify the corresponding browser session.

Why should it be generated as a random number instead of using an incremental number to ensure uniqueness?

How would you attack a website that uses an incremental session ID?

View this question

Want instant access to all verified answers on moodle.ut.ee?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome