# Morpho Midnight Adapter review: root merge 2 of 2 (21 results) Target: morpho-org/vault-v2 at commit `bbeda7b27ae80abcf070e0158cb8a31e87bb2286`, `src/adapters/midnight/**`. Nothing was submitted anywhere and no one was contacted. All results below are deliverables for the requester only. Each claim names the result it comes from, by the short ids below. Line references are `src/adapters/midnight/…` unless a path says otherwise. "Verified" means the source result ran a Foundry test at the pinned commit and gives its output. "UNVERIFIED" means the claim comes from reading code only, or the result says it was not run. | id | result (item) | executed? | |---|---|---| | b07 | leads-c/stateful-gated | yes: invariant campaigns, 2 seeds | | b11b | fixes/fix-buy | **no**: blocked, disk full; static diff only, everything UNVERIFIED | | b11s | fixes/fix-sell | **no**: blocked, disk full; static diff only, everything UNVERIFIED | | b11f | fixes/fix-force-ratify | yes: `test/poc/ForceRatifyReview.t.sol`, 9/9 pass | | b13 | known2/more (prior-audit register) | no build needed; **13 of its sources did not hold on re-read** (see §8) | | b14 | lowinfo/list (consolidated Low/Info list of earlier "after-*" reviews) | consolidation; per-entry `verified` flags kept | | b15v | leads-d/vault-roles-caps | yes | | b15g | leads-d/gates-config | yes | | b15l | leads-d/liveness | yes | | b15m | leads-d/midnight-assumptions | yes | | b15o | leads-d/maker-offers | yes | | b17f | leads-e/ratifier-forgery | yes (unit level, mocks for adapter/vault/Midnight) | | b17r | leads-e/rogue-adapter | yes | | b17n | leads-e/nested-trades | yes | | b19 | notes-fixes/list (re-test of fix-buy/sell/force-ratify notes) | yes | | b20i | recheck/ikr-size | yes | | b20n | recheck/notes (N1–N4) | yes | | b21b | leads-f/bad-debt-combos | yes | | b21s | leads-f/stateful-extended | yes: invariant campaign | | b21d | leads-f/duration-buckets | **no**: network proxy refused github.com; nothing read or run | | b21r | leads-f/rate-ratifier-fees | yes; **6 of its sources did not hold on re-read** (see §8) | --- ## 1. Bottom line - **No Medium or High finding survives in any of the 21 results.** Every result has `candidates: []` / `hasCandidates: false`. None claims a fault that an untrusted account can cause with real impact. b19 states it outright: "None found. No note became a fault that an untrusted account can cause with real impact." - So there is no surviving finding to give a PoC, command and output for. Step 4 (an independent re-run from a clean clone to refute a finding) had nothing to apply to. Several results say plainly that no second-agent refutation was done (b15o, b15l, b21s, b21r). The recheck batch (b19, b20i, b20n) re-ran and re-classified the earlier notes. It is the nearest thing to an independent check in this group. - Two results rated something **Low**. A later re-check downgraded both (§3): 1. IKR admission not bounded by share size. b15g says Low; b20i says "refuted / not an issue". 2. The factory registers adapters for any parentVault. b11f says Low, UNVERIFIED; b19 downgraded it to Informational. - b14 lists two more Lows (shared cap ids, relative caps). Both are prior-audit items TRST-L-2 and TRST-L-3, so they are out of scope (§4, items 31–32). - Three results did not cover their lead (b11b, b11s, b21d). Where possible, b19 later turned the b11b/b11s statements into tested ones. **The duration-buckets lead (b21d) has no direct coverage of its own.** Parts of it are covered elsewhere (§6). --- ## 2. Competition rules that apply (from b13; see §8 on source reliability) b13 read the public competition page `https://cantina.xyz/competitions/78a6e652-de09-435f-918d-471243508009` (readable: true) and recorded: - Out of scope: "Previous security reports / audits" (Cantina and TrustSec Midnight Adapter drafts, 2026-10-12), "Expected behaviors such as trusted / untrusted roles", and "Accepted risks". The page gives no itemised accepted-risk or known-issue list. - Severity: "This competition uses Cantina's standard severity definitions." The impact × likelihood matrix is High/Medium/Low. - Rules quoted: "All High and Medium findings require a valid coded POC before the end of the competition."; "Issues that require admin access (or equivalent) to perform should at most be low severity, unless the protocol was designed to be resilient against such actions in the first place."; "Any finding that has been acknowledged in a previous report will be considered invalid."; "The competition README must be used as the main reference for protocol behavior and not other sources." - Rule summaries (not quotes) that b13 gives: weird-token findings are at most Low; dust rounding losses are at most Low; user errors a frontend can handle are at most Informational. These rules are why the trusted-role notes below (curator/allocator/sentinel) are Informational at most. --- ## 3. Where results disagree ### 3.1 IKR admission is not proportional to the taker's vault shares (b15g Low vs b20i "not an issue" vs b07 Informational) - **Mechanics (agreed and reproduced by three results).** In the forceDeallocate branch, `deallocate` only checks `IVaultV2(parentVault).balanceOf(taker) > 0` (MidnightAdapter.sol:430) before admitting the taker in the market's IKRCompatibleEnterGate (:462). VaultV2.forceDeallocate (src/VaultV2.sol:790) takes the penalty from `onBehalf`, which can be another account. - **b15g** (`testDustShareholderEntersGatedMarketWithLargeCredit`, verified): a taker holding 1 wei / 1 share and not credit-whitelisted cannot buy directly (`BuyerGatedFromIncreasingCredit`). Through forceDeallocate it ends with `50000000000000000000000` credit in the gated market, while a second account pays a 2% penalty of `1000000000000000000000` shares. b15g classes this **Low**: "a credit-side whitelist … does not keep out any account able to get 1 wei of the parent vault's shares, at any size". It also says it "costs the attacker money and does not harm the vault". Suggested fix: require `previewRedeem(balanceOf(taker)) >= assets` or `taker == onBehalf`, or document it. - **b20i** (G1, `testG1_IkrAnySizeTaker`, verified) reproduces it: outsider shares 1; paid 50,000e18; got 50,000e18 credit; borrower offer price `994100700000000000`; adapter credit `100593430826474621736007` → `50593430826474621736007`; payer penalty `1000000000000000000000`. It gives the verdict **"refuted … not an issue"**, because it is documented design. README.md:162 says: "During `forceDeallocate`, a Midnight adapter from a registered factory can temporarily admit a shareholder of its parent vault to receive credit without subgate approval." Further reasons: the taker pays face value, about 1,295e18 more than a direct buy at 0.9941 (about 49,705e18); size is bounded by the adapter's credit (rest+1 reverted); `admitEnabled=false` or vault share gates close it; and the payer's penalty needs a share allowance, so it is consensual. Fix: none needed; optionally document it, or cap at previewRedeem. - **b07** observed the same thing 697 times (seed 0x1) and 718 times (seed 0x2) in its campaign, with 0 admission leaks. It classes it **Informational**. - **Merged position:** at most Informational. It is documented in the README, the competition README is the reference for intended behaviour, and no party loses. Keep the operator-facing note that admission size does not depend on share size; the README does not say this. ### 3.2 Factory registers adapters for any parentVault, and IKRCompatibleEnterGate.admit trusts `isCreated` (b11f Low/UNVERIFIED vs b19 Informational) - b11f `test_07`: an adapter whose vault is a stub exposing only `asset()` reports `isCreated = true`. b11f called this "Low … UNVERIFIED as exploitable". - b17r (`testRogueAdapterCannotHandCreditToNonWhitelisted`, verified): admit is reachable. The gate emits `Admit(rogue, evil, factory)` for a non-whitelisted `evil`. But the whole forceDeallocate reverts `MakerCreditOrDebtIncreased`, because the reduceOnly self-sale has no credit to sell, and `evil` credit stays 0. The positive control, honest IKR, gives `1000000000000000000000` credit. - b15g: an attacker-owned registered adapter "can only reach admit through deallocate, which requires msg.sender == parentVault … and it holds no credit". b14 #5 (`testFakeVaultAdapterPassesIsCreatedButAdmissionIsTransient`) agrees. b14's dropped list rejects "Every account can acquire gated credit through an unverified parent vault". - b19 rank 9 downgrades it to **Informational**: "no impact was shown, and the trust is documented" (README.md:29; Cantina 3.6.3 note 7, unchanged). - **Merged position:** Informational, known (Cantina 3.6.3 note 7). Defence-in-depth suggestions: an approved-vault check in the factory, or have the gate check the vault/asset it expects (b17r, b14 #5). ### 3.3 Smaller corrections between results - "Matured non-forceSellable … taker sales after fees always fail" (b11s, UNVERIFIED). b19 corrected it: the sale fails only when the settlement fee at ttm 0 is non-zero. With no fee, a sale at price 1 passes (repository test `testMaxNetSellRatePostMaturityRequiresFaceValue`). See item 10. - The OtherSellInProgress revert inside a taker callback in a loss market is UNVERIFIED in b15l and b17n but **verified** in b21b (item 22). - b19 rank 10 calls UNVERIFIED that "a 0-asset force call on a held market with a realised loss resyncs stored net credit". b15v (`testZeroAssetForceDeallocateSyncsLoss`: 30000e18 → 8000e18) and b15m (`100593430826474621736007` → `50296715413237310868003`) both ran this. It is therefore verified elsewhere (item 6). --- ## 4. Ranked Low / Informational list (merged and de-duplicated) Ranking is by usefulness to the requester: undocumented behaviour first, then hardening, then documented or known items. Every item is **Informational** unless marked otherwise. None needs an untrusted account to cause a loss. "Known" means a prior audit or the NatSpec/README already covers it, so it is not submittable as new. **1. IKR admission is not proportional to share balance.** See §3.1. Refs: MidnightAdapter.sol:427-470, gates/IKRCompatibleEnterGate.sol:38-55, src/VaultV2.sol:790-799, README.md:162. Verified (b15g, b20i, b07). Disputed between Low and not-an-issue; merged as Informational. **2. `setMinForceSellPrice` is immediate in both directions, but the NatSpec says relaxing guardrails is timelocked.** Refs: MidnightAdapter.sol:54-57, :334-338, :638-639; README.md:123. The NatSpec (54-55) lists minForceSellPrice among the guardrails whose "Relaxing … is timelocked". README.md:123 says "`setMinForceSellPrice` is curator-only and immediate in either direction." The default is 0. - b20n N1, verified: a 0.95e18 floor first blocks a tick-0 sale (`ForceSellPriceTooLow`). The curator then sets it to 0 in the same block, even with `timelock[setMinForceSellPrice]=30 days`, and the allocator sells 1000e18 units for 0 assets. realAssets went `100000000000030600145311` → `99005899300030295949053` (loss `994100700000304196258`, about 994.1 tokens). - b19 rank 1, verified: floor 0.9e18 → 0. realAssets fell 1e18 → 0.5e18 and the vault received 0.25e18. - b11s first raised it (UNVERIFIED). - Severity reasoning (b20n): it needs a curator plus an allocator (trusted roles), and the market must already be through the timelocked setForceSellable. Admin-only issues are at most Low under the competition rules, and README:123 discloses it. That makes it a documentation inconsistency, Informational. - Not in either 2026-10-12 draft. The nearest items are Cantina 3.2.10 and TRST-L-5 (b20n, b19). - Fix: correct NatSpec 54-55, or split into an immediate increase and a timelocked `decreaseMinForceSellPrice`. **3. Immediate tightenings do not cancel pending relaxations, and anyone can execute those once due.** Refs: MidnightAdapter.sol:191-226, :258-270, :291-332, :82; README.md:49. - b20n N2, verified: with 7-day timelocks, three relaxations are pending. The curator then tightens all three. After 7 days a stranger executes the old payloads: `maxNetSellRate=317097919830`, `shortfallAllowance=1000000000000000000000000`, `minNetBuyRate=0`. A sentinel `revoke` before expiry makes execution revert `DataNotTimelocked`. - b19 rank 2, verified: maxNetSellRate 0 → `5000000000`; shortfallAllowance 0 → `100000000000000000000`. - b11s notes that `increaseShortfallAllowance` adds to the remaining allowance. - This is the documented VaultV2 timelock design ("(by anyone)", README.md:49). Not in either draft; TRST-R-11 is related. - Fix: document that an emergency tightening must be paired with `revoke` of each pending relaxation, or have tightenings reject or clear matching pending data. **4. When lossFactor is maxed (full bad-debt wipe), forceDeallocate always reverts, so shareholders cannot resync stale cap allocations.** Refs: MidnightAdapter.sol:427-477, :716-737, :846-855; lib/midnight/src/Midnight.sol:332; lib/midnight/test/LiquidationTest.sol:926. - b15m `testFullWipeBlocksForceDeallocateSync` and b20n N3 (`testN3_LossFactorMaxedOut`), both verified: lossFactor = `type(uint128).max` (b15m prints `170141183460469231731685612341188336919` in its partial-loss test). In the full-wipe case, stored netCredit = allocation = `durationAllocations[0]` = `100593430826474621736007` while realAssets = 0. forceDeallocate with 0 or 1 asset reverts `MarketLossFactorMaxedOut`. Only an allocator or sentinel `deallocate(market, 0)` clears it (netCredit 0, allocation 0, marketIdsLength 0), or the timelocked forceRemove. - No value is at stake: realAssets is already 0. Only cap bookkeeping is stale, which can block new buys. The general stale-credit point is Cantina 3.2.5; the maxed-lossFactor revert is not in the drafts (b15m, b20n). - Fix: document it. Optionally, when lossFactor is max and assets == 0, skip the take and just resync (b20n). **5. Disabling a sub-ratifier pauses offers but does not cancel them; re-enabling revives old roots.** Refs: MidnightAdapter.sol:348-352, :503-505; ratifiers/MidnightAdapterPriceRatifierV1.sol:21, :107. - b15o `testSubRatifierToggleRevivesOffer`, verified: the fill reverts `SubRatifierFailed` while disabled, then fills netCredit 1000e18 after re-enable. - b20n N4, verified: credit after the first half fill is `50296715413237310868003`. A sentinel re-enable reverts `NotAuthorized`. After an allocator re-enables, the old proof fills again and credit becomes `75445073119855966302004`. - b14 #11 (UNVERIFIED there) agrees. - The re-enable needs an allocator (trusted). Related: TRST-R-5. - Fix: state in the NatSpec that disabling is a pause and sentinels must unratify roots, or add a per-sub-ratifier epoch. **6. Stored net credit (cap, family, collateral and duration allocations) stays at the pre-loss value until synced; any shareholder can sync it with a 0-asset forceDeallocate.** Known: Cantina 3.2.5 covers the staleness. The public sync route is the new, documentation-only part. Refs: MidnightAdapter.sol:60, :69, :427-477, :716-737, :816-834. - b15v, verified: stored 30000e18 vs live 8000e18, over-counted by 22000e18. A 0-asset forceDeallocate by any ≥1-share holder costs 0 penalty and brings allocations to 8000e18. A later 100e18 forceDeallocate took allocations 68000e18 → 46633.33e18 with no underflow. - b15m: allocation `100593430826474621736007` → `50296715413237310868003` after a shareholder sync. - b14 #3: allocation stayed `100593430826474621736007`, then `50296715413237310868003` after sync. - b21s invariant E: stored ≥ live always, and equal while lossFactor = 0. b21s did not measure how long staleness lasts (UNVERIFIED there). - Staleness only makes cap checks stricter; it never lets an allocation underflow (b15v). - The NatSpec at :717 mentions only `withdrawToVault(0)`, which is allocator/sentinel-only, so the public route is worth documenting. **7. `isRatified` approves any offer for any caller while `inForceDeallocate` is set.** Refs: MidnightAdapter.sol:465-469, :493, :520-526; lib/midnight/src/interfaces/IGate.sol:6-7. - b11f and b19 rank 3, verified to the extent that `test_02` shows the self-made offer is refused once the flag is off: three ratifierData variants revert, two with `IncorrectCallbackAddress` 0x30119bd7. - No reentry into the window was shown. Midnight.take only calls the ratifier and the view gate functions in that window (b11f, b15m, b15g, b17n). - Documented at NatSpec :487 per b19. Not in the drafts. - Hardening: return early only if `msg.sender == midnight` and the offer is the adapter's own (maker == this, callback == 0, tick == 0, reduceOnly). **8. The IKR gate admission is one unkeyed transient slot, and `unadmit()` is permissionless.** Refs: gates/IKRCompatibleEnterGate.sol:38-56; MidnightAdapter.sol:519-528. - b07 #2 (UNVERIFIED) and b14 #28 (UNVERIFIED): a contract running between admit and onBuy could clear the admission and revert only its own transaction. In the adapter's flow no third-party code runs in that window. - b15g (verified): admission is not reusable in the same transaction. After forceDeallocate, `canIncreaseCredit(attacker)` is false, and a take in a second market sharing the gate reverts; attacker m2 credit = 0. - b07: 0 leaks in 2,573 probes across both seeds. - Hardening: key the admission by the admitting adapter, and restrict unadmit to it. **9. A rogue factory-made adapter can reach `admit()` but cannot use it.** Informational, known (Cantina 3.6.3 note 7). See §3.2 (b11f, b17r, b15g, b14 #5, b19 rank 9). **10. After maturity, a non-forceSellable sale needs proceeds ≥ face value.** Refs: MidnightAdapter.sol:141-144, :641-642; README.md:126-132. - b19 rank 6, verified: settlementFee at ttm 0 = `1000000000000`, maxNetSellRate = `18446744073709551615`. A post-maturity taker sale at price 1 reverted `NetSellRateTooHigh`. - b11s's "always fail" is corrected (§3.3). - b14 #15, verified: valuation is 1e21 at maturity and one year later, and a matured position has an unchanged rate in the shortfall loop. - b15o: a live sell offer at price < 1 after maturity reverts `NetSellRateTooHigh`. - The only exit below face is the timelocked setForceSellable. NatSpec :142 states it; the fix is a clearer statement. **11. `forceRemove` is irreversible and strands later recoveries.** Refs: MidnightAdapter.sol:375-391, :435, :631, :726. - b19 rank 4, verified: after a full repay, withdrawable = `1000000000000000000` and adapter credit = 1e18, but realAssets = 0. `withdrawToVault(1e18)`, `withdrawToVault(0)` and forceDeallocate all revert `ForceRemoved`. - b11s raised it (UNVERIFIED). - Documented (README.md:135-138, NatSpec :375-376). Curators should prefer forceSellable for markets that may recover. **12. The force path relies on `tickToPrice(0) == 0`.** Refs: MidnightAdapter.sol:436-456, :342-346; lib/midnight/src/libraries/TickLib.sol:46-53. - b11f `test_04`/`test_05` and b19 rank 5, verified: tickToPrice(0) = 0. `consumed[adapter][0]` stays 0 after a 1000-token exit, and an exit still works after `setConsumed(0, uint128 max)` (consumed printed `340282366920938463463374607431768211455`, units bought `1000000000000000000000`). - b14 #22 agrees: its expected-revert assertion failed because the exit succeeded. - If tick 0 ever priced above 0, every exit would consume group-0 capacity and `setConsumed(0, max)` would block all exits. Nothing in the adapter states this. Fix: a comment and a test, or a dedicated group. **13. Rate-floor rounding recognises a little interest early on each non-empty buy.** Known: TRST-R-14, Cantina 3.2.8 and 3.6.6, documented at NatSpec :19-24. Refs: MidnightAdapter.sol:22, :24, :543-547, :859. - b19 rank 7, verified: on net credit `526102247340447919244567`, a 1e18 par buy raised realAssets by `540032400388` wei more than paid, under the bound `1318204296536` (netCredit·ttm/1e18). Three zero-unit buys left netRate `20140582732` and realAssets unchanged, so the 3.2.8 ratchet is gone. - b11b estimate (UNVERIFIED): about 300 wei per buy for 1e13 net credit at ttm 3e7. - b14 #8, verified: one 100,000-token buy raised idle + realAssets by about 30.6 million wei; splitting it into 50 fills added 42 wei. - b21b, verified: the shortfall spread raised realAssets + idle by `99002934003`, `64450280378` and `147793655051` wei on 8.8e22–1e23. That is below 1e-6 of the shortfall, and it is the same before or after a loss sync. - b14 #26 and b15o: zero-unit fills change nothing (netRate `9812017633`). - Dust rounding is at most Low under the competition rules, and it is known. **14. A 0-asset or 1-unit first buy into an empty market panics with division by zero (0x12) instead of a named error.** Refs: MidnightAdapter.sol:535-547. Documented in the inline comment at :546 and in the Cantina draft §3.4. - Verified by b15l (`testOneUnitFirstBuyReverts`), b15o (`testFirstDustFillPanics`, tick 4400) and b19 rank 8. In b19, a 0-asset buy of 1e18 units into a held market moved netCredit `1052204494680895838` → `2052204494680895838`, netRate `20140622947` → `405943092081`, and realAssets by +1224477 wei, within the floor bound. - b11b raised it statically. - Only the taker's own transaction reverts. Fix: a named error, or require buyerAssets > 0 when units > 0. **15. An untrusted taker can fill the 250-market list with dust takes; this is documented ("Fillable with dust takes.", :96).** Refs: MidnightAdapter.sol:96-97, :548-553, :837-863; src/VaultV2.sol:24. - b15l, verified: 2-unit takes give stored net credit 2 and netRate `1446759259259`. Totals: 250 markets, attacker gas `438858060`, attacker assets received 250. A legitimate 251st-market take then reverts `TooManyMarkets`. - Cold gas with 250 markets: realAssets `1946060`, durationAllocations(1) `1257586`, vault.deposit `2049489`, shortfall sale `2719633`. Removing one dust market by forceDeallocate costs `2296041`; refilling the slot costs `2854394`. - All of this is far below the block gas limit. The team's `testForceDeallocateGasWorstCase` (250 markets with bad debt, within 10M gas) passes. - b14 #9 (UNVERIFIED) agrees. - Hardening: an owner-settable minimum net credit for new-market entries, or a minimum fill per take in sub-ratifiers. **16. A duration cap stops counting a position one second after a buy at exactly that duration.** Refs: MidnightAdapter.sol:586-603, :816-834; README.md:47-53. - b11f `test_08` and b19 rank 12, verified: `durationAllocations(1)[0]` = `100593430826474621736007` right after the buy, and 0 one second later. - b14 #6, verified (`testDurationBoundary`): a 1,000-unit buy just below a 7-day threshold succeeds under a 500-token cap, the same buy at the threshold reverts, and the position ages out one second later. Duration ids are not in `ids()`, so read `durationAllocations`. - Matches the NatSpec ("counts toward every duration <= its remaining TTM"). **17. Duration inputs: thresholds above Midnight's maturity ceiling are accepted, and PackedDurationsLib does not mask its inputs.** Refs: MidnightAdapter.sol:161-169; libraries/PackedDurationsLib.sol:5-30; lib/midnight/src/Midnight.sol:749-756. - b14 #14, verified: a 4,294,967,295 s threshold is accepted, but Midnight allows maturities at most 3,153,600,000 s ahead, so such a slot can never apply. Empty arrays deploy with zero buckets. - b14 #18, verified (`testPackedDurationsLibEdges`): packing `[2^32 + 4, 2]` decodes as `[4, 3]`, and index 8 yields 0. The constructor bounds inputs to ≤8 strictly increasing non-zero 32-bit values, so this is safe for the adapter. - b11f `test_08`: 8 durations with uint32 max round-trip (`4294967295`), while 9 durations, a zero, 2^32 and equal neighbours all revert. - b14 dropped "every index above seven necessarily returns zero": `32 * index` is unchecked and can wrap. - Fix: validate against the Midnight ceiling in deployment tooling, and add input checks if the library gets other callers. **18. A named funding adapter is always deallocated for the full buyerAssets, and empty `callbackData` reverts.** This changed from the audited commit 6476e9d. Refs: MidnightAdapter.sol:36-38, :578-584; README.md:94-95. - b19 rank 13, verified with repository tests `testOnBuyFundsFromCallbackDataAdapterWithIdleAssets` and `testOnBuyEmptyCallbackDataReverts`. - b11b raised it statically. - Allocator-chosen and documented. Integrators upgrading from the audited version must change their offer encoding. **19. A Midnight authorization granted by an allocator also confers ratification rights on every adapter where that allocator serves.** Refs: ratifiers/MidnightAdapterPriceRatifierV1.sol:20-21, :38-44, :74-80; RateRatifier :42-48, :76-82. - b11f `test_06` and b19 rank 11, verified on the Price ratifier only. The Rate ratifier is the same code by diff (UNVERIFIED by run). - Documented in NatSpec :20; TRST-R-6 suggested documenting it. Suggestion: per-ratifier delegation. **20. A direct `setIsRootRatified` does not advance `rootNonce`.** Known: TRST-R-5 (unchanged). Refs: PriceRatifier :33-51, :70-91; RateRatifier :37-55, :72-93. - b11f `test_06`: rootNonce is 1 after a signed ratification and still 1 after a direct revocation. - b14 #4, verified with the repository test `testSignatureReplayAndStatusChange`. A replay is a no-op while the status matches. - Not new. **21. Factory: no lookup by vault and salt, duplicate deployments fail by CREATE2 collision, and a shared msg.sender means a shared salt namespace.** Refs: MidnightAdapterFactory.sol:15, :28-41; gates/IKRCompatibleEnterGateFactory.sol:11-21; gates/WhitelistEnterSubGateFactory.sol:11-28. - b11f `test_07` and b19 rank 14, verified: a front-runner using the victim's preSalt gets `0x1c8e1561958999eAf5f7D7b88d4F78c56f7AD160`, while the victim still gets `0xE5864780419774B5864884aF7F953eEaCEa179Ad`. A second identical call reverts; b11f says about 1.05e9 gas was used in the test run. - b14 #20, verified (`testFuzzFactoryAddresses`, all three factories). - TRST-R-4 is fixed. The NatSpec tells bundlers to put the initiator into preSalt. **22. realAssets reverts `OtherSellInProgress` when a taker reenters the vault from its onBuy during an adapter sale in a market with lossFactor ≠ 0.** Refs: MidnightAdapter.sol:848-853; lib/midnight/src/Midnight.sol:437-468. - **Verified by b21b**: a strict taker's take reverts `OtherSellInProgress`. A try/catch taker fills `2500000000000000000000` units, an outsider fills the rest, and in a healthy market the same deposit works. - UNVERIFIED in b15l and b17n. b14 #23 cites the repository test `testBackingCallbackFirstValuationAfterDefaultBlocked`. - It hits only the taker's own composed transaction; it is not a third-party DoS. Internal paths are unaffected (VaultV2.sol:567-586, 790-797, per b15l). Close to TRST-R-11/R-13. - Fix: document the first-valuation constraint for callback integrators. **23. During a nested buy, cap checks count the stored pre-sale credit of a market whose sale is in progress.** Refs: MidnightAdapter.sol:591-603, :817-829. b17n, verified: this only makes checks stricter, and after the sale the vault adapter allocation `69000e18` = stored A 35000e18 + stored B 34000e18. b14 #24 (`testProbe_BuyerCallbackReentersDuringAdapterSale`) found consistent accounting (1e18 + 1.5e18 = 2.5e18 allocation). **24. Ratifier input edge cases with no security impact (b17f, all verified, unit level with mocks).** - (a) Trailing bytes in `ratifierData` are accepted: a 200-byte ratifierData returns `CALLBACK_SUCCESS` (PriceRatifier/RateRatifier :100-101). - (b) The rate ratifier panics on `rate*timeToMaturity` overflow instead of reverting `WorsePrice` (RateRatifier :105-106). b14 #16 agrees: a panic at one year, and acceptance at WAD at maturity. - (c) `HashLib.isLeaf(root, root, 0, [])` is true (lib/midnight/src/ratifiers/libraries/HashLib.sol:131-142). It is safe because the ratifiers recompute the leaf from the offer. - b14 #25, verified (`testFuzzRateRatifierBound`): the rate-ratifier rounding matches the exact inequalities. **25. Liveness limits of the rate and shortfall paths (b21s, verified in a diagnostic run that is not part of its delivered output).** - (a) A sale whose shortfall exceeds the total remaining interest reverts `ShortfallTooHigh` (0x0e0afa7b), even when the allowance would cover it (MidnightAdapter.sol:646-667). - (b) Rate-ratifier maker sell offers become unfillable as ttm shrinks (`WorsePrice`, 0x1768d9f2; RateRatifier :107-108). makerSellRate had 511 reverts of 1460 calls. This fails in the protective direction. **26. Early withdrawal of repaid liquidity forgives pending continuous fee and realises the remaining discount in one step.** Known: Cantina 3.6.5. Refs: MidnightAdapter.sol:717-737; lib/midnight/src/Midnight.sol:481-486. - b15m, verified: with a 1%/yr fee, stored net credit fell by `49990410958929440000000` for `50000000000000000000000` withdrawn. realAssets + idle went `100000000000042545435847` → `100294965000021398212068` (+294.96e18). - b11s: withdrawToVault is now internal (allocator/sentinel only), so the public timing vector of Cantina 3.6.5 is gone, but the step gain remains. **27. Live offers after a cap is zeroed or the adapter loses a role (documented).** b15v, verified: - Collateral cap zeroed: buys revert `ZeroAbsoluteCap`; sells and forceDeallocate still work (allocations 18000e18). - Allocator role removed: sell fills revert `Unauthorized`; forceDeallocate still works (17000e18). - Sentinel role only: sells work and buys revert. - b15o: offers stay live after the allocator is removed (netCredit 1000e18). Ratified sell roots revive if the role is restored. Refs: MidnightAdapter.sol:29-30, :606-611, :693-698. b14 #17 (UNVERIFIED) lists the same role dependencies. **28. A 1-wei shareholder can run the force path with 0 assets on any market of the loan token at no penalty.** Refs: MidnightAdapter.sol:427-477. b11f `test_03` and b19 rank 10, verified: on an unheld sibling-maturity market, allocation stays `100593430826474621736007` and marketIdsLength stays 1; 1 wei reverts `MakerCreditOrDebtIncreased`. It costs gas and emits events only. On a held market with a loss it acts as the sync route of item 6. **29. Loss timing and in-kind redemption in loss markets behave as designed (b21b, verified).** - (a) Exiting in the same transaction as a loss uses the cached share price: redeem returns `19999999999999999999999`, the same as before the loss, against `17999098083130871512618` in a later transaction. This gives no more than exiting just before the liquidation. Documented at VaultV2.sol:28-33. - (b) forceDeallocate in a loss market sells fresh credit at face: 5000e18 paid for 5000e18 units; adapter realAssets drops `4975395391673975227364`; the penalty burns `113569063572893043550` shares; liveNetCredit+1 reverts. - (c) realAssets drops by exactly the amortized slashed credit `12011810212001199220233` with no sync. - b14 #7 (UNVERIFIED) states (a) as a general Vault V2 property. **30. Tokens donated to the adapter are not counted and stay until skimmed.** b21s, verified: the adapter's final balance equals the donated total exactly (`1026871939340070811348`), and NAV never moved. Documented skim behaviour (MidnightAdapter.sol:393-400). **31. Low, known: shared cap ids aggregate exposure across adapters.** b14 #1, UNVERIFIED. The family id omits adapter and maturity, and the collateral-token id shares the Morpho Market V1 adapter's namespace (MidnightAdapter.sol:787-809; src/adapters/MorphoMarketV1AdapterV2.sol:189-196). Known as TRST-L-2, so out of scope. b11f notes the related TRST-R-10 status as partial. **32. Low, known: relative caps compare Midnight face value with vault book value.** b14 #2, UNVERIFIED (MidnightAdapter.sol:60-61, :591-611; VaultV2.sol:539-557). Known as TRST-L-3, so out of scope. **33. Gate configuration notes (b15g, verified).** - (a) A gate with admit disabled is rejected (`IncorrectEnterGate`) even when its credit side is open. This is documented. - (b) `IKRCompatibleEnterGate.roleSetter()` is the sub-gate's credit-side role setter (:27, :32). The debt role setter gets `Unauthorized` on `addAdmitterFactory`, and `setRoleSetter(true, address(0))` freezes factory registration for good. b14 #12 (UNVERIFIED) adds: validate the sub-gate and its role setters at deployment. - (c) `setIsWhitelistedWithSig` accepts the high-s twin of a used signature as an idempotent replay that emits an event but changes no state (WhitelistEnterSubGate.sol:73-74). The code comment accepts this; it relates to Zellic 3.3 per b13. - (d) b14 #19, verified: the EIP-712 domains have no name or version. Chain and contract separation are tested (`testSignatureCannotCrossChainOrRatifier`). **34. Other notes from b14 with no impact.** - #13: a zero `enterGateFactory` opts out of the IKR restriction (UNVERIFIED). - #21: factory runtime size depends on the compiler profile (foundry.toml:62-66 has Osaka/833 runs). No size under the pinned profile was established, so b14 dropped the "894 bytes left" claim. - #27: vault hooks are callable only by the parent vault (UNVERIFIED). - #29: timelocks key on the exact calldata (UNVERIFIED). - b11f: a zero-asset call on a sibling maturity passes the vault's ZeroAllocation check because the joint id ignores maturity (`test_03`); no fault. - b21r: tokens with an expensive smallest unit (WBTC, cbBTC, 2-decimal stablecoins) are documented as unsupported (MidnightAdapter.sol:21). Not tested (UNVERIFIED). ### 4.1 Items b14 dropped, carried here so nothing is lost silently b14 dropped the following, each with a reason: - "forceDeallocate pulls the settlement fee rounded up, so dust stays on the adapter": Midnight's pull matches the adapter's rounded fee. b15m also found 0 reverts over 200 amounts and 0 dust for a 1234567-wei redemption. - "Continuous fees independently make stored net credit stale": the fee accrual is net-neutral. b15m `testPermissionlessUpdatePositionAndFeeChange` saw no change. - "Empty duration arrays prevent trading". - "Every account can acquire gated credit through an unverified parent vault" (§3.2). - "23,682-byte factory leaves 894 bytes": wrong profile. - "Shortfall multiplication overflow": no reachable state shown. - "realAssets stayed within net credit" as a finding: this is coverage, not a finding. - "Zero-unit sale always reports a zero allocation change": wrong, since onSell sends live minus stored. - "Forced-sale transient callback scope" as a standalone finding. - "Third-party use of the adapter as a payer": both routes reverted. - "Dirty padding is the only alternate timelock calldata". - "Every index above seven returns zero". - "Wallet omission of names increases phishing risk". - "ACC-1 and FUZZ-1 candidates": excluded by its brief (FUZZ-1 is the held whitelist-signature issue). --- ## 5. Team-held / prior-merge candidates checked against more audits (b13) The results name two issues as already held and exclude them (b07, b17r, b17n, b15g, b14): **A**, shortfallAllowance consumed faster by a piecewise-filled sale; **B**, an unused `setIsWhitelistedWithSig` re-admits an account after a direct removal. b13 compared them with 30 further sources: older Morpho audit PDFs under `audits/`, the competition page, and the in-scope sources. - **A**: verdict "new" in a narrow sense: no exact documentary duplicate was found. b13 warns that README.md:81-88, :114-124 and MidnightAdapter.sol:145-148 document per-sale consumption and global rate reduction, "this substantially weakens any claim that merely consuming allowance per sale is unexpected". It says the "up-to-38% number … and actual later-sale revert impact are UNVERIFIED here (no coded PoC)". b13 mentions the closest analogues: Blackthorn 2025-09-15 M-5/L-16, Market V1 adapter V2 Blackthorn L-6, Blue public allocator M-1..M-4. - **B**: verdict "new" in the same narrow sense. Mechanism present statically (WhitelistEnterSubGate.sol:52-56, 69-82). A used signature cannot be replayed after a direct deny (`WhitelistedStatusChanged`), so B "must not be described as unlimited replay of used signatures". Closest prior art: Blackthorn 2025-09-15 L-13 (permit cancellation) and Zellic 2025-07-15 3.3. "UNVERIFIED as a competition finding." - b13 also lists 69 historical findings from those reports, mapped by analogy to current code: 31 marked `present`, 38 `changed`. They are historical severities, not new findings. b13's own note: "codeNow=present records a remaining mechanism/design pattern, not a certified exploit". Several code references are loose analogies; for example, burnShares items from other adapters are mapped to forceRemove lines. **Because 13 of b13's sources did not hold on re-read (§8), the A/B verdicts and the 69-item register should be treated as unconfirmed leads.** Before relying on any of them, re-check the specific PDF page. --- ## 6. Status of prior-audit fixes in this group Statuses agree across b11b, b11s, b11f and b19 unless noted. b11b and b11s were static only. b19 re-tested them with named repository tests, which all pass, and its "tested" status supersedes theirs. | prior id | status | evidence | |---|---|---| | Cantina 3.2.3 (duration zero cap) | fixed: `DurationZeroAbsoluteCap` (:586-603), id preimage now "this/duration" | b19: `testDurationAbsoluteCapZeroRejectsZeroUnitBuy` etc. pass; b11f test_08: cap on the new preimage `340282366920938463463374607431768211455`, old preimage 0 | | Cantina 3.2.5 (stale allocations) | unchanged, documented as an upper bound (:69) | b11b; see item 6 | | Cantina 3.2.8 (rate ratchet) | fixed: carried value floored (:545) | b19 test_B2 and repository tests; b14 #26 | | Cantina 3.2.11 (blended rate check) | fixed: per-trade `NetBuyRateTooLow` (:537) | b19 repository tests | | Cantina 3.6.6 (rounding bias) | partial: bounded, documented | b19 measured 540032400388 wei | | TRST-L-5 (minRate not timelocked) | partial: decreases timelocked; default 0 | b19 | | TRST-PR-1 (approvals) | fixed: `forceApproveMax` at :426, :613 | b19 repository tests | | TRST-R-2 (packing) | partial: maturity uint40; rate still uint64, so extreme-rate buys revert | b19 | | TRST-R-7 (TTM curve) | partial: per-trade checks, no curve | b19 | | TRST-R-13 (transient pre-buy state) | partial: documented; edge cases (a)–(f) read by b11b, covered by repository tests in b19 but not one by one | b11b (UNVERIFIED), b19 | | TRST-R-14 (rounding docs) | fixed | b19 | | Cantina 3.1.1 (round-trip loss) | partial: bounded by shortfallAllowance and maxNetSellRate | b19 repository tests | | Cantina 3.2.4 (forceSellable pending buys) | partial: minForceSellPrice defaults to 0 and is immediate (item 2) | b19 | | Cantina 3.2.7, 3.6.4 (global flags) | fixed: per-market policy | b19 | | Cantina 3.2.10 (directional timelocks) | fixed, with the exceptions in items 2 and 3 | b19 | | Cantina 3.6.5 (public withdrawToVault) | partial: now internal, step gain remains | b19, b15m | | TRST-R-3 (forceDeallocate accrual) | fixed | b19 repository tests | | TRST-R-15 (maxTtm) | fixed; a pending increase survives a decrease unless revoked | b19 | | TRST-CR-1/2/3 (centralisation) | partial, by design | b19 | | TRST-L-1 (exit-offer front-running) | fixed: self-made offer | b11f test_01: 0.005% fee, `1000000000000000000007` units bought, `1000050000000000000008` paid, vault idle +`1000000000000000000007`, adapter dust 0 | | Cantina 3.2.2 / TRST-R-12 (isRatified binding) | partial: Midnight bound, caller and chain id not | b11f test_09: an offer with another chain id returns success from isRatified, and Midnight.take reverts | | Cantina 3.2.9 (offer.ratifier check) | unchanged | b11f (read only) | | Cantina 3.5.1, TRST-R-1 (durations per deployment) | fixed | b11f test_08 | | TRST-R-4 (factory salt) | fixed | b11f test_07 | | TRST-R-5 (rootNonce) | unchanged | b11f test_06 | | TRST-R-6 (signature submission) | fixed | b11f test_06 | | Cantina 3.6.2 (duration id NatSpec) | fixed | b11f test_08 | | TRST-R-10 (ids) | partial | b11f test_03 | | Cantina 3.6.3 (notes) | partial: notes 1, 2, 4 fixed; 3, 5–8 unchanged | b11f test_07 (note 7) | b11b also records changes it did not see as faults: a buy with ttm ≥ durations[0] now needs a positive absolute cap on each covered duration id, and the duration-allocation loop moved from `while` to `for` with `break` (same semantics). --- ## 7. What was run, and what was not covered ### 7.1 Builds and suites (as reported) - MidnightAdapterTest 314/314: b15v, b19, b21r (b21r: fuzz 2048 runs, 410 s). - Ratifier suites: 75 passed. b21r reports `MidnightAdapterRatifiersV1Test` 75/75; b15v reports Price 36, Rate 38 and RateIntegration 1. - IKRCompatibleEnterGateTest 24/24 (b15v). Gate/whitelist suites: 145 passed across 9 suites (b15g). - Integration suite 8/8: b07, b11f, b17r, b21r and others. - b15v total: 446 passed, 0 failed. - b19: `forge test --match-path test/MidnightAdapter*.sol` gave 389 passed and 1 failed. The failure is `MidnightAdapterGasTest` setUp, "vm.getCode: no matching artifact found", because of a partial build. b15l saw the same with 2 failures and fixed it by building SetterRatifier.sol and Morpho.sol; after that `testForceDeallocateGasWorstCase` passed. - Environment trouble reported: - b11b/b11s: disk 100% full (`No space left on device`). - b21d: `Proxy CONNECT aborted`. - b15m, b17f, b17n: full test compile SIGKILLed for memory. - b21r: inheriting the integration fixture failed with `Error (4619): Function "clz" not found` at lib/midnight/src/libraries/UtilsLib.sol:49 under solc 0.8.28. Its standalone PoC deploys the real artifacts instead. - Forge versions used: 1.8.3 (b07, b17n) and 1.9.0 (b11f, b17r, b21s). ### 7.2 Stateful and fuzz campaigns (all passing) - **b07**: real VaultV2 + Midnight, a 6-decimal asset, gated markets (IKR + whitelist), a second adapter as funding source, durations [1d, 7d, 30d], rate-ratifier offers, a force-sellable market, bad debt. Seeds 0x1 and 0x2, each 256 runs × depth 100 = 25,600 calls, 0 reverts, 0 invariant failures. - Per seed: forceDeallocate attempts 1,273 / 1,300 (ok 1,210 / 1,230; gated by non-whitelisted holders 697 / 718); admission leaks 0; rate-ratified maker buys 625 / 575 (funded by adapter 2: 158 / 126); bad-debt events 633 / 631; force sells 1,628 / 1,518; passive checks 8,548 / 8,417 with 0 violations. - Invariants: realAssets ≤ current net credit; allocation == stored net credit for 7 ids; no admission survives; no untrusted extraction. - Note: the AGG lines in b07's attached outputs show slightly different counts (e.g. admission probes 1232 / 1285, passive checks 8433 / 8406) from those in its summary and `runs` block. The output excerpts come from a different run of the same suite than the summary figures; both runs pass. The figures above are from b07's `runs` block. - **b21s**: 5 markets with settlement and continuous fees, both V1 sub-ratifiers, a 30d absolute cap of 60,000 tokens, shortfallAllowance 2,000 tokens, minNetBuyRate 0.5% APR, maxNetSellRate 100% APR, a 2% penalty. - 256 runs × depth 100 = 25,600 calls, 5,320 reverts (another run gave 5,178); all invariants A–F pass. Plus three 150-call sequences and a directed forceSellable test. - Maximum unexplained NAV or idle-depositor drop: 0 wei. Every recorded loss (bad debt, forceSellable, forceRemove) stayed within its bound. - Seed not pinned. - **b15v**: `testFuzzOutsiderSequence`, 12 random outsider actions, 2048 runs × 3 suites. allocation == stored == live after every step. Outsider-filled buys hit `AbsoluteCapExceeded`, `DurationAbsoluteCapExceeded`, `RelativeCapExceeded` or `ZeroAbsoluteCap` exactly at the cap. A fill within the headroom (90 of 100 tokens) passed. - **b17f**: ratifier fuzz, 2048 runs. No random root, index or proof verifies. - **b14** (consolidated from earlier inputs): 12 stateless properties at 10,000 runs each ("after-fuzz"), plus earlier invariant campaigns ("after-invariants"). ### 7.3 Directed real-stack PoC suites (no finding; tests pass) | file | result | count | |---|---|---| | ForceRatifyReview.t.sol | b11f | 9/9 | | GatesConfigPoC.t.sol | b15g | 17/17 | | LivenessPoC.t.sol | b15l | 11/11 | | MidnightAssumptionsPoC.t.sol | b15m | 13/13 | | MakerOffersPoC.t.sol | b15o | 20/20 | | VaultRolesCapsTest.sol | b15v | 14 | | RatifierForgeryTest.sol | b17f | 9 | | RogueAdapterGateTest.sol | b17r | 2 + 8 inherited | | NestedTradesPoC.t.sol | b17n | 11 | | NotesReview.t.sol | b19 | — | | G1IkrSize.t.sol | b20i | — | | NotesRecheckTest.sol | b20n | — | | BadDebtCombos.t.sol | b21b | 18 | | RateRatifierFeeBoundaryTest.sol | b21r | 7/7 | | StatefulGatedInvariant.t.sol | b07 | — | | StatefulExtended.t.sol | b21s | 5 | The b21r cases were: buys at the ratified rate rejected after a continuous fee; maxTtm; fill-time amounts one second before maturity; maturity rejection; sell checks on the maker's net proceeds; a sell rate rejected near maturity; outsider setConsumed on shared groups. Selected negative results: - b17n: a nested deposit during an adapter sale gets the same shares as a next-tx deposit (`49963688980049280464788` in both cases), and they redeem for `49999999999999999999999` of 50000e18. - b15o: a loop of 20 buy/sell rounds at the same tick changed nothing except the taker's balance, which fell by 20 wei. - b15o: 3×1000e18 fills equal one 3000e18 fill (netCredit 3000e18, netRate `9812017633`). - b15g: 6 of 6 cross-side/account/gate/chain/value signature replays rejected. - b15m: updatePosition plus a fee change left stored, live and realAssets unchanged. ### 7.4 Not covered (union of each result's list) - **Duration-buckets lead (b21d): no direct coverage.** That means eight-duration deployment at the limits, boundary-second placement, caps lowered while credit ages, maturity at timestamp ±1 on every path, and a brute-force check of durationAllocations. Partial coverage elsewhere: b11f test_08, b14 #6/#14/#18, b15v, and b21s invariant B (durationAllocations(1..3) == brute-force sum, durations 1d/7d/30d). - b11b, b11s: nothing executed at all. Much of it was later tested by b19. - Malicious or reentrant enter gates, sub-gates, tokens and oracles; liquidator gates (b07, b11f, b17n, b21s). - Multi-collateral markets with fees beyond the b21s set; changing settlement fees between ratification and take (TRST-L-4 territory) (b07, b15m). - Allocator shortfall sales (the maxNetSellRate/shortfallAllowance path) in gated setups (b07). Multi-market shortfall with lossFactor ≠ 0 markets (b15m). Total loss plus several losses in one market, non-zero fees in loss markets, and non-18-decimal assets in b21b. - Nested trades with lossFactor ≠ 0; two adapters of one vault trading with each other; gated markets in nested flows (b17n, b15v). - Self-funded buys across adapters beyond reading the code (b15v). Cap overshoot there is Cantina 3.2.6. - Rate ratifier fills on the real stack were not run in b15o and b11f. b21r ran its own standalone real-artifact test, and b07/b21s ran rate-ratifier offers in campaigns. - Signed ratification, Merkle trees of height > 0 and allowedTaker in the campaigns (b21s). Hostile reentry into the inForceDeallocate window (b11f, b19). - Vault receive/send-share gates combined with IKR (b15g). Multi-adapter gas (b15l). - No result produced a finding that needed step-4 refutation, and no clean-clone second-agent re-run was done. --- ## 8. Source reliability caveats - **b13 (known2/more): 13 sources did not hold when re-read.** A cited page could not be read, or does not say what it was quoted for. Affected: the competition-rules quotes (§2), the A/B "new" verdicts and their quotes (§5), and the 69-item historical register. The scope and out-of-scope list in §2 matches the brief, so it holds independently. Severity-rule details and the reward figures b13 lists (Medium $150,000 pot, High $400,000, $40,000 for Low/Info) are left unconfirmed here; they do not affect any classification above. - **b21r (leads-f/rate-ratifier-fees): 6 sources did not hold.** Its citations are its prior-audit check (TRST-L-4 "p. 11", Cantina §3.2.9 "p. 10") and the documented-precision note. Its test results (7/7 pass and the existing suites) are executed output and do not depend on those sources. Its claim that this maker-side lead is distinct from TRST-L-4 should be re-checked against the draft before it is relied on. - b15g says some glyphs in both 2026-10-12 PDFs did not decode, so partial overlap with the drafts cannot be fully excluded for its notes. b15m, b15v, b20n and b19 did read the drafts and give the duplicate mapping used above. - b17f's ratifier tests use mock adapter, vault and Midnight contracts, not the integration fixture. - No result in this group was missing or empty. Three were blocked or empty in substance: b11b and b11s ran nothing (disk full); b21d read and ran nothing (network).