ambind: fix unsecure use of FD_SET() #225
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ambind does not check user-provided fd value given on its command-line. This fd is then used in calls to
FD_SET()
and thenselect()
.from
man(3) fd_set
:For example, it can be triggered with an int overflow:
ltrace stack:
Current patch fix this behaviour by checking for fd being in range
]0;FD_SETSIZE[
. Note thatFD_SETSIZE
is often 1024 but it is not guaranteed.I am unsure of the security implications of the misuse. ambind is currently SUID root on my debian. However I do not have a clear picture of how that binary is typically used and how often. It is possible that it can lead to denial of service (DoS) if an attacker can provide the port to bind to but I doubt exploitation could go further. I am interested in getting your feedback on that.
Similar issue in other projects:
https://www.chiark.greenend.org.uk/~sgtatham/putty/wishlist/vuln-fd-set-overflow.html
https://www.cvedetails.com/cve/CVE-2011-0719/