Skip to content

Access control tests#244

Open
mts1715 wants to merge 8 commits intomainfrom
taras/177-access-control-test
Open

Access control tests#244
mts1715 wants to merge 8 commits intomainfrom
taras/177-access-control-test

Conversation

@mts1715
Copy link
Contributor

@mts1715 mts1715 commented Mar 6, 2026

Closes: #177

Summary

Implements the full Actor Capability Matrix test suite for FlowALPv0.Pool entitlements, as defined in docs/security-permission-matrix.md

Description

cap_test.cdc

The previous file only validated pool creation. This PR replaces it with a structured security test suite covering every row in the permission matrix across all 6 entitlements — one test per matrix operation, organised in sections matching the matrix columns.

Negative test strategy

Cadence entitlements for Pool capabilities (EParticipant, EPosition, ERebalance, EGovernance, EImplementation) are enforced by the cadence type checker.
EPositionAdmin is the only entitlement in this file where negative (access-denied) tests are meaningful at runtime by borrowAuthorizedPosition, so testEPositionAdmin_BorrowUnauthorizedPosition_Fails exists.

Transaction reorganisation

Old pool-management/ and pool-governance/ stubs removed. Replaced by entitlement-scoped folders matching the matrix columns:
egovernance, eimplementation, eparticipant, eposition, epositionadmin, erebalance, setup (grant_e*_cap.cdc helpers), helpers (liquidation, insurance swapper, pool pause)

docs/security-permission-matrix.md

  • Added Test Coverage table mapping each test file to the matrix rows it covers.
  • Added Audit Notes section documenting union/conjunction semantics (EPosition | ERebalance for rebalance ops; FungibleToken.Withdraw + EPositionAdmin conjunction for borrowAuthorizedPosition).
  • Clarified which rows are covered by paid_auto_balance_test.cdc (rebalancer-local entitlements) and withdraw_stability_funds_test.cdc (withdrawStabilityFund).

Known issue documented (not fixed here)

publish_beta_cap.cdc grants EParticipant + EPosition to beta users. EPosition is not needed for normal user actions and allows any beta user to withdraw from or freeze any other user's position. The over-grant is explicitly tested in the eParticipantPositionUser section. Fix: grant EParticipant only — tracked separately.

vishalchangrani and others added 8 commits February 19, 2026 11:56
Maps all FlowALPv0 entitlements to operations by resource, with plain-language descriptions. Intended for audit/security review.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Mark EPosition as protocol-internal only, not for end users
- Add ownership-check warnings on all pool-level EPosition operations
- Document the beta capability over-grant issue (EPosition -> EParticipant fix needed)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace resource-grouped columns with actor columns (User, User w/ EPosition,
Rebalancer, Position Owner, Governance, Protocol Internal). The beta over-grant
is now directly visible as a dedicated column showing what current beta users
can do vs. what they should be able to do.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mts1715 mts1715 self-assigned this Mar 6, 2026
@mts1715 mts1715 requested a review from a team as a code owner March 6, 2026 15:15
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.

Access Control - Unauthorized access, privilege escalation, entitlement enforcement

2 participants