Repository navigation
Validate operation delegation targets at connection time - #1105
Merged
aaronzi merged 2 commits intoNov 23, 2026
Merged
Conversation
The delegation target validator resolved the target host with InetAddress, but the WebClient's Reactor Netty connector resolved the host again on its own before connecting. A host whose DNS answer changes between the two lookups (DNS rebinding) could therefore pass validation with a public address and still be connected to a loopback or private address. The WebClient now uses a Reactor Netty HttpClient with a custom AddressResolverGroup that resolves the host once through the validator and hands only validated addresses to the connector. The pre-exchange URI validation (scheme, port, IP literals) is kept. - Extract OperationDelegationWebClientFactory so tests exercise the production WebClient wiring - Add an injectable HostResolver to OperationDelegationTargetValidator - Add OperationDelegationAddressResolverGroup (resolution runs off the event loop) - Add a regression test reproducing the rebinding bypass and unit tests for the connection-time resolver
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Trailing-dot normalization can redirect DNS resolution to an unintended search-suffixed host, and the tests do not prove that the production HTTP client successfully uses the validated address.
2 open issues
What changed in this PR
This PR strengthens HTTP operation delegation in the submodel repository by validating the addresses used for outbound connections, closing the DNS-rebinding gap between validation and connection.
Changes:
- Adds a Netty resolver that validates resolved addresses off the event loop.
- Shares production and test WebClient setup while retaining pre-request URI checks.
- Adds resolver and DNS-rebinding tests and documents connection-time validation.
| File | Description |
|---|---|
| TestOperationDelegationFeature.java | Uses production client setup and adds a rebinding regression test. |
| TestOperationDelegationAddressResolverGroup.java | Tests address validation, allowlists, and resolution failures. |
| OperationDelegationWebClientFactory.java | Centralizes WebClient creation with the validating resolver. |
| OperationDelegationTargetValidator.java | Adds injectable resolution and returns validated addresses. |
| OperationDelegationSubmodelRepositoryConfiguration.java | Wires delegation through the shared client factory. |
| OperationDelegationAddressResolverGroup.java | Supplies validated connection addresses without blocking the event loop. |
| Readme.md | Documents connection-time DNS-rebinding protection. |
Review effort: Balanced
Normalization stripped the trailing dot of absolute host names before resolution, so a target such as "service.example." was looked up as the relative name "service.example" and could pick up DNS search domains. The host is now resolved as given; the normalized form is only used for allowlist matching. Also add a test that a delegated request to a host name known only to the injected resolver succeeds, proving the HTTP client connects to the validated address instead of performing its own DNS lookup.
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.

Description of Changes
Operation delegation targets are now validated by the HTTP client's own name resolution at connection time.
Previously, the delegation target host was resolved and checked by
OperationDelegationTargetValidatorbefore the request, while the outbound connection was opened by Reactor Netty after a separate DNS lookup of its own. The address that was checked was therefore not necessarily the address that was connected to.With this change, the host is resolved once and only addresses that passed validation are used for the connection.
Changes
OperationDelegationAddressResolverGroupAddressResolverGroupthat resolves delegation target hosts through the validatorOperationDelegationWebClientFactoryWebClientwith a Reactor NettyHttpClientthat uses the resolver aboveOperationDelegationSubmodelRepositoryConfigurationand by the tests, so the tests exercise the production wiringOperationDelegationTargetValidatorresolveAndValidate(String host), which resolves a host once and validates every addressHostResolverconstructor argument (defaults toInetAddress::getAllByName) so DNS answers can be simulated in testsHost and CIDR allowlists and
security.enabled=falsebehave as before. The request URI is not rewritten, so theHostheader and TLS SNI are unchanged.Related Issue
N/A
BaSyx Configuration for Testing
Default configuration; the Operation Delegation security defaults apply (
basyx.submodelrepository.feature.operation.delegation.security.*).AAS Files Used for Testing
None; covered by unit tests.
Additional Information
TestOperationDelegationFeature#invokeOperationDelegationBlocksDnsRebindingToLoopback: the simulated DNS returns a public address for the first lookup and the loopback address for later lookups. The test verifies that the delegated request never reaches the loopback server. It fails without the new resolver.TestOperationDelegationAddressResolverGroup: blocked addresses, mixed public/private answers, a single lookup per resolution, host and CIDR allowlists, disabled security, and unknown hosts.