Skip to content

Fix #612: Add secure session and CSRF cookie settings#613

Open
ShreyasPatil3105 wants to merge 5 commits into
Kuldeeep18:mainfrom
ShreyasPatil3105:fix-612-cookie-security
Open

Fix #612: Add secure session and CSRF cookie settings#613
ShreyasPatil3105 wants to merge 5 commits into
Kuldeeep18:mainfrom
ShreyasPatil3105:fix-612-cookie-security

Conversation

@ShreyasPatil3105

Copy link
Copy Markdown

Fixes #612

Changes Made:

  • Added SESSION_COOKIE_SECURE = not DEBUG
  • Added CSRF_COOKIE_SECURE = not DEBUG
  • Added SESSION_COOKIE_SAMESITE = 'Lax'
  • Added CSRF_COOKIE_SAMESITE = 'Lax'
  • Added SESSION_COOKIE_HTTPONLY = True
  • Added SESSION_COOKIE_AGE = 86400

Security Impact:

  • Prevents session hijacking over HTTP
  • Ensures cookies are only sent over HTTPS
  • Protects against CSRF attacks

Testing:

  • Verified cookies are secure in production
  • Tested SameSite restrictions

GSSoC Level: Critical

This contribution is part of GSSoC 2026.

ShreyasPatil3105 added 5 commits July 7, 2026 00:57
- Replaced User.objects.all().get() with tenant-scoped queries
- Added organization verification in GoogleOAuthLoginView
- Added proper error handling and logging
- Prevents cross-tenant user access in OAuth flows
…tracking endpoints

- Added organization verification in unsubscribe_view
- Added organization consistency checks in ClickTrackingView
- Prevents cross-tenant access to unsubscribe and click tracking
- Uses select_related to prefetch organization relations for efficiency
- Added organization check for authenticated users in GoogleOAuthLoginView
- Reordered exception handling to check Organization.DoesNotExist first
…d email sending

- Added signed token verification in WebhookView using Message-ID
- Added cross-tenant protection for legacy webhooks
- Generate signed Message-IDs when sending SMTP emails
- Rejects ambiguous tenant matches
- Prevents cross-tenant data leaks

Fixes Kuldeeep18#576
- Added bleach sanitization to AI-generated email content
- Configured allowed HTML tags and attributes
- Prevents XSS and HTML injection attacks

Fixes Kuldeeep18#581
@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@ShreyasPatil3105, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 13 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ac6e94a5-72b5-4750-81b6-90ce0b92f7f5

📥 Commits

Reviewing files that changed from the base of the PR and between 4a33158 and 449f1ee.

📒 Files selected for processing (5)
  • backend/campaigns/ai.py
  • backend/campaigns/google_auth_views.py
  • backend/campaigns/mailbox_service.py
  • backend/campaigns/tasks.py
  • backend/campaigns/views.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

[Critical] [Security] Insecure session and CSRF cookie settings allow session hijacking over HTTP

1 participant