Skip to content

feat(validator): reject null bytes in mount fields during spec validation - #3633

Open
tkshsbcue wants to merge 1 commit into
youki-dev:mainfrom
tkshsbcue:fix/validate-mount-null-bytes
Open

feat(validator): reject null bytes in mount fields during spec validation#3633
tkshsbcue wants to merge 1 commit into
youki-dev:mainfrom
tkshsbcue:fix/validate-mount-null-bytes

Conversation

@tkshsbcue

Copy link
Copy Markdown
Contributor

Summary

Fixes #3591.

When a mount string field (destination, source, type, or an entry in options) contains an interior null byte (\0), the value was passed unchanged all the way down to the mount(2) syscall. The kernel then rejects it with a generic EINVAL, producing a cryptic error that gives no indication of which mount or field is at fault.

Changes

  • Add Validator::validate_spec_for_mounts, wired into Validator::validate_spec, which scans every mount's destination, source, type, and options for an interior null byte and returns a clear error early during spec validation.
  • Add ErrInvalidSpec::MountContainsNullByte { field, value } so the error names the offending field and value.

Because validate_spec runs on both the create and exec (tenant) paths, invalid mounts are now rejected up front with an actionable message instead of failing late at the syscall level.

Tests

Added unit tests covering a null byte in each of destination, source, type, and options, plus the happy path (clean mounts) and the no-mounts case.

…tion

Mount string fields (destination, source, type, options) containing an
interior null byte (`\0`) were passed unchanged down to the `mount(2)`
syscall, where the kernel rejects them with a generic `EINVAL`, producing
a cryptic error that does not indicate which mount or field is at fault.

Validate these fields early in `Validator::validate_spec` and return a
clear `MountContainsNullByte` error naming the offending field and value.
This runs on both the create and exec (tenant) paths.

Fixes: youki-dev#3591
@nayuta723

Copy link
Copy Markdown
Contributor

@tkshsbcue
Please check DCO.

@saku3

saku3 commented Jul 13, 2026

Copy link
Copy Markdown
Member

I do not think validation needs to be this strict.

If we make any changes here, I feel that improving the error message would be sufficient.

There is also a comment like the following, so I think it is reasonable to be cautious about adding more validation:

opencontainers/runc#5320 (comment)

@tkshsbcue

Copy link
Copy Markdown
Contributor Author

alright i will have a look into this!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Validate mount options for null bytes (\u0000) early to provide clearer error messages

3 participants