Skip to content

fix(security): Confirm repo-provided setup script before running#3804

Merged
charlesvien merged 1 commit into
mainfrom
fix/veria-353-repo-setup-script-consent
Jul 26, 2026
Merged

fix(security): Confirm repo-provided setup script before running#3804
charlesvien merged 1 commit into
mainfrom
fix/veria-353-repo-setup-script-consent

Conversation

@charlesvien

@charlesvien charlesvien commented Jul 24, 2026

Copy link
Copy Markdown
Member

Problem

Resolves VERIA-353: RCE via untrusted repository configuration.

Changes

Ask before running a repo-provided environment setup script, and stop silently auto-selecting the first repo-provided environment. The prompt is shown on every run rather than remembered: the script text does not determine what the command does, so a stored approval for npm run setup would still hold after the repository changed what that runs.

How did you test this?

Unit tests in @posthog/ui: the confirm gate returns the user's answer, prompts on every run, and warns that the script can execute other repository files; the selector never selects an environment on its own.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

@github-actions

github-actions Bot commented Jul 24, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit fd3a090.

@charlesvien
charlesvien marked this pull request as ready for review July 24, 2026 20:57
@charlesvien charlesvien changed the title confirm repo-provided setup script before running fix(security): Confirm repo-provided setup script before running Jul 24, 2026
Comment thread packages/ui/src/features/settings/settingsStore.ts Outdated
@greptile-apps

