Summary
PraisonAI's AgentService.loadAgentFromFile method parses user-supplied YAML agent definitions with js-yaml while leaving dangerous tags like !!js/function enabled, enabling arbitrary JavaScript execution during parsing.
If an attacker can upload a crafted YAML agent file via the exposed API, they can trigger remote code execution on the PraisonAI server.
Affected context
This vulnerability affects PraisonAI deployments where:
- The AgentService.loadAgentFromFile method is used to load agent definitions from YAML files
- The js-yaml library is configured with default or permissive settings that allow execution-oriented tags
- External users, tenants, or integrated services can upload or submit agent definition files through an API endpoint
The risk is highest in multi-tenant or internet-exposed environments where file upload or agent-definition APIs are reachable by untrusted parties.
Exploit preconditions
- Attack surface: HTTP(S) API endpoint that accepts agent definition uploads or YAML-based configuration for PraisonAI agents.
- Required access: Ability to send requests to the PraisonAI server's agent upload/definition API (e.g., authenticated tenant, compromised account, or misconfigured public endpoint).
- Trigger point: Invocation of AgentService.loadAgentFromFile, which parses the attacker-controlled YAML with js-yaml and honors dangerous tags such as !!js/function.
- Why exploitation is possible: The YAML parser treats the document as trusted code-like input, permitting execution-capable tags without sandboxing or tag restrictions, which is a classic unsafe deserialization pattern.
Why this happens
The root cause is the use of js-yaml in a configuration that permits execution-capable tags to be processed on untrusted input.
By not disabling dangerous tags (such as !!js/function and !!js/undefined), the deserialization step goes beyond simple data parsing and allows logic to be instantiated and executed as part of loading configuration.
This directly maps to CWE-502: Deserialization of Untrusted Data, where attacker-controlled serialized data is interpreted in a way that can alter control flow or run code.
In abstract terms, a data-loading function is given both full trust in the structure of user-supplied documents and the ability to construct executable values from that structure, creating an implicit code execution channel.
Potential impact
- Remote execution of arbitrary JavaScript code within the PraisonAI server process
- Full compromise of the application runtime environment, including access to in-process secrets and credentials
- Unauthorized access to or modification of stored data managed by PraisonAI
- Use of the compromised server as a pivot point for lateral movement within the hosting infrastructure
- Deployment of backdoors, data exfiltration logic, or tampering with agent behavior to affect downstream users and automations
General mitigation guidance
Effective mitigation focuses on treating all uploaded agent definitions as untrusted data and ensuring that parsing is non-executable by design.
Pattern-oriented mitigation strategies include:
- Use data-only YAML parsing: Configure js-yaml or alternative parsers to disable all execution-capable tags, constructors, and schema extensions, so that only basic scalars, sequences, and mappings are allowed.
- Constrain allowed schema: Define a strict schema for agent definition files (e.g., using JSON Schema or a typed configuration model) and enforce it during or immediately after parsing.
- Validate and sanitize configuration: Validate all fields against expected types, ranges, and enumerations before using them to construct runtime objects or invoke logic.
- Reduce parser privilege: Run the component responsible for parsing and processing agent definitions with least-privilege permissions and minimal access to the filesystem, network, and secret stores.
- Harden upload endpoints: Apply authentication, authorization, and rate limiting to the agent upload/definition APIs, and avoid exposing them directly to the public internet where not required.
- Segregate configuration from execution: Ensure that configuration values cannot be passed directly into dynamic evaluation mechanisms (e.g., eval, Function, dynamic import) without explicit, constrained interpretation.
How teams detect issues like this
Detection and monitoring can focus on both code-level patterns and runtime behavior:
- Static analysis patterns:
- Flag usages of js-yaml (or similar libraries) where full or default schemas are applied to data that originates from file uploads or HTTP request bodies.
- Identify code paths where deserialized YAML values are subsequently passed into dynamic execution constructs, reflection APIs, or process-spawning functions.
- Enforce secure coding rules in CI/CD to disallow execution-capable YAML tags or unsafe deserialization helpers in request-handling components.
- Code review signals:
- Any use of YAML/JSON deserialization on user-controlled data without explicit schema validation and tag restrictions.
- Business logic that loads "agent definitions," "workflows," or "scripts" from files or requests and immediately instantiates them into runtime objects or functions.
- Runtime monitoring:
- Log and monitor uploads of agent definition files, focusing on unexpected patterns, unusually complex documents, or repeated failed parsing attempts.
- Observe for atypical process behavior (sudden outbound network requests, filesystem changes, or unexpected child processes) originating from the PraisonAI service.
Automated review tools and SAST products can be configured with custom rules targeting js-yaml usage and unsafe deserialization sinks as part of the secure development lifecycle.

