Securing PySpark applications in multi-tenant environments
Instruction: Outline the measures you would take to secure a PySpark application in a multi-tenant environment, including data access and processing.
Updated
Define the trust boundary first: mutually untrusted tenants running arbitrary Python code should not share a driver, executor credentials or an unrestricted Spark session. Prefer separately authorized applications and compute isolation appropriate to the threat model. A tenant column, directory partition, separate SQL schema or UI access rule is not by itself a security boundary.
Use distinct workload identities and least-privilege permissions at the actual storage/catalog service. Derive authorized tenant scope from a trusted identity, not a user-supplied path or filter. Verify that access through alternate APIs and direct object paths cannot bypass policy. Ranger or another policy system is useful only where the deployed integration actually enforces it; installing a catalog or governance product does not secure arbitrary file access.
Protect submission endpoints, driver/executor communication, the UI/history service and source/sink connections with the controls supported by that deployment. Spark security features are not universally enabled by default. UI HTTPS alone does not encrypt every RPC, shuffle, spill file or output object. Configure the relevant transport protection, storage encryption, secret management and credential renewal separately, and restrict unnecessary network reachability.
Review logs, event logs, checkpoints, temporary files, cached results and exported samples for cross-tenant exposure. Apply access controls and retention to these artifacts as well as the main dataset. Use per-tenant quotas/admission controls to limit resource abuse; a fair scheduler distributes work but does not provide data isolation.
Test negative access cases: another tenant's object path, forged tenant ID, unauthorized catalog query, leaked token, and denied read/write operations. Audit privileged changes and exercise credential rotation and incident response. Regulatory obligations require the organization's full legal and operational controls; Spark settings or metadata lineage alone do not establish compliance.