Prevent denial of service in filehash and filehash58 probes - #2407
Open
jan-cerny wants to merge 1 commit into
Open
Prevent denial of service in filehash and filehash58 probes#2407jan-cerny wants to merge 1 commit into
jan-cerny wants to merge 1 commit into
Conversation
| } else { | ||
| char *path_with_prefix = oscap_path_join(prefix, pbuf); | ||
| fd = open(path_with_prefix, O_RDONLY); | ||
| fd = open(path_with_prefix, O_RDONLY | O_NONBLOCK); |
jan-cerny
force-pushed
the
filehash_dos
branch
from
September 1, 2026 14:15
73f843a to
787da7f
Compare
The filehash and filehash58 probes call `open(pbuf, O_RDONLY)` without checking the file type. If the target is a FIFO (named pipe), `open()` blocks indefinitely waiting for a writer. The user simply runs `mkfifo ~/somefile` — when the compliance scan traverses their home directory, the entire oscap process hangs. Additionally, a symlink to `/dev/zero` causes an infinite read loop in `crapi_mdigest_fd()`. Both problems will be avoided by checking whether the file isn't blocking and is a regular file. The function `crapi_mdigest_fd` isn't modified by the commit but the issue is avoided because the function is guarded by the checks.
jan-cerny
force-pushed
the
filehash_dos
branch
from
September 4, 2026 07:13
787da7f to
49fbf03
Compare
|
jan-cerny
marked this pull request as ready for review
September 4, 2026 09:17
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



The filehash and filehash58 probes call
open(pbuf, O_RDONLY)without checking the file type. If the target is a FIFO (named pipe),open()blocks indefinitely waiting for a writer. The user simply runsmkfifo ~/somefileand when the compliance scan traverses their home directory, the entire oscap process hangs.Additionally, a symlink to
/dev/zerocauses an infinite read loop incrapi_mdigest_fd().Both problems will be avoided by checking whether the file isn't blocking and is a regular file. The function
crapi_mdigest_fdisn't modified by the commit but the issue is avoided because the function is guarded by the checks.Review hints
somefile, createsomefilenamed pipe using themkfifo somefilecommand. Then runoscap oval evalwith the OVAL content and verify that theoscapcommand isn't stuck but completes successfully. A similar OVAL is used in the test introduced in this PR.