SaaS Tenant Restriction using PAN-OS HTTP Header Insertion

Controlling user access *within* sanctioned Software-as-a-Service (SaaS) applications is a critical security challenge. Unsanctioned usage of SaaS applications, particularly accessing personal or consumer versions (e.g., personal Microsoft 365, Google Drive), can be a significant vector for sensitive information leaving your network.

Even if you need to allow access to the enterprise version of these applications for legitimate business purposes, you often want to prevent access to all other tenants from the corporate network. Blocking the entire SaaS application isn't feasible in these cases.

Palo Alto Networks firewalls can help enforce **SaaS Tenant Restrictions** by leveraging HTTP Header Insertion . This involves the firewall injecting specific HTTP headers, recognized by major SaaS providers like Microsoft and Google, into user login requests. These headers explicitly declare which specific tenant(s) the user is permitted to access from the corporate network.

This capability allows you to disallow SaaS consumer accounts while permitting access only to specific, sanctioned enterprise accounts.

Core Concept: The firewall intercepts SaaS login requests, decrypts them, and inserts predefined headers (e.g., `Restrict-Access-To-Tenants`) with specific values (allowed tenant IDs). The SaaS provider then reads this header and enforces access, blocking logins to unauthorized tenants.

Note: According to Palo Alto Networks documentation, using the HTTP Header Insertion feature for tenant restriction does not require a separate URL Filtering license.

Concept & Use Cases - Why Restrict SaaS Tenants?

Implementing SaaS tenant restrictions provides several key security benefits:

Scenario: Data Leak via Personal Drive

An employee wants to take work home. Instead of using the corporate OneDrive (which might have DLP policies), they log into their personal OneDrive account from their work laptop on the corporate network and upload sensitive design documents. Without tenant restriction, this is often possible. With tenant restriction enforced by the firewall inserting the corporate tenant ID header, Microsoft's login service would see the header, recognize the user is trying to access a different tenant (personal), and block the login from the corporate network.

Concept & Use Cases - How Header Insertion Enables Tenant Restriction

Unlike inserting user identity headers (like `X-Authenticated-User`), tenant restriction relies on inserting **specific, predefined header names** with **static values** (your allowed tenant IDs or domains).

  1. User Initiates Login: The user attempts to log in to a SaaS application (e.g., `login.microsoftonline.com`, `accounts.google.com`).
  2. Firewall Intercepts & Decrypts: The PAN-OS firewall intercepts the HTTPS connection. Decryption is essential as the headers need to be inserted into the encrypted HTTP request to the login service.
  3. Policy Match & Profile Application: A Security Policy rule matching the SaaS login domains/URLs and potentially specific users/groups triggers an associated HTTP Header Insertion profile.
  4. Header Insertion (Predefined or Custom Type): The profile is configured to insert the required header(s).
    • PAN-OS provides **Predefined Types** for common scenarios like Microsoft 365 enterprise restrictions, simplifying configuration. These are maintained via content updates.
    • For other SaaS apps, or specific cases like M365 consumer restriction, the **Custom Type** is used:
      • The **Header Name** is set to the exact name required by the SaaS vendor (e.g., `Restrict-Access-To-Tenants`).
      • The **Header Value** is set to a **static string** containing the list of allowed Tenant IDs or domains, formatted precisely as required by the vendor.
  5. Request Forwarded: The firewall forwards the modified HTTPS request (with the inserted tenant restriction header) to the SaaS provider's login service.
  6. SaaS Provider Enforcement: The SaaS provider's service reads the specific header. If the user is attempting to authenticate to a tenant *not* listed in the header's value, the SaaS provider blocks the login attempt. If they are logging into an allowed tenant, the login proceeds normally.
Key Difference: The firewall isn't dynamically determining the header value based on the user; it's inserting a *static policy statement* (the allowed tenants) defined in the profile. The *SaaS provider* reads this statement and enforces the restriction. User-ID on the firewall remains important for applying the *correct policy rule* to the user's traffic initially.

Concept & Use Cases - Use Case: Data Exfiltration Prevention

