Maintenance-pool `deposit()` allows pool-id squatting via `TokenMismatch` griefing
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 20/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- rust
- Lĩnh vực
- backend-api-design, security
Hướng nghiên cứu
Read contracts/maintenance-pool/src/lib.rs around deposit() and contracts/maintenance-pool/src/types.rs for the pool key, then inspect the pool ID generation assumption described in the issue. Review the open linked pull request before starting, since it may already be addressing this work. A complete fix must prevent token squatting, preserve permissionless recurring deposits and admin-authorized withdrawals, and include the described tests in contracts/maintenance-pool/src/test.rs; the issue specifies cargo test --workspace.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Background / Context
contracts/maintenance-pool/src/lib.rs::deposit() creates a MaintenancePool on first deposit for a given pool_id, locking in whatever token the first depositor supplies (pool.deposit_count > 0 && pool.token != token → TokenMismatch). pool_id is described in types.rs as "an off-chain-assigned id for a repo/org," implying it's likely derived deterministically (e.g., hash of owner/repo) and therefore guessable ahead of time by anyone watching GitHub activity.
Problem Statement
An attacker can call deposit(pool_id, attacker, some_worthless_token, 1) for any repo/org they expect to receive real sponsor funding, permanently locking that pool to the worthless token. Every subsequent legitimate sponsor deposit in the intended asset (e.g., USDC on Stellar) reverts with TokenMismatch, with no recovery path in the contract (no admin override, no per-token sub-pools). This is a cheap, repeatable denial-of-service against the "recurring maintenance funding" product surface, distinct from and worth separating from the escrow-id-squatting issue because the recovery constraints differ (a pool is meant to be long-lived and repeatedly topped up, so there's no natural "just use a different id" workaround the way there might be for a one-off escrow).
Requirements
- Determine whether
pool_idgeneration is/should be unpredictable (out of scope to change the backend, but document the assumption) or whether the contract must be hardened regardless. - Design and implement a fix: candidates include admin-gated pool creation (a separate
create_pool(pool_id, token)admin call beforedepositis permitted), an allowlist of valid tokens set atinitialize, or a per-(pool_id, token)compound key so multiple tokens can coexist per pool without collision (requires rethinkingget_pool/balancesemantics). - Add tests in
contracts/maintenance-pool/src/test.rsreproducing the squat and validating the fix. - Ensure the fix doesn't regress the "sponsors can deposit repeatedly over time" recurring-funding use case central to this contract's purpose.
Acceptance Criteria
- Documented threat model for
pool_idpredictability - Implemented fix in
contracts/maintenance-pool/src/lib.rsandtypes.rsas needed - Tests proving squat attempts no longer block legitimate sponsors
- No breaking change to
withdraw's admin-authorized payout flow -
cargo test --workspacepasses
Technical Notes / Hints
- Code:
contracts/maintenance-pool/src/lib.rslines ~51-104,DataKey::Pool(u64)intypes.rs. - Consider interaction with
Deposithistory keyed by(pool_id, deposit_index)if you change how pools are created/keyed.
Difficulty Justification
The naive fix (reject deposits from non-admin on pool creation) conflicts with the contract's explicit design goal of being sponsor-initiated and permissionless for deposits. A correct solution must preserve permissionless recurring deposits while eliminating the squatting vector — this is a genuine access-control/design tradeoff requiring judgment, not a mechanical patch.
- Ngôn ngữ chính
- Rust
- Star
- 1
- Fork
- 102
- Merge trung bình
- 4 giờ 12 phút
- Pull request đã merge (30 ngày)
- 30
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của MergeFi/contracts
-
allocations map retains released issues — phantom ledger driftCó thể làm lại được @PINYOPATTANAWASANPORN đã nhận 12 ngày trước và không có pull request nào đang mở. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 25/100
MergeFi/contracts#608 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
escrow::contribute and milestones::contribute accept new funds after deadline + GRACE_PERIOD, when anyone can already refund or cancelCó thể đã có người làm @urielit1313-creator đã nhận 29 ngày trước. Đang mởbug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
MergeFi/contracts#568 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Makefile deploy targets deploy the unoptimised .wasm — `stellar contract optimize` writes *.optimized.wasmCó thể đã có người làm @urielit1313-creator đã nhận 29 ngày trước. Đang mởbug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 25/100
MergeFi/contracts#567 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
keep_alive never refreshes instance storage, so a contract kept alive only via keep_alive can still archive Admin/Oracle/TreasuryCó thể đã có người làm @urielit1313-creator đã nhận 29 ngày trước. Đang mởbug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
MergeFi/contracts#566 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Regression on closed #254] milestones::deallocate still has no test asserting admin authorizationCó thể đã có người làm @urielit1313-creator đã nhận 29 ngày trước. Đang mởsecurity testing
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 25/100
MergeFi/contracts#565 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của MergeFi/contracts
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
design-data-spec
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
adobe/spectrum-design-data#1744 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
USERID reads /etc/passwd directly instead of looking the user upCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởdefect
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày