Skip to main content
CVE Vulnerability Database
Vulnerability Database/CVE-2025-27518

CVE-2025-27518: Cognita RAG Framework CSRF Vulnerability

CVE-2025-27518 is a Cross-Site Request Forgery vulnerability in Cognita RAG Framework by TrueFoundry caused by insecure CORS configuration. This article covers technical details, affected versions, security impact, and mitigation.

Published:

CVE-2025-27518 Overview

CVE-2025-27518 is an insecure Cross-Origin Resource Sharing (CORS) configuration vulnerability in Cognita, a Retrieval Augmented Generation (RAG) framework developed by TrueFoundry for building modular, open source production applications. The Cognita backend server accepts cross-origin requests from arbitrary websites, allowing malicious sites to send authenticated requests to the application on behalf of a victim user. The issue is tracked under [CWE-79] and was addressed in commit 75079c3d3cf376381489b9a82ee46c69024e1a15.

Critical Impact

Any website visited by an authenticated Cognita user can issue cross-site requests to the backend, potentially exfiltrating data or performing unauthorized actions within the RAG application.

Affected Products

  • TrueFoundry Cognita (versions prior to commit 75079c3d3cf376381489b9a82ee46c69024e1a15)
  • Cognita backend server (backend/server/app.py)
  • Deployments using the default CORS middleware configuration

Discovery Timeline

  • 2025-03-07 - CVE-2025-27518 published to the National Vulnerability Database
  • 2026-06-17 - Last updated in NVD database

Technical Details for CVE-2025-27518

Vulnerability Analysis

The Cognita backend registers the FastAPI CORSMiddleware with a wildcard origin policy while simultaneously enabling credentials. This combination causes browsers to attach cookies and authorization headers on cross-origin requests from any domain. An attacker who lures an authenticated Cognita user to a malicious page can trigger requests against the backend API and read the responses.

Because Cognita exposes RAG document ingestion, retrieval, and configuration endpoints, an exploited session can leak indexed corpora or modify data sources. The vulnerability aligns with [CWE-79] and abuses the browser as a confused deputy rather than requiring direct network access to the server.

Root Cause

The root cause is a permissive middleware declaration that pairs allow_origins=["*"] with allow_credentials=True and wildcard methods and headers. This configuration violates the browser same-origin protections that CORS is intended to preserve and grants any origin authenticated access to the API surface.

Attack Vector

Exploitation requires a victim with an active Cognita session to load attacker-controlled JavaScript in a browser. The malicious script issues fetch or XMLHttpRequest calls to the Cognita backend, with the browser automatically including session credentials. No user interaction beyond visiting the page is required, and no privileges on the target application are needed by the attacker.

python
     lifespan=_process_pool_lifespan_manager,
 )
 
-app.add_middleware(
-    CORSMiddleware,
-    allow_origins=["*"],
-    allow_credentials=True,
-    allow_methods=["*"],
-    allow_headers=["*"],
-)
+
+if settings.ALLOW_CORS:
+    app.add_middleware(
+        CORSMiddleware,
+        **settings.CORS_CONFIG,
+    )
 
 
 @app.exception_handler(Exception)
# Source: https://github.com/truefoundry/cognita/commit/75079c3d3cf376381489b9a82ee46c69024e1a15

The patch removes the unconditional wildcard middleware and gates CORS behind an explicit settings.ALLOW_CORS flag with an operator-supplied CORS_CONFIG dictionary.

Detection Methods for CVE-2025-27518

Indicators of Compromise

  • Unexpected HTTP requests to Cognita backend endpoints containing Origin headers from third-party domains.
  • Access logs showing authenticated API calls originating immediately after users browse untrusted websites.
  • Anomalous read or modification activity against RAG collections outside of normal user workflows.

Detection Strategies

  • Inspect running Cognita deployments for the presence of allow_origins=["*"] combined with allow_credentials=True in backend/server/app.py.
  • Deploy a reverse proxy or WAF rule that logs and alerts on requests where the Origin header does not match the approved frontend domains.
  • Correlate browser telemetry with backend logs to identify request patterns consistent with cross-site request abuse.

Monitoring Recommendations

  • Enable structured access logging on the Cognita backend and forward logs to a SIEM for baseline analysis of Origin and Referer headers.
  • Alert on outbound data volumes from RAG retrieval endpoints that exceed typical per-user thresholds.
  • Track configuration drift on the CORS middleware settings in version control and CI pipelines.

How to Mitigate CVE-2025-27518

Immediate Actions Required

  • Upgrade Cognita to a build that includes commit 75079c3d3cf376381489b9a82ee46c69024e1a15 or later.
  • Set ALLOW_CORS to false unless cross-origin access is explicitly required by the deployment.
  • When CORS is required, populate CORS_CONFIG with an allow-list of trusted frontend origins and remove wildcard methods and headers.

Patch Information

The fix is delivered in GitHub commit 75079c3d, merged through Pull Request #424. Additional context is available in the GitHub Security Advisory GHSL-2024-193.

Workarounds

  • Terminate TLS at a reverse proxy such as Nginx or Envoy and enforce a strict Access-Control-Allow-Origin allow-list at that layer.
  • Restrict access to the Cognita backend to trusted network segments or authenticated VPN users while the patch is being deployed.
  • Instruct users to log out of Cognita sessions when not actively using the application to reduce the window for CSRF-style abuse.
bash
# Configuration example: explicit CORS allow-list for Cognita
export ALLOW_CORS=true
export CORS_CONFIG='{
  "allow_origins": ["https://cognita.internal.example.com"],
  "allow_credentials": true,
  "allow_methods": ["GET", "POST"],
  "allow_headers": ["Authorization", "Content-Type"]
}'

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

Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

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.