DSS 2026 / Day 1 / Pearl Hall
Beyond the EVM: What Auditing NEAR Taught Me About Ecosystem-Specific Security
Nemveer
Source: YouTube automatic caption track · Exported 2026-11-16. Timestamps link to the source video. Cue end times were not supplied.
Transcript
0:00Nice.
0:01So, yeah, I'm Nambir. I'm a security
0:04researcher at Sartora.
0:06Earlier this year, we had audited a
0:08lending protocol on the near block
0:10chain.
0:11And we found several issues there. And
0:13some of those issue had nothing to do
0:16with the
0:17near chain.
0:19Some of those issues had nothing to do
0:21with the landing logic. It came from the
0:23chain itself. It came
0:26because of not considering all the
0:28scenarios unable by the execution model
0:30of the chain.
0:31So today I will be showing
0:33a couple of such example and what it
0:36taught me about the things that we take
0:39for granted. What it taught me about the
0:41assumptions that we may bring from the
0:44past chain we had audited to the new
0:47chain and which not might always hold
0:49there.
0:50So let's get started. Let's first look
0:52at the simplest borrow function. This is
0:55something that we have all seen. We have
0:57all audited simple borrow function three
0:59line.
1:01Check the limit, pay the borrower and
1:03update the debt. Limit is the something
1:05that the collateral allows the users to
1:08borrow.
1:09Looks pretty simple, right? Check, pay
1:12and update the debt.
1:14What could go wrong here?
1:17My question is
1:18can anything run between these two
1:20lines?
1:21I'm not talking about the re-entrancy.
1:23Just assume for the sake of this that
1:24the token contract is safe.
1:27Can anything run between these two line
1:29in this and in that case?
1:33Well, most of us are right that on the
1:35Ethereum nothing can run between the two
1:37lines because one transaction, one block
1:40and it's done.
1:42But on the near the answer is yes. And
1:46that gap essentially enabled several
1:49attack vectors that caused some findings
1:51to this protocol.
1:53So
1:54let's
1:56in order to understand that let's first
1:58see that how these three
2:00are modeled for the near. Please
2:02remember this three lines and we will
2:04see that how this are actually executed
2:06on the near.
2:07So near is a shaded blockchain.
2:09Everything runs in shard. One shard
2:11doesn't share any knowledge with the
2:12other shards. So the cross contract call
2:15your contract is making might actually
2:17live on the other shards.
2:19So calling another contract doesn't
2:21always happen right away.
2:24It's async. One transaction can actually
2:27span across multiple blocks. So if in
2:30our example
2:32uh
2:33after checking the limit the lending
2:35contract actually asked the token
2:37contract
2:39to pay the borrower.
2:41But the lending contract ends right
2:43there.
2:44The check is done.
2:46The request to transfer is sent. All of
2:48it is saved and that is block N.
2:51Each of these boxes are called receipt
2:53and inside a particular receipt
2:56everything is atomic.
2:58Then in a later block the transfer would
3:00attempt to pay the borrower. It might
3:02work. It might fail and then in a later
3:05block
3:07if the transfer was successful the
3:08callback would come back to the lending
3:10contract and the debt would be updated.
3:12So
3:14one borrow transaction spanned across
3:16three multiple blocks.
3:18Inside a particular receipt everything
3:20is atomic but across the receipt
3:22not at all.
3:25Whatever the state changes that has been
3:27saved by block N
3:29stays saved even if the later transfer
3:32fails.
3:33And this is not something uh
3:36this is not the case with the Ethereum
3:37or the any other chain we know because
3:40one transaction, one block and it's
3:43done. But in the near it is possible.
3:47And also
3:48uh
3:49the interesting thing is that
3:52anyone can come while the transfer is in
3:54the air and call any functionality of
3:57the lending protocol
3:59even while the first borrow transaction
4:01is not completed fully.
4:04So this is also the interesting thing,
4:06and let's keep this mind, and let's see
4:09our first example.
4:11Let's meet Sam.
4:13Sam has provided 100 collateral
4:16to the lending protocol with the
4:18with the collateral factor of the 80% he
4:21is allowed to borrow 80. He puts forward
4:23a request to borrow 80, so the check
4:25would be 0 + 80, and it it it's well
4:28below the limit, and the check passes.
4:30So the lending contract asks the token
4:32contract to please pay Sam.
4:35But
4:37while the transfer is in the air, and
4:39while the callback hasn't executed yet
4:42and the debt is not updated, Sam comes
4:45again and asks
4:46the lending contract for the 80 again.
4:50So my question is what debt does the
4:52second request see?
4:55The answer is zero
4:57because the first request callback
5:00hasn't executed yet, the debt is not
5:02updated.
5:04So the second request check would also
5:06pass. The two transaction two transfer
5:09goes through, two callbacks would come
5:11back. The first would write 80, the
5:13second would write 160, and the Sam has
5:15essentially borrowed 160 against the
5:17collateral of 100.
5:19And that's a bad debt.
5:21So
5:23pretty interesting, but
5:25how to fix it? And the solution is again
5:27very simple that we we
5:30we should count the seat when the ticket
5:32is sold and not while the passenger on
5:34boards. So the moment Sam requests a
5:36transfer, we have to reserve that
5:39amount. So our updated check would be
5:41existing debt plus the newly
5:45the reserved in air and the new amount
5:47requested, and that should be below the
5:49limit. So with this updated check, when
5:51Sam comes with his second request, our
5:53check would be 80 + 80, which is 160,
5:56which is above the limit, and his second
5:58request would be refused, and we are
6:00saved from the issues. So this
6:03this issue was about the timing the same
6:06made two consecutive request to bypass
6:08the limit. Now let's see one another
6:10interesting
6:12scenario
6:13that is enabled by the near execution
6:15model.
6:16In order to understand that let's first
6:20know how what is the storage rule on the
6:22near. On near blockchain the user have
6:25to pay for the storage that they are
6:26going to use. So for example if I want
6:29to hold a token
6:31I need to register in the token
6:33contract. I need to pay for it. It's
6:35it's like a bank that if I don't have a
6:38bank account in a particular bank no one
6:40would be able to transfer me money in
6:42that bank. So for example consider Dario
6:46he is everything right in the landing
6:48contract. There's a plenty of cap. There
6:50is no debt. Collateral is enough but and
6:53he wants to borrow 80 of the borrow
6:55asset but it doesn't have any
6:58token account in the borrow asset.
7:01So is is his borrow request would be
7:03refused because it doesn't have an
7:05account there.
7:07This is not something that we always
7:09think on the Ethereum because we always
7:11assume that the ERC 20 transfer to any
7:13address would always be successful
7:15because on Ethereum
7:17every address has account on every bank.
7:20So this is except it is a contract and
7:23we have a revert in the receive
7:24function.
7:27But on the near it is very much possible
7:29to refuse the transfer to ourselves.
7:33But why would someone do that? Why would
7:34someone make a transfer to himself
7:37revert?
7:39Let's let's understand that with the
7:40example.
7:42So for example as I said Dario has
7:44everything right in the landing
7:45contract. He wants to borrow 80 and the
7:48check easily passes
7:50but the landing contract does very
7:52sensible thing here. He puts aside a 80
7:56in order to not promise the same amount
7:58to some other user.
8:00So the free liquidity would be 20 if the
8:04initial free liquidity is 100 and if we
8:07are promising 80 to the Dario
8:10the fee would be 20.
8:12So as I said, the chat passes and the
8:15lending contract asks the token contract
8:17to pay to the Dario, but while that
8:20transfer is in the air
8:22Maya comes to the lending contract. Maya
8:24is a legit user. He asks the token
8:26contract to to please borrow borrow me
8:2930. But since the contract is only 20,
8:32Maya's request would be refused. And
8:34when the transfer tries to execute
8:37Dario's transfer,
8:39it would fail as well because Dario
8:41doesn't have any account on the token
8:44contract. So Maya's request is refused.
8:47Dario's request is refused as well.
8:50So Dario
8:52could do it repeatedly.
8:54Dario could essentially
8:58consume
9:00the pool's liquidity with nothing but
9:02the gas.
9:04Dario can
9:05DOS any legit user from borrowing. He
9:08could prevent all the suppliers for from
9:10earning
9:11any yield.
9:13And what's the cost to the Dario? Just
9:16the gas.
9:17So let's see how how to fix this.
9:20Again, the fix is very simple. The
9:22moment the request was initiated, we
9:25charge
9:27we we start charging interest from the
9:30block and only. So even if the later
9:32transfer fails,
9:35the Dario has to
9:36pay interest for the amount of time the
9:39transfer was in the air. So if the Dario
9:43now wants to DOS the other user and the
9:45lending protocol, he would not only have
9:47to pay the gas but also the interest.
9:50So
9:51if you notice, there were two things
9:53that needed to be seen here. The
9:56the first was the storage rule on the
9:59near and also the call model on the
10:01near. Those those two things combined
10:04enabled this attack. So let's just
10:07let's just bring everything together and
10:10again ask our
10:12question, our assumptions. That three
10:14lines were same, but the guarantee it
10:17provides differs across the chain.
10:20I earlier I never used to check those
10:23assumptions because I always used to
10:24believe that nothing runs between my
10:26lines. The transfer fails and everything
10:29before it automatically undoes because
10:31the revert takes the whole transaction
10:32downs with it and a transfer to a user
10:35who has an account would always be
10:36successful. And all of these hold true
10:39on the Ethereum. But let's see what
10:41about Solana.
10:42On Solana first two holds, but third
10:45doesn't hold because you need to have a
10:47token account on the token program.
10:50And on near
10:52none of these holds.
10:54So under questioning our assumptions and
10:57learning about the ecosystem is always
11:00beneficial because knowing the language
11:03you could just read the code, but
11:05knowing the chain would find the bug. So
11:07with this new learning
11:10I always
11:12try to question my assumptions. I always
11:14try to spend first few hours learning
11:16the ecosystem
11:18and doing some of these steps that draw
11:21one full function call, ask who controls
11:24each step and taste the weight.
11:26So yeah,
11:29please understand the ecosystem you are
11:31auditing. It would be
11:33it would tell you where to look for the
11:35bugs. And yeah, at last
11:38again that's my question. Can anything
11:40learn between line two and three?
11:43And it really depends on on which chain
11:47you are standing.
11:49So yeah, that was my time.
11:52Thank you so much for the listening.
Source and accuracy details
- Names, organizations, technical terms, code and numbers may be misrecognized.
- Source wording and disfluencies are preserved; no editorial corrections were applied.
- Export contains whole-second cue starts only; cue ends and subsecond timing are unavailable.
- A full caption-track export does not establish that every spoken word is represented.
- Automatic YouTube captions; not human-verified against the audio.
Source export SHA256: 6643fe823de81853d6bdf3dc89b360a6bc7efcc61c0aedb6e7ceaf6776ce405d