Skip to content

deleted#3

Closed
jechol wants to merge 1 commit into
mainfrom
fix/policy-bypass-condition-main
Closed

deleted#3
jechol wants to merge 1 commit into
mainfrom
fix/policy-bypass-condition-main

Conversation

@jechol

@jechol jechol commented Oct 17, 2025

Copy link
Copy Markdown
Owner

deleted

@jechol jechol mentioned this pull request Oct 17, 2025
@jechol jechol force-pushed the fix/policy-bypass-condition-main branch 15 times, most recently from b63f711 to a87b284 Compare October 17, 2025 04:25
The Policy Refactoring (ash-project#2365) introduced a bug where bypass policies
were contributing only their condition to one_condition_matches instead
of their complete expression (condition AND policies).

This caused bypass policies with always-true conditions (like always())
to incorrectly satisfy the "at least one policy applies" requirement
even when the bypass policies themselves failed.

For example, with these policies:
- bypass always() do authorize_if actor_attribute_equals(:is_admin, true)
- policy action_type(:read) do authorize_if always()

A non-admin user performing a create action would be incorrectly
authorized because:
1. bypass condition (always) was true → one_condition_matches = true
2. policy condition (action_type(:read)) was false
3. Final: true AND (tautology) = true (incorrect!)

The fix restores the old behavior where bypass policies contribute
their complete expression to one_condition_matches, ensuring that
a bypass only satisfies the requirement if it actually authorizes.

Fixes authorization bypass when bypass conditions are always true but
bypass policies fail.
@jechol jechol force-pushed the fix/policy-bypass-condition-main branch from a87b284 to 85eae74 Compare October 17, 2025 04:26
jechol added a commit that referenced this pull request Oct 17, 2025
Add failing test that shows bypass policies with always-true conditions
incorrectly authorize when bypass policies fail.

This test currently FAILS with:
  left:  true (incorrectly authorized)
  right: false (expected)

The bug is fixed in PR #3.
@jechol jechol closed this Oct 17, 2025
@jechol jechol deleted the fix/policy-bypass-condition-main branch October 17, 2025 04:47
@jechol jechol changed the title fix: use complete expression for bypass policy in one_condition_matches deleted Oct 17, 2025
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.

1 participant