Skip to content

Prevent denial of service in filehash and filehash58 probes - #2407

Draft
jan-cerny wants to merge 1 commit into
OpenSCAP:mainfrom
jan-cerny:filehash_dos
Draft

Prevent denial of service in filehash and filehash58 probes#2407
jan-cerny wants to merge 1 commit into
OpenSCAP:mainfrom
jan-cerny:filehash_dos

Conversation

@jan-cerny

Copy link
Copy Markdown
Member

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 jan-cerny added this to the 1.4.5 milestone Aug 31, 2026
} 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);
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.
@sonarqubecloud

sonarqubecloud Bot commented Sep 1, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants