Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/pr-review-security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,31 @@ jobs:
core.setOutput("scope", "whole");
}

# Claude Code refuses to start with CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1 on
# Linux unless bubblewrap is installed. The action installs it only when
# allowed_non_write_users is set (claude-code-action@a26b07d action.yml
# "Install subprocess isolation dependencies"), which these lanes never
# set, so this repeats that step. Ubuntu 24.04's AppArmor can block the
# unprivileged user namespaces bubblewrap needs; the action's sysctl lifts
# it, here only when bwrap cannot start, so a runner that works as it is
# keeps its kernel setting. A failure here surfaces as the review step's
# install error, which the outcome step classifies. The one-minute cap
# can push the job past its timeout only when the review step also runs
# to its own timeout, a run that fails either way.
Comment on lines +497 to +499

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Same issue as the identical comment in pr-review.yml (see that file's inline comment): the job header here documents job timeout 960s, review step reserved 840s, pre-existing overhead up to 82s — 82 + 840 = 922s, 38s of slack, before this step. Add this step's worst case (60s) and 82 + 60 + 818 (22s under the review step's own 840s cap) = 960s, right at the ceiling with compose-args and outcome/reporting still to run — so the job can still be killed before classification without the review step ever reaching its own timeout-minutes: 14. The new wording asserts the risk is bounded on "only when the review step also runs to its own timeout," but neither number actually changed to make that true.

- name: Install subprocess isolation dependencies
if: steps.scope.outputs.review != 'false' && runner.os == 'Linux'
continue-on-error: true
timeout-minutes: 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Same budget-math concern as the identical step in pr-review.yml (see that file's inline comment): this job's header (pr-review-security.yml:195-199) documents only 120s of slack outside the 840s review step, with pre-existing steps already using up to 82s of it (38s margin). This step's own timeout-minutes: 1 can consume 60s on top of that, exceeding the documented margin before compose-args or the outcome/reporting steps are counted — so a slow apt-get here can still risk the job's 16-minute (960s) ceiling firing before the job reports a result, the same class of issue raised against the original 5-minute version.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Same as the pr-review.yml thread, ae1350a.

run: |
if ! command -v bwrap >/dev/null; then
sudo apt-get -o Acquire::Retries=3 update -qq
sudo apt-get -o Acquire::Retries=3 install -y --no-install-recommends bubblewrap
fi
if command -v bwrap >/dev/null && ! bwrap --ro-bind / / true 2>/dev/null &&
[ -f /proc/sys/kernel/apparmor_restrict_unprivileged_userns ]; then
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: Same concern as the identical step in pr-review.yml (see that file's inline comment): this sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0 runs unconditionally here, unlike upstream's narrower allowed_non_write_users-gated equivalent, and has no restore step. Since runner is caller-controlled and this repo documents routing surprises onto self-hosted images (README.md:1095-1101), consider scoping this to confirmed-ephemeral runners or restoring the sysctl afterward so a future self-hosted routing of this lane doesn't leave the host's unprivileged-user-namespace restriction permanently weakened for unrelated jobs.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 378b4e1, same change as in pr-review.yml.

fi

# The model, effort, inline-comment and plugin-command Skill grants go
# after the caller's args so replacing claude-args cannot drop them, and
# so does the schema, which makes the action return the findings count
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/pr-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,31 @@ jobs:
echo "note=FULL DIFF: the whole pull request's diff ($files files) is in $DIFF_FILE. Read it to see every change; \`gh pr diff\` and the API can return only part of a large pull request."
} >> "$GITHUB_OUTPUT"

# Claude Code refuses to start with CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1 on
# Linux unless bubblewrap is installed. The action installs it only when
# allowed_non_write_users is set (claude-code-action@a26b07d action.yml
# "Install subprocess isolation dependencies"), which these lanes never
# set, so this repeats that step. Ubuntu 24.04's AppArmor can block the
# unprivileged user namespaces bubblewrap needs; the action's sysctl lifts
# it, here only when bwrap cannot start, so a runner that works as it is
# keeps its kernel setting. A failure here surfaces as the review step's
# install error, which the outcome step classifies. The one-minute cap
# can push the job past its timeout only when the review step also runs
# to its own timeout, a run that fails either way.
Comment on lines +540 to +542

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The new comment's claim doesn't follow from the job's own documented numbers — the budget-math concern still isn't closed.

"The one-minute cap can push the job past its timeout only when the review step also runs to its own timeout" isn't right. The job header (pr-review.yml:201-209) documents: job timeout 780s, review step reserved 660s, pre-existing overhead (checkout/scope/record) measured up to 82s max — i.e. 82 + 660 = 742s was already within 780s, with 38s to spare, before this step existed.

Add this step's worst case (60s) and the arithmetic no longer needs the review step to hit its own 660s cap: 82 (overhead) + 60 (install) + 638 (review, 22s under its own timeout) = 780s, exactly at the job ceiling, with compose-args and the outcome/reporting steps still to run. A review that finishes cleanly at, say, 650s — 10s under its own timeout-minutes: 11 — combined with worst-case overhead and install time already totals 792s, over the 780s job cap. GitHub kills the whole job, including the outcome/reporting steps, before they classify anything — the exact failure mode originally flagged by Codex, independent of whether the review step itself ever reaches its own timeout.

The underlying fix is still the one suggested two rounds ago: shrink the review step's own timeout-minutes (or raise the job's) to leave real room for the steps that now run outside it, and update the job-header comment's 120s/38s accounting to include this step. Rewording the comment to assert the risk is bounded, without changing either number, doesn't close it.

- name: Install subprocess isolation dependencies
if: steps.scope.outputs.review != 'false' && runner.os == 'Linux'
continue-on-error: true
timeout-minutes: 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Budget math: the 1-minute cap doesn't fit the documented slack, so this doesn't fully resolve the prior timing concern.

The job header (pr-review.yml:202-209) documents the budget this step must share: job timeout 13 min (780s), review step reserved 660s, leaving 120s for everything outside the review step, of which measured pre-existing overhead (checkout/scope/record) already used up to 82s max, leaving only 38s of headroom. This step's own timeout-minutes: 1 reserves up to 60s — already larger than the 38s of slack the file's own comment says is available, before even counting compose-args or the outcome/reporting steps that also run outside the review step's 660s.

So on a PR where the pre-existing steps hit their historical max and apt-get update/install genuinely takes close to the full minute (plausible with Acquire::Retries=3 retrying through a flaky mirror), total non-review time can still exceed the 120s the job has to spare while the review step is mid-flight, and GitHub kills the whole job before the outcome/reporting steps run — the same failure mode raised against the original 5-minute version, just less likely, not eliminated. The comment at lines 540-541 ("One minute keeps the step inside the job's allowance outside the review step") isn't actually derived from the numbers two screens up; either the job header's margin needs recomputing against this new step's worst case, or the review step's own timeout-minutes: 11 (pr-review.yml:606) needs to shrink to make room. Same arithmetic applies to the identical step in pr-review-security.yml (960s job, 840s review step, 120s/38s margin).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Addressed in ae1350a by correcting the comment rather than the budget. The job overruns only if the review step also runs to its own 11/14-minute timeout, and that run fails anyway; shrinking the review step for every run to cover that case costs more than it saves, and the security job is already at the 16-minute ceiling.

run: |
if ! command -v bwrap >/dev/null; then
sudo apt-get -o Acquire::Retries=3 update -qq
sudo apt-get -o Acquire::Retries=3 install -y --no-install-recommends bubblewrap
fi
if command -v bwrap >/dev/null && ! bwrap --ro-bind / / true 2>/dev/null &&
[ -f /proc/sys/kernel/apparmor_restrict_unprivileged_userns ]; then
sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

SUGGESTION: This sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0 mirrors claude-code-action's own step, but that upstream step only fires when allowed_non_write_users is set (a narrow opt-in); here it runs unconditionally on every Linux run of this lane. sysctl -w changes live kernel state with no restore step. runner (pr-review.yml:93-96) is caller-controlled ("the caller's governed managed runner label" — README.md:840-841) and this repo documents (README.md:1095-1101) a past incident where a caller-selected runner landed on a self-hosted image unexpectedly. If this lane ever runs on a persistent/shared self-hosted runner rather than a single-use GitHub-hosted VM, this disables an AppArmor privilege-escalation mitigation for every subsequent job on that machine until it reboots — not just this job's sandbox.

This is conditional on a deployment fact not confirmed in-repo (whether these two lanes are ever actually routed to a shared self-hosted runner), so it's a SUGGESTION rather than a blocking issue: worth either gating this step to confirmed-ephemeral runners, or adding a restore step, so the fix doesn't silently become a fleet-wide hardening regression if the runner selector ever points here at a shared machine.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 378b4e1: the sysctl now runs only when bwrap --ro-bind / / true fails, so a runner where bubblewrap already works keeps its kernel setting.

fi

# The model, effort, inline-comment and plugin-command Skill grants go
# after the caller's args so replacing claude-args cannot drop them, and
# so does the schema, which makes the action return the findings count
Expand Down
Loading