Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3 . 4 Task 4 : Attack Mitigation using HMAC In the tasks so far, we have observed the damage caused when a developer computes

3.4 Task 4: Attack Mitigation using HMAC
In the tasks so far, we have observed the damage caused when a developer computes a MAC in an insecure way by concatenating the key and the message. In this task, we will fix the mistake made by the developer. The standard way to calculate MACs is to use HMAC. Students should modify the server program's verify_mac () function and use Python's hmac module to calculate the MAC. The function resides in lab. py. Given a key and message (both of type string), the HMAC can be computed as shown below (if you copy and paste the code from this PDF file, the ' characters might not be copied correctly on some platforms).
real_mac = hmac.new (bytearray (key.encode ('utf-8')),
msg=message.encode ('utf-8', 'surrogateescape'),
digestmod=hashlib.sha256). hexdigest ()
After making the changes, stop all the containers, rebuild them, and start all the containers again. The change will then take effect. Students should repeat Task 1 to send a request to list files while using HMAC for the MAC calculation. Assuming that the chosen key is 123456, the HMAC can be computed in the following program.
#!/bin/env python 3
import hmac
import hashlib
key='123456'
message =?' lst cmd=1'
mac = hmac. new (bytearray (key.encode ('ut f-8')),
msg= message.encode ('utf-8', 'surrogateescape'),
digestmod=hashlib.sha256). hexdigest ()
print (mac)
Students should describe why a malicious request using length extension and extra commands will fail MAC verification when the client and server use HMAC.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Autonomous Database In Enterprise Architecture

Authors: Bal Mukund Sharma, Krishnakumar KM, Rashmi Panda

1st Edition

1801072248, 978-1801072243

More Books

Students also viewed these Databases questions

Question

Complexity of linear search is O ( n ) . Your answer: True False

Answered: 1 week ago

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago