Skip to content

feat: add SSRF allowlist - #8993

Open
bakirFS wants to merge 2 commits into
mainfrom
feat/ssrf-allowed-hosts
Open

bakirFS wants to merge 2 commits into
mainfrom
feat/ssrf-allowed-hosts

Conversation

@bakirFS

@bakirFS bakirFS commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Thanks for submitting a PR! Please check the boxes below:

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

closes #8992

Added an allowlist (SSRF_ALLOWED_HOSTS) coming from environment variables to let internal addresses be used

How did you test this code?

With tests and manually, created webhooks with http://127.0.0.1:9000/, it lets users use localhost if it is in
SSRF_ALLOWED_HOSTS otherwise not

@bakirFS
bakirFS requested review from a team as code owners November 17, 2026 13:17
@bakirFS
bakirFS requested review from Holmus and khvn26 and removed request for a team November 17, 2026 13:17
@vercel

vercel Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
docs Ready Ready Preview Nov 17, 2026 1:23pm UTC
2 Skipped Deployments
Project Deployment Actions Updated
flagsmith-frontend-preview Ignored Ignored Preview Nov 17, 2026 1:23pm UTC
flagsmith-frontend-staging Ignored Ignored Preview Nov 17, 2026 1:23pm UTC

Request Review

@github-actions github-actions Bot added api Issue related to the REST API docs Documentation updates labels Nov 17, 2026
@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Explain Change →

Walkthrough

Adds the SSRF_ALLOWED_HOSTS environment setting with an empty-list default. The validator normalises host patterns and skips the internal-address check when a host matches the allowlist. Tests cover allowed and rejected hosts, including a webhook request that uses an allowed private IP. The environment-variable reference describes the setting.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Severity of issue fixed: Medium

Merge Risk: Low · up to a544a

This adds an opt-in allowlist for trusted internal hosts, and it is off by default. The documentation should state that a leading-dot entry trusts the domain and all its subdomains. Operators otherwise may trust more hosts than they intend. A small documentation fix covers this before merge or soon after.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@github-actions github-actions Bot removed the docs Documentation updates label Nov 17, 2026
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-e2e:pr-8993 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api-test:pr-8993 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-frontend:pr-8993 Finished ✅ Results ✅
ghcr.io/flagsmith/flagsmith-api:pr-8993 Finished ✅ Results ✅
ghcr.io/flagsmith/flagsmith:pr-8993 Finished ✅ Results ✅
ghcr.io/flagsmith/flagsmith-private-cloud:pr-8993 Finished ✅ Results ✅

@github-actions github-actions Bot added the feature New feature or request label Nov 17, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

All reported issues were addressed across 5 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

@codecov

codecov Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.92%. Comparing base (4a45da1) to head (a544a38).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8993   +/-   ##
=======================================
  Coverage   98.92%   98.92%           
=======================================
  Files        1709     1710    +1     
  Lines       72181    72219   +38     
=======================================
+ Hits        71402    71440   +38     
  Misses        779      779           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor
✅ private-cloud · depot-ubuntu-latest-arm-16 — run #23326 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  3 passed

Details

stats  3 tests across 3 suites
duration  37.1 seconds
commit  a544a38
info  🔄 Run: #23326 (attempt 1)

🗂️ Previous results
✅ private-cloud · depot-ubuntu-latest-16 — run #23326 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  3 passed

Details

stats  3 tests across 3 suites
duration  32.4 seconds
commit  a544a38
info  🔄 Run: #23326 (attempt 1)

✅ oss · depot-ubuntu-latest-arm-16 — run #23326 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  36.2 seconds
commit  a544a38
info  🔄 Run: #23326 (attempt 1)

✅ oss · depot-ubuntu-latest-16 — run #23326 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  31.5 seconds
commit  a544a38
info  🔄 Run: #23326 (attempt 1)

✅ private-cloud · depot-ubuntu-latest-16 — run #23325 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  4 passed

Details

stats  4 tests across 3 suites
duration  55.3 seconds
commit  108b045
info  🔄 Run: #23325 (attempt 1)

