Skip to content

CP-25960: allowlist discovery-derived hosts before authenticating against them - #829

Open
roeezis wants to merge 3 commits into
jetstack:masterfrom
roeezis:CP-25960-ag1-discovery-host-allowlist
Open

CP-25960: allowlist discovery-derived hosts before authenticating against them#829
roeezis wants to merge 3 commits into
jetstack:masterfrom
roeezis:CP-25960-ag1-discovery-host-allowlist

Conversation

@roeezis

@roeezis roeezis commented Sep 3, 2026

Copy link
Copy Markdown

Summary

Two agent-side hardening findings from the Conjur Agent Authentication Secure Code Review (CP-24572):

  • CP-25960 / AG1 (Medium): service discovery's identity/discoverycontext/secrets_manager API hosts were trusted verbatim from the response body and handed straight to the Conjur/Identity clients, which then POST the agent's SA token (or username/password) to that host — no allowlist. Mirrors finding R2, already fixed on the discoverycontext-regional-resources side. Now constrains each discovered host to a known CyberArk root domain, or to the same host the discovery call itself succeeded against (covers ARK_DISCOVERY_API dev/CI overrides and same-origin test mocks with no per-env map needed). A dropped host is treated the same as one absent from the response.
  • CP-25964 / A1 (Low): the authn-jwt exchange error included up to 4KiB of Conjur's response body, which propagates to a Kubernetes Pod Event — readable by anyone with get events in the namespace. Now logged at V(2) instead; the error/Event carries only the status code and the existing troubleshooting hint.

Test plan

  • go vet ./...
  • make test-unit — 431 tests, 4 skipped, 2 pre-existing unrelated failures (KUBEBUILDER_ASSETS-gated test not run via make's own env in this invocation path is unaffected; the json.RawMessage/jsontext.Value message-drift failure in pkg/client is pre-existing on master, unrelated to this change)
  • New tests: servicediscovery host-allowlist accept/reject cases; conjur error-body-omitted-from-returned-error case

rzisholz added 2 commits September 3, 2026 17:55
CP-25960 (AG1, Medium): service discovery's identity/discoverycontext/
secrets_manager API hosts were trusted verbatim from the response body and
handed straight to the Conjur/Identity clients, which then POST the agent's
SA token (or username/password) to that host with no allowlist — an
SSRF-shaped hole if the discovery response is ever tampered with. Mirrors
finding R2 already fixed on the discoverycontext-regional-resources side
(token.py's iss-host allowlist). Constrain each discovered host to a known
CyberArk root domain, or to the same host we already made the successful,
TLS-authenticated discovery call to (covers the ARK_DISCOVERY_API dev/CI
override and same-origin test mocks without a per-env map). A dropped host
is treated the same as one absent from the response.

CP-25964 (A1, Low): the authn-jwt exchange error included up to 4KiB of
Conjur's response body, which propagates to a Kubernetes Pod Event
(pkg/agent/run.go's PushingErr notification) — readable by anyone with `get
events` in the namespace. The body can contain Conjur policy structure,
service IDs and host identities. Log it at V(2) instead; the returned error
(and therefore the Event) now carries only the status code and the existing
troubleshooting hint.

SCR: https://ca-il-confluence.il.cyber-ark.com/pages/viewpage.action?pageId=710861530
The allowlist added in the previous commit was copied from the identity
authorizer Lambda's local commercial-only clone of everest_env_utils'
ROOT_DOMAIN map, not the real package. The real map (everest_env_utils_cyberark,
v2.0.117) has 8 more entries for the GOV_* environments
(*-cyberarkgov.com/.cloud) that the clone omits. Without them, any gov-cloud
tenant's agent would have every discovery-derived host rejected, breaking
identity discovery entirely (fatal, since it's required unconditionally).
@roeezis

roeezis commented Sep 3, 2026

Copy link
Copy Markdown
Author

Follow-up commit: the allowlist added above was copied from the identity authorizer Lambda's local commercial-only clone of `everest_env_utils`'s `ROOT_DOMAIN` map. Checked the real package (`everest_env_utils_cyberark` v2.0.117, installed in `discoverycontext-file-ingestor-service`'s venv) and found 8 more entries for the GOV_* environments that the Lambda's local clone omits. Added them — without this, any gov-cloud tenant's agent would have every discovery-derived host rejected (fatal for identity, since it's required unconditionally).

CI's verify job failed: gci requires third-party imports (k8s.io/klog)
grouped separately from and before this module's own imports, per
.golangci.yaml's [standard, default, localmodule] section order.
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