fix: ground repository CI docs in checked-out config#396
fix: ground repository CI docs in checked-out config#396Ben Younes (ousamabenyounes) wants to merge 2 commits into
Conversation
ed7ddb8 to
90ddbef
Compare
There was a problem hiding this comment.
A symlink traversal vulnerability in the CI context loader allows a malicious repository to exfiltrate arbitrary local files by placing a symlink named .gitlab-ci.yml or bitbucket-pipelines.yml pointing to a sensitive path; the symlink target is read and injected into the LLM prompt.
90ddbef to
44129a5
Compare
|
Thanks, this was a valid finding. I fixed it in the latest push by switching direct CI path discovery from stat() to lstat(), ignoring symlinks before any readFile() call, and adding a realpath() containment check for normal files. I also added a regression test that creates a .gitlab-ci.yml symlink to a temp secret outside the repo and verifies the secret never appears in ciSummary. |
44129a5 to
150cfb3
Compare
There was a problem hiding this comment.
The .github/workflows directory is read without an lstat check on the directory itself, allowing a repository-supplied symlink at that path to redirect readdir() outside the repo and expose arbitrary YAML files to the LLM prompt; the protections applied to direct CI files (.gitlab-ci.yml, bitbucket-pipelines.yml) are not extended to this code path.
|
Rebased on latest main and addressed the Corridor finding about symlinked .github/workflows directories.\n\nValidation after the fix:\n- Corridor Review: passing\n- pnpm run format:check: passing\n- pnpm run lint:check: passing\n- pnpm run typecheck: passing\n- pnpm test: 51 files passed, 613 tests passed\n- pnpm run build: passing\n- OPENWIKI_DEV=1 node dist/cli.js code --dry-run --init: passing |
Summary
.gitlab-ci.yml,bitbucket-pipelines.yml, or.github/workflowsFixes #389
Why this is not prompt-only
The prompt instruction is now a secondary guard. The runtime also reads the checked-out CI files before the LLM run and injects their contents into the user prompt as repository automation context, so the agent receives the repo's actual workflow provider/model values without needing to decide to inspect those files first.
Security note
Direct root CI config paths and the
.github/workflowsdirectory are checked withlstat()before reading, so symlinks are ignored. Normal files and workflow directories are also checked withrealpath()to ensure their resolved path remains inside the repository root before their contents can be injected into the LLM prompt.Test verification (RED → GREEN)
RED on upstream-base behavior with the prompt regression test:
RED with the deterministic CI-context patch reverted, leaving only the earlier prompt-only change:
RED with only the CI-context cap/lookup code reverted while keeping the expanded tests:
RED for Corridor's symlink exfiltration finding before the
lstat()fix:RED for Corridor's symlinked GitHub workflows directory finding before the directory
lstat()/realpath()fix:GREEN with the full fix:
Full local verification: