Summary
Server-side request forgery in Gogs webhooks allows outbound HTTP requests to be redirected to internal network hosts within local CIDRs.
If an attacker can configure or influence webhook URLs, they may pivot these redirects to access internal services that are not directly exposed externally.
Affected context
This vulnerability occurs in Gogs' webhook handling for outbound HTTP requests from the server.
It is relevant when:
- Webhooks are configured to send HTTP requests to user-controlled or untrusted URLs
- The server performs automatic redirect following (e.g., HTTP 3xx responses)
- Internal services are reachable from the Gogs host within local CIDRs (e.g., 127.0.0.0/8, RFC1918 ranges)
The prior hostname resolution checks block direct webhook calls to internal IP ranges but do not apply to redirected targets, leaving a residual SSRF path.
Exploit preconditions
- Attack surface: Gogs webhook subsystem that issues outbound HTTP requests based on repository events.
- Required access: Ability to configure or modify webhook URLs for a repository or organization, or to cause the server to use attacker-controlled endpoints.
- Trigger point: A repository event (such as push, tag, or issue activity) that causes the webhook to fire and follow HTTP redirects from the initial response.
- Why exploitation is possible: The SSRF protection validates the hostname of the initial webhook URL against local CIDRs but does not enforce equivalent checks on redirected locations, allowing an attacker-controlled endpoint to respond with redirects to internal hosts.
Why this happens
The root cause is incomplete enforcement of SSRF protections on all outbound HTTP request destinations.
While the initial webhook URL is checked against local CIDR ranges, subsequent redirect targets are trusted implicitly and are not revalidated.
This maps to CWE-918: Server-Side Request Forgery, where the server makes HTTP requests on behalf of the attacker to unintended internal endpoints because redirects are treated as benign navigation rather than untrusted input requiring the same policy checks.
Potential impact
- Internal HTTP services may be probed or accessed via redirected webhook requests.
- Attackers could read or infer sensitive metadata from internal endpoints that respond to GET requests.
- SSRF may be chained to interact with cloud metadata APIs or orchestration endpoints reachable from the host.
- Internal application endpoints could be abused as part of lateral movement or reconnaissance within the network.
General mitigation guidance
Mitigation typically focuses on closing SSRF pathways by treating all outbound request destinations as untrusted, including redirected URLs.
Helpful patterns include:
- Applying the same network and hostname validation on redirect targets as on the initial request.
- Restricting webhook destinations to approved domains or well-defined allowlists instead of arbitrary URLs.
- Disabling automatic redirect following or limiting the number and type of redirects that can be followed.
- Isolating outbound network access from the application server, using egress filters or proxy layers with strict policies.
- Designing webhooks and integrations so that the server receives callbacks rather than initiating arbitrary outbound requests.
How teams detect issues like this
Detection approaches for SSRF in webhook handlers commonly include:
- Static analysis rules that flag unrestricted outbound HTTP clients, particularly when they follow redirects or accept arbitrary URLs from user-controlled configuration.
- Code review practices that examine webhook implementations for hostname/IP validation, redirect handling, and allowlist enforcement.
- Security policies that mandate egress restrictions for application servers and require outbound calls to pass through controlled proxies or gateways.
- Monitoring outbound traffic patterns from the Gogs host for unexpected access to internal IP ranges or metadata services, using network logs and SIEM correlation.

