Skip to content

Enforce source-network policy for administrative bearer tokens - #5686

Draft
vlast3k wants to merge 1 commit into
cloudfoundry:mainfrom
vlast3k:admin-token-network-policy
Draft

vlast3k wants to merge 1 commit into
cloudfoundry:mainfrom
vlast3k:admin-token-network-policy

Conversation

@vlast3k

@vlast3k vlast3k commented Nov 21, 2026 •

Copy link
Copy Markdown

Summary

Independently restrict validated administrative bearer tokens to operator-approved source networks,
before downstream middleware, user creation, and API authorization. UAA validates issuance and its
own token use, but Cloud Controller must enforce usage independently because it validates JWTs offline.

  • Protect uaa.admin, cloud_controller.admin, cloud_controller.admin_read_only,
    cloud_controller.global_auditor, and zones.<id>.admin in both scopes and authorities.
  • Deployment-wide, default disabled, with exact optional protected-scope additions.
  • Invalid numeric CIDRs fail startup even when disabled; enabled-empty allowlists deny protected tokens.
  • Direct Puma requests use the actual socket peer, not a spoofable Rack forwarding header.
  • Trust Nginx's overwritten X-Real-IP only on the actual configured Unix-domain socket.
  • Traverse explicitly trusted forwarded hops right-to-left; missing/malformed sources fail closed.
  • Apply the same check after relaxed upload decoding; return existing v2/v3 CF-NotAuthorized HTTP 403
    and clear validated context without invoking downstream handling.

Configuration: admin_token_network_policy.{enabled,allowed_cidrs,trusted_proxies,additional_protected_scopes}.
Ordinary and unauthenticated requests retain existing behavior. Feature docs describe trust and rollout.

Validation

  • 41 standalone policy examples passed, including IPv4/IPv6, mapped addresses, startup validation,
    forged headers, actual socket identity, and forwarded-chain bounds.
  • RuboCop passes for all six changed/new Ruby files; Markdown lint and git diff --check pass.
  • Added application middleware specs for v2/v3 denial, allowed use, and relaxed upload decoding.

Draft validation gap: full application middleware specs have not executed locally. The application
dependencies are absent (mock_redis is the first load failure; bundle check reports many missing
gems), and installed Ruby is 4.0.7 rather than this repository's 4.0.9. CI/full application integration,
actual Nginx/Puma header spoofing, Unix-socket permissions, and public/internal/upload ingress need review.

No deployment was changed. Real CIDRs, NAT/VPN egress, and trusted ingress topology remain operator inputs.

Coordinated changes

Deploy the matching Nginx source-header fixes before enabling Unix-socket header trust: canonical
X-Real-IP must be overwritten, legacy X-Real_IP removed, and upload forwarding sanitized.
This is not cryptographic sender constraint or an exhaustive escalation boundary.

This branch has not been deployed

No deployments
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