Skip to content

Security issue: unsafe json string in pulling job's annotations; unsa… - #251

Merged
cheyang merged 4 commits into
sgl-project:mainfrom
diw-zw:security/path-check
Apr 1, 2026
Merged

cheyang merged 4 commits into
sgl-project:mainfrom
diw-zw:security/path-check

Conversation

@diw-zw

@diw-zw diw-zw commented Mar 28, 2026

Copy link
Copy Markdown
Collaborator

Fixed some security issues:

  1. Use a safer approach to generate JSON strings in the llm pull CLI tool code.
  2. Add validation for user-provided file paths in the benchmark dashboard handler.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request enhances security by implementing input validation for experiment and file names to prevent path traversal and strengthening the path safety utility with more robust prefix checking. Additionally, it refactors metadata generation to use standard JSON marshaling instead of manual string formatting. A review comment suggests that an explicit check for '..' in the path safety function is redundant and could be removed to simplify the implementation.

Comment thread cmd/cli/cmd/llm/benchmark/dashboard/handlers.go Outdated
@diw-zw

diw-zw commented Mar 30, 2026

Copy link
Copy Markdown
Collaborator Author

@cheyang Could you please review this PR. Thanks.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Addresses reported security concerns by hardening JSON generation for LLM pull job metadata and adding/strengthening path validation in the benchmark dashboard HTTP handlers.

Changes:

  • Replace manual JSON string construction in injectMetadataSave with json.Marshal for safer encoding.
  • Add isValidName validation for experiment/file path segments in dashboard routes.
  • Tighten isPathSafe with filepath.Clean and a separator-aware prefix check to reduce path traversal risk.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
cmd/cli/cmd/llm/pull.go Uses structured JSON marshaling for metadata payload instead of string formatting/escaping helpers.
cmd/cli/cmd/llm/pull_test.go Removes unit tests tied to the deleted jsonSafeString helper.
cmd/cli/cmd/llm/benchmark/dashboard/handlers.go Adds name validation and improves path safety checks for experiment/result/image access.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/cli/cmd/llm/pull.go
Comment thread cmd/cli/cmd/llm/benchmark/dashboard/handlers.go Outdated
Comment thread cmd/cli/cmd/llm/benchmark/dashboard/handlers.go
Comment thread cmd/cli/cmd/llm/benchmark/dashboard/handlers.go
Comment thread cmd/cli/cmd/llm/benchmark/dashboard/handlers.go
Comment thread cmd/cli/cmd/llm/pull.go
Comment thread cmd/cli/cmd/llm/benchmark/dashboard/handlers.go

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cmd/cli/cmd/llm/pull.go Outdated
Comment thread cmd/cli/cmd/llm/benchmark/dashboard/handlers.go
@diw-zw
diw-zw force-pushed the security/path-check branch from ee5b36f to c34612c Compare April 1, 2026 02:00
@diw-zw

diw-zw commented Apr 1, 2026

Copy link
Copy Markdown
Collaborator Author

@cheyang All discussions are resolved. Please review, thanks

@cheyang cheyang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

/lgtm
/approve

@cheyang
cheyang merged commit a02bbcb into sgl-project:main Apr 1, 2026
8 of 9 checks passed
@diw-zw
diw-zw deleted the security/path-check branch April 30, 2026 08:44
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.

3 participants