{
 "item": "gov-propose-apply",
 "commit": "ff1c192b3798542997f600091f2dc73ff05e4c40",
 "forge": "forge 1.8.5 (older than the brief's 1.9; no --use solar). solc 0.8.38 is not installed (only 0.8.26), so every test RAN on a copy of the audited files at ff1c192 with only `pragma solidity 0.8.38` rewritten to 0.8.26 (via_ir, optimizer 200, cancun, as foundry.toml), in a scratch project compiling only the files under test: src/GovernedByKind.sol, Parameters*.sol, house/Parameters*.sol, hub/MinterHub.sol (+ImdUSD.sol, TransientReentrancyGuard.sol, IMinterHub.sol). External contracts (Ledger, join, feeds, token, vault) are minimal mocks.",
 "verdict": "findings",
 "findings": [
  {
   "id": "GPA-1",
   "severity": "low",
   "title": "House SET_DEPTH (kind 16) accepts any uint256 at propose; its _apply overflows in depthRule() (depthK x depthIMD) on a house without ImdDepth: accepted at propose, Panic 0x11 at apply (alone and in a BATCH). The same unbounded value is accepted from the deployer at genesis and makes risk(depthIlk) / depthLine() panic.",
   "property": "P3 (no arithmetic over payload fields in any _apply overflows for a value _validate accepts); P1 (a payload passing propose applies, alone and in a BATCH)",
   "claim": "C1 (find another propose-accepted / apply-dead payload beyond the 2 RETIRE_SLEEVE_TOKEN rows and house SET_OTHER_IMD)",
   "files": [
    "src/house/ParametersRules.sol:65",
    "src/house/ParametersRules.sol:66",
    "src/house/ParametersRules.sol:314",
    "src/house/ParametersRules.sol:317",
    "src/house/ParametersRules.sol:319",
    "src/house/ParametersBase.sol:461",
    "src/house/ParametersBase.sol:467",
    "src/house/ParametersBase.sol:480",
    "src/house/ParametersBase.sol:488",
    "src/house/Parameters.sol:93",
    "src/house/Parameters.sol:99",
    "src/house/Parameters.sol:323",
    "src/house/Ledger.sol:290",
    "src/house/earn/LoopVault.sol:341",
    "src/house/Parameters.sol:406"
   ],
   "sequence": "(a) House Parameters with depthIlk set and no ImdDepth (StageHouse/StageGenesis run _stageDepth only when cfg.depth.enabled; then depthIMD() returns the posted depthCap). Safe proposes SET_DEPTH(depth) with depth > type(uint256).max / depthK (e.g. 2^256-1, or 8.39e61 at depthK 0.5e18, the fuzz counterexample). _validate (ParametersRules.sol:65-66) only decodes and checks depthIlk != 0: accepted. After 48 h anyone calls applyPending(16): _apply stores depthCap then _flagDepth() -> depthRule() -> uint256(depthK) * depthIMD() overflows: Panic 0x11, whole apply reverts, the slot (and its lock) stays until cancel/expiry. Inside a BATCH the same item passes checkBatch as a 'waiting' item (it also fails alone, Parameters.sol:406 allows that) and kills the whole batch at apply. (b) If depthK is first lowered to 0 (lowerDepthK(0), instant), SET_DEPTH(huge) applies and is STORED; every later SET_DEPTH_K raise then panics at apply. (c) Deployer before seal: setGenesisDepthRule(ilk, k, 2^256-1, 0, 0) is accepted (Parameters.sol:99 bounds k, otherLines, otherChop but not depth, though its comment says the bound exists so a genesis value 'cannot make depthLine(), _depthNeed() ... panic'); after seal risk(depthIlk) and depthLine() panic, so house Ledger.sol:290 (borrow ceiling) and LoopVault (dust/rateFloor on lever and unwind) revert for the depth type until the governor's instant postLowerDepth.",
   "expected": "Every SET_DEPTH value _validate accepts applies (or is refused at propose); setGenesisDepthRule refuses a depth that makes depthRule()/depthLine() overflow.",
   "actual": "testFuzz_setDepthAppliesForEveryAcceptedValue fails with panic 0x11 (counterexample depth=8.387e61, batch=true); test_setDepthMaxPassesProposeDiesAtApply, test_depthK0ThenHugeDepthBlocksKRaise, test_genesisDepthUnboundedPanicsRisk pass (they assert the panic).",
   "reachableAtDeploy": "Only on a house deployed without ImdDepth (cfg.depth.enabled false; script/house/DeployConfig.sol:1340 copies it from the chain config). With ImdDepth, depthIMD() = min(measured, depthCap) and no overflow occurs. Needs a Safe proposal of an absurd value (>1e59) or the deployer before seal; no funds move; the governor repairs (b)/(c) instantly with postLowerDepth. Severity low (governance liveness / temporary DoS of the depth type's borrow and LoopVault paths in (c)).",
   "fix": "Bound depth at propose and at genesis like otherLines: in ParametersRules SET_DEPTH and setGenesisDepthRule refuse depth > type(uint128).max (depthK <= 1e18 then cannot overflow). Generally: make checkBatch / a single-proposal dry run refuse a Panic(uint256) or empty revert instead of classing it as 'waiting'.",
   "test": {
    "source": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.26;\n\nimport \"forge-std/Test.sol\";\nimport {Parameters} from \"../src/house/Parameters.sol\";\nimport {ParametersRules} from \"../src/house/ParametersRules.sol\";\nimport {ParametersBase, IFeed} from \"../src/house/ParametersBase.sol\";\n\ncontract HM {\n    address public token;\n    address public ledger;\n    constructor(address t, address l) { token = t; ledger = l; }\n    function latestValue() external view returns (uint256, uint64) { return (2000e18, uint64(block.timestamp)); }\n    function isStale() external pure returns (bool) { return false; }\n}\n\ncontract HouseTest is Test {\n    address gov = address(0xA11CE);\n    Parameters p;\n    bytes32 constant ILK = \"SIMD\";\n\n    function _risk() internal pure returns (ParametersBase.Risk memory r) {\n        r = ParametersBase.Risk({mat: 1.5e18, chop: 0.1e18, cut: 0.5e18, chip: 0.01e18, rateFloor: 0.01e18, yieldFee: 0,\n            skew: 0.05e18, pegFloor: 0, line: 100_000e18, dust: 100e18, redeemFloor: 0.005e18, redeemDivisor: 2,\n            redeemCap: 0});\n    }\n\n    function setUp() public {\n        HM tok = new HM(address(0), address(0));\n        HM led = new HM(address(0), address(0));\n        HM join = new HM(address(tok), address(led));\n        HM feed = new HM(address(0), address(0));\n        p = new Parameters(gov, address(this), new ParametersRules(gov));\n        p.wire(address(led), address(tok));\n        p.addGenesisIlk(ILK, ParametersBase.Config(address(tok), address(join), IFeed(address(feed)),\n            IFeed(address(feed)), IFeed(address(0)), address(0), address(0), IFeed(address(0)), false, false), _risk());\n        // the deploy's no-ImdDepth branch (cfg.depth.enabled false): the posted figure IS the depth\n        p.setGenesisDepthRule(ILK, 0.5e18, 1_000_000e18, 0, 0);\n        p.setGenesisChainLine(1_000_000e18);\n        p.seal();\n    }\n\n    function _go(bytes memory payload) internal {\n        vm.prank(gov);\n        p.propose(payload);\n        vm.warp(vm.getBlockTimestamp() + 48 hours);\n        p.applyPending(abi.decode(payload, (uint8)));\n    }\n\n    // which overflows (Panic 0x11) for depth > type(uint256).max / depthK: accepted at propose, dead at apply.\n    function testFuzz_setDepthAppliesForEveryAcceptedValue(uint256 depth, bool batch) public {\n        bytes memory item = abi.encode(uint8(16), depth);\n        bytes memory payload = item;\n        if (batch) {\n            bytes[] memory items = new bytes[](1);\n            items[0] = item;\n            payload = abi.encode(uint8(17), items);\n        }\n        vm.prank(gov);\n        try p.propose(payload) {} catch { return; } // only what propose accepts\n        vm.warp(vm.getBlockTimestamp() + 48 hours);\n        p.applyPending(abi.decode(payload, (uint8))); // must not revert for an accepted value\n    }\n\n    function test_setDepthMaxPassesProposeDiesAtApply() public {\n        bytes memory payload = abi.encode(uint8(16), type(uint256).max);\n        vm.prank(gov);\n        p.propose(payload); // accepted\n        vm.warp(vm.getBlockTimestamp() + 48 hours);\n        vm.expectRevert(stdError.arithmeticError);\n        p.applyPending(uint8(16));\n        (, uint256 eta) = p.pendingOf(16);\n        assertGt(eta, 0, \"slot still held until cancel/expiry\");\n    }\n\n    // With depthK lowered to 0, SET_DEPTH(huge) applies and is stored; any later SET_DEPTH_K raise then panics at apply.\n    function test_depthK0ThenHugeDepthBlocksKRaise() public {\n        vm.prank(gov);\n        p.lowerDepthK(0);\n        _go(abi.encode(uint8(16), type(uint256).max));\n        assertEq(p.depthCap(), type(uint256).max);\n        vm.prank(gov);\n        p.propose(abi.encode(uint8(15), uint64(0.5e18))); // accepted\n        vm.warp(vm.getBlockTimestamp() + 48 hours);\n        vm.expectRevert(stdError.arithmeticError);\n        p.applyPending(uint8(15));\n    }\n\n    // wrong genesis value cannot make depthLine(), _depthNeed() ... panic\") but not `depth`: risk(depthIlk) then panics.\n    function test_genesisDepthUnboundedPanicsRisk() public {\n        HM tok = new HM(address(0), address(0));\n        HM led = new HM(address(0), address(0));\n        HM join = new HM(address(tok), address(led));\n        HM feed = new HM(address(0), address(0));\n        Parameters q = new Parameters(gov, address(this), new ParametersRules(gov));\n        q.wire(address(led), address(tok));\n        q.addGenesisIlk(ILK, ParametersBase.Config(address(tok), address(join), IFeed(address(feed)),\n            IFeed(address(feed)), IFeed(address(0)), address(0), address(0), IFeed(address(0)), false, false), _risk());\n        q.setGenesisDepthRule(ILK, 0.5e18, type(uint256).max, 0, 0); // accepted\n        q.seal();\n        vm.expectRevert(stdError.arithmeticError);\n        q.risk(ILK); // read by Ledger (borrow ceiling) and LoopVault (dust / rateFloor on every lever and unwind)\n        vm.expectRevert(stdError.arithmeticError);\n        q.depthLine();\n        vm.prank(gov);\n        q.postLowerDepth(1_000_000e18); // the governor's instant repair\n        q.risk(ILK);\n    }\n}\n",
    "ran": "forge 1.8.5, solc 0.8.26 on pragma-rewritten copy of ff1c192 (see forge field): forge test --match-path t/House.t.sol (fuzz runs 512)",
    "result": "[FAIL: panic: arithmetic underflow or overflow (0x11); counterexample: args=[83874635335900888156104634742579942706925873704699623142277783 [8.387e61], true]] testFuzz_setDepthAppliesForEveryAcceptedValue(uint256,bool); [PASS] test_setDepthMaxPassesProposeDiesAtApply (gas: 311437); [PASS] test_depthK0ThenHugeDepthBlocksKRaise (gas: 650404); [PASS] test_genesisDepthUnboundedPanicsRisk (gas: 1361765)"
   }
  }
 ],
 "claims": [
  {
   "id": "C1",
   "result": "refuted",
   "evidence": "Another short row exists: house SET_DEPTH (GPA-1), accepted at propose, Panic 0x11 at apply, alone and in a BATCH. Fuzzed and holding (512 runs each): core SET_SAVINGS_SHARE, SET_UNBACKED_BRAKE, SET_EXOTIC_MARGIN, SET_CHAIN_LINE, SET_TARGET alone and in a BATCH (testFuzz_scalarDecodeAtApply); core SET_RISK over 1-4 consecutive applies with RISK_GRACE versioning (testFuzz_setRiskApplies); core SET_CAP x2 in a BATCH; house SET_CHAIN_LINE, SET_DEPTH_K, SET_OTHER_IMD (any lines <= 2^128-1, chop <= 1e18), SET_MAX_LULL, SET_TARGET, SET_GROUP, SET_GROUP_LINE, SET_RISK (any line/redeemCap) alone and in a BATCH: apply succeeds or reverts only DepthRuleFails (a state gate) (testFuzz_houseScalarDecodeAtApply); MinterHub every kind byte, 4 kinds pending at once, applied in fuzzed order: apply succeeds or reverts only BadConfig re-check (testFuzz_hubAnyKindAppliesIfProposed). Code-read (not run, external callees): core/house RETIRE_SLEEVE_TOKEN now decodes the apply tuple at propose (ParametersRules.sol core :86, house :116); its remaining apply-time failure is Backstop.retire's StillPriced (backstop/Backstop.sol:233-241, house :291-299), a state gate. house ADD_SLEEVE_ILK saleMax/saleSlope are unchecked but Backstop.addIlk (house Backstop.sol:248) does not check them either. ADD_DEPTH_SAMPLER uses ImdDepth.canAdd = addSampler's checks; SET_DEPTH_LEG repeats setLeg's checks; FeeNotes.open (peg/FeeNotes.sol:112) has no check beyond caller; SeatJoin.setLimits/setClaimRule (seats/SeatJoin.sol:202,210) none. Treasury and house Treasury decode (address,address,uint256) identically in _validate and _apply (Treasury.sol, house/Treasury.sol:213-219): no kinds."
  },
  {
   "id": "C2",
   "result": "refuted",
   "evidence": "Same kind twice in a BATCH is NOT refused: _kindsOf only ORs bits (ParametersBase.sol:265, house :365) and _validate has no duplicate check (ParametersRules.sol:96-105). test_batchSameKindTwiceAccepted: BATCH[SET_SAVINGS_SHARE 0.15e18, SET_SAVINGS_SHARE 0.2e18] proposes and applies (PASS). No bound escapes through it: every item is first validated against the pre-batch state (ParametersRules.sol:98-101), so testFuzz_batchSameKindTwiceSavingsStep (share stays within pre-batch +- MAX_SAVINGS_STEP) and testFuzz_batchSameKindTwiceCap (cap <= max(2 x pre-batch cap, live low)) hold over 512 runs each. The nested part holds: a BATCH item of kind BATCH reverts UnknownKind (ParametersRules.sol:100, house :130), and a retired kind nested is refused (testFuzz_retiredKindsRefused, testFuzz_houseRefusedKinds). The claim's wording should be 'accepted, each item bounded against the pre-batch state'."
  },
  {
   "id": "C3",
   "result": "holds",
   "evidence": "forge inspect storageLayout: core Parameters and ParametersRules both 22 entries, identical (label, slot, offset, type) hash 75c1133cc6bb; house both 35 entries, identical hash c674ba3841a4 (both inherit ParametersBase; Parameters adds only the immutable `rules`). Ledger/LedgerSettlement (core and house) both `is LedgerBase` and declare no state variable of their own (grep of non-constant, non-immutable declarations: 0 in each file); not compiled here (repo test/unit/AuditD1Layout.t.sol covers it, not run)."
  },
  {
   "id": "C4",
   "result": "holds",
   "evidence": "One invariant per GovernedByKind contract (Parameters core/house, MinterHub): for every payload p and state S, propose(p) succeeds in S => in S, a rolled-back run of _validateAtApply(p); _apply(p) reverts only with an error from the contract's declared state-gate list (core: StillPriced via Backstop.retire, BadConfig/OutOfBounds re-checks; house: + DepthRuleFails; hub: BadConfig), never Panic, empty revert or decode failure. Treasury (Governed): propose(p) => abi.decode(p,(address,address,uint256)) succeeds (holds by construction). Smallest replacement design: run the existing checkBatch dry run for EVERY proposal (a single proposal = a 1-item batch) and classify an item's failure by its revert data: Panic(uint256), empty or ABI-decode reverts refuse at propose; only listed state-gate selectors count as 'waiting'. Under this design GPA-1 is refused at propose. The fuzz tests listed under C1 are this invariant per contract; it fails only for GPA-1."
  }
 ],
 "holds": [
  {
   "property": "P1 (decode at apply) for core Parameters, MinterHub, Treasury, house Treasury",
   "tried": "Core: abi.decode tuples identical in _validate and _apply for every live kind (ParametersRules.sol _validate :35, _apply :148); fuzz testFuzz_scalarDecodeAtApply, testFuzz_setRiskApplies, testFuzz_batchSameKindTwice* (512 runs, alone and BATCH, warps of 48 h + 0-9 days). Hub: testFuzz_hubAnyKindAppliesIfProposed (512 runs, 4 kinds pending, fuzzed apply order, 3 rows incl. exotic and a marked row). Treasuries: one tuple in both. House P1 fails only for SET_DEPTH (GPA-1)."
  },
  {
   "property": "P2 retired kinds refused at propose, alone and in a BATCH",
   "tried": "Core: testFuzz_retiredKindsRefused, every kind byte outside {1,2,4,5,8,11,17,19,21,22,26,27,28} (covers 3,6,7,9,10,12-16,18,20,23-25 and 29-255) refused alone and as item 2 of a BATCH (512 runs). House: testFuzz_houseRefusedKinds, 3,6,7,4,14,19 and 29-255 revert UnknownKind alone and in a BATCH (512 runs). Hub: testFuzz_hubUnknownKindsRefused, every kind outside 0x00-0x03, 0x10, 0x20-0x6F refused (512 runs). Note: house 9,10,12,13,15,16,18,20,23,24,25 are live house kinds, not retired."
  },
  {
   "property": "P3 no overflow in _apply for accepted values (core Parameters, MinterHub, Treasuries)",
   "tried": "Core: SET_CHAIN_LINE uint128 cast after <= MAX_CHAIN_LINE; SET_RISK _bindAt/_pushVersion uint64 casts of bounded mat/chop/timestamps (fuzzed); hub: _uncover clamps amount to covered (MinterHub.sol:575 and the clamp in _apply's RELEASE_COVERED branch), LOWER_MARK --marks only after mark < s.mark > 0 re-checked at apply, RELEASE_RESERVE amount <= reserve re-checked against min(reserveLow, balance); fuzzed. House: SET_OTHER_IMD bounded (lines <= 2^128-1, chop <= 1e18) holds under fuzz; fails only for SET_DEPTH (GPA-1)."
  }
 ],
 "notRun": [
  "No [fork]/[data] claims in this sheet: none RAN, none needed.",
  "forge 1.9 / --use solar / solc 0.8.38 runs NOT RUN (not installed); all tests ran on a pragma-0.8.26 copy (see forge).",
  "Ledger/LedgerSettlement layout and repo test/unit/AuditD1Layout.t.sol NOT RUN (reasoned from inheritance).",
  "Backstop, FeeNotes, SeatJoin, ImdDepth, ImdUSD.setBridge apply-side checks reasoned from code, not run against the real contracts (mocks only).",
  "Earlier submissions (api.imd.fun) NOT fetched; ids 5937da4b-..., d9aa6add-... from the sheet not checked."
 ],
 "observations": [
  "MinterHub SET_RESERVE_RULE (kind 0x02) is only decoded at propose (MinterHub.sol:446-447); the apply can leave exoticCap above exoticFloor + reserve x reserveMultiple, the rule RELEASE_RESERVE enforces (MinterHub.sol:452). A Safe choice (ACCEPTED within its rules), no test run; outside this item's decode/overflow properties.",
  "README:1256 ('A 3-word `RETIRE_SLEEVE_TOKEN` payload passes `propose` and fails at apply') no longer matches the code: _validate now decodes the full apply tuple (README:176 says so); the only apply-time failure left is Backstop.retire StillPriced, a state gate."
 ]
}