Skip to content

fix(graphql): path traversal in GetChaosFault (#5606) - #5610

Open
Kanika0306 wants to merge 1 commit into
litmuschaos:masterfrom
Kanika0306:fix/path-traversal-5606
Open

fix(graphql): path traversal in GetChaosFault (#5606)#5610
Kanika0306 wants to merge 1 commit into
litmuschaos:masterfrom
Kanika0306:fix/path-traversal-5606

Conversation

@Kanika0306

Copy link
Copy Markdown

Proposed changes

Fixes #5606

Summary of Changes:

  • Path Containment Check: Implemented isSubPath(baseDir, targetPath string) bool helper using standard Go filepath.Clean and filepath.Rel in chaoscenter/graphql/server/pkg/chaoshub/service.go.
  • Root Directory Enforcement: Updated GetChaosFault to clean the ChaosHub faults directory path (cleanHubPath) and ensure basePath, csvPath, enginePath, and faultPath cannot escape cleanHubPath.
  • Safe Rejection: Rejects any path traversal attempt (such as ../../../etc, pod-delete/../../etc, or absolute paths) with error invalid path: path traversal detected.
  • Unit Tests: Added regression tests in chaoscenter/graphql/server/pkg/chaoshub/service_test.go covering:
    • Legitimate category & experiment path resolution
    • Relative path traversal (../../../etc)
    • Nested path traversal (pod-delete/../../etc)
    • Containment-prefix manipulation (../../test-hub-other/faults/pod-delete)
    • Absolute path resolution

Types of changes

What types of changes does your code introduce to Litmus? Put an x in the boxes that apply

  • New feature (non-breaking change which adds functionality)
  • Bugfix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices applies)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING doc
  • I have signed the commit for DCO to be passed.
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have added necessary documentation (if appropriate)

Dependency

  • None

Special notes for your reviewer:

  • Uses Go standard library primitives (path/filepath) for path resolution and containment checking without adding external dependencies.
  • Verified locally with gofmt and go test -v . in chaoscenter/graphql/server/pkg/chaoshub.

Signed-off-by: Kanika0306 <kanikakatare0306@gmail.com>
Copilot AI lite review requested due to automatic review settings August 27, 2026 05:37

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Kanika0306

Copy link
Copy Markdown
Author

@torumakabe
could you review this pr
Thankyou!

@Kanika0306

Copy link
Copy Markdown
Author

@PriteshKiri
kindly review

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.

seclog: path traversal in chaos hub fault lookups (GetChaosFault)

2 participants