Skip to content
This repository was archived by the owner on Aug 6, 2026. It is now read-only.

fix(cloud-agent): use refreshed token for signed commits - #3652

Merged
trunk-io[bot] merged 2 commits into
mainfrom
posthog-code/fix-signed-commit-token-refresh
Jul 21, 2026
Merged

fix(cloud-agent): use refreshed token for signed commits#3652
trunk-io[bot] merged 2 commits into
mainfrom
posthog-code/fix-signed-commit-token-refresh

Conversation

@tatoalo

@tatoalo tatoalo commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Problem

Why: Long-running cloud agents need signed commits to use credentials refreshed after the agent process starts.

Changes

Read GitHub credentials from the dedicated live credential file while keeping general sandbox metadata resolution unchanged.

Generated-By: PostHog Code
Task-Id: 5d51048c-d903-459e-a770-028ab37f9099
@trunk-io

trunk-io Bot commented Jul 21, 2026

Copy link
Copy Markdown

😎 Merged directly without going through the merge queue, as the queue was empty and the PR was up to date with the target branch - details.

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit b593418.

@tatoalo tatoalo self-assigned this Jul 21, 2026
Generated-By: PostHog Code
Task-Id: 5d51048c-d903-459e-a770-028ab37f9099
@tatoalo
tatoalo marked this pull request as ready for review July 21, 2026 18:32
@tatoalo tatoalo added the Stamphog This will request an autostamp by stamphog on small changes label Jul 21, 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.

Straightforward fix that points signed commits to a dedicated credential file. No logic changes, no security issues, no API contract changes.

@tatoalo
tatoalo enabled auto-merge (squash) July 21, 2026 18:33
@greptile-apps

greptile-apps Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Security Review

Mixed-version sandbox deployments can fall back to a stale process-start GitHub token when /tmp/agent-github-env is unavailable. This can cause a signed commit to use the previous actor's credentials after an actor change.

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

---

### Issue 1 of 1
packages/agent/src/utils/github-token.ts:10
**Missing Live File Reuses Stale Token**

When a sandbox deployment still writes refreshed credentials only to `/tmp/agent-env`, this new default misses the live file and silently falls back to the process-start token. After credentials rotate or the GitHub actor changes, signed commits can use the expired or previous actor's token instead of the refreshed credential.

Reviews (1): Last reviewed commit: "chore(cloud-agent): organize imports" | Re-trigger Greptile

// this live file is how in-process tools pick up a refreshed token without a
// process restart.
export const SANDBOX_ENV_FILE = "/tmp/agent-env";
const SANDBOX_GITHUB_ENV_FILE = "/tmp/agent-github-env";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 security Missing Live File Reuses Stale Token

When a sandbox deployment still writes refreshed credentials only to /tmp/agent-env, this new default misses the live file and silently falls back to the process-start token. After credentials rotate or the GitHub actor changes, signed commits can use the expired or previous actor's token instead of the refreshed credential.

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/agent/src/utils/github-token.ts
Line: 10

Comment:
**Missing Live File Reuses Stale Token**

When a sandbox deployment still writes refreshed credentials only to `/tmp/agent-env`, this new default misses the live file and silently falls back to the process-start token. After credentials rotate or the GitHub actor changes, signed commits can use the expired or previous actor's token instead of the refreshed credential.

How can I resolve this? If you propose a fix, please make it concise.

@tatoalo
tatoalo disabled auto-merge July 21, 2026 18:40
@trunk-io
trunk-io Bot merged commit 0717517 into main Jul 21, 2026
42 checks passed
@trunk-io
trunk-io Bot deleted the posthog-code/fix-signed-commit-token-refresh branch July 21, 2026 18:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Stamphog This will request an autostamp by stamphog on small changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant