WebhookUrlValidator
AgentPrism.Core.dllValidates webhook target addresses against SSRF.
public static class WebhookUrlValidatorInheritance
Section titled “Inheritance”Inherited Members
Section titled “Inherited Members”object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Remarks
Section titled “Remarks”This phase’s biggest security risk. The webhook
address is given by the user, and the server sends a request to
that address. If left uncontrolled, it becomes a means of reaching
internal-network services — including cloud metadata endpoints
(169.254.169.254), which often hand out unauthenticated temporary
credentials.
Defense layers:
- Scheme:
httpsonly;httponly for loopback and with explicit permission. - Address: DNS is resolved, private network ranges are rejected.
- Rebinding: connects directly to the resolved IP, with the
Hostheader preserved. - Redirects: not followed — a redirect is an escape route into a private network.
Methods
Section titled “Methods”IsAllowedTarget(IPAddress, AgentPrismWebhookOptions)
Section titled “ IsAllowedTarget(IPAddress, AgentPrismWebhookOptions)”Reports whether delivery to an address is allowed.
public static bool IsAllowedTarget(IPAddress address, AgentPrismWebhookOptions settings)Parameters
Section titled “Parameters”address IPAddress
The resolved address.
settings AgentPrismWebhookOptions
The webhook settings.
Returns
Section titled “Returns”true if a connection to the address can be made.
Remarks
Section titled “Remarks”Loopback is accepted while AgentPrismWebhookOptions.AllowInsecureHttp
is enabled. That setting already means “this is a local
development setup” and applies only to loopback targets. Otherwise,
testing a local listener would require
AgentPrismWebhookOptions.AllowPrivateNetworkTargets,
which opens the entire private network, including
10/8 and 169.254.169.254 — this would trade production
security for development convenience.
No private range other than loopback is opened by that setting.
IsPrivate(IPAddress)
Section titled “ IsPrivate(IPAddress)”Reports whether an IP address falls within a private/local range.
public static bool IsPrivate(IPAddress address)Parameters
Section titled “Parameters”address IPAddress
The address.
Returns
Section titled “Returns”true if the address falls within a private range.
Remarks
Section titled “Remarks”The rules live in EgressAddressValidator.IsPrivate, which all three outbound surfaces share. This member forwards to it and holds no copy of its own.
ToPolicy(AgentPrismWebhookOptions, AgentPrismEgressOptions?)
Section titled “ ToPolicy(AgentPrismWebhookOptions, AgentPrismEgressOptions?)”Converts webhook settings into the shared egress address policy.
public static EgressAddressPolicy ToPolicy(AgentPrismWebhookOptions settings, AgentPrismEgressOptions? egress)Parameters
Section titled “Parameters”settings AgentPrismWebhookOptions
The webhook settings.
egress AgentPrismEgressOptions?
The shared egress settings, or null to consider only the webhook settings.
Returns
Section titled “Returns”The policy applied to webhook targets.
Remarks
Section titled “Remarks”Both flags matter. AgentPrismWebhookOptions.AllowPrivateNetworkTargets
predates the shared AgentPrismEgressOptions and stays
honoured, so a setup that already opened the private network for
webhooks keeps working. The shared option is read where the policy is
built, in WebhookHttpClient and WebhookDeliveryJobHandler;
either one being enabled is enough.
Exceptions
Section titled “Exceptions”settings is null.
ValidateFormat(string?, AgentPrismWebhookOptions)
Section titled “ ValidateFormat(string?, AgentPrismWebhookOptions)”Validates an address by its scheme, without resolving DNS.
public static WebhookUrlVerdict ValidateFormat(string? url, AgentPrismWebhookOptions settings)Parameters
Section titled “Parameters”url string?
The address to validate.
settings AgentPrismWebhookOptions
The webhook settings.
Returns
Section titled “Returns”The result. Rejects if the address format or scheme is invalid.
Remarks
Section titled “Remarks”Used at save time (in the HTTP endpoint): DNS resolution would slow down the save, and the target may be unreachable at that moment. Real protection is applied at delivery time, with WebhookUrlValidator.ValidateResolvedAsync.
ValidateResolvedAsync(string?, AgentPrismWebhookOptions, AgentPrismEgressOptions, CancellationToken)
Section titled “ ValidateResolvedAsync(string?, AgentPrismWebhookOptions, AgentPrismEgressOptions, CancellationToken)”Validates an address by resolving DNS and checking the IP range.
public static ValueTask<WebhookUrlVerdict> ValidateResolvedAsync(string? url, AgentPrismWebhookOptions settings, AgentPrismEgressOptions egress, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”url string?
The address to validate.
settings AgentPrismWebhookOptions
The webhook settings.
egress AgentPrismEgressOptions
The shared egress settings.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”The result. Carries the resolved address if allowed.
Remarks
Section titled “Remarks”Called at delivery time. The returned WebhookUrlVerdict.ResolvedAddress must be used when establishing the connection; resolving the address again opens the door to a DNS rebinding attack.