✅ private-cloud · depot-ubuntu-latest-arm-16 — run #23325 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  3 passed

Details

stats  3 tests across 3 suites
duration  37.3 seconds
commit  108b045
info  🔄 Run: #23325 (attempt 1)

✅ oss · depot-ubuntu-latest-arm-16 — run #23325 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  37.2 seconds
commit  108b045
info  🔄 Run: #23325 (attempt 1)

✅ oss · depot-ubuntu-latest-16 — run #23325 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  32.1 seconds
commit  108b045
info  🔄 Run: #23325 (attempt 1)

…nt-variables.md


remove whitespace - cubic suggestion

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
@github-actions github-actions Bot added docs Documentation updates feature New feature or request and removed feature New feature or request docs Documentation updates labels Nov 17, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

0 issues found across 1 file (changes from recent commits).

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Requires human review: Adds an operator-configured SSRF_ALLOWED_HOSTS allowlist that exempts matching hosts from SSRF validation, with docs and tests. Decisive factor: this deliberately weakens SSRF protection for configured or wildcard hosts, a security-policy tradeoff needing human sign-off.

Turn on auto-fix | Re-trigger cubic

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Visual Regression

24 screenshots compared. See report for details.
View full report

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 927e893f-9138-426a-8754-cfbee2b9fba5
Commits

Reviewing files that changed from the base of the PR and between 108b045 and a544a38.

Files selected for processing: 1

  • docs/docs/deployment-self-hosting/core-configuration/environment-variables.md

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.


- `DJANGO_ALLOWED_HOSTS`: Comma-separated list of domains that can access the API. Alternatively `*` to allow any.
- `SSRF_ALLOWED_HOSTS`: Comma-separated list of trusted hosts that webhook and integration URLs can target, even if they
resolve to a private network address, e.g. `.internal.example.com`.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Minor · Security & Privacy · Quick win

Document the subdomain scope of a leading-dot entry.

A leading dot trusts the domain and all its subdomains. For example, .internal.example.com also trusts every name under internal.example.com. An operator who only intends to trust internal.example.com can therefore trust more hosts than planned. A subdomain under that domain that resolves to a private address can then be used as a webhook or integration target. The practical risk depends on who can create names under the trusted domain.

State this scope in the entry, and show the exact-host form for narrow access. A value without a leading dot matches only that host.

Suggested documentation change

--- "a/docs/docs/deployment-self-hosting/core-configuration/environment-variables.md"
+++ "b/docs/docs/deployment-self-hosting/core-configuration/environment-variables.md"
@@ -14,7 +14,8 @@
 
 - `DJANGO_ALLOWED_HOSTS`: Comma-separated list of domains that can access the API. Alternatively `*` to allow any.
 - `SSRF_ALLOWED_HOSTS`: Comma-separated list of trusted hosts that webhook and integration URLs can target, even if they
   resolve to a private network address, e.g. `.internal.example.com`.
+  A leading dot trusts the domain and all its subdomains. To trust only one host, omit the dot, e.g. `internal.example.com`.
 - `DATABASE_URL`: The URL of your PostgreSQL database. Both `postgres://` and `postgresql://` schemas are supported.
 - `DJANGO_DB_CONN_MAX_AGE`: Lifetime of a database connection, in seconds. Defaults to `60`. Set to `-1` to close the
   connection at the end of each request (Django's default behaviour). See

Scope reference: Django validate_host

Committable suggestion

IMPORTANT
Review the replacement and indentation, then test before committing.

Suggested change
resolve to a private network address, e.g. `.internal.example.com`.
resolve to a private network address, e.g. `.internal.example.com`.
A leading dot trusts the domain and all its subdomains. To trust only one host, omit the dot, e.g. `internal.example.com`.
Tools

LanguageTool

[typographical] ~17-~17: Two consecutive dots
Context: ...solve to a private network address, e.g. .internal.example.com. - DATABASE_URL: The URL of your Postg...

(DOUBLE_PUNCTUATION)

This branch was successfully deployed

1 active deployment
Preview – docs — a544a384 Deployed Nov 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Issue related to the REST API feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add an allowlist for SSRF protected URLs

1 participant