Launch price: every exam for $29.99 a year, for the first 300 buyers. See the price

CertStreak
Menu

Apply the principle of least privilege for all securables

A worked example

Single answer

An Azure SQL Database supports semantic product search. An external model object named Ada2Embeddings calls an Azure OpenAI embedding endpoint by using a database scoped credential. Two database users were created WITHOUT LOGIN:

  • embedding_refresh_svc is used by a nightly job that calls the external model to generate embeddings. The job inserts new rows and updates existing rows in dbo.ProductEmbeddings, and it never deletes rows.
  • app_query_user serves interactive search. It reads the stored vectors from dbo.ProductEmbeddings and never calls the model.

Each principal must be able to do its work, and neither may hold any permission beyond that work.

Designembedding_refresh_svcapp_query_user
Design 1EXECUTE on EXTERNAL MODEL::Ada2Embeddings; REFERENCES on the database scoped credential; INSERT, UPDATE on dbo.ProductEmbeddingsSELECT on dbo.ProductEmbeddings
Design 2EXECUTE on EXTERNAL MODEL::Ada2Embeddings; REFERENCES on the database scoped credential; INSERT, UPDATE on dbo.ProductEmbeddingsSELECT on dbo.ProductEmbeddings; EXECUTE on EXTERNAL MODEL::Ada2Embeddings
Design 3REFERENCES on the database scoped credential; INSERT, UPDATE on dbo.ProductEmbeddingsSELECT on dbo.ProductEmbeddings
Design 4EXECUTE on EXTERNAL MODEL::Ada2Embeddings; REFERENCES on the database scoped credential; INSERT, UPDATE, DELETE on dbo.ProductEmbeddingsSELECT on dbo.ProductEmbeddings

Which permission design should you implement?

Choose one answer
Why

Least privilege here means splitting the workload across two principals and giving each only what its task uses. The nightly refresh account must call the model, so it needs EXECUTE on the external model and REFERENCES on the credential, plus INSERT and UPDATE because it only adds and changes rows. The search user only reads stored vectors, so SELECT on the table is enough and it has no route to the external endpoint. Design 1 is the only design that lets both principals work without any extra permission.

  • Not correct: Design 4. DELETE lets the refresh account remove data from the table, but the job only inserts and updates, so this permission exceeds its work.
  • Not correct: Design 3. The nightly job needs EXECUTE on Ada2Embeddings to generate embeddings.
  • Not correct: Design 2. Search reads the stored vectors directly, so EXECUTE on the external model exceeds the permissions app_query_user needs.
  • Correct: Design 1. The refresh account gets EXECUTE on the model, REFERENCES on the credential, and INSERT and UPDATE on the table. The query user gets SELECT on the table to read the stored vectors.

Practise this topic until it's automatic.

Ten questions a day, every answer explained, and misses that come back until you beat them.

Start free