# Embedding partner tools in MENA portals: iframe security

A merchant opens a supplier tool inside a business portal. The frame looks like part of the product, but another organisation operates it. Then the tool sends a message asking the portal to select a customer, resize the page or mark a task complete.

The engineering question is what that message is allowed to mean. An iframe gives a partner a place on screen; it should not quietly give that partner the authority of the signed-in user.

This guide proposes an integration contract for Arabic-English MENA business portals. Consider separate Saudi and UAE customer deployments, each with approved partner tools. The examples are design recommendations, not claims about a named provider's API, national hosting requirements or a tested implementation.

*Cover: original SultanByte artwork showing a partner frame separated from the portal and its server-side permission checks.*

## Decide whether the tool belongs in a frame

Ask the supplier for its supported embedding model before writing the integration. Get the production and test origins, authentication flow, message protocol and required browser capabilities. A working demonstration on a developer's laptop is not a support commitment.

Use a top-level handoff when the supplier cannot support an embedded journey reliably. Keep an ordinary link available for recovery, but make the destination and the fact that the user is leaving the portal clear. Do not put credentials in that link to make the transition convenient.

For the proposed deployments, maintain a server-controlled mapping from customer configuration to approved partner origin. Saudi and UAE entries may differ because the contracted integrations differ. The interface language must not choose the partner environment, and a query-string parameter must not override the mapping.

Keep the integration record small enough to review: owner, purpose, exact origins, permitted messages, requested capabilities and exit route. Changes to those fields deserve review even when the supplier calls them a minor widget update.

## Separate permission to embed from permission to act

