Skip to content

Missing referenced gateway grants wildcard egress and starts the task #350

Done
fkautz/ax
#2

Description

@fkautz

Problem

A task referencing a nonexistent Gateway is accepted. Worker.processEvent leaves the resolved gateway nil after the lookup fails. Reconcile treats this as no restriction and submits a wildcard egress policy, then resumes the actor.

Reproduction

Create a Task with spec.gateway.name set to does-not-exist, without creating that Gateway. Process its event through Worker.Run.

Observed behavior

The test records an allow-all Substrate egress policy and a ResumeActor call for the task.

Expected behavior

An explicitly referenced gateway must resolve successfully before task execution. A missing reference or lookup failure must not substitute unrestricted egress.

Executable regression test

TestReviewMissingGatewayDoesNotGrantWildcardEgress (includes fixture in the same file).

git clone --branch test/review-regressions https://github.com/fkautz/ax.git ax-review
cd ax-review
git checkout 1dc2613d29e12f306154a7e1183c1825a55d24ed
go test ./internal/controller -run '^TestReviewMissingGatewayDoesNotGrantWildcardEgress$' -count=1 -v

Requires the Go toolchain specified by go.mod. The test asserts the desired behavior and fails on the published revision. Production code is unchanged.

This exercises the production API, worker, reconciler, and Substrate client against an in-memory store and stateful in-process gRPC fake. It verifies outbound control RPCs, not packet-level enforcement in a deployed cluster. Related issue #345 concerns hostname TLS blocking and ignored ports, a different failure.

Activity

  1. arbazkhan971 commented on Sep 22, 2026

    @arbazkhan971

    Fix ready: implemented on my fork (branch fix/350-gateway-fail-closed, regression test included, make test green) and ready to PR — but this repo's collaborators_only PR creation policy rejects PRs from non-collaborators (see #358), so I cannot open it. If PR creation opens for external contributors, I will open the PR immediately. Happy to adjust scope per maintainer feedback.

  2. yjjnls commented on Nov 19, 2026

    @yjjnls

    Friendly heads-up: this looks fixed on main — a missing referenced gateway now fails closed on both paths.

    • Creation rejects the dangling reference up front: the gateway must exist when the task is created, NotFound → FailedPrecondition "gateway %q not found in atespace %q" (internal/server/server.go:235-246).
    • For existing tasks, bindGateway (introduced by gateway: enforce a task's bound Gateway rules #585, fd126cb) fails when the actor has no egress policy and the referenced gateway can't be resolved — gw == nil → a not available in atespace %q error, recorded as a NotReady condition (ReasonGatewayBindingFailed, or ReasonSubstrateUnavailable for transient errors) and returned, so no wildcard policy is minted and the actor is not resumed (internal/controller/reconciler.go:315-339).

    That is the fail-closed semantics the report asks for ("a missing reference or lookup failure must not substitute unrestricted egress"; the worker/processEvent wiring it describes has since been replaced by the explicit Suspend/Resume flow in #536). This issue could be closed — just flagging so the credit for the report and regression test (@fkautz) and @arbazkhan971's fork fix don't get lost.

  3. yongruilin commented on Nov 23, 2026

    @yongruilin
    Collaborator

    Friendly heads-up: this looks fixed on main — a missing referenced gateway now fails closed on both paths.

    • Creation rejects the dangling reference up front: the gateway must exist when the task is created, NotFound → FailedPrecondition "gateway %q not found in atespace %q" (internal/server/server.go:235-246).
    • For existing tasks, bindGateway (introduced by gateway: enforce a task's bound Gateway rules #585, fd126cb) fails when the actor has no egress policy and the referenced gateway can't be resolved — gw == nil → a not available in atespace %q error, recorded as a NotReady condition (ReasonGatewayBindingFailed, or ReasonSubstrateUnavailable for transient errors) and returned, so no wildcard policy is minted and the actor is not resumed (internal/controller/reconciler.go:315-339).

    That is the fail-closed semantics the report asks for ("a missing reference or lookup failure must not substitute unrestricted egress"; the worker/processEvent wiring it describes has since been replaced by the explicit Suspend/Resume flow in #536). This issue could be closed — just flagging so the credit for the report and regression test (@fkautz) and @arbazkhan971's fork fix don't get lost.

    Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions