fix(agent): let secret rule hosts bypass the egress allowlist by radim10 · Pull Request #75 · stashbase/cli · GitHub
Skip to content

fix(agent): let secret rule hosts bypass the egress allowlist - #75

Merged
radim10 merged 4 commits into
masterfrom
fix/secret-hosts-bypass-egress-allowlist
Oct 17, 2026
Merged

radim10 merged 4 commits into
masterfrom
fix/secret-hosts-bypass-egress-allowlist

Conversation

@radim10

@radim10 radim10 commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Summary

A secret rule's hosts are now reachable without being listed in egress_hosts, but only by requests that carry that secret and match its rules. egress_hosts covers requests without a credential.

Before, setting egress_hosts meant every secret rule host also had to be listed there, which opened those hosts to any request, with or without the credential. Without egress_hosts, secret hosts already worked on their own; the meaning flipped depending on whether the key was present.

Changes

  • Proxy (src/handlers/run/proxy.rs): the CONNECT gate and the early request gate accept secret rule hosts; requests without a credential still need egress_hosts (now also in non-strict mode when it is set).
  • agent explain: connection is one of allowed_by_egress_hosts, allowed_with_credential (new), denied_by_egress_hosts, denied_by_deny_hosts. The old "no egress_hosts restriction configured" was wrong: without egress_hosts only credentialed requests are allowed. New Reachable hosts section (reachable_hosts in JSON): egress_hosts, the hosts each credential unlocks, and deny_hosts. Credential lines are sorted.
  • agent policy test: a credential is no longer denied because its host is missing from egress_hosts.
  • Docs: README.md, docs/agent-profiles.md, docs/agent-profiles/credential-policies.md.

JSON changes

  • agent explain: connection: "no_egress_restriction" is removed; allowed_with_credential, egress_hosts_configured and reachable_hosts are new.
  • agent policy test: reason denied_by_egress_hosts is removed.

Testing

  • cargo test: 620 unit + integration tests pass; cargo fmt --check clean.
  • New end-to-end proxy test fails without the fix (403) and passes with it.
  • Real stashbase agent run over HTTPS, local and --remote against a local backend with the matching Agent Proxy backend change: secret host outside egress_hosts with the secret → injected; without it → proxy.host_not_allowed; path outside the rule → proxy.credential_not_allowed; unlisted host → tunnel refused.

Release after or with the matching Agent Proxy backend change; until then, --remote runs still require credential hosts in egress_hosts.

A secret rule's hosts are reachable without being listed in egress_hosts,
but only by requests that carry that secret and match its rules. Requests
without a credential still need egress_hosts. Previously, setting
egress_hosts also required every secret rule host to be listed there.
Starts the real proxy with egress_hosts set and a secret rule for an
unlisted local upstream, and checks that a request carrying the secret
reaches it with the real value while one without the secret is refused.
…bility

agent explain now reports a host outside egress_hosts as allowed only with
an eligible credential instead of denied, and no longer claims there is no
restriction when egress_hosts is omitted. It also lists every reachable
host: egress_hosts, the hosts each credential unlocks, and deny_hosts.
agent policy test no longer denies a credential because its host is not
in egress_hosts.

The explain JSON connection value no_egress_restriction and the policy
test reason denied_by_egress_hosts are removed.
@radim10 radim10 self-assigned this Oct 17, 2026
@radim10
radim10 merged commit 6a4e96b into master Oct 17, 2026
3 checks passed
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