forked from vibemafiaclub/vooster-v2-mvp
-
Notifications
You must be signed in to change notification settings - Fork 0
๐ก๏ธ Sentinel: [CRITICAL] ๊ฒฝ๋ก ํ์ ์ทจ์ฝ์ ์์ #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
seonghobae
wants to merge
1
commit into
main
Choose a base branch
from
fix-path-traversal-gherkin-14294950985736443331
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| ## 2024-06-09 - Path Traversal Vulnerability in `exportGherkin` | ||
| **Vulnerability:** The `--output` argument in `vspec export gherkin` does not sanitize the `output` file path. It is concatenated with the config root directly (`join(config.root, output)`). | ||
| **Learning:** This allows an attacker to provide a path like `../../../../etc/passwd` to write Gherkin export data to unauthorized locations outside the project directory. | ||
| **Prevention:** Implement strict input validation on constructed paths to verify they remain within the expected directory bounds. Use `path.resolve` and check if the resolved relative path starts with `..` or is an absolute path. |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,23 @@ | ||
| import { readFileSync } from "node:fs"; | ||
| import { join } from "node:path"; | ||
| import { describe, expect, it } from "vitest"; | ||
| import { renderGherkin } from "../src/export/gherkin.js"; | ||
| import { renderGherkin, exportGherkin } from "../src/export/gherkin.js"; | ||
| import { parseUseCaseMarkdown } from "../src/format/parse.js"; | ||
| import { VspecError } from "../src/errors.js"; | ||
|
|
||
| describe("gherkin export", () => { | ||
| it("renders the golden feature byte-for-byte", () => { | ||
| const useCase = parseUseCaseMarkdown(readFileSync(join(import.meta.dirname, "fixtures/export/VSPEC-010-export-gherkin.md"), "utf8")); | ||
| const expected = readFileSync(join(import.meta.dirname, "fixtures/export/VSPEC-010.feature"), "utf8"); | ||
| expect(renderGherkin(useCase)).toBe(expected); | ||
| }); | ||
|
|
||
| it("prevents path traversal vulnerabilities", () => { | ||
| // VSPEC-001 is present in the mock project root (tests/fixtures/doctor/clean) so it would succeed | ||
| // if not for the traversal in the --output path. | ||
| const cwd = join(import.meta.dirname, "fixtures/doctor/clean"); | ||
| expect(() => | ||
| exportGherkin({ key: "VSPEC-001", output: "../../../tmp/hacked.feature", cwd }) | ||
| ).toThrowError(new VspecError("INVALID_ARGUMENT", "Output path must be within the project root.")); | ||
| }); | ||
| }); |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๐งฉ Analysis chain
๐ Script executed:
Repository: Seongho-Bae/vooster-v2-mvp
Length of output: 141
๐ Script executed:
Repository: Seongho-Bae/vooster-v2-mvp
Length of output: 175
๐ Script executed:
Repository: Seongho-Bae/vooster-v2-mvp
Length of output: 5884
๐ Script executed:
Repository: Seongho-Bae/vooster-v2-mvp
Length of output: 12646
๐ Script executed:
Repository: Seongho-Bae/vooster-v2-mvp
Length of output: 2038
๐ Script executed:
Repository: Seongho-Bae/vooster-v2-mvp
Length of output: 11940
[๊ฒฝ๋ก ๊ฒ์ฆ ์ฐํ ๊ฐ๋ฅ์ฑ ๋ณด๊ฐ ํ์] src/export/gherkin.ts (43-47) ์
resolve + relative + (..)/isAbsolute๊ฒ์ฆ์ ๋ฌธ์์ด ๊ฒฝ๋ก ๊ฒฝ๊ณ๋ง ํ์ธํ๋ฏ๋ก,config.root๋ด๋ถ์ ์๋ ๋๋ ํฐ๋ฆฌ/๊ฒฝ๋ก ๊ตฌ์ฑ์์๊ฐ symlink์ผ๋ก ์ธ๋ถ๋ฅผ ๊ฐ๋ฆฌํค๋ ๊ฒฝ์ฐmkdirSync(dirname(outputPath))๋ฐwriteFileSync(outputPath, ...)๊ฐ ํ๋ก์ ํธ ๋ฃจํธ ๋ฐ์ ํ์ผ์ ์์ฑํ ์ ์์ต๋๋ค. ๋ํ ์ฝ๋๋ฒ ์ด์ค์์ ์ด ๊ฒฝ๋ก ๊ฒ์ฆ์realpathSync/realpath์ฒ๋ผ ์ค์ ๊ฒฝ๋ก( symlink ํด์ ) ๊ธฐ์ค์ผ๋ก ๋ค์ ํ์ธํ๋ ์ฒ๋ฆฌ๊ฐ ์์ต๋๋ค.fs.realpathSync()(๋๋ ์กด์ฌํ๋ ์์ ๊ฒฝ๋ก ๊ธฐ์ค์ผ๋ก realpath ํ)๋ก ์ค์ ๊ฒฝ๋ก๋ฅผ ๋น๊ตํ๊ฑฐ๋, ๊ฒฝ๋ก ์ธ๊ทธ๋จผํธ๋ณ๋กlstatSync๋ก symlink์ ์ฐจ๋จํ๋ ๋ฐฉ์์ผ๋ก ๋ณด์ํ์ธ์.๐ค Prompt for AI Agents