Skip to content

Implement CSRF protection with Flask-WTF #21#59

Merged
Eswaramuthu merged 2 commits into
Eswaramuthu:mainfrom
VishalRaut2106:feature/csrf-protection-21
Feb 12, 2026
Merged

Implement CSRF protection with Flask-WTF #21#59
Eswaramuthu merged 2 commits into
Eswaramuthu:mainfrom
VishalRaut2106:feature/csrf-protection-21

Conversation

@VishalRaut2106

Copy link
Copy Markdown
Contributor

mplements CSRF protection to prevent Cross-Site Request Forgery attacks on form submissions.

Changes:

Installed Flask-WTF.
Initialized CSRFProtect in app.py.
Added {{ csrf_token() }} to all POST forms in templates.
Verification:

Verified that forms (Login, Registration, Achievement Submission) include the token.
Verified that requests without the token are rejected (400 Bad Request).
Closes #21

@vercel

vercel Bot commented Feb 6, 2026

Copy link
Copy Markdown

@VishalRaut2106 is attempting to deploy a commit to the 007's projects Team on Vercel.

A member of the Team first needs to authorize it.

Comment thread app.py
# Enable CSRF protection
csrf = CSRFProtect(app)
app.secret_key = os.environ.get('SECRET_KEY', 'dev-secret-key-change-this-in-prod')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Correctness: The hardcoded fallback 'dev-secret-key-change-this-in-prod' for app.secret_key makes session and CSRF tokens predictable if the SECRET_KEY environment variable is not set. This is a security vulnerability that allows for session hijacking and CSRF bypass. Use a cryptographically secure random fallback or raise an error if the environment variable is missing.

🤖 AI Agent Prompt for Cursor/Windsurf

📋 Copy this prompt to your AI coding assistant (Cursor, Windsurf, etc.) to get help fixing this issue

In `app.py` at the line setting `app.secret_key`, remove the predictable hardcoded default. Use `os.environ.get('SECRET_KEY') or secrets.token_hex(16)` so dev remains functional while avoiding a fixed secret in production.

@vercel

vercel Bot commented Feb 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
achievement-management-system Ready Ready Preview, Comment Feb 12, 2026 0:05am

@VishalRaut2106

Copy link
Copy Markdown
Contributor Author

@Eswaramuthu i have resolved the conflicts

@Eswaramuthu Eswaramuthu merged commit d1fdb2b into Eswaramuthu:main Feb 12, 2026
1 of 2 checks passed
@VishalRaut2106

Copy link
Copy Markdown
Contributor Author

@Eswaramuthu bro, my all pr got merged,d but still I haven't got any point
image

@VishalRaut2106

Copy link
Copy Markdown
Contributor Author

@Eswaramuthu bro why arte you not giving points to me its more than a week and still i am on 0 points
#57
#59
#168

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SECURITY] Missing CSRF Protection on Form Submissions

2 participants