Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Python
__pycache__/
*.py[cod]
*.pyo
*.pyd
.Python
*.egg
*.egg-info/
dist/
build/
eggs/
parts/
var/
sdist/
develop-eggs/
.installed.cfg
lib/
lib64/

# Virtual Environment
venv/
.venv/
env/
ENV/

# Environment Variables
.env

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

backend/.env is tracked despite the .env gitignore rule.

The pattern .env on line 27 should match backend/.env in any subdirectory, yet backend/.env is committed in this PR. This typically means the file was staged with git add -f or was tracked before the .gitignore was applied. Once a file is tracked by Git, .gitignore no longer prevents changes from being staged — meaning if a developer later writes real Clerk keys or database credentials into backend/.env, those secrets will be committed automatically.

Remove the file from tracking immediately:

git rm --cached backend/.env

Use backend/.env.example (already in the repo per the AI summary) for documentation of required keys, and keep real .env files untracked.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.gitignore at line 27, Tracked backend/.env is still in Git despite the .env
rule in .gitignore; stop tracking it by removing it from the index (while
keeping the file locally), commit that removal, and ensure .gitignore contains
the .env pattern so it won’t be re-added; then verify and document required keys
using backend/.env.example instead of committing real secrets.

.env.local
.env.development
.env.production

# Next.js
.next/
out/
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# Build
dist/
build/

# Database
*.db
*.sqlite
*.sqlite3

# Logs
logs/
*.log

# OS
.DS_Store
Thumbs.db
desktop.ini

# IDE
.vscode/settings.json
.idea/
*.swp
*.swo

# Exports
backend/exports/

# Prisma
prisma/dev.db

# pnpm
.pnpm-store/
18 changes: 18 additions & 0 deletions backend/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
APP_NAME=Inferix
APP_ENV=development
APP_PORT=8000
DEBUG=True

DATABASE_URL=postgresql://dummy:dummy@localhost/inferix

OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_MODEL_1=gemma:2b
OLLAMA_MODEL_2=phi3:mini
OLLAMA_MODEL_3=llama3.2:3b

CLERK_SECRET_KEY=dummy_secret_key
CLERK_PUBLISHABLE_KEY=dummy_publishable_key

ALLOWED_ORIGINS=http://localhost:3000

EXPORT_DIR=./exports
Comment on lines +1 to +18

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Do not commit backend/.env — tracked .env files invite credential leaks.

This file is the downstream consequence of the git tracking issue flagged in .gitignore. Even with placeholder values now, the file being tracked means any future replacement of dummy_secret_key or dummy:dummy@localhost/inferix with real credentials will be silently committed and pushed. The canonical practice is to commit only .env.example and let each developer create their own untracked .env.

See the .gitignore comment above for the git rm --cached remediation.

🧰 Tools
🪛 dotenv-linter (4.0.0)

[warning] 2-2: [UnorderedKey] The APP_ENV key should go before the APP_NAME key

(UnorderedKey)


[warning] 14-14: [UnorderedKey] The CLERK_PUBLISHABLE_KEY key should go before the CLERK_SECRET_KEY key

