ClockLend — Round-14 Internal Audit Report

2026-09-29 · Round-14 internal AI-assisted audit · Program ID: 4Dp2A6SHQHEpuoMT4GuzZnnpLcDYrJnpELm1UjuNHgv7 (Solana Mainnet-beta)
STRONG
Program Security — no unprivileged theft path found
D+
Mobile Security — remediation in progress
NOT READY
Ops Readiness
FALSE
ready_for_mainnet — at audit time
How to read this report. These are internal, AI-assisted audit rounds performed by the ClockLend team's own agents and reviewed by the team. No third-party audit firm has been engaged and no external audit has been performed. The grades above are the round-14 findings as recorded at audit time; entries marked "Fixed in source, awaiting redeploy" are not yet on chain. Verify every deployment claim yourself against the on-chain addresses below.

Deployment & on-chain verification

The program is deployed and its bytecode is hash-verifiable. Reproduce the hash with: fetch the ProgramData account, slice data[45 .. 45 + <local ELF size>] (offset 45 skips the BPF upgradeable metadata header), and compare to sha256sum program/target/deploy/clock_lend.so.

FieldValueHow to verify
Program ID4Dp2A6SHQHEpuoMT4GuzZnnpLcDYrJnpELm1UjuNHgv7Solscan
ClusterSolana Mainnet-beta (genesis 5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d)getGenesisHash
ProgramData9ikmDTbbRhtgYKjRhcnzCK9RpPWQ8uTYUeNJ16kWMLSGsolana program show
Allocated bytes357,517 (ELF is 357,472; the remainder is retained zero padding)ProgramData account length
Deploy slot451,589,196ProgramData slot field
Upgrade authority8YvdDpWVAxpuyDHw3tpUheq99vgtakFELdqezykYosdsProgramData authority field
Bytecode sha256019da88bc97498b127ddbaa76468ff8ad86c5094ae46045f7f9a9127b3c1dbdbMatches the local build artifact
Upgradeable?Yes — the deployer key can replace the programProgramData Option flag = 1

Note the last row: the program is upgradeable, not immutable. A "fully trustless, immutable contract" is not what is deployed today. The upgrade authority is a single team-held key; it is not a multisig and is not timelocked.

Historical record. Everything from here down is the per-round log as written at the time. Details describe the state at that round, not today — most notably the Pyth pull-oracle integration, which was removed entirely in round 11 in favour of admin price feeds, and the per-round test counts (which differ from the current 103). Read the round-14 section above for present status.

Round-8 regression check — all present

FixStatusEvidence
let-bound unpack (AccountBorrowFailed)PRESENTprocessor.rs:868-881, 2330-2334
oracle-omit bypass closedPRESENTprocessor.rs:1300-1316
admin-feed decimals cross-checkPRESENTprocessor.rs:1319-1322 + P2P twin
InitializePool USDC allowlistPRESENTprocessor.rs:436-437
hex32! length assertPRESENTpyth.rs:50-60
Mobile: quorum-aware Pyth attach, blockhash ordering, exact-amount reads, raw-string fields, honest statePRESENTverified at each site by the mobile agent

Critical findings

CRITICAL C-1

Share inflation: cached total_staked_skr + unstake that never decrements = one stake drains the dividend pool

program/src/processor.rs:3582-3588 (claim sync) · 725-815 (unstake) · 3596-3607 (no-profile branch)

vault.total_staked_skr is only ever mutated inside process_claim_skr_yield, from profile.staked_skr + locked_skr. process_unstake_skr returns the SKR to the user and never touches the yield vault, and the claim path's no-profile branch keeps earning on the cached position.staked_skr. Exploit: stake X → ClaimSkrYield (registers X shares) → UnstakeSKR (SKR back, shares remain) → repeat with N fresh accounts re-staking the same X → N·X shares against X real escrowed SKR. On the next dividend the attacker's positions claim ~all of it (payout is first-come, capped by the vault token balance); honest stakers receive 0 and their accrued_rewards is silently written off. Cost to the attacker: transaction fees only.

Derive stake from the real SKR escrow token account balance (spl_token::state::Account::unpack(&skr_escrow...)) instead of the cached counter — or at minimum decrement vault.total_staked_skr in process_unstake_skr (and the ClaimDefault slash path) and make the profile account mandatory on the claim path.
✔ VERIFIED — claim sync reads the profile counter; unstake grep-shows zero yield-vault references; no-profile branch re-earns cached stake
CRITICAL C-2

InitializeSkrYieldVault is permissionless AND has no is_initialized guard — anyone can zero the vault and strand all rewards

program/src/processor.rs:3355-3399

create_or_allocate_pda returns Ok when the account is already program-owned, and there is no is_initialized read anywhere in the handler — so a second call unconditionally packs a fresh zeroed vault: acc_reward_per_share = 0, total_staked_skr = 0, pending_rewards = 0, authority = caller. The PDA is derived from reward_mint only, so any wallet can call it. Consequences: every user's stored reward_debt now exceeds staked·acc/1e12 → all accrued rewards compute to 0 (stranded), and with total_staked_skr == 0 all subsequent deposits stop updating acc → permanently unclaimable dividends. This is repeatable sabotage, and it also lets anyone race the team for first-call ownership of the vault (the authority field is currently read nowhere, but any future consumer inherits the hole).

Unpack first and bail: if existing.is_initialized { return Err(...) }, and gate first init on the AdminConfig admin (same pattern as WithdrawTreasury).
✔ VERIFIED — no is_initialized check; zeroed struct packed unconditionally; no admin/authority check in the handler
CRITICAL C-3

Deploy script ships a stale artifact — today's deploy would silently omit round-8 hardening AND the yield feature

mobile/scripts/deploy-mainnet.mjs:106-109 · program/target/deploy/clock_lend.so

The script's only check is fs.existsSync(soPath) — it never builds and never compares freshness. The artifact on disk (300,104 bytes, md5 189a61df, mtime 2026-09-23 09:30) predates both the round-8 commit (09:46) and the yield sources — all five program/src/*.rs files are newer. Running the runbook command today write-buffers and upgrades that old ELF, prints "MAINNET BOOTSTRAP COMPLETE", and ships a program without the Pyth Full-verification hardening, the ±staleness bounds, the allowlists, or the yield feature.

