Commit 8b83efa
authored
Merge commit from fork
The Policy Refactoring (#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 to incorrectly satisfy the "at least one
policy applies" requirement when their condition evaluates to true
but their authorization checks fail.
For example, with these policies:
bypass always(), do: authorize_if(actor_attribute_equals(:is_admin, true))
policy action_type(:read), do: authorize_if(always())
The final authorization decision is: one_condition_matches AND all_policies_match
When a bypass condition is true but bypass policies fail, and subsequent
policies have non-matching conditions:
1. one_condition_matches = cond_expr (bypass condition) = true
(bug - should check if bypass actually authorizes)
2. all_policies_match = (complete_expr OR NOT cond_expr) for each policy
- For non-matching policies: (false OR NOT false) = true (policies don't apply)
3. Final: true AND true = true (incorrectly authorized)
The bypass condition alone satisfies "at least one policy applies" even
though the bypass fails to authorize.
The fix ensures bypass policies contribute their complete expression
(condition AND policies) to one_condition_matches.1 parent b2e4d62 commit 8b83efa
2 files changed
+65
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | | - | |
55 | | - | |
| 54 | + | |
56 | 55 | | |
57 | 56 | | |
58 | 57 | | |
59 | 58 | | |
60 | 59 | | |
61 | 60 | | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | 61 | | |
66 | 62 | | |
67 | 63 | | |
68 | 64 | | |
69 | | - | |
| 65 | + | |
| 66 | + | |
70 | 67 | | |
71 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
72 | 71 | | |
73 | 72 | | |
74 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
912 | 912 | | |
913 | 913 | | |
914 | 914 | | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
915 | 973 | | |
0 commit comments