Repository navigation
fix: Prevent path traversal via webhook head commit SHA - #942
Merged
Merged
Conversation
Signed-off-by: Tetiana Naumenko <t.naumenko@samsung.com>
t-naumenko
marked this pull request as ready for review
October 13, 2026 10:46
t-naumenko
requested review from
MoonkiHong,
o-kopysov,
tdrozdovsky and
tiokim
as code owners
October 13, 2026 10:46
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #942 +/- ##
============================================
+ Coverage 94.02% 94.11% +0.08%
- Complexity 443 456 +13
============================================
Files 30 30
Lines 1841 1869 +28
Branches 236 243 +7
============================================
+ Hits 1731 1759 +28
Misses 48 48
Partials 62 62 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…mage Signed-off-by: Tetiana Naumenko <t.naumenko@samsung.com>
o-kopysov
self-requested a review
October 14, 2026 07:55
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Description
The
pull_request.head.shavalue from GitHub webhook payloads was stored without validation and appended to file system paths with string concatenation (~/LPVS/Projects/<repo>/<id>-<sha>).LPVSFileUtil.saveGithubDiffsthen recursively deleted that path, recreated it and wrote the pull request files into it. A sender with a valid webhook signature could set the SHA to a traversal string such asx/../../../../etc/cron.dto delete and create directories and write files anywhere the JVM user can write. The official Docker image ran the JVM as root, so this extended to the whole container file system. The repository name, taken from the last segment ofrepository.html_url, could similarly be...Changes:
LPVSPayloadUtil): the head commit SHA must be 40 (SHA-1) or 64 (SHA-256) hexadecimal characters; the repository owner and name must contain onlyA-Z a-z 0-9 . _ -and must not be.or... Invalid webhooks are rejected with400 Bad Requestand are not saved, queued or reported to GitHub (GitHubController).LPVSFileUtil): newresolvePathInside(base, relative)resolves and normalizes paths and rejects any path outside the base directory. It is applied to the project directory, scan results directory and JSON file, and to PR file names written bysaveFileToDisk. This also protects queue entries already stored in the database and any future input source.HtmlUtils.htmlEscapefrom the scan results file name: it never protected against path traversal (/and.are not escaped).lpvs(uid 10001) andUSER lpvs. Python and SCANOSS stay installed as root and are read-only for the application. The working directory/home/lpvs/LPVSis pre-created and owned bylpvs, so Docker volumes mounted there are writable by the application.Single scan (
/scan) and CLI modes take the SHA from the GitHub API and are covered by the path containment check.Fixes GHSA-66xf-749c-4648
Type of change
Upgrade notes:
lpvs(uid 10001); its working directory moved from/root/LPVSto/home/lpvs/LPVS(and the thin launcher dependency cache from/root/.m2to/home/lpvs/.m2). This directory holds only temporary files of the running scan, and the provided docker-compose files do not mount it, so no migration is needed. Docker volumes mounted at/home/lpvs/LPVSwork out of the box; host directories (bind mounts) must be writable by uid 10001.400 Bad Request. Payloads sent by GitHub are not affected.Testing
LPVSPayloadUtilTest: valid SHA-1, SHA-256 and uppercase SHAs are accepted; traversal, wrong-length and non-hex SHAs and invalid repository URLs (..,., spaces, missing owner) are rejected.LPVSFileUtilTest:resolvePathInsideaccepts paths inside the base directory and rejects.., absolute paths, the base directory itself and sibling directories with the same name prefix; directory paths with a traversal SHA or..repository name are rejected;saveFileToDiskrejects../file names; end-to-endsaveGithubDiffstest with a traversal SHA verifies that a directory outside the sandbox is not deleted and no file is written into it.GitHubControllerTest: a correctly signed webhook with a traversal SHA returns 400 with no repository, GitHub or queue interactions.mvn verify— 332 tests, 0 failures. All changed lines inLPVSPayloadUtil,LPVSFileUtilandGitHubControllerare covered (JaCoCo).google-java-format 1.20.0with the workflow flags reports no changes.lpvs(uid 10001), can write to~/LPVS, and cannot write to/etc/cron.d,/root, Pythonsite-packages,/usr/local/binorlpvs.jar. A CLI single scan (singlescanprofile, network disabled) started successfully aslpvsand created its project and results directories without permission errors.Test Configuration:
maven:3.9-eclipse-temurin-17)main)Checklist: