Skip to main content

CVE-2024-5711: Stitionai Devika Stored XSS Vulnerability

CVE-2024-5711 is a stored Cross-Site Scripting flaw in Stitionai Devika that enables attackers to inject malicious scripts into the chat feature. This article covers the technical details, impact on credentials and data, and steps to protect your application.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2024-5711 Overview

CVE-2024-5711 is a stored Cross-Site Scripting (XSS) vulnerability in the stitionai/devika AI software engineer application. The flaw resides in the chat feature, where the application fails to validate or sanitize user input on both frontend and backend components. Attackers can inject malicious JavaScript payloads into chat messages that execute in the browser context of any user viewing the conversation. The weakness is classified under CWE-79. All versions of the application are affected.

Critical Impact

Successful exploitation allows attackers to steal session credentials, extract sensitive data from chat logs and projects, and perform actions in the context of authenticated users.

Affected Products

  • stitionai/devika — all versions
  • Devika AI software engineer deployments exposed via Flask backend
  • Instances with permissive CORS configuration (CORS(app) wildcard)

Discovery Timeline

  • 2024-07-08 - CVE-2024-5711 published to NVD
  • 2026-06-17 - Last updated in NVD database

Technical Details for CVE-2024-5711

Vulnerability Analysis

The vulnerability is a stored XSS flaw in the chat input handler of stitionai/devika. User-supplied content is persisted and later rendered in the browser without HTML encoding or sanitization. When another user loads the affected chat, the injected script executes under the application origin.

Two compounding issues amplify the impact. First, the Flask backend applies no server-side sanitization to incoming chat payloads. Second, the application originally initialized CORS with CORS(app), which allows any origin to interact with the API. This combination enables cross-origin attackers to deliver and trigger payloads that read session data or exfiltrate project contents.

Because Devika is an autonomous coding agent, chat logs frequently contain API keys, repository paths, and generated source code. A single stored payload can harvest credentials and intellectual property across sessions.

Root Cause

The root cause is missing input validation and output encoding on chat messages, combined with an overly permissive CORS policy. The application treats chat content as trusted HTML when rendered in the frontend, allowing arbitrary <script> tags and event handlers to execute.

Attack Vector

Exploitation requires network access to the Devika instance and user interaction (viewing the poisoned chat). An unauthenticated attacker submits a crafted message containing JavaScript. When any user — including administrators — opens the project or chat view, the payload runs with their privileges, enabling token theft and data exfiltration.

python
# Security patch in devika.py — restricting CORS to trusted origin
app = Flask(__name__)
-CORS(app)
+CORS(app, resources={r"/*": {"origins": ["https://localhost:3000"]}})
 app.register_blueprint(project_bp)
 socketio.init_app(app)

Source: GitHub commit 6acce21

Detection Methods for CVE-2024-5711

Indicators of Compromise

  • Chat messages or project records containing <script>, onerror=, onload=, or javascript: substrings in the Devika database
  • Outbound HTTP requests from browser sessions to unknown external hosts referencing document.cookie or session tokens
  • Unexpected cross-origin requests reaching the Flask backend from domains other than the configured frontend

Detection Strategies

  • Review persisted chat storage for HTML or JavaScript artifacts in user-submitted fields
  • Inspect browser Content Security Policy violation reports originating from the Devika frontend
  • Audit Flask access logs for POST requests to chat endpoints containing encoded script payloads (%3Cscript%3E, <script)

Monitoring Recommendations

  • Enable verbose logging on the project_bp blueprint and chat socket handlers to capture raw message bodies for forensic review
  • Monitor the Origin and Referer headers on API requests to detect calls from unauthorized frontends
  • Track outbound network traffic from browsers interacting with Devika for anomalous destinations that may indicate data exfiltration

How to Mitigate CVE-2024-5711

Immediate Actions Required

  • Update stitionai/devika to a build that includes commit 6acce21, which sanitizes HTML inputs and restricts CORS
  • Rotate any API keys, tokens, or credentials that may have been pasted into chat sessions on vulnerable instances
  • Restrict network access to the Devika web interface to trusted users and internal networks only
  • Audit existing chat and project records for stored payloads and purge malicious entries

Patch Information

The fix is published in the upstream stitionai/devika repository under commit 6acce21fb08c3d1123ef05df6a33912bf0ee77c2. The patch introduces werkzeug.utils.secure_filename for upload handling and replaces the wildcard CORS configuration with an explicit origin allowlist. See the Huntr bounty report for additional context.

Workarounds

  • Place the Devika service behind an authenticating reverse proxy that strips or encodes HTML in chat payloads
  • Deploy a strict Content Security Policy (CSP) header disallowing inline scripts (script-src 'self') to limit payload execution
  • Limit application exposure to localhost or a VPN segment until the patched version is deployed
bash
# Example reverse-proxy CSP header to blunt stored XSS execution
add_header Content-Security-Policy "default-src 'self'; script-src 'self'; object-src 'none'; frame-ancestors 'none'" always;

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.