Skip to content

[Bug]: [Bug]: /api/poisoning/* endpoints crash — llm_poisoning_defense.py referenced by the router does not exist #1000

Description

@Rudra-clrscr

Bug Description

All four routes mounted under /api/poisoning (POST /validate, POST /detect, POST /train, GET /status) spawn a Python script at backend/llm_poisoning_defense.py via child_process.spawn. That file does not exist anywhere in the repository, so every call fails with ENOENT and each endpoint returns a 500 error. The LLM poisoning defense feature (originally implemented for #910, which is closed) is currently non-functional.

Affected file: backend/routes/poisoningRoutes.js (script path defined L9, used in every handler: L32, L67, L100, L126)
Confirmed mounted/reachable at: backend/server.js L33, L289 (app.use('/api/poisoning', poisoningRoutes))
Missing file: backend/llm_poisoning_defense.py

For comparison, the sibling routers point at scripts that do exist and work:

// backend/routes/adversarialRoutes.js
const DEFENSE_SCRIPT = path.join(__dirname, '../multi_level_defense.py'); // exists ✅
 
// backend/routes/evoMailRoutes.js
const EVOMAIL_SCRIPT = path.join(__dirname, '../evo_mail.py'); // exists ✅

llm_poisoning_defense.py has no such file in backend/.

Steps to Reproduce

  1. Start the Node/Express backend:
   cd backend
   npm start
  1. Confirm the script is missing:
   ls backend/llm_poisoning_defense.py
   # ls: cannot access 'backend/llm_poisoning_defense.py': No such file or directory
  1. Call any poisoning endpoint with a valid auth token (system_config permission required for /validate and /train):
   curl -X POST http://localhost:5000/api/poisoning/detect \
     -H "Authorization: Bearer <token>" \
     -H "Content-Type: application/json" \
     -d '{"text": "some text"}'
  1. Observe the failure response.

Expected Behavior

The endpoint should run the poisoning detector and return a JSON analysis (isSuspicious, score, patterns, etc.) combining the Python-side and Node-side (req.poisoningAnalysis) results, as documented in the route comments.

Actual Behavior

The request fails with a 500 response, e.g.:

{ "success": false, "error": "spawn python ENOENT" }

This happens identically for /api/poisoning/validate, /api/poisoning/train, and /api/poisoning/status — every route that calls runPoisoningDefense().

Screenshots

No response

Additional Information

No response

Metadata

Metadata

Assignees

Labels

SSoC26bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions