←
Ahmed26 posts
Ahmed avatar

Ahmed

@4hm8d

Security researcher | Immunefi | NEAR / DeFi lending

◷ Joined February 2014▧ 6 Photos and videos
Ahmed avatar
Ahmed@4hm8d·Nov 17

On May 13, I reported a Critical bug (Report 77956) to @TemplarProtocol (deployed on @NEARProtocol blockchain): two withdrawal-queue flaws that could permanently freeze supplied funds, including ~$1.50M of @StellarOrg USDC in a market with zero access keys. Over 6 months: • $1.44M moved out of that keyless pool • 22 keyed markets (~$15.40M supply) were patched • @Immunefi ruled Critical ($100,000 cap) • Templar offered $3,000, conditioned on my permanent silence. Technical post-mortem 🧵👇 #immunefitribe #NEARProtocol

Post attachment
Ahmed avatar
Ahmed@4hm8d·Nov 17

With 22 keyed markets (~$15.40M) updated and its unescrowed Immunefi program ended, @TemplarProtocol launched Precept (institutional lending) on @StellarOrg on Nov 10. One day later (Nov 11), after letting my $60,000 settlement offer expire, it offered $3,000 conditioned on permanent silence. I declined. ⚠️ Supplier note: Keyless ixlm-ixlmusdc.v1.tmplr.near (59.1k USDC active; 40.5k available) and izec-isolusdc.v1.tmplr.near (250 USDC active; 4.33 USDC available) cannot be patched. Do not add liquidity; check active amounts, limits, and execution-time liquidity before withdrawing. Full write-up, Mediation PDF & 22-market evidence ledger: 4hm8d.github.io/templar-prot… #NEARProtocol #Stellar

Ahmed avatar
Ahmed@4hm8d·Nov 17

On Oct 22, 2026, @Immunefi Mediation rejected Griefing, Certora L-05, and Sybil, ruling Report 77956: Critical: Permanent freezing of funds ($100,000 cap). Hoping to resolve 6 months of work cooperatively, I offered a 40% reduction ($60,000), which went unanswered through its Nov 8 deadline. On Nov 11, @RoyalF00l sent a final offer of $3,000: "If you publicly disclose this on Monday or in the future, we will not pay anything. If you don't publicly disclose it, we'll pay you the $3k as a thank you."

Post attachment
Ahmed avatar
Ahmed@4hm8d·Nov 17

Git commit history refuted the Certora L-05 duplicate claim: • Certora's manual review (a96e44d) closed Sep 19, 2025, when the queue processed 1 withdrawal per call with no batch_limit and no EmptyPosition branch. • PR #264 (ac072f1f) introduced the batch loop and EmptyPosition 40 days later on Oct 29, 2025. • Templar's own PR #659 (dbfcd42b) left withdrawal minimums untouched, counted visited entries + scaled 01_finalize gas (6 + 3 * batch.len() TGas), and documented both defects in withdrawal_queue_bounds.rs.

Ahmed avatar
Ahmed@4hm8d·Nov 17

While 96% of the keyless market's supplied USDC moved in July, triage on @Immunefi stayed stalled: • Jul 2: Immunefi paused Templar's BBP for unresponsiveness • Aug 7: Immunefi removed Templar's BBP for repeated SLA breaches • Sep 15: Templar edited SECURITY.md stating its Immunefi program had ended Then on Oct 7-8, five days after confirming the NEP-509 proof cap, Templar used its retained FullAccess keys to deploy v1.6.0-labeled bytecode across 22 keyed markets (~$15.40M supply). 9 hours after the 22nd deploy settled, Templar offered $2,500 and claimed Report 77956 failed under Certora L-05 and Sybil exclusions.

Post attachment
Ahmed avatar
Ahmed@4hm8d·Nov 17

Why was this Critical (Permanent Freeze) instead of temporary delay? ixlm-ixlmusdc.v1.tmplr.near (native @StellarOrg XLM collateral / Stellar USDC borrow via NEAR Intents, holding ~$1.50M) deleted its sole FullAccess key on Jan 19 (tx 5PPCjn58…). Zero keys, zero admin or pause methods. • Jun 8: Templar's migration map marked ixlm-ixlmusdc -> TBD. • Jul 8: I emailed @RoyalF00l warning the keyless pool faced an unrecoverable freeze. He replied 15 mins later: "We are still swamped." • Jul 14-27: Keyed ixlm-ixlmusdc-1 deployed, the map updated, and $1,441,627 USDC (96% of supply, from a wallet gas-funded via templarllc.near -> simrat.near) moved out. #Stellar #XLM

Post attachment
Ahmed avatar
Ahmed@4hm8d·Nov 17

Four months in, Templar raised an objection: NEAR Protocol 83 (nearcore 2.11.0) had lifted max prepaid gas from 300 TGas to 1,000 TGas. 1,000 TGas still could not drain the queue, because of NEAR's NEP-509 storage-proof cap. NEP-509 caps recorded trie storage proof at 4,000,000 bytes (4.0 MB) per receipt. On a Sept 30 mainnet fork of keyless ixlm-ixlmusdc.v1.tmplr.near (block 202,648,000) with all 1,000 TGas attached, execution aborted at 734.8 TGas and rolled back every pop(). Templar confirmed the mechanism on Oct 2.

Post attachment
Ahmed avatar
Ahmed@4hm8d·Nov 17

How can zero-balance ghosts brick the FIFO withdrawal queue? 1) create_supply_withdrawal_request checks Deposit::total(), which sums active + outgoing, letting any ghost re-enter the queue. 2) When an honest supplier or keeper calls execute_next_supply_withdrawal_request(Some(1)), each ghost scores WithdrawalAttempt::EmptyPosition: the while loop calls withdrawal_queue.pop() without incrementing batch.len(). batch.len() stays 0, forcing one receipt to walk the entire ghost wall.

Post attachment
Ahmed avatar
Ahmed@4hm8d·Nov 17

Unlike EVM, a .then() callback on NEAR executes in a separate receipt. If it runs out of gas, parent state writes and completed token transfers do NOT roll back. In Templar v1.2.0-v1.3.0, execute_next_supply_withdrawal_request moved active supply to outgoing, sent outbound token transfers, and gave 01_finalize a fixed 8 TGas budget even though callback work grew linearly with batch size. Push 01_finalize out of gas and two things happen: 1. Outbound transfers still return 100% of principal to the withdrawing accounts (reusable across batches) 2. Positions remain stranded as zero-balance "ghosts": active = 0, outgoing > 0.