Skip to content

Validate file paths in ReadFile and sanitize HTML in process table#3864

Open
mohammadmseet-hue wants to merge 1 commit intogoogle:masterfrom
mohammadmseet-hue:fix-filepath-validation-and-html-sanitization
Open

Validate file paths in ReadFile and sanitize HTML in process table#3864
mohammadmseet-hue wants to merge 1 commit intogoogle:masterfrom
mohammadmseet-hue:fix-filepath-validation-and-html-sanitization

Conversation

@mohammadmseet-hue
Copy link
Copy Markdown

Summary

  • manager/container.go: After path.Join resolves the file path in ReadFile, verify the result stays within the expected container root prefix. This prevents ../ sequences in the input from resolving to paths outside the intended directory.

  • cmd/internal/pages/assets/js/containers.js: Add escapeHtml() helper and apply it to all string fields (user, start_time, status, running_time, cmd, cgroup_path) rendered in the process listing table where allowHtml: true is set. The cgroup link href is also wrapped with encodeURI().

Test plan

  • go build ./... passes (verified locally)
  • Confirm ReadFile rejects paths containing ../ that escape the container root
  • Confirm process table renders correctly with the escapeHtml wrapper
  • Confirm cgroup links still work in the root container view

🤖 Generated with Claude Code

@google-cla
Copy link
Copy Markdown

google-cla bot commented Apr 11, 2026

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.

…table

- manager/container.go: Verify that the resolved file path in ReadFile stays
  within the expected container root prefix after path.Join normalization.
- containers.js: Add escapeHtml() to sanitize string values rendered in the
  process listing table where allowHtml is enabled, and use encodeURI for
  the cgroup link href.
@mohammadmseet-hue mohammadmseet-hue force-pushed the fix-filepath-validation-and-html-sanitization branch from fbf6404 to 03255bf Compare April 11, 2026 16:58
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