Skip to content

chore(security): make shell=False invariant explicit in sandboxed E2E subprocesses - #700

Closed
seonghobae wants to merge 3 commits into
mainfrom
sentinel-fix-b603-command-injection-11513872304597016254
Closed

chore(security): make shell=False invariant explicit in sandboxed E2E subprocesses#700
seonghobae wants to merge 3 commits into
mainfrom
sentinel-fix-b603-command-injection-11513872304597016254

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • explicitly pass shell=False to the sandboxed web E2E helper’s Popen and run calls
  • pin that invariant in unit tests
  • narrowly acknowledge Bandit B603 at the reviewed call sites

Security assessment

This is defense-in-depth and regression hardening, not remediation of an active shell-injection vulnerability: Python already defaults these calls to shell=False, the command is parsed into an argv list with shlex.split, and no shell executable is supplied. The explicit keyword and tests make that boundary visible and harder to regress during later refactoring.

The helper still intentionally executes the requested argv inside its existing sandbox boundary; this change does not claim that shell=False alone makes arbitrary executables trustworthy.

Validation

  • target tests retain 100% line coverage
  • Bandit accepts the narrowly documented B603 suppressions
  • no runtime behavior changes beyond making the existing default explicit

Summary by CodeRabbit

  • 보안

    • 외부 명령 실행 시 셸 사용을 명시적으로 비활성화해 보안을 강화했습니다.
    • 명령 인자를 안전하게 분리해 실행하도록 관련 지침을 보완했습니다.
  • 테스트

    • 프로세스 실행 시 보안 설정이 정확히 적용되는지 검증하도록 테스트를 개선했습니다.
  • 문서

    • 정적 분석 경고 대응 및 안전한 명령 실행 방법을 문서화했습니다.

- Explicitly pass `shell=False` to `subprocess.run` and `subprocess.Popen` in `scripts/ci/sandboxed_web_e2e.py`.
- Suppress Bandit B603 warning with `# nosec B603` now that the arguments are parsed via `shlex.split` and `shell=False` is explicit.
- Update tests in `tests/test_sandboxed_web_e2e.py` to assert the explicit presence of the `shell=False` keyword argument.
- Add a critical learning entry to `.jules/sentinel.md` regarding securely satisfying the Bandit B603 warning while preventing command injections.
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

subprocess 호출에 shell=False# nosec B603을 명시했습니다. 관련 테스트는 명시적 옵션을 검증하도록 변경했습니다. Bandit B603 대응 지침을 추가했습니다.

Changes

subprocess 실행 안전성

Layer / File(s) Summary
subprocess 옵션 및 검증 갱신
scripts/ci/sandboxed_web_e2e.py, tests/test_sandboxed_web_e2e.py, .jules/sentinel.md
서비스 시작과 E2E 명령 실행에 shell=False를 추가했습니다. 호출부에 # nosec B603을 추가했습니다. 테스트는 shell=False 설정을 검증합니다. 지침은 동일한 Bandit 대응 방식을 설명합니다.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 샌드박스 E2E subprocess 호출에 shell=False를 명시하는 주요 변경 사항을 정확하고 간결하게 설명합니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sentinel-fix-b603-command-injection-11513872304597016254

Comment @coderabbitai help to get the list of available commands.

@seonghobae
seonghobae enabled auto-merge (squash) August 3, 2026 00:57
@seonghobae seonghobae changed the title 🛡️ Sentinel: [MEDIUM] Fix command injection warning in sandboxed_web_e2e.py chore(security): make shell=False invariant explicit in sandboxed E2E subprocesses Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.


Your included review limit is currently reached under our Fair Usage Limits Policy. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 43 minutes.

- Explicitly pass `shell=False` to `subprocess.run` and `subprocess.Popen` in `scripts/ci/sandboxed_web_e2e.py`.
- Suppress Bandit B603 warning with `# nosec B603` now that the arguments are parsed via `shlex.split` and `shell=False` is explicit.
- Update tests in `tests/test_sandboxed_web_e2e.py` to assert the explicit presence of the `shell=False` keyword argument.
- Add a critical learning entry to `.jules/sentinel.md` regarding securely satisfying the Bandit B603 warning while preventing command injections.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
scripts/ci/sandboxed_web_e2e.py (1)

105-113: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

.jules/sentinel.md의 명령 실행 설명을 수정하세요.

shell=False는 셸 해석을 차단하고 shlex.split은 argv 토큰화만 수행합니다. --*-cmd 옵션은 호출자가 실행 프로그램을 지정하는 의도된 계약이므로, 허용 목록 부재를 자체 보안 결함으로 설명하지 마세요. shlex.split을 입력 검증이 아닌 argv 토큰화로 설명하세요.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/ci/sandboxed_web_e2e.py` around lines 105 - 113, 문서의 명령 실행 설명을 수정하세요.
.jules/sentinel.md 38-41에서는 shell=False가 셸 해석을 차단하고 shlex.split이 입력 검증이 아닌 argv
토큰화만 수행한다고 설명하며, --*-cmd가 호출자가 실행 프로그램을 지정하는 의도된 계약임을 명시하고 허용 목록 부재를 보안 결함으로
기술하지 마세요. scripts/ci/sandboxed_web_e2e.py 105-113 및 141-150은 Popen 호출의 동작을 보여주는
근거 사이트이므로 직접 변경하지 마세요.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@scripts/ci/sandboxed_web_e2e.py`:
- Around line 105-113: 문서의 명령 실행 설명을 수정하세요. .jules/sentinel.md 38-41에서는
shell=False가 셸 해석을 차단하고 shlex.split이 입력 검증이 아닌 argv 토큰화만 수행한다고 설명하며, --*-cmd가
호출자가 실행 프로그램을 지정하는 의도된 계약임을 명시하고 허용 목록 부재를 보안 결함으로 기술하지 마세요.
scripts/ci/sandboxed_web_e2e.py 105-113 및 141-150은 Popen 호출의 동작을 보여주는 근거 사이트이므로
직접 변경하지 마세요.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: cacb3bed-02eb-411b-b051-4b7293f23197

📥 Commits

Reviewing files that changed from the base of the PR and between 5983b41 and dd2b57c.

📒 Files selected for processing (3)
  • .jules/sentinel.md
  • scripts/ci/sandboxed_web_e2e.py
  • tests/test_sandboxed_web_e2e.py

Copy link
Copy Markdown
Contributor Author

Closing as redundant defense-in-depth during a constrained central-check queue. Python already executes these reviewed argv lists with shell=False by default, and this PR explicitly states there is no active shell-injection defect or runtime behavior change. The additional keyword, suppressions, and tests do not justify another full privileged-workflow review cycle ahead of the current security, coverage, and merge-throughput fixes.

@seonghobae seonghobae closed this Aug 3, 2026
auto-merge was automatically disabled August 3, 2026 03:57

Pull request was closed

@google-labs-jules

Copy link
Copy Markdown

Closing as redundant defense-in-depth during a constrained central-check queue. Python already executes these reviewed argv lists with shell=False by default, and this PR explicitly states there is no active shell-injection defect or runtime behavior change. The additional keyword, suppressions, and tests do not justify another full privileged-workflow review cycle ahead of the current security, coverage, and merge-throughput fixes.

Understood. Acknowledging that this PR has been closed and stopping work on this task.

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.

1 participant