Skip to content

criu: validate non-regular descriptor files - #5402

Open
rst0git wants to merge 1 commit into
opencontainers:mainfrom
rst0git:fix-readjson-regular-files
Open

criu: validate non-regular descriptor files#5402
rst0git wants to merge 1 commit into
opencontainers:mainfrom
rst0git:fix-readjson-regular-files

Conversation

@rst0git

@rst0git rst0git commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

When restore opens descriptors.json from the checkpoint image, a FIFO at this path may block the read indefinitely, so repeated restore attempts can exhaust caller threads in container runtimes. To fix this, we should open this file through the pre-opened image directory with O_PATH, verify the inode is a regular file, and reopen that handle for reading. This patch also rejects symlinks and other special files, and limits the read to 1 MiB to prevent unbounded allocations.

Comment thread libcontainer/criu_linux.go
Comment thread libcontainer/criu_linux.go Outdated
Comment thread libcontainer/criu_linux.go Outdated
Comment thread libcontainer/criu_linux.go Outdated
Comment thread libcontainer/criu_linux.go Outdated
@kolyshkin

Copy link
Copy Markdown
Contributor

So, we have the same issue when reading say config.json or state.json. Does it make sense to harden against fifos and large files in there? Does this PR make sense? I mean, are we doing this for security? If yes, how could the possible exploit look like?

@rst0git
rst0git force-pushed the fix-readjson-regular-files branch from 58e9b3e to 227b349 Compare August 18, 2026 12:23
@rst0git

rst0git commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

Does this PR make sense? I mean, are we doing this for security? If yes, how could the possible exploit look like?

We recently received a report about a similar issue with the ReadJSONFile functionality in checkpointctl, and to fix this I used Aleksa's method in runc as an example. While working on this, I noticed that we have the issue with descriptors.json. The main concern is a potential denial of service (if descriptors.json replaced by FIFO in the checkpoint, opening it may cause the container runtime to hang during restore).

In the CRIU project we also clarified that we assume all image files in the checkpoint to be authentic, confidential, and to have not been tampered with by an untrusted actor (i.e., we consider such issues as bugs): https://github.com/checkpoint-restore/criu/blob/criu-dev/Documentation/under-the-hood/security/image-security.md

we have the same issue when reading say config.json or state.json. Does it make sense to harden against fifos and large files in there?

My understanding is that, in comparison to descriptors.json, config.json and state.json are not read from the supplied checkpoint during restore, so they belong to different code paths and trust boundaries.

@rst0git
rst0git force-pushed the fix-readjson-regular-files branch from 227b349 to e745887 Compare August 26, 2026 12:04
When restore opens `descriptors.json` from the checkpoint image, a FIFO
at this path may block the read indefinitely, so repeated restore
attempts can exhaust caller threads in container runtimes. To fix this,
we should open this file through the pre-opened image directory with
`O_PATH`, verify the inode is a regular file, and reopen that handle for
reading. This patch also rejects symlinks and other special files, and
limits the read to 1 MiB to prevent unbounded allocations.

Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
@rst0git
rst0git force-pushed the fix-readjson-regular-files branch from e745887 to 48a3200 Compare August 26, 2026 12:05
@rst0git
rst0git requested a review from kolyshkin August 26, 2026 12:06
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