greptile-apps Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Comments Outside Diff (1)

  1. packages/core/src/task-detail/taskCreationHost.ts, line 121-127 (link)

    P2 Parallel setup approval system

    This models setup authorization as a custom host method backed by durable UI-store state, creating a second authorization system whose persistence, auditing, and cross-host behavior must be maintained separately from the established permission-tool flow.

    Context Used: CLAUDE.md (source)

    Knowledge Base Used:

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: packages/core/src/task-detail/taskCreationHost.ts
    Line: 121-127
    
    Comment:
    **Parallel setup approval system**
    
    This models setup authorization as a custom host method backed by durable UI-store state, creating a second authorization system whose persistence, auditing, and cross-host behavior must be maintained separately from the established permission-tool flow.
    
    **Context Used:** CLAUDE.md ([source](https://github.com/posthog/code/blob/main/CLAUDE.md))
    
    **Knowledge Base Used:**
    - [Shared foundation: `packages/shared`, `packages/core`, `packages/di`](https://app.greptile.com/posthog-org-19734/-/custom-context/knowledge-base/posthog/code/-/docs/shared-foundation.md)
    - [`@posthog/ui` shared UI package](https://app.greptile.com/posthog-org-19734/-/custom-context/knowledge-base/posthog/code/-/docs/ui-package.md)
    
    How can I resolve this? If you propose a fix, please make it concise.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
packages/core/src/task-detail/taskCreationHost.ts:121-127
**Parallel setup approval system**

This models setup authorization as a custom host method backed by durable UI-store state, creating a second authorization system whose persistence, auditing, and cross-host behavior must be maintained separately from the established permission-tool flow.

### Issue 2 of 2
packages/ui/src/features/task-detail/taskCreationHostImpl.ts:204
**Approval read precedes hydration**

This reads persisted approvals without checking `_hasHydrated`, so task creation during the desktop store's asynchronous hydration sees the initial empty map and unnecessarily prompts again for an already approved script.

Reviews (1): Last reviewed commit: "confirm repo-provided setup script befor..." | Re-trigger Greptile

@veria-ai

veria-ai Bot commented Jul 24, 2026

Copy link
Copy Markdown

PR overview

All previously flagged issues have been addressed. No open security concerns remain on this pull request.

Security review

No open security issues remain on this pull request.

Fixed/addressed: 1 · PR risk: 0/10

Comment thread packages/ui/src/features/task-detail/taskCreationHostImpl.ts Outdated
@charlesvien
charlesvien force-pushed the fix/veria-353-repo-setup-script-consent branch from 8ee7112 to bd00bef Compare July 24, 2026 21:21
@charlesvien
charlesvien force-pushed the fix/veria-354-mcp-sandbox-csp branch 2 times, most recently from 4fe2690 to 983fcb0 Compare July 24, 2026 21:38
@charlesvien
charlesvien force-pushed the fix/veria-353-repo-setup-script-consent branch from bd00bef to be5d307 Compare July 24, 2026 21:38
@charlesvien
charlesvien force-pushed the fix/veria-354-mcp-sandbox-csp branch from 983fcb0 to db731e4 Compare July 24, 2026 21:57
@charlesvien
charlesvien force-pushed the fix/veria-353-repo-setup-script-consent branch from be5d307 to 98953ce Compare July 24, 2026 21:57
@charlesvien
charlesvien force-pushed the fix/veria-354-mcp-sandbox-csp branch from db731e4 to ee998b2 Compare July 24, 2026 22:01
@charlesvien
charlesvien force-pushed the fix/veria-353-repo-setup-script-consent branch from 98953ce to 0f3f6db Compare July 24, 2026 22:01
@charlesvien
charlesvien force-pushed the fix/veria-354-mcp-sandbox-csp branch from ee998b2 to 9dd79b8 Compare July 24, 2026 22:12
@charlesvien
charlesvien force-pushed the fix/veria-353-repo-setup-script-consent branch from 0f3f6db to 2dd6bde Compare July 24, 2026 22:12
@charlesvien charlesvien added the Stamphog This will request an autostamp by stamphog on small changes label Jul 24, 2026
github-actions[bot]
github-actions Bot previously approved these changes Jul 24, 2026

@github-actions github-actions 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.

Security-sensitive fix (gating repo-provided setup script execution behind explicit confirmation), but both flagged review concerns are verifiably fixed in the diff — approval is keyed to the exact script text (re-prompts if the script changes, addressing veria-ai's reuse concern) and the hydration race greptile flagged is now guarded before reading persisted approvals — and a security-focused agent reviewer's latest comment confirms no open security concerns remain, giving independent assurance over the risky surface.

  • Author wrote 0% of the modified lines and has 19 merged PRs in these paths (familiarity MODERATE).
  • 👍 on the PR from greptile-apps[bot].
  • Greptile raised an unresolved architectural point (discussion comment) that this introduces a second, parallel authorization system alongside the existing permission-tool flow — a design concern worth follow-up, not a blocking defect.
Gate mechanics and policy version
Gate Result
prerequisites all clear
deny-list no deny categories matched
size 84L, 5F substantive, 260L/9F incl. docs/generated/snapshots — within ceiling
tier T1-agent / T1c-medium (260L, 9F, single-area, fix)
stamphog 2.0.0b3 .stamphog/policy.yml @ bf27356 · reviewed head 2dd6bde

@charlesvien
charlesvien force-pushed the fix/veria-354-mcp-sandbox-csp branch from 9dd79b8 to 120d2f2 Compare July 25, 2026 23:50
@charlesvien
charlesvien force-pushed the fix/veria-353-repo-setup-script-consent branch from 2dd6bde to 0eb97b8 Compare July 25, 2026 23:50
@charlesvien
charlesvien changed the base branch from fix/veria-354-mcp-sandbox-csp to main July 25, 2026 23:51
@trunk-io

trunk-io Bot commented Jul 25, 2026

Copy link
Copy Markdown

😎 This pull request was merged.

@stamphog
stamphog Bot dismissed github-actions[bot]’s stale review July 25, 2026 23:51

New commits pushed (delta classified non_linear_history) — stamphog approval dismissed; re-review running automatically.

@stamphog

stamphog Bot commented Jul 25, 2026

Copy link
Copy Markdown

Note

🤖 stamphog reviewed fd3a09045ecab7de72cdb12a56bbf6ada0174b8a — verdict: ESCALATE

This is a security-sensitive change to the setup-script execution/authorization flow (RCE fix), and both bot reviews are stale (older commit). Greptile's unaddressed architecture/security concern — that this introduces a second, ad-hoc authorization system (a raw window.confirm) parallel to the project's established permission-tool flow, with separate persistence/auditing behavior — is not resolved in the current diff and was never responded to.

  • 👍 on the PR from greptile-apps[bot].
  • Greptile's 'Parallel setup approval system' comment (taskCreationHost.ts) flags that confirmEnvironmentSetup creates a bespoke authorization mechanism (window.confirm) instead of routing through the established permission-tool flow — unaddressed in the diff and unresponded to.
  • Both existing bot reviews (veria-ai, greptile-apps) are marked COMMENTED on an older commit (8ee7112), not the current head, so their sign-off doesn't verifiably cover the latest changes.
  • This is auth/security-sensitive surface (fixing an RCE via untrusted repo config) — per policy this cannot be self-certified without independent assurance tied to the current head.
Gate mechanics and policy version
Gate Result
prerequisites all clear
deny-list no deny categories matched
size 41L, 4F substantive, 128L/7F incl. docs/generated/snapshots — within ceiling
tier T1-agent / T1c-medium (128L, 7F, single-area, fix)
stamphog 2.0.0b3 .stamphog/policy.yml @ e60a53a · reviewed head fd3a090

Updated in place — this replaces 2 earlier stamphog review(s) on this PR.

@stamphog stamphog Bot removed the Stamphog This will request an autostamp by stamphog on small changes label Jul 25, 2026
@charlesvien
charlesvien force-pushed the fix/veria-353-repo-setup-script-consent branch from 0eb97b8 to fd3a090 Compare July 26, 2026 00:29
@charlesvien charlesvien added the Stamphog This will request an autostamp by stamphog on small changes label Jul 26, 2026
@stamphog stamphog Bot removed the Stamphog This will request an autostamp by stamphog on small changes label Jul 26, 2026
@charlesvien charlesvien added the Stamphog This will request an autostamp by stamphog on small changes label Jul 26, 2026
@stamphog stamphog Bot removed the Stamphog This will request an autostamp by stamphog on small changes label Jul 26, 2026
@charlesvien
charlesvien merged commit 9e6e0ca into main Jul 26, 2026
45 checks passed
@charlesvien
charlesvien deleted the fix/veria-353-repo-setup-script-consent branch July 26, 2026 00:51
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