Skip to content

Reject mount destination path traversal - #298

Draft
AliAltivate wants to merge 1 commit into
google:masterfrom
AliAltivate:agent/mount-destination-traversal
Draft

Reject mount destination path traversal#298
AliAltivate wants to merge 1 commit into
google:masterfrom
AliAltivate:agent/mount-destination-traversal

Conversation

@AliAltivate

Copy link
Copy Markdown

Summary

Reject mount destinations containing .. path components in both the legacy and new mount APIs.

Security impact

MountPt.dst is documented as the mount point inside the jail, but the legacy path-based implementation and the new openat-based implementation accepted traversal components. A crafted mount configuration such as tmp/../../outside_marker could resolve outside the jail root. With a non-mandatory src_content mount, this allowed a file to be written outside the root while nsjail continued successfully.

The issue was reproduced locally in a privileged container built from this repository. The same probe affected both mount implementations.

Fix

  • Add a shared mount-destination validator.
  • Reject .. components before path or mount side effects in both APIs.
  • Add focused regression checks for both legacy and new mount modes.

Validation

  • Clean build with -Wall -Wextra -Werror.
  • Pre-fix escape reproduced in both APIs.
  • Post-fix escape blocked in both APIs.
  • Existing true/false sanity checks continue to pass.
  • git diff --check passes.

This change intentionally preserves existing handling of other destination components and is limited to preventing lexical path traversal.

@google-cla

google-cla Bot commented Aug 2, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

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