security(pair/AutoLP): enforce net execution floors and bounded hook work #1398
Labels
No labels
agent:fix_bugfix
agent:fix_conflicts
agent:fix_security
agent:gap_analysis
agent:implement
agent:implement
agent:implement
agent:open_issues
agent:ready
agent:research
agent:security_audit
agent:verify
architecture
backend
blocker:hybrid
blocker:launch
blocker:limit-orders
blocker:v2
block:log_only
block:security
bug
ci
contracts
correctness
deploy
dev
devops
docs
documentation
duplicate
e2e
enhancement
epic
feature
frontend
functional-completion
gas
good first issue
governance
help wanted
high-risk
hooks
hybrid
indexer
infra
infrastructure
integrators
invalid
launch-blocker
limit-orders
localnet
localterra
low priority
missing-implementation
needs-design
ops
performance
priority
high
priority
medium
product
qa
QA
question
ready
ready
research
scripts
security
security-hardening
smartcontracts
tech-debt
testing
ux
UX
v2
verification
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
code/cl8y-dex-terraclassic#1398
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary and severity
Medium price-protection completeness; privileged hook availability. Protection must cover user net output and issued LP shares, and trusted hook work must have finite admission limits.
Internal review references: KIMIK3 SC-03/04/05; conditional hook/MEV chains. Investigated against source revision
748579ab718026efad54afcef4b2a5186fe82662on 2026-10-04. These are engineering findings, not third-party audit certification. Only technical findings and synthetic test cases are included; no conversation, user identity, credentials or real-user activity is published.Current codebase and evidence
Pair asserts max_spread on pre-hook return, then collects fee-hook deductions and checks optional min_return on net_return. A direct caller supplying max_spread without a net minimum can receive less than that protection appears to promise; callers with a sufficient net min_return are already protected. UpdateHooks accepts an arbitrary-length list from factory governance, increasing per-swap GetConfig/AfterSwap work. AutoLP's swap has protections, but its reply supplies all remaining balances with ProvideLiquidity slippage_tolerance=None; pair only enforces LP ratio tolerance when Some is supplied.
Hooks are governance-gated and transactions atomic. Whole-transaction front-running can change the pool before execution; no actor can insert a transaction between the AutoLP swap and reply. Economic extraction is a test hypothesis, not an observed mainnet loss.
Why a new implementation is needed
Protection must cover user net output and issued LP shares, and trusted hook work must have finite admission limits.
Constraints and guardrails
Relevant files
Recommended direction
Acceptance criteria
Test plan: supported and failure paths
Test plan: attack, hack and abuse vectors
Verification criteria
Record revision, UTC time, exact commands, outcomes and evidence scope. Complete runnable checks first. Unavailable signing, deployment, device or infrastructure checks must be explicitly recorded as unverified; they do not block filing or implementation. An executed failure remains FAIL. Never claim deployment acceptance from unit tests or read-only probes. Public receipts must use synthetic identities and omit secrets.
Related work and duplicate check
Closed #377 hardened hook trust/charging but does not enforce these end-to-end bounds; preserve its intended reverting-hook policy.
Related remediation reports
1389: reverse-budget, 1390: launch-guards. Each report owns its stated acceptance scope.
Merge sweep 2026-10-05: the two existing October 4 audit reports are being preserved on main with the sanity receipt. They document findings; committing them does not implement remediation.
Remaining implementation: Enforce pair/AutoLP net execution floors and cap hook work. No pair or AutoLP behavior changes are included in this merge. This issue stays open for that substantive work, not merely a verification hold.
Merged PR #1425 with signed post-hook minima, bounded hook admission and anchored AutoLP issuance protection retained. The #1427 version conflict was resolved in favor of integrated router 1.4.0, pair 1.21.0 and factory 1.12.0; rollout defaults/checklists agree. Final optimized artifacts were rebuilt and checksums verified.
make verify-issue-1398: 7 PASS, 0 FAIL, 0 SKIP, including 982 contract workspace tests and 168 focused frontend tests per pass. Funding and guard regressions pass, and all 18 actual funded 3M queries pass twice on the new versions. Production maximum-hook/AutoLP gas and migration remain #1421. Actual-manager recovery for token-owned legacy AutoLP policies is now separately tracked in #1429; unchanged token settings remain a no-op. This completed source issue can close without pretending that legacy rollout has happened.
All four source PRs #1424–#1427 are merged; final receipt published through #1430. Local main is reconciled with both remotes, with no stashes. Hosted CI was skipped by explicit operator instruction; no fake PASS status was posted. Original merge protection is restored. Integrated evidence. Source closure does not claim production deployment.