Kuboid
Open Luck·Kuboid.in
Security BSides2025
Open in YouTube ↗

Mapping the SaaS Attack Surface

Security BSides San Francisco177 views28:4010 months ago

This talk demonstrates techniques for mapping an organization's SaaS attack surface by leveraging DNS records, JavaScript imports, and OSINT tools to identify external-facing assets. It highlights how attackers can exploit misconfigured SaaS tenants, lack of MFA, and SSO misconfigurations to gain unauthorized access. The presentation provides actionable best practices for both organizations and SaaS providers to mitigate these risks, including the use of SAML identity provider (IdP) tokens as canary tokens. A custom tool for automating SaaS tenant discovery is also introduced.

Mapping the SaaS Attack Surface: Beyond the Perimeter

TLDR: SaaS applications are the new, unmanaged perimeter, and attackers are actively exploiting misconfigured tenants and weak SSO implementations to gain unauthorized access. By leveraging DNS records, JavaScript imports, and OSINT, researchers can map an organization's entire SaaS footprint to identify shadow IT and potential entry points. This post details how to automate this discovery process and why your organization's reliance on default SaaS configurations is a critical security failure.

Security teams spend years hardening the network perimeter, only to watch developers and business units bypass those controls by signing up for dozens of SaaS applications. These services are often integrated into the corporate identity provider, yet they remain largely unmanaged and invisible to the security operations center. This visibility gap is exactly where modern attackers are focusing their efforts. They are not looking for complex zero-day exploits in your firewall; they are looking for the misconfigured SaaS tenant that allows anyone with a corporate email address to join, or the SSO implementation that fails to enforce multi-factor authentication.

The Mechanics of SaaS Discovery

Mapping an organization's SaaS attack surface starts with the realization that these services leave a trail of breadcrumbs in public records. The most straightforward method involves analyzing DNS records. Many SaaS providers require domain ownership verification, which is often implemented through TXT records or specific subdomains.

A simple query against a target's DNS can reveal a surprising amount of information. For example, checking MX and SPF records often exposes the email security stack, such as Proofpoint or other gateways, while TXT records frequently contain domain verification strings for services like Google Workspace or Microsoft Entra ID.

Beyond DNS, JavaScript imports on a company's public-facing websites are a goldmine. By crawling these pages, you can identify the analytics, marketing, and support tools the organization uses. If you see a script tag pointing to a specific CDN or a known SaaS endpoint, you have identified a potential target. Tools like urlscan.io are invaluable here, as they provide a historical view of these imports and can help you correlate them with specific business units or departments.

Exploiting the SSO Trust Relationship

Once you have mapped the SaaS footprint, the real work begins. The most dangerous misconfiguration is the "Service Provider-initiated" (SP-initiated) SSO flow. In this scenario, a user navigates to the SaaS application, enters their email, and is redirected to the organization's identity provider.

The vulnerability arises when the SaaS application is configured to allow any user from the organization's domain to authenticate, regardless of whether they have been explicitly provisioned. An attacker can simply enter a target email address into the login page. If the application redirects them to the corporate IdP, they have confirmed that the organization uses that service. If the IdP then allows the authentication to proceed without requiring MFA, the attacker has a direct path into the application.

This is particularly effective against multi-tenant SaaS platforms that do not enforce strict tenant isolation. An attacker can create a "shadow tenant" of the same application, or even a completely different one, and use it to test for valid corporate credentials. If the organization has not disabled user invites or restricted access to specific domains, the attacker can often gain a foothold with minimal effort.

Automating the Hunt

Manual discovery is slow, but the process is highly automatable. By building a tool that iterates through a list of common SaaS providers and attempts to trigger their SSO flows using a target domain, you can map an entire organization's SaaS usage in minutes.

# Example logic for checking SaaS SSO redirection
import requests

def check_sso(domain, provider_url):
    response = requests.get(f"{provider_url}/login?email=test@{domain}")
    if "redirect" in response.headers:
        return True
    return False

This approach allows you to identify which applications are integrated with the corporate IdP and, more importantly, which ones are not. For those that are not, you can then pivot to testing for password reuse or brute-forcing, as these applications often lack the centralized security controls of the main IdP.

Defensive Strategies for the Modern Enterprise

Defending against this requires a shift in mindset. You cannot protect what you cannot see. The first step is to implement a strict policy for SaaS adoption that requires all new services to be integrated with the corporate IdP. If a service does not support SSO, it should be treated as a high-risk asset and subjected to additional scrutiny.

Furthermore, you should monitor for the creation of new, unmanaged tenants. Many SaaS providers offer APIs that allow you to query for existing tenants associated with your domain. Regularly auditing these, combined with monitoring for suspicious login activity from unusual IP addresses or user agents, is essential.

Finally, consider using SAML IdP tokens as "canary tokens." By creating a dummy application in your IdP and monitoring for any authentication attempts against it, you can detect when an attacker is probing your SSO configuration. This is a low-effort, high-signal technique that can provide early warning of an ongoing reconnaissance effort.

The SaaS attack surface is not going away. It is growing, and it is becoming the primary vector for initial access in many modern breaches. Stop treating these applications as external to your security program and start mapping them with the same rigor you apply to your internal infrastructure. If you don't, the attackers will do it for you.

Talk Type
talk
Difficulty
intermediate
Has Demo Has Code Tool Released


BSidesSF 2025

94 talks · 2025
Browse conference →
Premium Security Audit

We break your app before they do.

Professional penetration testing and vulnerability assessments by the Kuboid Secure Layer team. Securing your infrastructure at every layer.

Get in Touch
Official Security Partner
kuboid.in