NIFI-16135 Sanitize URL-derived segments used to build nifi-api requests#11462
Merged
Conversation
Add safeApiPath and isSameOriginTarget shared utilities and apply them to route/query-derived values in AccessPolicyService, DocumentationService, and the content viewer, so untrusted deep-link input cannot redirect authenticated requests or bypass the same-origin ref check.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add safeApiPath and isSameOriginTarget shared utilities and apply them to route/query-derived values in AccessPolicyService, DocumentationService, and the content viewer, so untrusted deep-link input cannot redirect authenticated requests or bypass the same-origin ref check.
Summary
NIFI-16135
Hardens the UI's handling of values that originate from the browser URL (route
parameters and query parameters) before they are used to build authenticated
nifi-apirequests. These values can be influenced by a crafted link opened byan authenticated user but were previously trusted as-is when constructing the
request path.
This adds two small shared utilities in
libs/sharedand applies them at thepoints where URL-derived values reach a request:
safeApiPath(...segments)— validates each value as a single, atomic pathsegment (rejecting path separators,
..traversal sequences includingpre-encoded forms such as
%2e%2e/%2f, control characters, empty andnon-decodable values) and percent-encodes it. On an invalid segment it throws,
so the caller fails closed and no request is issued. Legitimate values
(identifiers and enumerated resource names) are unchanged, so existing URL
shapes are preserved.
isSameOriginTarget(candidate, base, { requireBasePathPrefix })—canonicalizes both values and compares origins with a segment-boundary-aware
path check, replacing a bypassable
startsWithprefix check.Applied to:
DocumentationService— component/step documentation requests built fromroute-supplied definition coordinates.
AccessPolicyService— policy requests built from route-suppliedaction/resource/identifier values. Affected methods are wrapped in
defer(...)so a rejection surfaces on the observable error channel that callers already
handle.
ContentViewerComponent— the query-supplied contentrefguard now uses asame-origin comparison instead of a string prefix match.
Unit tests cover the new validation and same-origin logic, including traversal,
pre-encoded traversal, control-character, look-alike-origin, and path-boundary
cases.
Tracking
Please complete the following tracking steps prior to pull request creation.
Issue Tracking
Pull Request Tracking
NIFI-00000NIFI-00000Pull Request Formatting
mainbranchVerification
Please indicate the verification steps performed prior to pull request creation.
Build
mvn clean install -P contrib-checkLicensing
LICENSEandNOTICEfilesDocumentation