Featured Check out our Deep & Dark Web Monitoring Platform — DarkWiser Meet DarkWiser — Dark Web Monitoring

Research

Penetration Testing for Open-Source AI Agent Frameworks

Open-source AI agent frameworks connect language models to code execution environments, files, APIs and business data through configurable tools and integrations. Each connection introduces permissions and trust relationships that can create security risks if an agent processes malicious input or interacts with a compromised integration. AI agent penetration testing examines what a deployed agent can access and execute under these conditions. It considers three interconnected layers: the framework server, the tools available to the agent and the protocol connections that handle communication and credentials between them.

This article examines each layer through documented security weaknesses and practical attack scenarios. It begins with a framework vulnerability that allowed remote code execution through a code-validation endpoint, then explores risks involving excessive tool permissions and Model Context Protocol (MCP) integrations. Drawing on OWASP guidance and MCP security recommendations, it explains what organisations should include in a structured penetration test to identify and validate these weaknesses.

1. The Framework Server Is an Exposed Web Application

Visual agent builders operate as web applications with APIs that may be accessible independently of the AI model. In Langflow versions earlier than 1.3.0, the /api/v1/validate/code endpoint accepted Python code submissions from unauthenticated users. Horizon3.ai's disclosure explains how the server parsed submitted code and executed function definitions during validation. Because Python evaluates decorators and default arguments when a function is defined, an attacker could place executable code in these elements and trigger it on the server without calling the function itself. CISA added CVE-2025-3248 to its Known Exploited Vulnerabilities (KEV) Catalog on 5 May 2025.

Langflow 1.3.0 addressed the unauthenticated access path by requiring authentication for the affected endpoint. However, this change did not remove the platform's existing code-execution capability for authenticated users, as the researchers noted. Accounts with access to this functionality could still execute code on the host, making account security, access permissions and network exposure important considerations. A related risk appeared in a pre-run script command injection case, where a vulnerable workflow field enabled root-level access within a container.

2. Tool Permissions Determine the Potential Impact

AI agents perform actions through tools using the permissions assigned to them, regardless of where an instruction originates. The OWASP AI Agent Security Cheat Sheet identifies indirect prompt injection through documents, emails and API responses as a risk alongside tool misuse and data exfiltration. Malicious instructions embedded in retrieved content can influence an agent's subsequent actions. If tool execution is not subject to independent authorisation checks, this influence could lead to unauthorised file access, command execution or requests to external services.

OWASP recommends enforcing authorisation within the execution layer rather than relying solely on the model to follow security instructions. Penetration testing can help determine whether these controls are effective by examining how agents handle untrusted input and whether their tools enforce the intended access restrictions. This is one of the areas covered by Laburity's AI agent security validation.

3. MCP Integrations Introduce Risks Across Trust Boundaries

The Model Context Protocol (MCP) enables AI agents to communicate with external tools and services, but these connections also introduce security boundaries that require careful assessment. The MCP security best practices identify several risks associated with authentication, token handling and external requests. Two important examples require separate testing.

3.1 Token Passthrough

Token passthrough occurs when an MCP server accepts a client token that was not issued for that server and forwards it to a downstream service. The MCP specification prohibits this practice because it can bypass the intended security controls of the downstream service and compromise the integrity of access controls and audit trails. Each server should instead obtain and use credentials intended for its own interactions with downstream services.

3.2 Server-Side Request Forgery (SSRF)

SSRF presents a separate risk involving the MCP client's handling of OAuth metadata URLs. During the discovery process, a client may retrieve metadata from URLs supplied by the server it connects to. If these URLs are not properly validated, a malicious server could direct the client towards internal network addresses or cloud metadata endpoints, potentially exposing services that should not be accessible externally.

A focused MCP server security assessment can examine token handling, authentication boundaries and the validation of external URLs to identify weaknesses across these integrations.

4. How AI Agent Penetration Testing Examines Each Layer

A structured penetration test begins with clearly defined scope and rules of engagement, followed by an assessment of the agent's tools, credentials, integrations and accessible systems. Testers examine potential attack paths under controlled conditions, manually validate identified vulnerabilities, assess their potential business impact and retest the affected areas after remediation.

Depending on the framework and deployment environment, the assessment typically covers:

  • Framework security: Testing APIs and endpoints for unauthorised access, insecure configurations and potential code-execution vulnerabilities.
  • Access control: Determining whether agents can access data or perform operations beyond their assigned permissions.
  • Tool execution: Evaluating whether tool calls are subject to independent authorisation checks and appropriate approval controls.
  • MCP integration security: Assessing token handling, audience restrictions, permission scopes and protections against SSRF.
  • Prompt injection: Testing whether malicious instructions embedded in documents or tool responses can influence agent behaviour or trigger unauthorised actions.

As AI agent frameworks evolve and organisations introduce new integrations, the permissions granted to agents can create security risks if they are not regularly reviewed. Assessing the framework, connected tools and protocol layer together helps organisations understand the extent of an agent's access, identify weaknesses in its security controls and determine how those weaknesses could be exploited.

If you're looking to assess your organisation's exposure to similar risks, Scan your organisation's exposure, explore Laburity, or book a consultation.

Strengthen your security posture before attackers expose the gaps.

Don't wait for a breach, secure your cyber space now. You would be talking to an actual cyber security expert.

[email protected]+44 7380 443020