Preflight: run cargo build-sbf (or hard-fail without --skip-build); fail if any program/src/** file or program/Cargo.lock is newer than the .so; print md5 + size before upload.
✔ VERIFIED — mtimes and md5 checked; all five source files newer than the artifact

High findings

HIGH H-1

The yield feature is inert in the shipped client — and the deployed program can't run it anyway

mobile/src/solana/onChainService.ts:1954 · program/src/instruction.rs:210-240

buildClaimSkrYieldTx has zero callers; there are no buildInitializeSkrYieldVaultTx / buildDepositSkrYieldTx builders at all; no UI screen wires it; and buildBorrowTx never appends the two yield-vault PDAs, so the program's 50/50 origination-fee split never fires from the app — the vault can never be funded in production. The deployed program (devnet) predates tags 15–17, so a claim would revert with invalid-instruction-data even if wired. ✔ VERIFIED — grep: zero callers

Either ship it (add the two missing builders, append the vault PDAs in buildBorrowTx gated on vault-is-initialized, add UI gated on an on-chain CLK_SYLD read) or cut the dead code until the upgrade lands. Don't ship a live-looking claim path against an un-upgraded program.
HIGH H-2

No time weighting / cooldown — JIT front-running snipes origination-fee dividends

program/src/processor.rs:3467-3475, 3644

Accrual is purely by acc_reward_per_share snapshot; last_interaction_time is recorded but never enforced. Both deposit triggers (permissionless DepositSkrYield and the borrow-path fee split) are observable before they land, so an attacker can stake in slot N, register shares, let the dividend land in N+1, claim pro-rata, and unstake in N+2 — capital returned, zero holding risk, disproportionate payout. ✔ VERIFIED in source — no time check on the claim path

Time-weighted accrual (per-slot reward_rate with last_acc_update), or a minimum stake age before claimability.
HIGH H-3

DepositSkrYield is permissionless and the reward mint is unrestricted at init

program/src/processor.rs:3417, 3342

Only assert_signer — no vault-authority/treasury/admin check, so anyone can push rewards at any time and thereby control exactly when acc moves (who gets entitled), or interleave dust deposits to shift rounding. Init accepts any reward_mint pubkey. ✔ VERIFIED in source

Gate deposits on vault.authority (with a rotation path proving upgrade authority), allowlist reward_mint to {USDC devnet/mainnet, SKR}. If the drip is meant to be permissionless, add epoch pacing so it can't control accrual timing.
HIGH H-4

SOL collateral sizing always uses a hardcoded $150.0 — the live-price lookup can never match

mobile/src/components/P2PExpressView.tsx:43

solHolding = tokenList.find(symbol === 'SOL') is always undefined — tokenList comes from getParsedTokenAccountsByOwner, which never contains native SOL — so 150.0 is always used. That flows into the on-chain collateral amount: the tx reverts InvalidCollateralRatio when the price is above market and silently over-locks when below. Two hardcoded SOL prices coexist (150.0 here, 101.12 in livePrices). ✔ VERIFIED

Use livePrices.sol (already fetched every 120s); disable the borrow CTA with "price unavailable" when stale rather than substituting a constant.
HIGH H-5

Runbook devnet hash is unreproducible — its own verify recipe reports a false mismatch

docs/MAINNET_RUNBOOK.md:5

Live devnet ProgramData holds a 299,937-byte ELF (md5 69577ae6…); the local artifact is 300,104 bytes (189a61df) and the ELFs differ at e_entry — different builds. The runbook recipe yields 1c4ac89d for live devnet vs 189a61df locally — a false mismatch — and no 600fba4a prefix is reproducible from anything on this box. The field churns each round (9bbcdc68 → 25b68ef2 → 600fba4a) without a recorded recipe. ✔ VERIFIED via live RPC by the ops agent

Record the exact recipe + inputs; add a verify-devnet.sh that computes it; state which build the deployed ELF actually is.
HIGH H-6

The multi-user yield test is flaky — "96/96 passing" is not reproducible

program/tests/skr_yield_and_lst_tests.rs:572, 581

Observed ~30–50% failure rate across agents (4/12 for one, multiple runs for another), always left: 0 at :572/:581; also reproduces in isolation. An instrumented verbatim copy passed 3/3, so the mechanism is inconclusive — non-deterministic solana-program-test behavior, not a proven program error. Either way, cargo test is not a trustworthy deploy gate today. ✔ OBSERVED by two independent agents

Give each submission a distinct blockhash and assert on returned results/program state rather than later reads; require ≥20 consecutive green runs before treating the gate as real.
HIGH H-7

Dividends deposited while total_staked_skr == 0 are permanently stranded

program/src/processor.rs:3467 (deposit), 1588 (borrow split)

Both allocation sites skip acc_reward_per_share when total_staked_skr == 0 but still credit pending_rewards — and claims pay only staked · acc / 1e12, which never includes that money. The first dividend (e.g. keeper deposits before any user syncs) is lost forever. On devnet this is 100% of routed revenue, because the SKR mint doesn't exist there. ✔ VERIFIED in source

Add an unallocated_rewards field rolled into the next acc increase, or reject deposits while total_staked_skr == 0.

Mediums

Lows

Clean areas (verified)

Proposed fix rounds

P0: C-1 escrow-derived stake (or decrement on unstake) · C-2 reinit guard + admin gate · C-3 build-sbf/freshness preflight · H-7 unallocated-rewards carry · H-2/H-3 deposit auth + time-weighting decision.
P1: H-1 wire the feature or cut it · H-4 live price · H-5 verify recipe · H-6 deterministic test · M-1..M-8.
P2: lows + runbook yield section + doc comments.
Product decisions needed from the user: ship the yield feature or cut it for now; rebuild the artifact before any deploy.

Round-9 fix round — APPLIED (2026-09-24)

All P0/P1/P2 fixes from this report are implemented and verified. C-1: claim stake is now escrow-authoritative (skr_escrow account required, accrual bounded by the real balance, UnstakeSKR syncs positions down). C-2: vault init is admin-gated and reinit-rejected. C-3: the deploy script builds the ELF itself and hard-fails on a stale artifact (fresh build: 339,928 bytes, md5 308dbba1, not yet deployed). H-2/H-3/H-7: 1h claim cooldown (error 40), authority-gated deposits, unallocated_rewards folding so pre-stake dividends are never stranded. Mobile: yield client fully wired (init/deposit/claim builders, borrow fee-split append, unstake sync, on-chain-gated yield card), live prices replace the hardcoded $150, honest banners, strict collateral parsing, cache namespacing. Tests: 97/97, yield suite 6/6 consecutive runs green (flakiness root-caused: identical-(blockhash,message) memoization — every submission now advances a slot). Details: .superstack/build-context.md.

Round-10 fix round — APPLIED & VERIFIED (2026-09-25)

All P0 and P1 fixes implemented and verified across program, client, and scripts (101/101 tests green):

Round-11 zero-day hunt (2026-09-25) — 6 highs, all PoC-verified

Adversarial cross-instruction hunt on the full contract + client. Invariant verdicts: conservation HOLDS (every lamport/token flow sums exactly, error paths included), auth matrix HOLDS (no aliasing/role-confusion path found), state machine violated in 2 places, oracle violated in 3. New highs: a borrower-supplied Pyth account overrides the pool's mandatory custom feed (2 independent PoCs — borrow ~77x the configured limit); the 1h cooldown is a payout-delay only (unstake harvests and frees capital in the same slot — the zero-risk snipe survives); the Pyth attach signs before the body instructions are appended (invalid signature once Hermes is enabled); the borrow UI hardcodes 7 days while offering 3/7/14/30; the devnet-smoke script inherits the MAINNET RPC from .env; and the Wormhole anchor is wrong (receiver Config.wormhole = 4uQeVzbXX…, proven via the SDK struct layout — HDwc and worm2 are both wrong, and the atomic posting path is unviable on mainnet). Fuzzer permanently extended with yield ops + 3 share/dividend invariants (9 seeds green). Full list + fixes: .superstack/build-context.md (round-11 section).

Round-13 reaudit (2026-09-26) — critical ABI regression found & fixed

Post-round-12 verification found a critical introduced by the rescue instruction: inserting WithdrawUnusedYield before ClaimSkrYield shifted the borsh discriminants (Withdraw=17, Claim=18) while the mobile client still sends tag 17 — every dividend claim dispatched to the rescue handler and reverted. Fixed by reordering (Claim=17, Withdraw=18) and pinned forever by test_wire_tags_are_pinned (asserts the byte encoding of all 19 variants). Also fixed: Pyth receiver removed from the signing allowlist, the local order's 7-day hardcode, the missing stake-builder yield appends (round-10's share registration now fires from the app), builder network params, modal live prices, cooldown error 38, the rescue builder, and full runbook alignment incl. a 10-minute keeper workflow. 100/100 tests.

Round-14 fresh-eyes audit (2026-09-29) — findings and current status

An independent, fresh-eyes pass over the deployed program produced the grades at the top of this page. Program security came back strong: no path was found by which an unprivileged account can steal funds. Three executable proof-of-concept bugs were found, and the ops tooling was judged not ready. Statuses below are current as of the date on this page — "Fixed in source, awaiting redeploy" means the fix is committed but is NOT yet in the on-chain bytecode.

IDSeverityAreaFindingStatus
POC-1 High Yield / fee routing When the SKR yield-vault leg of the origination-fee split cannot pay (accounts present but unusable), the fee could be partially stranded instead of routing in full to the treasury. Fixed in source, awaiting redeploy
POC-2 High P2P pawns CreateP2POffer did not default the loan asset to the canonical mainnet USDC mint when no mint account was appended, letting a mainnet funder be handed an unfundable offer. Fixed in source, awaiting redeploy
POC-3 High Oracle-free pools On oracle-free pools the borrower could price collateral above the hardcoded baseline using a live feed, rather than being capped at min(baseline, live). Fixed in source, awaiting redeploy
OPS-1 Critical (ops) Keeper automation Price-feed automation was not reliable. At the time of writing both mainnet feeds are stale well past the 600s on-chain pricing limit (observed age ≈ 14,100s), so borrow and liquidation paths that read them revert. The Keeper workflow had also been pointed at a devnet RPC while using the mainnet program id, so it had never cranked a mainnet feed. Open
OPS-2 High (ops) Key separation Operator scripts allowed dangerous defaults: a burn path could burn more than it bought, an oracle rotation could silently fall back to a default local key path, and treasury withdrawal could default its destination to the admin hot wallet. Mitigated in tooling; keys not yet rotated
OPS-3 High (ops) Treasury state The treasury PDA (5buCUcCHHDCzQpanMKCK8uruErL5D2UzSFVrbtPrKV7y) has no account on chain at audit time — only its USDC ATA exists, with a 0 balance. No protocol fee has ever been collected, and fee-bearing instructions would fail until it is initialized. Open
MOB-1 Medium Mobile client Mobile security graded D+ at audit time (hardcoded prices, fabricated yield/LST banners, inconsistent collateral parsing, cache namespacing gaps). Remediation in progress

Test suite

The on-chain test suite is counted directly from the source rather than asserted: grep -c '#\[test\]\|#\[tokio::test\]' program/tests/*.rs sums to 103 test functions across bank_integration, functional, security_tests, fuzz_invariants, skr_yield_and_lst_tests and the round-14 zz_round14_poc regression file. A green count is a regression signal, not a security proof — the three POC items above were found with that suite green.

What has NOT been done

Per-round internal history: .superstack/build-context.md. Deployment facts on this page were captured live from mainnet-beta RPC on 2026-09-29.