Route an Incoming SMS to the Right Tenant Before Showing Its Body

Published: · Updated:
Share

Before displaying an incoming SMS, establish its tenant using trusted resource mappings. A valid provider signature supports source authentication; it does not replace the application’s own tenant authorisation.

Authentication is the beginning of routing

Verify the provider request using the documented mechanism. Then resolve its account and resource references against server-controlled configuration. Do not let an arbitrary tenant name in a URL parameter or message body replace that mapping.

The recipient number can be one useful field, but it may be insufficient on its own. Resource assignments can change, providers can have subaccounts and internal applications can represent the same resource in different environments. Document the actual mapping rather than assuming the visible digits are a permanent tenant identifier.

Route only after a trusted association

OWASP’s multitenant security guidance recommends establishing verified tenant context and maintaining it through asynchronous work. In an SMS integration, that means a validated callback should enter a queue with a trusted resource association, not with an unverified tenant selector copied from outside.

Missing mappings need a controlled failure state

If an authenticated event cannot be associated with an authorised resource, stop ordinary tenant delivery. Keep a restricted operational record sufficient for investigation under the applicable data policy. Do not place the body into a public catch-all inbox or whichever tenant was most recently active.

BoundaryRequired association
Provider eventVerified origin and documented resource identity
Internal routingCurrent server-controlled ownership mapping
Queued workTrusted scope carried to the consumer
Browser accessAuthorisation for the requested record

Keep the boundary through downstream work

A later worker should re-establish the relevant scope and permissions rather than relying on an ambient connection setting left by another job. Where ownership can change during a delay, define how the event is associated with the assignment at receipt and what access remains appropriate later. That policy needs to be explicit.

Test the wrong-account path as well as the working one

Use two controlled tenants and harmless, distinguishable records. Test the normal mapping, an unknown resource, an invalid selector and a reused worker connection. Verify that one tenant cannot retrieve the other tenant’s body by guessing a record identifier or changing a URL value.

Include previews, exports and cached responses in the review if the application offers them. A correctly scoped main inbox does not protect a separate download route that omits the same checks. Keep fixture data synthetic so the test does not itself distribute private messages.

Operational logs should retain the verified account and resource references needed to diagnose routing, with access limited appropriately. A log reader should not acquire every tenant’s message text simply because delivery failed. The success condition is precise: the intended tenant can use its authorised record, and unintended tenants receive neither the body nor a broader route to it.

Technical reference: OWASP: multitenant security.

Need help?

Click here and start chatting with us!