Summary
SiYuan contains an SSRF protection bypass in SafeMode because its private-address check does not recognize IPv6 transition addresses that can represent private IPv4 destinations. An authenticated attacker may use proxy endpoints to access internal services, cloud metadata endpoints, and returnable response content when the application can resolve and connect to attacker-supplied destinations.
Affected context
The vulnerability occurs in SiYuan deployments that enable SafeMode and expose the network forward proxy, WebSocket proxy, or SSE proxy functionality to authenticated users. The risk is present when hostname resolution produces IPv6 transition addresses, such as NAT64, 6to4, or Teredo addresses, that embed or route to otherwise restricted private IPv4 destinations.
Exploit preconditions
- Attack surface: SiYuan network proxy endpoints
- Required access: Valid authenticated access to a feature that accepts a destination URL
- Trigger point: URL resolution and outbound connection through the proxy
- Why exploitation is possible: The SSRF guard checks common private, loopback, link-local, and unspecified ranges but does not adequately classify IPv6 transition addresses that can reach private IPv4 targets
Why this happens
The underlying bug is incomplete destination-address validation in the isPrivateIP function used by the SSRF-safe dialer. The check recognizes several directly represented restricted address classes but omits IPv6 transition mechanisms that encode or route to private IPv4 destinations. This maps to CWE-918: Server-Side Request Forgery, where attacker-controlled network destinations are accepted without sufficiently comprehensive validation.
Potential impact
- Internal services could be accessed from the SiYuan server
- Cloud instance metadata and temporary credentials could be exposed
- Internal infrastructure could be enumerated through response behavior
- Sensitive response bodies could be returned to the attacker
- Network segmentation and egress restrictions could be bypassed
- Compromised credentials could enable further access or lateral movement
General mitigation guidance
Mitigation generally focuses on making outbound destination validation comprehensive and reducing the trust placed in user-controlled URLs.
Common defensive patterns include:
- Resolve hostnames before connection and validate every resulting address
- Treat IPv4-mapped, NAT64, 6to4, Teredo, and other transition addresses according to their effective destination
- Revalidate the final socket destination to reduce DNS rebinding and resolution inconsistencies
- Prefer explicit outbound allowlists over broad URL acceptance
- Restrict proxy functionality to trusted administrative workflows where possible
- Block access to cloud metadata services and sensitive management ranges at the network layer
- Apply least-privilege network policies and limit the process's access to internal services
How teams detect issues like this
Organizations can identify similar SSRF risks through:
- Static analysis for user-controlled URLs passed to HTTP clients, dialers, or proxy handlers
- Code review checks for IP filtering that validates only textual or incomplete address categories
- Tests covering IPv4, IPv6, mapped addresses, DNS rebinding, NAT64, 6to4, and Teredo representations
- Egress monitoring for application connections to private ranges, metadata endpoints, and unexpected internal ports
- Policy enforcement requiring outbound allowlists for server-side fetch functionality
- Neutral automated review tools that flag network requests using attacker-influenced destinations

