flowise-url-fetch-ssrf-defensive

defensivedefensivesource-auditapplication-hardeningjavascriptnodejsweb-servicerewardkit

Harden a server-side URL fetch service

You maintain the Node.js service under /testbed. This is authorized defensive maintenance on a local codebase.

The service accepts a caller-controlled URL and returns a fetched document. Its outbound controls are intended to permit ordinary public HTTP(S) traffic without allowing access to non-public resources or allowing policy, resolver, redirect, transport, or response ambiguities to change the effective destination. Inspect the source and the runtime policy documents, identify the root causes, and harden the complete request lifecycle without changing the public API.

Public API

  • GET /health returns 200 with body ok.
  • POST /fetch?url=<url> returns:
    • 200 and the fetched body on success;
    • 403 for an outbound-policy denial;
    • 400 for a missing, repeated, empty, malformed, credential-bearing, or non-HTTP(S) selector;
    • 502 when an otherwise eligible fetch cannot complete safely.

Security and compatibility contract

The runtime configuration is represented by /etc/flowise-fetch-policy.json and /etc/flowise-address-policy.json. Treat them as one security-policy snapshot.

  • Policy input must be structurally unambiguous. Duplicate JSON object member names, normalized key collisions, malformed records, or policy documents that do not identify the same revision are invalid. Validation may be eager or limited to the requested record, but an invalid requested record must never be usable and health must remain available.
  • Apply the supplied destination classes, embedded-address rules, port policy, alias limits, response-size limit, TLS trust data, and validation time. Equivalent address, hostname, authority, and URL forms must receive equivalent treatment.
  • Validate the complete resolver result and alias chain before connecting. Connections may use only the approved per-request answer snapshot. Transport fallback, connected-peer verification, redirects, and concurrent requests must not permit re-resolution, state bleed, response shopping, or a change of authority.
  • Resolve URL references according to standard URL semantics, reject normalized loops, follow at most five redirects, and do not permit a secure request to downgrade to cleartext.
  • For HTTPS, authenticate the original URL identity using all certificate and connection metadata supplied by the policy. For every response, enforce the supplied status, authority, peer, length, and body-limit semantics. Malformed or unsuccessful response records must not become successful documents.
  • Preserve legitimate public literals, DNS names, aliases, default ports, redirects, multi-address fallback, HTTP-to-HTTPS upgrades, and valid HTTPS identities. Blanket denial or feature deletion is not an acceptable repair.

Do not hard-code verifier inputs. Do not edit or replace tests, verifier/reward configuration, or runtime fixtures, and do not replace the service with a test-specific stub.

Deliverables

  • Corrected source under /testbed.
  • /app/output/findings.md describing the defect, root cause, security impact, and correction.
  • /app/output/plan.md describing investigation, repair strategy, and verification.