Summary
Krayin CRM versions up to 2.1.5 contain a code injection flaw in the compose email functionality that allows remote attackers to execute arbitrary code on the server.
When user-controlled input is processed unsafely during email composition, it can be interpreted as executable code instead of data, leading to high-impact compromise under certain configurations.
Affected context
This vulnerability affects deployments of Krayin CRM that expose the email compose feature to end users or integrated systems.
The issue manifests when user-supplied content in email fields (such as body, templates, or dynamic placeholders) is processed in a way that supports dynamic evaluation or templating on the server side.
Environments where email content is programmatically transformed, rendered, or extended through plugins are more likely to be impacted, especially if application-level safeguards around code evaluation are weak or absent.
Exploit preconditions
- Attack surface: Network-accessible web interface or API endpoint for composing emails.
- Required access: Ability to submit or influence email content (e.g., as an authenticated CRM user, integration, or compromised account).
- Trigger point: Server-side processing of the email compose request, particularly where dynamic content is parsed or evaluated.
- Why exploitation is possible: User-controlled fields are interpreted in a context where they can affect executable code paths (such as dynamic evaluation, templating, or script injection), allowing crafted input to be executed on the server instead of treated purely as data.
Why this happens
The root cause aligns with CWE-94: Improper Control of Generation of Code ('Code Injection').
Within the compose email functionality, user-supplied input is incorporated into a processing pipeline that supports dynamic behavior (for example, templating, macro expansion, or scripting).
Instead of strictly treating this input as inert content, the implementation allows it to influence generated code or expressions that are subsequently executed or evaluated.
This lack of separation between data and code, combined with insufficient validation or neutralization of dangerous constructs, enables attackers to inject input that becomes part of the executable context on the server.
Potential impact
- Remote execution of arbitrary code within the application or web server context
- Compromise of CRM data, including customer records, emails, and attachments
- Use of the CRM server as a pivot point for lateral movement within the network
- Installation of backdoors, webshells, or other persistent malicious components
- Unauthorized access to secrets, configuration files, or connected services
General mitigation guidance
Mitigations typically focus on ensuring that user-supplied content in email composition is never treated as executable code.
Recommended defensive patterns include:
- Avoiding dynamic evaluation (such as eval-like operations, expression parsing, or execution of user-controlled template logic) in email rendering.
- Constraining email templating systems to a safe subset of operations that cannot influence control flow or execute arbitrary expressions.
- Applying strict validation and sanitization to all fields used in email composition, especially those that feed into any parser or renderer with dynamic features.
- Separating configuration and code from content, ensuring that user content cannot override or extend server-side logic.
- Running email processing components with least-privilege accounts and limiting filesystem and network permissions to reduce blast radius if a flaw is exploited.
How teams detect issues like this
Detection approaches can combine code-level analysis with runtime monitoring:
- Static analysis: Search for patterns where user-controlled input from email-related controllers or endpoints is passed into dynamic evaluation routines, script engines, or template engines that support arbitrary expressions.
- Code review: Pay special attention to email templating and composition logic, flagging any use of eval-like APIs, dynamic function construction, or configurable expressions derived from user input.
- Security testing: Use fuzzing or security-focused test cases against email compose endpoints to identify unintended interpretation of special syntax or constructs in message bodies or templates.
- Policy enforcement: Establish development guidelines prohibiting direct evaluation of user content and require security sign-off for any new dynamic templating features in communication modules.

