ci: harden workflows against shell injection - #18
Conversation
- sync-upstream.yml: escape VERSION in sed to prevent special char
injection, replace heredoc with echo block to avoid unquoted
variable expansion, quote gh pr create arguments
- release.yml: use shell variable ${VERSION} instead of
${{ env.VERSION }} in run block to prevent injection
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughUpdated GitHub Actions workflows to improve shell interpolation and safe substitution of the release version: added an escaped intermediate Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/release.yml:
- Line 43: The sed invocation that replaces version in pyproject.toml currently
interpolates ${VERSION} unescaped, which breaks if VERSION contains sed
metacharacters; before the sed -i "s/^version = \".*\"/version =
\"${VERSION}\"/" call, create an escaped variable (e.g., ESCAPED_VER) by piping
VERSION through printf and a sed that escapes &, / and \ (same approach used in
sync-upstream.yml), then use ${ESCAPED_VER} in the substitution so the sed
replacement is safe; keep the target file (pyproject.toml) and the surrounding
sed command names (VERSION, ESCAPED_VER) to locate and replace the line.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 569cc284-a6e8-41a8-a377-43873ea11ded
📒 Files selected for processing (2)
.github/workflows/release.yml.github/workflows/sync-upstream.yml
ChangelogAll notable changes to langchain-opendataloader-pdf will be documented in this file. Format follows Keep a Changelog. [Unreleased]Added
Changed
Fixed
[2.0.0] - 2026-03-26Added
Changed
[1.2.0] - 2025-12-15Changed
[1.1.0] - 2025-11-20Changed
[1.0.0] - 2025-10-01Added
|
1 similar comment
ChangelogAll notable changes to langchain-opendataloader-pdf will be documented in this file. Format follows Keep a Changelog. [Unreleased]Added
Changed
Fixed
[2.0.0] - 2026-03-26Added
Changed
[1.2.0] - 2025-12-15Changed
[1.1.0] - 2025-11-20Changed
[1.0.0] - 2025-10-01Added
|
Code ReviewThis is a well-motivated security hardening PR. The changes follow GitHub Security Lab guidance and improve the CI workflows. What is good
This is the most impactful fix. Interpolating
Good defense-in-depth. Escaping Echo block instead of heredoc Cleaner and removes ambiguity around heredoc delimiter quoting. The previous
Correct -- quotes prevent word splitting on the comma-separated label string. Issues and suggestions1. The version is already validated against 2. The unquoted form is actually correct here: when FLAGS=(--base main --label "${LABELS}")
[ "$STATUS_DRAFT" == "true" ] && FLAGS+=(--draft)
gh pr create --title "..." --body-file /tmp/pr-body.md "${FLAGS[@]}"3. Remaining unbraced A few occurrences were not updated:
Not a security issue given the semver validation, but inconsistent with the PR goal of using 4.
Test plan noteThe PR mentions running SummaryThe core fixes are correct and this is a net improvement to CI security posture. Main suggestions:
Happy to approve once those points are addressed or acknowledged. |
- Add defense-in-depth comment on ESCAPED_VER in both workflows
- Add comment explaining intentional DRAFT_FLAG unquote
- Consistent ${VERSION} braces across all shell references
- Apply ESCAPED_VER pattern to release.yml sed command
|
Addressed in aebeb41: 1. ESCAPED_VER defense-in-depth comment ✅ Added to both sync-upstream.yml and release.yml. 2. DRAFT_FLAG unquote comment ✅ Explains why it must remain unquoted. 3. Brace consistency ✅ All bare 4. release.yml sed escape ✅ Applied same ESCAPED_VER pattern as sync-upstream.yml. Skipped:
Independent sub-agent review confirmed all 5 checks PASS. |
Follow-up ReviewAll four action items from the previous review have been addressed in aebeb41:
The The PR is in good shape. No further blocking issues. |
Summary
$VERSIONin sed to prevent special character injection, replace heredoc with echo block to avoid unquoted variable expansion, quotegh pr createarguments with${}${VERSION}instead of${{ env.VERSION }}inrun:block to prevent injectionContext
Security audit of CI workflows found that
$VERSION(derived from git tags or workflow inputs) was used unescaped insedpatterns and unquoted in shell commands. While git tags are typically controlled, this pattern is vulnerable to special characters (/,&,\) breaking or exploitingsedcommands.${{ env.VERSION }}inrun:blocks is a known shell injection vector per GitHub Security Lab guidance. Using shell variables (${VERSION}) fromenv:blocks is the safe pattern.Test plan
actionlint .github/workflows/*.ymlpassessync-upstream.ymlviaworkflow_dispatchwith a test versionrelease.ymlbuilds correctly on manual triggerSummary by CodeRabbit
Note: This release contains internal infrastructure updates with no user-facing feature changes.