The [W3C Content Security Policy specification](https://www.w3.org/TR/CSP3/#directive-frame-src) distinguishes two directions. The parent's `frame-src` constrains what it loads into child frames. The child's `frame-ancestors` constrains which ancestors may embed it. One does not configure the other.

Ask the supplier to permit the intended portal origins in its embedding policy. Check the deployed response, including any intermediate hosting layer. `frame-ancestors` does not inherit a missing value from `default-src`, and it is ignored in a CSP meta element; it belongs in the response policy.

Neither directive authorises a customer-record update. Keep that decision on the application's server. [OWASP's authorization guidance](https://cheatsheetseries.owasp.org/cheatsheets/Authorization_Cheat_Sheet.html#validate-the-permissions-on-every-request) calls for permission checks on every request, regardless of its initiator.

In this design, a child can announce that its workflow has finished. The parent then asks its own backend for the authoritative status. It must not treat a message such as `approved: true` as sufficient evidence to approve a supplier, release funds or close a compliance review.

The distinction also helps procurement. The provider should explain which outcomes its browser UI can report and which require a server integration. If that boundary is undocumented, treat it as unfinished integration work.

## Choose the sandbox deliberately

The [HTML Standard's iframe definition](https://html.spec.whatwg.org/multipage/iframe-embed-object.html#attr-iframe-sandbox) describes sandbox restrictions and the tokens that relax them. A sandbox without allowances disables capabilities including scripts and forms and gives the content an opaque origin. Adding tokens changes that boundary.

There is no universal safe token string for every partner. Start from the supplier's documented requirements, justify each allowance and test the resulting journey. A document viewer should not inherit popup, download or top-level navigation permissions simply because a different integration needs them.

Pay attention to `allow-same-origin`: it preserves the embedded document's real origin; it does not make a foreign site same-origin with the portal. The standard warns that combining it with `allow-scripts` for content already on the parent's origin can let that content remove the sandbox and reload out of it. Keep untrusted content off the portal's origin.

The origin-checked message contract below assumes a reviewed partner document with its normal, non-opaque origin. Do not accept the string `null` as a trusted partner identity to accommodate an opaque-origin sandbox. Choose a different reviewed integration model rather than weakening the check.

Review camera, microphone and location separately. The [W3C Permissions Policy draft](https://www.w3.org/TR/permissions-policy/) describes feature controls across parent documents and frames. Delegating a feature through an iframe's `allow` attribute cannot override a restriction inherited from the parent. Verify the specific features on supported browsers; a policy declaration is not a cross-browser test result.

## Give messages a narrow vocabulary

The [HTML Standard's cross-document messaging guidance](https://html.spec.whatwg.org/multipage/web-messaging.html) requires care with both sender origin and message format. It advises against a wildcard target origin for confidential messages. It also recommends waiting for the child to announce readiness before sending messages to a newly navigated document.

For this design, accept a message only when its origin exactly matches the approved origin and its `source` matches the active iframe's `contentWindow`. Validate the protocol version, message type and bounded payload before dispatching it. Checking the frame reference alone does not establish the document's origin.

Use a short vocabulary such as ready, resize and completion-notice. Give each type its own schema. A resize request may supply a finite height within product-defined limits; it must not supply arbitrary CSS. A completion notice may identify the current interaction; it must not choose a tenant, API URL or privileged operation.

[OWASP's HTML5 security guidance](https://cheatsheetseries.owasp.org/cheatsheets/HTML5_Security_Cheat_Sheet.html#web-messaging) warns against substring origin checks and against evaluating received data as code or inserting it as HTML. An approved hostname appearing somewhere inside a longer hostname is not an exact match.

Keep both sides of the protocol responsible. The child should validate its parent and use an explicit destination origin too. Do not send the portal's session token, full customer record or unrestricted API credential through this channel. Define the minimum context needed for the agreed interaction.

![Proposed partner-frame contract: approve the embed origin and capabilities; validate the message origin, source and schema; bind messages to the current interaction; then let the server authorise any business change. A frame message is a request, not a grant of authority.](https://cdn.hashnode.com/uploads/covers/60ecf4a0fc37a15ec15655e8/9f9d92e8-8305-45e4-b6f2-fa517f5d5a07.png align="center")

*Original infographic: SultanByte. Proposed integration framework informed by WHATWG HTML, W3C CSP and Permissions Policy, and OWASP guidance, October 2026. It shows design responsibilities, not measured security performance.*

## Retire the conversation when the context changes

An origin check does not answer whether a message belongs to the customer currently on screen. A user can switch customers while a partner operation is still running. A delayed message from an otherwise valid origin must not update the new customer's view.

Give each interaction a fresh identifier bound to the current account, tenant, frame instance and workflow. Keep that binding in parent-controlled state. Require replies to refer to the active interaction, and reject unknown, retired or out-of-order message types.

Treat navigation as a new handshake. A ready message should lead to a fresh parent-issued challenge and a validated response before business messages become eligible. The challenge correlates the exchange; it does not make a compromised partner trustworthy. Do not send sensitive initialization data in an unsolicited first message.

On logout, customer change, frame replacement or an unexpected reload, retire the interaction and stop accepting its business messages. Remove listeners when the component is destroyed. If a provider cannot echo the required interaction identity, avoid overlapping workflows or require a different integration contract.

Bound accepted message frequency as well as payload size. A valid partner origin can still produce a broken resize loop. Collapse redundant presentation updates and prevent repeated completion notices from triggering unlimited backend calls. The server must independently handle repeated requests without duplicating a consequential action.

## Make the Arabic journey usable outside the happy path

Give the frame a descriptive, localised title. [W3C technique H64](https://www.w3.org/WAI/WCAG22/Techniques/html/H64) explains that the iframe `title` labels the frame for navigation; it does not label the document's internal content. Ask the supplier to provide a meaningful document title and accessible controls inside its own page as well.

Test the actual Arabic child document, not an English frame surrounded by an RTL parent. Agree how locale is selected, whether changing it restarts the interaction and what happens to unsaved work. Preserve identifiers and amounts as typed data rather than extracting them from translated display strings.

For the proposed portal, require keyboard entry and exit, a visible recovery route and error messages that distinguish loading failure from business rejection. Check focus after the frame closes. If embedded authentication fails on a supported browser, offer the approved handoff instead of endlessly reloading the frame or relaxing security policy.

## Use an acceptance record the supplier can reproduce

Keep these proposed cases beside the integration contract. Record the browser version, parent and child builds, starting account context and observed outcome. These are release requirements, not reported test results:

- Send a valid-looking message from an unapproved origin. Require no business request and no privileged UI change.
- Send from a second frame on the approved origin. Require rejection when its source does not match the active frame.
- Send an unknown type, malformed payload or excessive resize value. Require bounded rejection without interpreting supplied markup.
- Switch customer context, then deliver an old completion notice. Require the new customer's state to remain unchanged.
- Navigate or replace the child, then replay the retired interaction. Require a new handshake before accepting business messages.
- Revoke the user's server permission after the frame opens. Require the backend to refuse the protected action even if browser messaging succeeds.
- Repeat the Arabic journey with keyboard navigation, narrow screens, expired authentication and a failed partner load. Require a usable exit and an accurate status message.

The buyer's deliverable is a supported integration contract with named owners on both sides. The engineering team's deliverable is evidence that an embedded tool can request only the agreed behaviour, within the current interaction, while the server retains authority over customer data and business outcomes.
