Skip to content

fix(agents): validate the agent slug before building the ingress URL - #3954

Merged
trunk-io[bot] merged 1 commit into
mainfrom
fix/agent-slug-ingress-validation
Jul 29, 2026
Merged

fix(agents): validate the agent slug before building the ingress URL#3954
trunk-io[bot] merged 1 commit into
mainfrom
fix/agent-slug-ingress-validation

Conversation

@tatoalo

@tatoalo tatoalo commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Problem

The agent slug from an ?agent=<slug> approval deep link becomes a subdomain label in the ingress URL (<slug>.agents.<region>.posthog.com), and it was interpolated into that template with no validation.

Deep links are untrusted input — anyone can hand a user a <scheme>://approval/...?agent=<anything> URL. A slug that isn't a plain DNS label (one containing ., /, @, #, ?, : or \) can therefore alter the structure of the resulting URL rather than just naming an agent, which is not a shape we want a credentialed client request to take.

Changes

  • Adds shared slug validation so the main process and renderer use the same rules
  • Rejects malformed slugs at the deep link boundary and falls back to the project-scoped Approvals inbox
  • Returns null instead of building an ingress URL for invalid slugs, preserving the existing no-ingress path
  • Validation exists at both the boundary and URL builder to prevent invalid state now and in future callers
  • No behavior changes for valid slugs or existing callers

@trunk-io

trunk-io Bot commented Jul 29, 2026

Copy link
Copy Markdown

😎 Merged successfully - details.

@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 797fac9.

@tatoalo tatoalo self-assigned this Jul 29, 2026
The agent slug becomes a subdomain label in the ingress URL
(`<slug>.agents.<region>.posthog.com`), but it arrived from an `?agent=`
approval deep link and was interpolated without any validation, so a
slug that isn't a plain label could change where the resulting request
goes.

Validate it as a single DNS label in two places: the deep-link handler
drops a malformed slug so the link falls back to the fleet Approvals
inbox, and `agentIngressBaseUrl` returns null rather than interpolating
one, which keeps callers on their existing "no ingress" path.
@tatoalo
tatoalo force-pushed the fix/agent-slug-ingress-validation branch from 0ebcce2 to 797fac9 Compare July 29, 2026 14:46
@tatoalo
tatoalo requested a review from a team July 29, 2026 14:47
@tatoalo
tatoalo marked this pull request as ready for review July 29, 2026 14:47
@greptile-apps

greptile-apps Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "fix(agents): validate the agent slug bef..." | Re-trigger Greptile

@tatoalo
tatoalo enabled auto-merge (squash) July 29, 2026 14:56
@trunk-io
trunk-io Bot merged commit 211a86a into main Jul 29, 2026
39 of 40 checks passed
@trunk-io
trunk-io Bot deleted the fix/agent-slug-ingress-validation branch July 29, 2026 15:07
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.

2 participants