This is the most common driver for implementing tenant restrictions.

This significantly reduces the risk of accidental or intentional data leakage via common cloud vectors by leveraging the SaaS provider's own enforcement capabilities.

Concept & Use Cases - Use Case: Compliance & Policy Enforcement

Tenant restrictions also support broader compliance and IT policy goals:

Consider how tenant restrictions align with your Acceptable Use Policy (AUP) and data governance framework.

SaaS Support & Headers - SaaS Header Overview

Before configuring, it's crucial to understand the specific custom HTTP headers required by the SaaS application you intend to manage. Different providers use different header names and expect different values.

Palo Alto Networks provides predefined support for common applications, simplifying configuration. However, for others, or for more granular control, you'll use the 'Custom' header type.

The following sections detail the headers for major providers based on available documentation. Remember that SaaS applications not listed here might still support tenant restriction via headers, but you will need to consult their specific documentation.

Be aware that some headers control access to *types* of accounts (enterprise vs. consumer), while others control access to *specific* tenants/organizations, and some control in-app features (like YouTube's content restriction).

Always verify the exact header requirements with the SaaS vendor's current documentation.

SaaS Support & Headers - Microsoft 365 Headers

Microsoft supports tenant restrictions targeting Azure AD (Entra ID) logins.

Reference: Microsoft Tenant Restrictions V2 Documentation (Note: PAN-OS configuration examples often reference V1 headers.)

Enterprise Tenant Restriction (V1 Headers):

Consumer Account Restriction (MSA):

Configure both sets of headers (typically via one Predefined entry and one Custom entry in the profile) to control both unauthorized enterprise and personal Microsoft account access.
Find your Tenant ID/Directory ID in the Azure/Entra portal. Verify header names and target domains against current Microsoft documentation, especially regarding V1 vs. V2 implementations.

SaaS Support & Headers - Google Workspace Headers

Google Workspace supports restriction via headers.

Reference: Google Workspace - Block access to consumer accounts

Use the `Custom` type. Prefer `X-Goog-Allowed-Resources` with Customer IDs per Google's recommendation. Ensure prerequisites like QUIC blocking and potential HTTP/2 handling are addressed.

SaaS Support & Headers - Dropbox & YouTube Examples

PAN-OS provides predefined types or guidance for other services:

Dropbox (Tenant Restriction):

YouTube (Content Restriction):

Use the correct header for the intended purpose (tenant restriction vs. content filtering). Leverage Predefined types when available and applicable.

SaaS Support & Headers - Header Limits & Vendor Documentation

PAN-OS Header Limits:

Be aware of the character limits for HTTP header insertion in PAN-OS:

These are generally sufficient, but verify if your SaaS provider uses exceptionally long header names or requires extremely long lists of IDs/domains in the value field.

Importance of Vendor Documentation:

Before configuring, always consult the official documentation for the specific SaaS application .

The SaaS vendor's documentation is the definitive source for tenant restriction header requirements.

Configuration Steps - Prerequisites (Decryption)

Key prerequisites must be met before configuring tenant restriction:

  1. SSL Forward Proxy Decryption: **(MANDATORY)**
    • Configure Decryption Profiles and Policies to successfully decrypt traffic to the specific SaaS **login domains** identified for the target application(s).
    • Deploy the firewall's forward trust certificate to client machines.
    • Address potential certificate pinning issues with appropriate exclusions if necessary (but note that excluded traffic cannot have headers inserted).
  2. Identify SaaS Login Domains: Obtain the list of FQDNs used during authentication from vendor documentation (e.g., `login.microsoftonline.com`, `accounts.google.com`, `login.live.com`).
  3. Obtain Allowed Tenant Info: Find your corporate Tenant ID(s), registered domain(s), or Customer ID(s) in the vendor-required format.
  4. Network Path: Ensure relevant user traffic routes through the PAN-OS firewall.
  5. (If Google) Handle QUIC: Create a high-priority Security rule to block the `quic` App-ID.
  6. (If needed) Handle HTTP/2: Consider enabling `Strip ALPN` in the relevant Decryption Profile if header insertion issues persist, particularly with Google.
PCNSE Relevance: SSL Decryption configuration (policies targeting specific URLs/Categories, profiles, certificate handling) is essential. Understanding protocol dependencies (QUIC, HTTP/2) is also relevant.

Configuration Steps - Profile (Predefined & Custom Types)

Configure the profile under Objects > Security Profiles > HTTP Header Insertion .

Using Predefined Types (e.g., M365 Enterprise, YouTube, Dropbox):

This simplifies setup for common, known headers.

  1. Click **Add** to create a new profile or edit an existing one.
  2. Give the profile a **Name** (e.g., `Tenant-Restrictions-Profile`).
  3. Inside the profile, click **Add** to create an entry.
  4. Give the entry a **Name** (e.g., `TR-M365-Enterprise`).
  5. Select the `User-Agent` tab for the entry.
  6. Select the relevant **Type** from the dropdown (e.g., `Microsoft Office365 Tenant Restrictions`).
  7. The `Domains` list and `Headers` section will pre-populate.
  8. Fill in the required **Value(s)** for the pre-populated Headers based on vendor requirements (e.g., Allowed Tenant IDs for `Restrict-Access-To-Tenants`, Your Tenant ID for `Restrict-Access-Context`).
  9. (Optional) Enable `Log`.
  10. Click **OK** for the entry, then **OK** for the profile.

Using Custom Type (e.g., M365 Consumer, Google, Other SaaS):

Use this when no predefined type exists or for specific control.

  1. Within the same or a new profile, click **Add** to create another entry.
  2. Give the entry a **Name** (e.g., `TR-Google`, `TR-M365-Consumer`).
  3. Select the `User-Agent` tab.
  4. Select the **Type:** `Custom`.
  5. In the `Domains` list, **Add** the specific SaaS login domain(s) for *this* specific restriction (e.g., `accounts.google.com`).
  6. In the `Headers` list, click **Add**:
    • Enter the vendor-required header **Name** (e.g., `X-Goog-Allowed-Resources`).
    • Enter the required static **Value** (e.g., `YourGoogleCustomerID1`).
  7. Repeat adding headers if needed for this entry.
  8. (Optional) Enable `Log`.
  9. Click **OK** for the entry, then **OK** for the profile.
A single HTTP Header Insertion Profile object can contain multiple entries, each targeting different domains with different headers (Predefined or Custom). Apply this single profile object to your Security Policy rule(s).
PCNSE Relevance: Knowing how to configure both Predefined and Custom header entries within the HTTP Header Insertion profile object is key.

Configuration Steps - Policy (Targeting SaaS Logins)

Apply the profile via a Security Policy rule ( Policies > Security ) specifically matching the login traffic.

  1. Create or modify Security Policy rule(s). You might need distinct rules if decryption requirements or source users differ for various SaaS login domains.
  2. Configure the rule match criteria:
    • Source: Appropriate internal zones/users.
    • Destination Zone: `untrust`.
    • Application: Specific login App-IDs if accurate (e.g., `ms-entra-id`) or `ssl`.
    • Service/URL Category: **CRITICAL:** Use a Custom URL Category or Address Objects containing **only the specific login FQDNs** targeted by the entries in your Header Insertion profile (e.g., `login.microsoftonline.com`, `accounts.google.com`, `login.live.com`).
  3. Configure the **Actions** tab:
    • Action: `Allow`.
    • Profile Setting:**
      • Type: `Profiles`
      • Select the **HTTP Header Insertion** profile object containing your tenant restriction entries.
      • Ensure **Decryption** is applied (either via Decryption Profile here, or ensure a matching Decryption Policy rule exists with Action=Decrypt).
    • Logging: Enable 'Log at Session End'.
  4. Click **OK** and **Commit**.
Applying the profile to rules matching broad App-IDs (like `google-drive`) or general web categories will likely fail or insert headers unnecessarily. Target only the specific login URLs/domains.

Configuration Steps - Verification (Testing Blocked Access)

The primary verification goal is confirming that access to **unauthorized** tenants is blocked **by the SaaS provider**.

Testing Steps:

  1. Test Allowed Tenant(s): Log in to your sanctioned corporate SaaS tenant(s). This must succeed normally.
  2. Test Disallowed Tenant(s): **(Most Important)** Attempt to log in to a known disallowed tenant (personal account, different org) from a client subject to the policy.
    • Expected Result: The SaaS provider should block the login and display their specific error message related to tenant restrictions or organizational policy. See example below.
  3. Check Firewall Logs (Troubleshooting):
    • Traffic Log: Verify the login attempt hits the correct Security Rule and the action is 'allow'.
    • Decryption Log: Verify the session to the login domain was successfully 'decrypted'.
  4. Packet Capture (Advanced): Egress capture on the firewall during a disallowed login attempt can confirm the correct header *was inserted* by the firewall before being sent to the SaaS provider.
Microsoft error page indicating access blocked by organizational policy
Example error message from Microsoft when Tenant Restriction blocks access.
Successful verification means the **SaaS provider blocks unauthorized logins**, not the firewall itself.

Configuration Steps - M365 Configuration Example Notes

This summarizes the configuration steps based on the provided Palo Alto Networks KCS article description (focused on V1 headers):

  1. Decryption Policy: Ensure a Decryption rule decrypts traffic (SSL Forward Proxy) to:
    • login.microsoftonline.com
    • login.microsoft.com
    • login.windows.net
    • login.live.com
    (Using a Custom URL Category for these is recommended).
    Example Decryption Policy Row Snippet
    Example snippet of a Decryption Policy targeting login URLs.
  2. HTTP Header Insertion Profile: (Objects > Security Profiles > HTTP Header Insertion)
    • Add Entry 1 (Enterprise):
      • Name: e.g., `TR-M365-Enterprise`
      • Type: `Microsoft Office365 Tenant Restrictions`
      • Value for `Restrict-Access-To-Tenants`: Your allowed Tenant IDs/domains
      • Value for `Restrict-Access-Context`: Your Tenant ID
      Example M365 Enterprise Header Insertion Configuration
      Example M365 Enterprise Header Configuration (Predefined Type).
    • Add Entry 2 (Consumer):
      • Name: e.g., `TR-M365-Consumer`
      • Type: `Custom`
      • Domains: `login.live.com`
      • Headers: Add Name=`sec-Restrict-Tenant-Access-Policy`, Value=`restrict-msa`
      Example M365 Consumer Header Insertion Configuration
      Example M365 Consumer Header Configuration (Custom Type).
    Example HTTP Header Insertion Entries List
    Example list showing both M365 entries in the profile.
    (Note: The source images show configuration within a URL Filtering profile, which is the older method. Configure these entries within an HTTP Header Insertion profile object instead).
  3. Security Policy:
    • Create a rule allowing traffic to the Microsoft login domains (using the Custom URL Category or Address Objects).
    • Apply the HTTP Header Insertion profile object created above.
    • Ensure Decryption is active for this rule.
    Example Security Policy Row Snippet
    Example snippet of a Security Policy allowing login traffic.
    Example Security Policy Actions Tab showing Profile applied
    Example Security Policy Actions tab applying the profile.
  4. Commit Changes.
  5. Verify: Test logins as described in the Verification section. Expect the Microsoft block page for disallowed tenants.

Advanced & PCNSE - Tenant Restriction vs. User Identity Headers

It's crucial to distinguish these two uses of HTTP Header Insertion:

Feature Tenant Restriction Headers User Identity Headers
Purpose Inform SaaS provider which tenant(s) are allowed for login/access. Inform downstream device (CASB, proxy, web app) who the user is.
Typical Header Name(s) Defined by SaaS vendor (e.g., `Restrict-Access-To-Tenants`) Custom or conventional (e.g., `X-Authenticated-User`)
Header Value Source **Static** string (List of allowed Tenant IDs/Domains) **Dynamic** value from User-ID mapping
Profile Header Type Used **Custom** or **Predefined** (if available) Username, Domain, User@Domain, Domain\User
Who Enforces? The **SaaS Provider** The **Downstream Device**
Primary Benefit Prevent access to unauthorized SaaS tenants. Enable user-aware logging/policy downstream.

Advanced & PCNSE - Limitations & Caveats

Tenant restriction via header insertion has limitations:

Advanced & PCNSE - Troubleshooting Tenant Restriction

If disallowed tenant access is *not* being blocked:

  1. Confirm Decryption Success: Check Decryption logs for the specific SaaS login domain(s). Status MUST be 'Success'.
  2. Verify Policy Match for Login: Check Traffic logs. Is the login attempt hitting the *correct* Security rule with the TR profile applied?
  3. Check Profile Configuration: Correct Header Name(s)? Type=Custom/Predefined? Correct static Value? Correct login Domains listed in the profile entry? (M365) Both headers included?
  4. Check Profile Application: Is the profile correctly selected in the Security rule's Actions tab?
  5. Packet Capture (Egress): Analyze decrypted request. Are headers present *exactly* as configured?
  6. Confirm Tenant IDs/Values: Double-check Tenant IDs, Customer IDs, domain names against vendor portals/docs. Check required format (commas, no spaces etc).
  7. Verify SaaS Provider Side: Consult vendor docs – are there server-side settings? Is the header/value still supported?
  8. (Google) Check QUIC/HTTP2: Is QUIC blocked? Try stripping ALPN.
PCNSE Relevance: Troubleshooting requires checking Decryption -> Policy Match -> Profile Applied -> Profile Config -> Egress Packet.

Advanced & PCNSE - PCNSE Exam Relevance Summary

Understanding HTTP Header Insertion for Tenant Restriction tests core PAN-OS knowledge relevant to the PCNSE:

Focus on the interplay between Decryption, precise Policy targeting, and correct Profile configuration (especially Custom type with static values) for implementing specific SaaS controls.

Quiz: SaaS Tenant Restriction via Header Insertion

Test your understanding of using PAN-OS for SaaS Tenant Restriction.

1. What is the primary security risk addressed by SaaS Tenant Restriction using HTTP headers?

2. Which configuration object defines the specific header (e.g., `Restrict-Access-To-Tenants`) and its value (the allowed Tenant IDs)?

3. What 'Type' must be selected in the HTTP Header Insertion profile when configuring the `sec-Restrict-Tenant-Access-Policy: restrict-msa` header for M365 consumer accounts?

4. What is the MOST critical prerequisite for the firewall to insert tenant restriction headers into SaaS login requests?

5. Which entity actually enforces the tenant restriction based on the inserted header?

6. What header does Microsoft 365 typically use to receive the list of allowed tenant IDs (V1 method)?

7. What information should be placed in the value of the `Restrict-Access-Context` header for M365?

8. What value format is generally recommended by Google for the `X-Goog-Allowed-Resources` header?

9. How should the Security Policy rule destination be configured for applying M365 tenant restrictions effectively?

10. The BEST way to confirm SaaS tenant restriction via header insertion is working is to:

11. The value inserted for tenant restriction headers is determined by:

12. What is the purpose of the `YouTube-Restrict` predefined header insertion type?

13. If Decryption logs show "Policy Deny" for `login.microsoftonline.com`, what is the impact on tenant restriction?

14. The PAN-OS documentation mentions blocking which protocol is often necessary for reliable header insertion with Google services?

15. What is the maximum length of a header *name* that can be configured in a PAN-OS HTTP Header Insertion profile?

16. Where do you typically find the authoritative information on the exact header name and value format required for tenant restriction by a specific SaaS vendor?

17. True or False: Tenant restriction headers (like `Restrict-Access-To-Tenants`) contain dynamically generated user information from User-ID.

18. If you need to implement tenant restrictions for a SaaS app not listed in PAN-OS predefined types, which profile type MUST you use?

19. What is the primary purpose of the `Restrict-Access-Context` header in M365 tenant restrictions?

20. Implementing SaaS tenant restriction requires careful coordination between firewall configuration and understanding: