Summary
Anyquery versions before 0.4.5 expose URL-capable SQLite virtual table modules through an unauthenticated MySQL-compatible server port without sufficiently restricting outbound destinations. A remote attacker may cause the server to request loopback, private-network, link-local, or cloud metadata URLs and expose returned data through query results.
Affected context
The issue occurs in Anyquery server deployments where the unauthenticated MySQL-compatible interface permits queries using URL-capable modules such as json_reader or log_reader. Risk increases when the server can make outbound requests to internal networks, local services, or cloud metadata endpoints and return fetched responses as queryable table data.
Exploit preconditions
- Attack surface: Anyquery's unauthenticated MySQL-compatible server port
- Required access: Network reachability to the exposed server port; application authentication is not required
- Trigger point: A query that causes a URL-capable virtual table module to fetch a remote resource
- Required environmental condition: The Anyquery process must have network access to the targeted internal, loopback, link-local, or metadata endpoint
- Why exploitation is possible: Outbound destinations are not sufficiently restricted, and fetched responses can be surfaced through query results
Why this happens
The underlying defect is insufficient server-side validation and authorization of outbound requests initiated through database virtual table modules. User-controlled or remotely supplied URLs are passed to a fetching mechanism without enforcing an appropriate destination policy, allowing the server to act as a proxy toward protected network locations.
This maps primarily to CWE-918: Server-Side Request Forgery, with related aspects of CWE-284: Improper Access Control, CWE-441: Unintended Proxy or Intermediary ('Confused Deputy'), and CWE-862: Missing Authorization.
Potential impact
- Internal services or APIs may be probed from the server's network position
- Cloud instance metadata or temporary credentials could be disclosed
- Responses from private or loopback services may be exposed as queryable data
- Internal APIs may receive unauthorized requests
- State-changing operations could cause low-integrity impact where reachable services permit them
- Sensitive network topology and service information could be revealed
General mitigation guidance
Mitigation generally focuses on reducing trust in URL inputs and enforcing a restrictive outbound network policy.
Common defensive patterns include:
- Restricting URL-capable modules to approved schemes, hosts, ports, and destinations
- Blocking loopback, private-network, link-local, broadcast, and cloud metadata address ranges
- Revalidating destinations after DNS resolution and across redirects
- Disabling unnecessary URL-fetching modules or requiring explicit administrative enablement
- Requiring authentication and authorization before permitting query execution
- Applying egress firewall controls and network segmentation around the Anyquery process
- Running the service with only the minimum network and filesystem privileges required
- Avoiding exposure of administrative or database-compatible ports to untrusted networks
How teams detect issues like this
Organizations can detect related risks through:
- Static analysis and code review for user-controlled URLs passed to HTTP or file-fetching libraries
- Review of database extensions and virtual table modules that perform network access
- Tests covering loopback, private, link-local, metadata, redirect, and DNS-rebinding destinations
- Monitoring outbound requests from Anyquery processes to internal address ranges or cloud metadata services
- Network policy alerts for unexpected egress from query-engine workloads
- Access-log correlation between unauthenticated database queries and subsequent internal HTTP requests
- Policy enforcement that requires authentication, destination allowlists, and restricted egress for network-enabled extensions