(UnorderedKey)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/.env` around lines 1 - 18, The repository is currently tracking
backend/.env (containing keys like APP_NAME, DATABASE_URL, OLLAMA_BASE_URL,
CLERK_SECRET_KEY, etc.); stop tracking that file, add a safe template, and
ensure .env is ignored: remove backend/.env from the index (git rm --cached),
add a .env entry to .gitignore if missing, create/commit backend/.env.example
containing the placeholder entries (APP_NAME, DATABASE_URL, OLLAMA_MODEL_1/2/3,
CLERK_SECRET_KEY, ALLOWED_ORIGINS, EXPORT_DIR) and instruct developers to
populate their own local untracked backend/.env, then commit the changes.

24 changes: 24 additions & 0 deletions backend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# App
APP_NAME=Inferix
APP_ENV=development
APP_PORT=8000
DEBUG=True

# Database — NeonDB
DATABASE_URL=your_neondb_connection_string_here

# Ollama
OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_MODEL_1=gemma:2b
OLLAMA_MODEL_2=phi3:mini
OLLAMA_MODEL_3=llama3.2:3b

# Auth — Clerk
CLERK_SECRET_KEY=your_clerk_secret_key_here
CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key_here

# CORS
ALLOWED_ORIGINS=http://localhost:3000

# Export
EXPORT_DIR=./exports
40 changes: 40 additions & 0 deletions backend/app/core/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from pydantic_settings import BaseSettings
from typing import List

class Settings(BaseSettings):
# App
APP_NAME: str = "Inferix"
APP_ENV: str = "development"
APP_PORT: int = 8000
DEBUG: bool = True

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

DEBUG defaults to True — unsafe for production deployments.

If this service is ever deployed without an explicit DEBUG=False in the environment, debug mode will be active, potentially exposing stack traces and internal details to end users.

🔒 Proposed fix
-    DEBUG: bool = True
+    DEBUG: bool = False
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
DEBUG: bool = True
DEBUG: bool = False
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/app/core/config.py` at line 9, The DEBUG flag in config.py is
dangerously set to True by default; change the default of DEBUG to False and
load/override it from an environment/config source so production is not
accidentally exposed (update the DEBUG variable initialization and any
Config/Settings loader that sets DEBUG); ensure the environment variable (e.g.,
DEBUG or APP_DEBUG) can enable True when explicitly provided and add a short
comment indicating DEBUG must be explicitly enabled in non-dev environments.


# Database
DATABASE_URL: str

# Ollama
OLLAMA_BASE_URL: str = "http://localhost:11434"
OLLAMA_MODEL_1: str = "gemma:2b"
OLLAMA_MODEL_2: str = "phi3:mini"
OLLAMA_MODEL_3: str = "llama3.2:3b"

# Auth - Clerk
CLERK_SECRET_KEY: str
CLERK_PUBLISHABLE_KEY: str

# CORS
ALLOWED_ORIGINS: str = "http://localhost:3000"

# Export
EXPORT_DIR: str = "./exports"

@property
def OLLAMA_MODELS(self) -> List[str]:
return [
self.OLLAMA_MODEL_1,
self.OLLAMA_MODEL_2,
self.OLLAMA_MODEL_3
]

model_config = {"env_file": ".env", "extra": "ignore"}

settings = Settings()
Binary file added backend/app/robo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions backend/app/routers/ai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from fastapi import APIRouter

router = APIRouter()
3 changes: 3 additions & 0 deletions backend/app/routers/benchmark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from fastapi import APIRouter

router = APIRouter()
3 changes: 3 additions & 0 deletions backend/app/routers/chat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from fastapi import APIRouter

router = APIRouter()
3 changes: 3 additions & 0 deletions backend/app/routers/compare.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from fastapi import APIRouter

router = APIRouter()
3 changes: 3 additions & 0 deletions backend/app/routers/export.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from fastapi import APIRouter

router = APIRouter()
3 changes: 3 additions & 0 deletions backend/app/routers/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from fastapi import APIRouter

router = APIRouter()
3 changes: 3 additions & 0 deletions backend/app/routers/report.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from fastapi import APIRouter

router = APIRouter()
3 changes: 3 additions & 0 deletions backend/app/routers/templates.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from fastapi import APIRouter

router = APIRouter()
3 changes: 3 additions & 0 deletions backend/app/routers/voice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from fastapi import APIRouter

router = APIRouter()
56 changes: 56 additions & 0 deletions backend/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from contextlib import asynccontextmanager
from app.core.config import settings
from app.routers import (
chat, benchmark, compare,
models, templates, report,
export, ai, voice
)

@asynccontextmanager
async def lifespan(app: FastAPI):
print(f"🚀 Inferix Backend starting on port {settings.APP_PORT}")
print(f"🤖 Ollama URL: {settings.OLLAMA_BASE_URL}")
yield
print("🛑 Inferix Backend shutting down...")

app = FastAPI(
title="Inferix API",
description="Privacy-first, offline AI playground backend",
version="0.1.0",
lifespan=lifespan
)

# CORS
app.add_middleware(
CORSMiddleware,
allow_origins=[settings.ALLOWED_ORIGINS],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
Comment on lines +26 to +32

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

CORS is overly permissive: wildcard methods and headers combined with allow_credentials=True.

The FastAPI documentation explicitly states that none of allow_origins, allow_methods, and allow_headers can be set to ['*'] when allow_credentials is set to True — all of them must be explicitly specified. Using ["*"] for both methods and headers while allow_credentials=True is a broad attack surface: any HTTP method and any custom header (including auth-bearing headers) will be accepted cross-origin from the configured domain.

Restrict to the specific methods and headers this API actually needs:

🔒 Proposed fix
 app.add_middleware(
     CORSMiddleware,
     allow_origins=[settings.ALLOWED_ORIGINS],
     allow_credentials=True,
-    allow_methods=["*"],
-    allow_headers=["*"],
+    allow_methods=["GET", "POST", "PUT", "DELETE", "OPTIONS"],
+    allow_headers=["Authorization", "Content-Type"],
 )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
app.add_middleware(
CORSMiddleware,
allow_origins=[settings.ALLOWED_ORIGINS],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.add_middleware(
CORSMiddleware,
allow_origins=[settings.ALLOWED_ORIGINS],
allow_credentials=True,
allow_methods=["GET", "POST", "PUT", "DELETE", "OPTIONS"],
allow_headers=["Authorization", "Content-Type"],
)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/main.py` around lines 26 - 32, The CORS config uses CORSMiddleware
with allow_credentials=True but allows wildcard methods and headers, which
violates FastAPI rules and is overly permissive; update the CORSMiddleware call
(where app.add_middleware is used with CORSMiddleware and
settings.ALLOWED_ORIGINS) to replace allow_methods=["*"] and allow_headers=["*"]
with explicit lists of only the HTTP methods and headers your API needs (e.g.,
["GET","POST","PUT","PATCH","DELETE","OPTIONS"] for allow_methods and a minimal
set like ["Authorization","Content-Type","Accept"] for allow_headers), and
ensure settings.ALLOWED_ORIGINS is a concrete list of origins rather than a
wildcard when allow_credentials=True.


# Routers
app.include_router(chat.router, prefix="/api/chat", tags=["Chat"])
app.include_router(benchmark.router, prefix="/api/benchmark", tags=["Benchmark"])
app.include_router(compare.router, prefix="/api/compare", tags=["Compare"])
app.include_router(models.router, prefix="/api/models", tags=["Models"])
app.include_router(templates.router, prefix="/api/templates", tags=["Templates"])
app.include_router(report.router, prefix="/api/report", tags=["Report"])
app.include_router(export.router, prefix="/api/export", tags=["Export"])
app.include_router(ai.router, prefix="/api/ai", tags=["AI"])
app.include_router(voice.router, prefix="/api/voice", tags=["Voice"])

@app.get("/")
async def root():
return {
"app": "Inferix",
"version": "0.1.0",
"status": "running",
"docs": "/docs"
}

@app.get("/health")
async def health():
return {"status": "healthy"}
32 changes: 32 additions & 0 deletions backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Framework
fastapi
uvicorn[standard]

# LangChain + Ollama
langchain
langchain-ollama
langchain-community

# Database
prisma
asyncpg

# AI/ML
psutil

# Auth
python-jose[cryptography]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

CVE-2024-33663 python-jose algorithm confusion vulnerability

💡 Result:

CVE-2024-33663 is an algorithm-confusion vulnerability in the Python library python-jose that affects versions up to and including 3.3.0, where handling of OpenSSH ECDSA keys (and other key formats) can allow an attacker to confuse the algorithm expected during JWT verification [1]. Impact (what can go wrong) If an attacker can influence what key material and algorithm are used during JWT verification, the algorithm confusion can undermine signature validation and lead to authentication bypass / forged JWT acceptance; multiple vulnerability databases describe it as enabling bypass of authentication/signature verification under the affected conditions [1][2][3]. Affected versions python-jose through 3.3.0 is listed as affected [1][4]. Fix / remediation The package advisory data indicates the issue is fixed in python-jose 3.4.0 (and later), with affected versions introduced through 3.3.0 and fixed at 3.4.0 [4]. The upstream release notes for 3.4.0 explicitly state “Fix for CVE-2024-33663 - signing JWT with public key is now forbidden” [5]. Practical guidance 1) Upgrade python-jose to at least 3.4.0 (prefer the latest available) [4][6]. 2) If you cannot upgrade immediately, ensure your JWT verification logic strictly uses the intended algorithm(s) and key type for verification, and do not accept attacker-controlled algorithm/key-type combinations (the issue is fundamentally about algorithm enforcement during verification) [1][2]. References (evidence) - NVD entry summarizing the issue and affected scope (python-jose through 3.3.0; algorithm confusion with OpenSSH ECDSA and other formats) [1]. - pypa advisory database record for PYSEC-2024-232 (CVE-2024-33663), including the fixed version boundary at 3.4.0 [4]. - Upstream python-jose 3.4.0 release notes mentioning the specific fix for CVE-2024-33663 [5].

Citations:


🌐 Web query:

CVE-2024-33664 python-jose JWT bomb DoS vulnerability

💡 Result:

CVE-2024-33664 is a denial-of-service (DoS) vulnerability in the python-jose library, nicknamed a "JWT bomb." It affects versions up to and including 3.3.0. Attackers can cause resource consumption by crafting a JSON Web Encryption (JWE) token with a high compression ratio, leading to excessive memory and processing time during decoding.[1][2][3] CVSS v3.1 base score: 5.3 (Medium), with vector AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L.[1][4] The vulnerability was reported in GitHub issue #344, which includes a PoC demonstrating significantly longer processing times for compressed tokens.[2] It is similar to CVE-2024-21319.[1] Fix: Upgrade to python-jose version 3.4.0 or later, released on 2025-02-14. The fix limits incoming JWE tokens and decompressed data to 250 KiB, implemented in pull request #352 (merged Feb 6, 2025).[3][5][6] Workaround: If not using JWE (jose.jwe), the vulnerability does not affect the application. Otherwise, monkey-patch by removing 'DEF' compression support: import jose.constants; jose.constants.ZIPS.SUPPORTED.discard('DEF')[2]. Limit maximum token length to 250K.[2]

Citations:


🏁 Script executed:

cat -n backend/requirements.txt | head -30

Repository: ASHUTOSH-KUMAR-RAO/Inferix

Length of output: 567


Upgrade python-jose[cryptography] to version 3.4.0 or higher to address two critical security vulnerabilities.

CVE-2024-33663 is an algorithm confusion vulnerability in python-jose ≤ 3.3.0 that affects JWT signature verification, particularly with OpenSSH ECDSA keys. An attacker with access to the public key can forge JWT signatures and bypass authentication.

CVE-2024-33664 is a denial-of-service vulnerability ("JWT bomb") in python-jose ≤ 3.3.0 where crafted JWE tokens with high compression ratios cause excessive memory and CPU consumption.

Both vulnerabilities are fixed in python-jose 3.4.0 (released February 14, 2025).

📌 Proposed fix
-python-jose[cryptography]
+python-jose[cryptography]>=3.4.0
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
python-jose[cryptography]
python-jose[cryptography]>=3.4.0
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/requirements.txt` at line 18, The requirements entry
"python-jose[cryptography]" is vulnerable; update the requirement to pin version
3.4.0 or later (e.g., change to "python-jose[cryptography]>=3.4.0") in
backend/requirements.txt, then regenerate any lock/compiled dependency files you
use (pip-compile, poetry lock, or pipenv lock) and reinstall dependencies so the
new version is picked up; finally run the test suite and your dependency
vulnerability scan to confirm the CVE fixes are applied.

httpx

# Utils
python-dotenv
python-multipart
pydantic
pydantic-settings

# Export
reportlab
markdown

# Voice
SpeechRecognition