Skip to content

Fix shadow cache path resolution with host_root#42

Merged
jserv merged 1 commit intomainfrom
shadow-cache-path
Apr 1, 2026
Merged

Fix shadow cache path resolution with host_root#42
jserv merged 1 commit intomainfrom
shadow-cache-path

Conversation

@jserv
Copy link
Copy Markdown
Contributor

@jserv jserv commented Apr 1, 2026

ensure_path_shadow_cache and reopen_cached_shadow_fd called open() on guest-relative paths (host_root prefix already stripped by kbox_translate_path_for_lkl), resolving against the supervisor's real root instead of host_root. Read-only sandbox escape when host_root is set: guest opens /etc/passwd, supervisor opens the host's /etc/passwd rather than host_root/etc/passwd.

Add build_host_open_path() that re-prefixes ctx->host_root before open(). In pure image mode (no host_root) the helper is a passthrough.

Change-Id: I9957ce0127bc733b1013fe2ee04e0654635d8ba9


Summary by cubic

Fixes path resolution when host_root is set so shadow cache opens files under host_root instead of the supervisor’s real root. Prevents a read-only sandbox escape (e.g., /etc/passwd resolving to the host).

  • Bug Fixes
    • Added build_host_open_path() to prefix ctx->host_root before open().
    • Updated ensure_path_shadow_cache and reopen_cached_shadow_fd to use it; passthrough when no host_root.

Written for commit 0000933. Summary will update on new commits.

ensure_path_shadow_cache and reopen_cached_shadow_fd called open() on
guest-relative paths (host_root prefix already stripped by
kbox_translate_path_for_lkl), resolving against the supervisor's real
root instead of host_root.  Read-only sandbox escape when host_root is
set: guest opens /etc/passwd, supervisor opens the host's /etc/passwd
rather than host_root/etc/passwd.

Add build_host_open_path() that re-prefixes ctx->host_root before
open().  In pure image mode (no host_root) the helper is a passthrough.

Change-Id: I9957ce0127bc733b1013fe2ee04e0654635d8ba9
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@jserv jserv merged commit 5933bc4 into main Apr 1, 2026
6 checks passed
@jserv jserv deleted the shadow-cache-path branch April 1, 2026 08:49
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