1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Nataly_w [17]
2 years ago
13

Consider the following general code for allowing access to a resource:

Computers and Technology
1 answer:
Margaret [11]2 years ago
6 0

Answer:

a) The code allows access even when  IsAccessAllowed(...) method fails.

b) Either use If

(dwRet = ACCESS_ALLOWED)

or use

if (dwRet == NO_ERROR)

to avoid flaw

Explanation:

Lets first see what the code chunk does:

DWORD dwRet = IsAccessAllowed(...);

if (dwRet == ERROR_ACCESS_DENIED) {

// Security check failed.

// Inform user that access is denied.

} else {

// Security check OK.

}

In the given code, DWORD is basically a data type for double word type integers and this is defined in windows.h

So there is DWORD type variable dwRet that is assigned a method calls.

The method is IsAccessAllowed() which checks if the access is allowed to user.

if (dwRet == ERROR_ACCESS_DENIED) condition basically checks if the value of DWORD type variable dwRet is equal to ERROR_ACCESS_DENIED

If this condition evaluates to true then the security checks fails and user is informed via some message or action that the access is denied.  But when the if condition evaluates to false then the else part executes which allows access.

So basically this chunk of code checks if the error ERROR_ACCESS_DENIED is returned.

Now the flaw in this program is what if the method IsAccessAllowed() by any reason. The reasons can be system failure or the memory failure. In memory failure case for example, the system returns out of memory error. So this means that the error is not  ERROR_ACCESS_DENIED. Instead it is out of memory error. So in such a case the user is allowed access as the if condition evaluates to false and else part executes. So if any other error is produced due to some reason like mentioned above, then user has unrestricted access.

This shows that the doe should not check for the failure or rely on checking ERROR_ACCESS_DENIED to allow access but instead it should check for success. Code should only give access privilege if access is allowed successfully or no error is produced.

So to avoid this flaw the code is altered as:

DWORD dwRet = IsAccessAllowed(...);

If (dwRet = ACCESS_ALLOWED) {

//Security check OK.

} else {

//Security check failed.

//Inform user that access is denied.

}

This will only allow access if ACCESS_ALLOWED evaluates to true and success is checked instead of failure here

You can also alter the if condition as:

If (dwRet = No_Error)

or

If (dwRet = 0)

The above if conditions checks if the access is allowed or if no error is produced. Only then it will allowed access otherwise not. So the access check is a success is checked first and failure (for any reason). The user is allowed access only if there is no error otherwise user is not allowed access.

You might be interested in
What command will prevent all unencrypted passwords from displaying in plain text in a configuration file?.
Juli2301 [7.4K]

Answer:

(config)# enable password secret

(config)# enable secret Encrypted_Password

(config-line)# password secret

(config)# enable secret Secret_Password

(config)# service password-encryption

Explanation:

To prevent all configured passwords from appearing in plain text in configuration files, an administrator can execute the service password-encryption command. This command encrypts all configured passwords in the configuration file. For more: https://ccnav7.net/what-command-will-prevent-all-unencrypted-passwords-from-displaying-in-plain-text-in-a-configuration-file-2/

3 0
2 years ago
Do laws ever change to help enforce cyber hacking crimes
prisoha [69]
No I don’t think so personally
5 0
2 years ago
Read 2 more answers
I need help with the rest also
dalvyx [7]

Answer:

??? blackkkkkkkkkkkkkkkkk

6 0
2 years ago
The text help readers understand the relationship between gender and sports?THESE PUMPKINS SURE CAN KICK!
AleksAgata [21]

Answer:

What's the question?????I don't understand

4 0
3 years ago
You want to add the same functionality to various web sites you have created for your school district without having to add the
Shkiper50 [21]
You should place your javascript in a separate file and name it appropriately, e.g. script.js.

Then you should call for your script using the HTML:

<script src="script.js" type="text/javascript"<span>></script></span>
3 0
2 years ago
Other questions:
  • HELP ASAP!!!!!!!!! ITS A UNIT TEST: WILL MARK AS BRAINLIEST&gt;
    13·1 answer
  • I have been trying to work on this for a while now, and this is on excel
    11·1 answer
  • What is the meaning for science?
    14·1 answer
  • One way bloggers decide how to present information is by understanding
    7·2 answers
  • Which term is used to identify the connection of computers that are physically close to one another?
    8·2 answers
  • Please help quickly!!! which of the following is not a peripheral?
    8·2 answers
  • The parts of a memo are _____.
    9·2 answers
  • Which of the following expressions yields an integer between 0 and 100, inclusive? Question 5 options: (int)(Math.random() * 100
    6·1 answer
  • Explain the bad effect and good effect of mobile phone and internet.<br>​
    15·2 answers
  • Complete the concept map on computer as outlined below​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!