Skip to content

fix(network): prevent path traversal in network interface name#118

Merged
JanZachmann merged 1 commit intoomnect:mainfrom
JanZachmann:fix/clippy-ci
Apr 8, 2026
Merged

fix(network): prevent path traversal in network interface name#118
JanZachmann merged 1 commit intoomnect:mainfrom
JanZachmann:fix/clippy-ci

Conversation

@JanZachmann
Copy link
Copy Markdown
Contributor

@JanZachmann JanZachmann commented Apr 8, 2026

Summary

  • Validate network interface name field against path traversal (../, /) before using it in filesystem path construction
  • Uses Path::file_name() to ensure the name is a plain filename with no directory components
  • Adds 4 regression tests covering traversal, absolute paths, .., and valid names
  • Bumps version to 1.2.2

Reason

The network_config_file! macro builds paths like /network/10-{name}.network directly from user input. A crafted name containing ../ could write systemd-networkd config files outside the /network/ directory.

Validate that the network interface name contains no path separators
before using it in filesystem operations. Without this check, a crafted
name like "../etc/foo" could write systemd-networkd config files outside
the /network/ directory.

Signed-off-by: Jan Zachmann <50990105+JanZachmann@users.noreply.github.com>
@JanZachmann JanZachmann merged commit 2e069a1 into omnect:main Apr 8, 2026
1 check passed
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.

1 participant