exam questions

Exam CS0-002 All Questions

View all questions & answers for the CS0-002 exam

Exam CS0-002 topic 1 question 289 discussion

Actual exam question from CompTIA's CS0-002
Question #: 289
Topic #: 1
[All CS0-002 Questions]

A security analyst found an old version of OpenSSH running on a DMZ server and determined the following piece of code could have led to a command execution through an integer overflow:



Which of the following controls must be in place to prevent this vulnerability?

  • A. Convert all integer numbers in strings to handle the memory buffer correctly.
  • B. Implement float numbers instead of integers to prevent integer overflows.
  • C. Use built-in functions from libraries to check and handle long numbers properly.
  • D. Sanitize user inputs, avoiding small numbers that cannot be handled in the memory.
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
OnA_Mule
2 years, 1 month ago
Selected Answer: C
The vulnerability in the code is an integer overflow, which happens when the size of a variable exceeds its maximum capacity. Attackers can exploit this vulnerability to execute arbitrary code, escalate privileges, or cause a denial of service. To prevent integer overflows, it is recommended to use built-in functions from libraries to check and handle long numbers properly. In this case, OpenSSH should be updated to the latest version, which includes patches to fix this vulnerability. Additionally, it is good practice to use static analysis tools and perform code reviews to detect vulnerabilities before they are deployed to production.
upvoted 4 times
...
2Fish
2 years, 1 month ago
Selected Answer: C
C. Me thinks this is correct, libraries with built-in functions for checking and handling long numbers can prevent integer overflows from happening.
upvoted 2 times
...
G_f_b
2 years, 2 months ago
Selected Answer: C
C makes sense to me
upvoted 3 times
...
gnnggnnggnng
2 years, 3 months ago
Selected Answer: D
The code provided has a vulnerability due to an integer overflow. The variable "nresp" is assigned a value from the function "packet_get_inf()". If the value of "nresp" is greater than zero, an array of char pointers "response" is created with the size of "nresp" multiplied by the size of a char pointer. The problem with this approach is that if the value of "nresp" is very large, it could cause an integer overflow and allocate a much larger buffer than intended. This buffer overflow vulnerability could potentially allow an attacker to execute arbitrary code on the affected system. To prevent this vulnerability, the input should be sanitized to avoid small numbers that cannot be handled in the memory. This can be achieved by using built-in functions from libraries to check and handle large numbers properly. Additionally, user inputs can be sanitized to avoid values that can cause an integer overflow.
upvoted 3 times
G_f_b
2 years, 2 months ago
"This can be achieved by"... Don't you mean "C. Use built-in functions from libraries to check and handle long numbers properly."?
upvoted 4 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago