Skip to content

Do not route the internal (v3Internal) API through the external router#16154

Open
evilgensec wants to merge 2 commits into
cdapio:developfrom
evilgensec:dont-route-v3internal-from-external-router
Open

Do not route the internal (v3Internal) API through the external router#16154
evilgensec wants to merge 2 commits into
cdapio:developfrom
evilgensec:dont-route-v3internal-from-external-router

Conversation

@evilgensec
Copy link
Copy Markdown

Problem

The /v3Internal API is an internal, service-to-service surface: its handlers (for example FileFetcherHttpHandlerInternal, AppStateHandler, PreferencesHttpHandlerInternal, AppLifecycleHttpHandlerInternal) do not call accessEnforcer.enforce(...) and rely on callers presenting an internal credential.

RouterPathLookup.getRoutingService only special-cases the public /v3 prefix and otherwise falls through to return APP_FABRIC_HTTP. The external NettyRouter therefore forwards /v3Internal/... requests to app-fabric for any authenticated external user, and the app-fabric pipeline does not require an internal credential for those paths. A low-privileged user can then call the internal API across namespaces — for example GET /v3Internal/location/<absolute-path> (FileFetcherHttpHandlerInternalLocations.getLocationFromAbsolutePath) reads files rooted at the filesystem root, and the app-state / preferences / app-lifecycle internal handlers read or modify another namespace's data.

Internal callers do not use the external router for these paths — they go through service discovery (RemoteClient against Constants.Service.APP_FABRIC_HTTP, e.g. RemoteArtifactManager), so the router can stop routing /v3Internal without affecting internal traffic.

Change

RouterPathLookup returns DONT_ROUTE for any path whose first segment is v3Internal, mirroring the existing treatment of /v3/metadata-internals. RouterPathLookupTest is updated accordingly.

The /v3Internal API is for service-to-service calls and its handlers do not perform per-request authorization, relying on callers presenting an internal credential. RouterPathLookup only special-cased the public /v3 prefix and fell through to APP_FABRIC_HTTP for everything else, so the external NettyRouter forwarded /v3Internal requests from any authenticated external user to app-fabric, which applies no internal-only gate. Internal callers reach these endpoints over service discovery (RemoteClient against the APP_FABRIC_HTTP service), not the external router, so the router can stop routing /v3Internal, matching the existing handling of /v3/metadata-internals.
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request prevents external routing of internal APIs by returning DONT_ROUTE when the request path starts with the internal API version token, and updates the corresponding unit tests. Feedback suggests adding a defensive check for empty uriParts to avoid throwing an ArrayIndexOutOfBoundsException when routing empty paths.

…athLookup.java

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
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