Skip to content

Security Fix: Add CSRF Protection Middleware#3399

Open
Regg819 wants to merge 1 commit intoaimhubio:mainfrom
Regg819:main
Open

Security Fix: Add CSRF Protection Middleware#3399
Regg819 wants to merge 1 commit intoaimhubio:mainfrom
Regg819:main

Conversation

@Regg819
Copy link
Copy Markdown

@Regg819 Regg819 commented Apr 1, 2026

Summary

This PR adds CSRF (Cross-Site Request Forgery) protection to the Aim web API.

Vulnerability

  • Type: CWE-352 (Cross-Site Request Forgery)
  • Severity: Medium (CVSS 6.5)
  • Affected: All versions up to 3.29.1

Fix

  • Add starlette.middleware.csrf.CSRFMiddleware to FastAPI application
  • Update CORS headers to allow X-CSRF-Token header

Impact

Prevents attackers from performing state-changing actions on behalf of authenticated users.

References

Buy Me a Coffee at ko-fi.com

- Add starlette CSRFMiddleware to FastAPI application
- Update CORS headers to allow X-CSRF-Token header
- Prevents Cross-Site Request Forgery attacks on state-changing API endpoints

CWE-352: https://cwe.mitre.org/data/definitions/352.html

Co-authored-by: Regg819 <Regg819@users.noreply.github.com>
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 1, 2026

CLA assistant check
All committers have signed the CLA.

@Regg819
Copy link
Copy Markdown
Author

Regg819 commented Apr 1, 2026

Hi team! Just checking in on this PR. Happy to address any feedback or make adjustments. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants