Skip to content

Models and proofs of correctness for permissions queries algorithms#827

Open
john-h-kastner-aws wants to merge 3 commits intomainfrom
pq-final
Open

Models and proofs of correctness for permissions queries algorithms#827
john-h-kastner-aws wants to merge 3 commits intomainfrom
pq-final

Conversation

@john-h-kastner-aws
Copy link
Contributor

A permissions query algorithm is an procedure for enumerating resources with a specific type that a principal is authorized to access.

For each algorithm, this PR proves that a resources is listed if and only if it has the expected type and access is in fact allowed.

Specifically, the two main theorems are

theorem resource_scan_correct (n : Nat) (schema : Schema) (req : ResourcesForPrincipalRequest) (entities : Entities) (policies : Policies) (r : EntityUID) :
    validateWithLevel policies schema n = .ok () →
    schema.validateWellFormed = .ok () →
    validateRequest schema (req.req r) = .ok () →
    validateEntities schema entities = .ok () →
    (r ∈ scanResourcesForPrincipal n schema req entities policies ↔
    (r ∈ entities ∧ r.ty = req.resourceType ∧ (isAuthorized (req.req r) entities policies).decision = .allow))

theorem discretionary_resource_for_principal_correct :
  arePoliciesDiscretionary ps = true →
    (r ∈ discretionaryResourcesForPrincipal pq es ps ↔ (r.ty = pq.resourceType ∧ (isAuthorized (pq.req r) es ps).decision = .allow))

Signed-off-by: John Kastner <jkastner@amazon.com>
Signed-off-by: John Kastner <jkastner@amazon.com>
Comment on lines +36 to +38
match p.resourceScope.scope.bound with
| some e => e.ty == resourceType
| none => true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these three lines, which check whether the policy could possibly apply to resourceType, could

  • be factored out into a separate def since they're repeated three times in this file
  • be further optimized to consider policies with resource is in the scope (my understanding is these have .bound none, but we could exclude some of them)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the current code is the clearest way to implement the intended algorithm

Signed-off-by: John Kastner <jkastner@amazon.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants