Prevent permission bypass when sync has_permission returns an awaitable - #4605
Conversation
|
Thanks for adding the Below is the changelog that will be used for the release. This release fixes a permission bypass (GHSA-pfvf-fwfp-25mp) where a custom When a permission's Strawberry now detects this case and fails closed: the synchronous permission This release was contributed by @patrick91 in #4605 |
Greptile SummaryThis patch closes an authorization bypass caused by synchronous permission methods returning awaitables.
Confidence Score: 5/5The PR appears safe to merge and closes the permission bypass across the reachable synchronous and asynchronous execution paths. Synchronous permission chains now reject awaitable results before truthiness can authorize access, while asynchronous chains continue to await those results correctly.
|
| Filename | Overview |
|---|---|
| strawberry/permission.py | Adds a fail-closed guard for awaitables on synchronous permission chains while preserving correct awaiting on asynchronous chains. |
| strawberry/exceptions/init.py | Introduces and exports a clear exception for awaitables returned in a synchronous permission context. |
| tests/schema/test_permission.py | Verifies that the protected resolver remains uncalled under both execute_sync and execute. |
| RELEASE.md | Accurately documents the permission bypass, affected execution paths, and required permission implementation contract. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Field resolution] --> B[Call synchronous has_permission]
B --> C{Result is awaitable?}
C -- Yes --> D{Result is coroutine?}
D -- Yes --> E[Close coroutine]
D -- No --> F[Raise configuration error]
E --> F
C -- No --> G{Result is truthy?}
G -- No --> H[Return unauthorized response]
G -- Yes --> I[Invoke protected resolver]
Reviews (1): Last reviewed commit: "Prevent permission bypass when sync has_..." | Re-trigger Greptile
|
This PR was published as 0.326.1. Thank you for contributing! |
Summary by Sourcery
Fail closed when synchronous permission checks return awaitables to prevent protected fields from being accessed accidentally.
Bug Fixes:
has_permissionreturns an awaitable by failing closed with a clear error.Enhancements:
Documentation:
has_permissionimplementations in the release notes.Tests: