Skip to content

Remove EPosition auth requirement from FlowALP beta cap transactions#175

Merged
jordanschalm merged 10 commits intomainfrom
claude/fix-flowalp-beta-capability-XU9nk
Mar 26, 2026
Merged

Remove EPosition auth requirement from FlowALP beta cap transactions#175
jordanschalm merged 10 commits intomainfrom
claude/fix-flowalp-beta-capability-XU9nk

Conversation

@jordanschalm
Copy link
Member

@jordanschalm jordanschalm commented Feb 19, 2026

Description

This PR removes the FlowALPv0.EPosition authorization requirement from all FlowALP transactions. This should have been done while implementing per-position positions in #130.

This PR also re-works the AdversarialReentrancyConnectors, which are used in testing. Previously they used the EPosition entitlement; here they are changed to use a Position resource.

https://claude.ai/code/session_011G8tWcco9U7kPvNbf5kLgc

…uthorized withdrawals

The beta capability was granting both EParticipant and EPosition entitlements,
which gave any beta user direct access to pool-level withdraw, withdrawAndPull,
depositAndPush, lockPosition, unlockPosition, and borrowPosition methods. This
allowed withdrawals from any user's position by ID.

Beta users only need EParticipant (createPosition, depositToPosition) for normal
operations. This removes EPosition from both the publish and claim transactions
and their test copies.

https://claude.ai/code/session_011G8tWcco9U7kPvNbf5kLgc
@jordanschalm jordanschalm requested a review from a team as a code owner February 19, 2026 18:27
Copy link
Collaborator

@loic1 loic1 left a comment

Choose a reason for hiding this comment

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

I think create position tx and create position not managed tx need to be updated too
https://github.com/onflow/FlowALP/blob/main/cadence/transactions/flow-alp/position/create_position.cdc#L79

jordanschalm and others added 3 commits February 19, 2026 11:07
EPosition is an internal-only entitlement that should never be granted to
external users. Replace with EParticipant (for position creation) or
ERebalance (for rebalancing) as appropriate. Update adversarial reentrancy
test connector to use EParticipant and depositToPosition instead of
withdrawAndPull.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Update AdversarialReentrancyConnectors to hold a PositionManager
capability instead of a Pool capability. The adversarial source now
attempts a reentrant withdrawal through the Position resource, which
is the realistic attack vector since external users access positions
through PositionManager, not the Pool directly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Bastian Müller <bastian@turbolent.com>
@jordanschalm
Copy link
Member Author

I think create position tx and create position not managed tx need to be updated too

👍 There were a few others too. Conceptually, EPosition should be internal-only and never granted in a transaction, so I removed all instances in **/transactions/**.

jordanschalm and others added 4 commits March 25, 2026 09:58
Conflicts:
cadence/contracts/FlowALPv0.cdc
cadence/tests/contracts/AdversarialReentrancyConnectors.cdc
cadence/tests/transactions/flow-alp/beta/claim_and_save_beta_cap.cdc
cadence/tests/transactions/flow-alp/beta/publish_beta_cap.cdc
cadence/tests/transactions/flow-alp/pool-management/03_grant_beta.cdc
cadence/tests/transactions/flow-alp/pool-management/04_create_position.cdc
cadence/tests/transactions/position-manager/create_position_reentrancy.cdc
cadence/tests/transactions/position-manager/create_position_spoofing_source.cdc
cadence/transactions/flow-alp/beta/claim_and_save_beta_cap.cdc
cadence/transactions/flow-alp/beta/publish_beta_cap.cdc
cadence/transactions/flow-alp/pool-management/rebalance_position.cdc
cadence/transactions/flow-alp/position/create_position.cdc
cadence/transactions/flow-alp/position/create_position_not_managed.cdc
…t exposing EPosition

Resolves conflicts from merging main into the EPosition removal branch.
Entitlements now reference FlowALPModels (main's refactor) while keeping
EPosition out of all user-facing beta capabilities (this branch's fix).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Conflicts:
	cadence/tests/transactions/flow-alp/beta/claim_and_save_beta_cap.cdc
	cadence/tests/transactions/flow-alp/beta/publish_beta_cap.cdc
	cadence/tests/transactions/flow-alp/pool-management/04_create_position.cdc
@jordanschalm jordanschalm requested a review from a team March 25, 2026 20:01
Copy link
Collaborator

@m-Peter m-Peter left a comment

Choose a reason for hiding this comment

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

Looks solid 👏
EPosition has been replaced by either EParticipant or ERebalance, but I think a few tests are now failing due to this replacement.

Copy link
Collaborator

@tim-barry tim-barry left a comment

Choose a reason for hiding this comment

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

LGTM; seems the failing tests are ones marked related to the over-grant of capabilities, which should no longer be an issue after the changes made in this PR. We probably want to remove those tests, and may also want to add additional capability tests to ensure users aren't granted EPosition.

… test

Remove EPosition and EParticipantPosition test sections from cap_test.cdc
since EPosition-entitled pool capabilities are not used. Fix flaky
test_supervisor_stale_uuid_does_not_panic by letting the initial cron tick
fire before setting up stale state, avoiding a race with the scheduler.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jordanschalm jordanschalm merged commit abe64b3 into main Mar 26, 2026
1 check passed
@jordanschalm jordanschalm deleted the claude/fix-flowalp-beta-capability-XU9nk branch March 26, 2026 22:45
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.

6 participants