Harden HTTP streaming proxy surface#437
Open
larohra wants to merge 13 commits into
Open
Conversation
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Author
|
@copilot investigate and fix failing Azure pipeline runs. |
Agent-Logs-Url: https://github.com/Azure/azure-functions-nodejs-library/sessions/bc6e87b1-273c-4bd6-a0d1-fc53f15f0613 Co-authored-by: larohra <41490930+larohra@users.noreply.github.com>
I investigated the failing pipeline checks and applied a targeted fix in Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
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.
Context
src/http/httpProxy.tsis the internal HTTP streaming bridge behindapp.setup({ enableHttpStream: true }).server.listen()with no host, so Node binds the proxy on a wildcard interface even though the worker advertiseshttp://localhost:<port>/back to the host.azure-functions-host,src/WebJobs.Script.Grpc/Channel/WorkerChannel.csonly parsesHttpUriwithnew Uri(httpUri)and uses it for proxying, whilesrc/WebJobs.Script/Http/DefaultHttpProxyService.csoverwritesx-ms-invocation-idbefore forwarding.Assessment
HttpUrias a customer contract. The real gap is the worker’s wildcard listener plus permissive handling of direct requests from anything that can reach the sandbox/pod namespace. Even if the host never leaks the URI, the wildcard bind (and the fixed 55000-55025 fallback range) still creates discoverable local surface.localhosttoday, and it accepts any absoluteHttpUri. No for full channel authentication: the host does not send any shared secret today, andWorkerChannelstarts HTTP forwarding before the worker receives the gRPC invocation, so the library cannot repo-only pre-whitelist expected invocation IDs.server.listen()behavior with no evidence that wildcard binding was an intentional security posture. PR Add port validation checks for HTTP streaming #315 (“Add port validation checks for HTTP streaming”) later fixed Windows/VNET port-0 reliability but still returnedlocalhost, which reinforces that loopback was the intended contract and wildcard binding was an implementation gap.HttpUrias an opaque absolute URI string, so returning127.0.0.1or[::1]is not a customer API break. The real risks are IPv4/IPv6 family selection, URI formatting, and port-0 retry behavior.npm ci(357 passing), but this repo still lacks direct coverage forsrc/http/httpProxy.tsandProgrammingModel.getCapabilities/streamed invocation setup. The host repo does have contract-oriented coverage for correlation-header override (DefaultHttpProxyServiceTests), forwarded-header behavior (ScriptInvocationRequestTransformerTests), and theHttpUriproxying path (ScriptInvocationContextExtensionsTests).Implementation direction
src/http/httpProxy.tsto bind one concrete loopback address, use it consistently for the listener and port-probe/rebind path, and fail malformed proxy requests fast.HttpUrias an internal absolute URI capability and keepx-ms-invocation-idcorrelation semantics; do not add new repo-only auth signals or public API changes.ProgrammingModeland streamed invocation behavior so the hardened worker stays compatible with the current host contract and avoids address-family regressions.Non-goal / follow-up
azure-functions-host+ library handshake change rather than a library-only patch.