Summary
Vanna AI's Flask endpoint functions update_sql and run_sql are vulnerable to server-side request forgery (SSRF), allowing an attacker to abuse the server as a proxy to make arbitrary outbound requests.
When exposed remotely and provided with attacker-controlled input, the endpoint may be coerced into connecting to internal or external services that are not directly accessible to the attacker.
Affected context
This vulnerability affects deployments of the vanna-ai package (up to version 2.0.2) that:
- Use the legacy Flask component (
src/vanna/legacy/flask/__init__.py) - Expose the
update_sqland/orrun_sqlendpoints over a network interface - Accept user-controlled parameters that influence where SQL is executed or what data source is contacted
Risk increases significantly when the application can reach internal services (e.g., databases, metadata services, admin panels) that are not otherwise directly exposed to the internet.
Exploit preconditions
- Attack surface: The exposed Flask HTTP endpoints that wrap
update_sql/run_sql. - Required access: Ability to send HTTP requests to the affected endpoint (typically unauthenticated or weakly protected API).
- Trigger point: Supplying crafted parameters that are used to construct or route backend requests to data sources or URLs.
- Why exploitation is possible: The endpoint uses attacker-controlled input to drive server-side connections without adequate validation, normalization, or allowlisting of destinations, creating an SSRF primitive as described by CWE-918.
Why this happens
The root cause is the use of untrusted client input to influence server-initiated network activity without enforcing strict constraints on destinations or protocols.
In the affected update_sql / run_sql logic, user-provided values (such as connection strings, URLs, hosts, or similar routing parameters) are likely passed into networking or database access layers directly.
This pattern maps to CWE-918: Server-Side Request Forgery, where an attacker can coerce the server into making arbitrary requests to internal or external targets, taking advantage of the server's network position and trust relationships.
Potential impact
- Access to internal-only services (databases, admin dashboards, metadata services) that are not publicly exposed
- Enumeration of internal network topology and reachable hosts
- Bypassing IP-based access controls or perimeter firewalls by tunneling through the vulnerable server
- Potential data exfiltration from internal services reachable by the server
- In certain environments, stepping stone toward further compromise (e.g., cloud instance metadata abuse, credential retrieval)
General mitigation guidance
Effective mitigation generally focuses on constraining how server-side network calls are constructed and where they can go:
- Apply strict allowlists for destinations (e.g., fixed hosts or DSNs) that
update_sql/run_sqlcan interact with, avoiding user-specified endpoints. - Separate configuration of data sources from user input; treat connection targets and credentials as static, trusted configuration instead of dynamic request parameters.
- Normalize and validate any user-influenced network parameters, rejecting private IP ranges, loopback addresses, link-local metadata endpoints, and unexpected protocols.
- Enforce network-level egress controls (e.g., firewall rules, VPC security groups) so the application server cannot freely initiate outbound connections to arbitrary addresses.
- Run the application with least-privilege networking permissions, limiting its ability to reach sensitive infrastructure segments.
How teams detect issues like this
Organizations can detect and monitor SSRF risks in this context through:
- Static analysis and code review:
- Flag endpoints where URL, host, or connection information is derived directly from HTTP request parameters, headers, or body.
- Look for direct use of user input in networking or database connection APIs in
src/vanna/legacy/flask/__init__.pyand related modules. - Review for absence of allowlists, schema validation, or network segmentation checks around these calls.
- Runtime monitoring:
- Track unusual outbound connections from the application server, especially to internal IP ranges (e.g., 10.0.0.0/8, 169.254.169.254).
- Set alerts for sudden increases in failed outbound requests or unexpected DNS resolution patterns from the application.
- Policy and tooling:
- Integrate automated security checks into CI/CD to identify SSRF patterns (e.g., user input flowing into network sinks).
- Use API gateways or service meshes to enforce egress policies and restrict which upstream services these endpoints may contact.

