Work & reportsReport

NEAR / Defuse LabsNEAR Intents Security Review

View PDF on GitHub
NEAR / Defuse Labs logo
All findings
4
Critical
0
High
0
Medium
1
Low
1
Informational
2

Date of engagement: 12th February 2025 - 5th March 2025

Timur GüvenkayaMichal Bajor

Security review by

Timur Guvenkaya, Michal Bajor

Meet the team

About Us

Guvenkaya is a security research firm specializing in Rust security, Web3 security of Non-EVM protocols, and Web2 security. With our expertise, we provide both security auditing services and custom security solutions

About Aurora

Aurora is a Virtual Chain built on NEAR. It’s, at the same time, the sandbox and the proof of the robustness of the parent protocol. It’s a smart contract - probably the most complex that exists - that is also an Ethereum Virtual Machine, providing a turn-key solution for developers to operate their apps on an Ethereum-compatible, high-throughput, scalable and future-safe platform, with low transaction costs.

Audit Results

Guvenkaya conducted a security assessment of the NEAR Intents from 12th February 2025 to 5th March 2025. NEAR Intents are a new type of transaction that allow information, requests, assets, and actions to be exchanged between AI agents, services, and end users. During this engagement, a total of 4 findings were reported. 1 of the findings was medium and the remaining were either low or informational severity. The Aurora team has not fixed the issues yet.

Project Scope

FilesLink
Engine Modhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/core/src/engine/mod.rs
Engine Inspectorhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/core/src/engine/inspector.rs
State Modhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/core/src/engine/state/mod.rs
State Cachedhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/core/src/engine/state/cached.rs
State Deltashttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/core/src/engine/state/deltas.rs
Errorhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/core/src/error.rs
Eventshttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/core/src/events.rs
Feeshttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/core/src/fees.rs
Intents Modhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/core/src/intents/mod.rs
Intent Accounthttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/core/src/intents/account.rs
Token Diffhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/core/src/intents/token_diff.rs
Tokens (Intents)https://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/core/src/intents/tokens.rs
Noncehttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/core/src/nonce.rs
Payload Modhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/core/src/payload/mod.rs
FilesLink
ERC191 Payloadhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/core/src/payload/erc191.rs
Multi Payloadhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/core/src/payload/multi.rs
NEP413 Payloadhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/core/src/payload/nep413.rs
Raw Payloadhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/core/src/payload/raw.rs
WebAuthn Payloadhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/core/src/payload/webauthn.rs
Tokens (Core)https://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/core/src/tokens.rs
Crypto Libhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/crypto/src/lib.rs
Curve Modhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/crypto/src/curve/mod.rs
ED25519https://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/crypto/src/curve/ed25519.rs
P256https://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/crypto/src/curve/p256.rs
Secp256k1https://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/crypto/src/curve/secp256k1.rs
Payload (Crypto)https://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/crypto/src/payload.rs
Public Keyhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/crypto/src/public_key.rs
Serde Modhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/crypto/src/serde/mod.rs
FilesLink
Serde Curvehttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/crypto/src/serde/curve.rs
Signaturehttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/crypto/src/signature.rs
Defuse Libhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/lib.rs
Accounts (Defuse)https://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/accounts.rs
Contract Modhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/contract/mod.rs
ABIhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/contract/abi.rs
Accounts Modhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/contract/accounts/mod.rs
Accounthttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/contract/accounts/account.rs
State (Accounts)https://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/contract/accounts/state.rs
Adminhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/contract/admin.rs
Confighttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/contract/config.rs
Events (Contract)https://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/contract/events.rs
Fees (Contract)https://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/contract/fees.rs
Intents Mod (Contract)https://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/contract/intents/mod.rs
FilesLink
Executehttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/contract/intents/execute.rs
Relayerhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/contract/intents/relayer.rs
Simulatehttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/contract/intents/simulate.rs
State (Intents)https://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/contract/intents/state.rs
State (Contract)https://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/contract/state.rs
Tokens Mod (Contract)https://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/contract/tokens/mod.rs
NEP141 Modhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/contract/tokens/nep141/mod.rs
NEP141 Deposithttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/contract/tokens/nep141/deposit.rs
NEP141 Nativehttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/contract/tokens/nep141/native.rs
NEP141 Withdrawhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/contract/tokens/nep141/withdraw.rs
NEP171 Modhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/contract/tokens/nep171/mod.rs
NEP171 Deposithttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/contract/tokens/nep171/deposit.rs
NEP171 Withdrawhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/contract/tokens/nep171/withdraw.rs
NEP245 Modhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/contract/tokens/nep245/mod.rs
FilesLink
NEP245 Corehttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/contract/tokens/nep245/core.rs
NEP245 Deposithttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/contract/tokens/nep245/deposit.rs
NEP245 Resolverhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/contract/tokens/nep245/resolver.rs
NEP245 Withdrawhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/contract/tokens/nep245/withdraw.rs
Upgradehttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/contract/upgrade.rs
Fees (Defuse)https://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/fees.rs
Intents (Defuse)https://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/intents.rs
Tokens Mod (Defuse)https://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/tokens/mod.rs
NEP141 (Defuse)https://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/tokens/nep141.rs
NEP171 (Defuse)https://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/tokens/nep171.rs
NEP245 (Defuse)https://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/defuse/src/tokens/nep245.rs
ERC191 Libhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/erc191/src/lib.rs
Map Utils Libhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/map-utils/src/lib.rs
BTree Maphttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/map-utils/src/btree_map.rs
FilesLink
Cleanuphttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/map-utils/src/cleanup.rs
Hash Maphttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/map-utils/src/hash_map.rs
Iterhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/map-utils/src/iter.rs
Near (Map Utils)https://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/map-utils/src/near.rs
Near Utils Libhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/near-utils/src/lib.rs
Cachehttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/near-utils/src/cache.rs
Gashttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/near-utils/src/gas.rs
Panichttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/near-utils/src/panic.rs
Prefixhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/near-utils/src/prefix.rs
NEP245 Libhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/nep245/src/lib.rs
Core (NEP245)https://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/nep245/src/core.rs
Events (NEP245)https://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/nep245/src/events.rs
Receiverhttps://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/nep245/src/receiver.rs
Resolver (NEP245)https://github.com/near/intents/blob/6da9e2b3ab598f277d45fb356aee01a5d80ac0a6/nep245/src/resolver.rs

Out of Scope

The audit will include reviewing the code for security vulnerabilities. The audit does not include a review of the tests and dependencies.

Timeline

  1. Start of the audit

    12th February 2025

  2. Draft report

    5th March 2025

Methodology

  • RESEARCH INTO PROJECT ARCHITECTURE
  • PREPARING ATTACK VECTORS
  • SETTING UP AN ENVIRONMENT
  • MANUAL CODE REVIEW OF THE CODE
  • ASSESSMENT OF RUST SECURITY ISSUES
  • ASSESSMENT OF NEAR SECURITY ISSUES
  • ASSESSMENT OF ARITHMETIC ISSUES
  • BUSINESS LOGIC VULNERABILITY ASSESSMENT
  • ONCHAIN TESTING USING NEAR WORKSPACES
  • BEST PRACTICES AND CODE QUALITY
  • CHECKING FOR CODE REFACTORING/SIMPLIFICATION POSSIBILITIES
  • ARCHITECTURE IMPROVEMENT SUGGESTIONS
  • PREPARING POCS AND/OR TESTS FOR EACH CRITICAL/HIGH/MEDIUM ISSUES

Severity Breakdown

Likelihood Ratings

Likely
The vulnerability is easily discoverable and not overly complex to exploit.
Possible
The vulnerability presents some challenges either in discovery or in the complexity of the attack.
Rare
The vulnerability is either very difficult to discover or complex to exploit, or both. This matrix provides a nuanced view, taking into account both the ease of discovering a vulnerability and the complexity involved in exploiting it.

Impact

Severe
The vulnerability is easily discoverable and not overly complex to exploit.
Moderate
The vulnerability presents some challenges either in discovery or in the complexity of the attack.
Negligible
The vulnerability is either very difficult to discover or complex to exploit, or both.

Severity Ratings

Critical
Assigned to vulnerabilities with severe impact and a likely likelihood of exploitation.
High
For vulnerabilities with either severe impact but only a possible likelihood, or moderate impact with a likely likelihood.
Medium
Used for vulnerabilities with severe impact but a rare likelihood, moderate impact with a possible likelihood, or negligible impact with a likely likelihood.
Low
For vulnerabilities with moderate impact and rare likelihood, or negligible impact with a possible likelihood.
Informational
The lowest severity rating, typically for vulnerabilities with negligible impact and a rare likelihood of exploitation.

Likelihood Matrix

Attack Complexity / Discovery EaseObviousConcealedHidden
ComplexPossibleRareRare
ModerateLikelyPossibleRare
StraightforwardLikelyPossiblePossible

Likelihood/Impact Matrix

Likelihood / ImpactSevereModerateNegligible
LikelyCriticalHighMedium
PossibleHighMediumLow
RareMediumLowInformational

Findings Summary

Remediation Complexity

This measures how difficult it is to fix the vulnerability once it has been identified.

Simple
Patches or fixes are readily available and easily implemented.
Moderate
Requires some time and resources to remediate, but well within the capabilities of most organizations.
Difficult
Remediation requires significant resources, specialized skills, or substantial changes to systems or architecture.

Status

This measures how difficult it is to fix the vulnerability once it has been identified.

Not Fixed
Indicates that the vulnerability has been identified but no remedial action has been taken yet. This status is crucial for newly discovered vulnerabilities or those awaiting prioritization.
Fixed
This status is applied when the vulnerability has been successfully remediated. It implies that appropriate measures (like patching, configuration changes, or architectural modifications) have been implemented to resolve the issue.
Acknowledged
This status is used for vulnerabilities that have been recognized, but for various reasons (such as risk acceptance, cost, or other business decisions), have not been fixed. It indicates that the risk posed by the vulnerability is known and has been consciously accepted.
Scheduled
This status indicates that the vulnerability has been acknowledged and a plan is in place to fix it in the future. It signifies that while remediation hasn't yet occurred, the issue has been prioritized and is part of the planned development roadmap.
FindingImpactLikelihoodSeverityRemediation complexityRemediation status
GUV-1: Potential Funds Stealing From Users Via Repeating Failed IntentsSevereRareMediumSimpleScheduled
GUV-2: Possible DoS Of Public Keys Viewing Per UserNegligiblePossibleLowSimpleNot Fixed
GUV-3: Arbitrary Public Key Setting In Privileged FunctionsNegligibleRareInformationalSimpleNot Fixed
GUV-4: Missing Event Emission For Critical Access Control OperationsNegligibleRareInformationalSimpleNot Fixed

Findings Details

GUV-1: Potential Funds Stealing From Users Via Repeating Failed Intents

Medium

Depending on the intent structure, it's possible to maliciously fail a transaction and then repeat specific intents, which could lead to:

Stealing tokens Making solvers lose money or perform unauthorized operations

Mainnet deadlines are permissive, ranging from 20 seconds to 10 minutes. This provides ample time to fail a transaction and repeat failed intents. A transaction can be failed by:

Invalidating the nonce after signing in a separate transaction. Adding an additional intent to your intent array that transfers funds out and fails your token diff

Malicious actor can:

Repeat selected intents. Repeat selected intents and, to maintain TokenDiff balance, resign your controlled intents with new values. Observe failed intents on the blockchain and reconstruct them like building blocks (while deadlines remain valid).

The risk is low when TokenDiff intent is used, as mainnet calculations are typically precise, making it difficult to modify the intent structure while maintaining zero delta and gaining benefits. The vulnerability is particularly dangerous in P2P transfer scenarios where TokenDiff intent isn't used, allowing for immediate exploitation with high success rates.

Impact:

Funds can be stolen in scenarios where TokenDiff intent isn't used.

Recommendation

This behavior should be documented to emphasize that TokenDiff is the preferred method, while Transfer should be discouraged for facilitating swaps. Users must understand they are responsible for reviewing and approving what they sign.

Remediation - Scheduled

The Aurora team has acknowledged the issue and will fix it soon by documenting this scenario.

View this finding in the original PDF

GUV-2: Possible DoS Of Public Keys Viewing Per User

Low

It was observed that since user can have unlimited public keys, it is possible for a malicious user to cause a DoS of public_keys_of method when their account is used. That’s because public_keys_of iterates over public keys of a provided account and if account has a lot of public keys it can lead to the error due to a gas limit.

defuse/src/contract/accounts/mod.rs

     fn public_keys_of(&self, account_id: &AccountId) -> HashSet<PublicKey> {
                self.accounts.get(account_id).map_or_else(
                    || {
                        PublicKey::from_implicit_account_id(account_id)
                         .into_iter()
                         .collect()
                    },
                  |account| account.iter_public_keys(account_id).collect(),
                )
              }

Impact:

Errors in off-chain components, which utilize public_keys_ofmethod. If iter_public_keys is utilized within the smart contract logic somewhere else, depending on a logic it can lead to the DoS on protocol level

Recommendation

It is recommended to limit the number of public keys each account can have

Remediation - Not Fixed

The Aurora team has not fixed the issue yet.

View this finding in the original PDF

GUV-3: Arbitrary Public Key Setting In Privileged Functions

Informational

The codebase accepts public keys in multiple locations without proper validation. The NEAR SDK's PublicKey type lacks comprehensive validation of public key formats and values. Malicious users could potentially inject invalid or malformed public keys, leading to undefined behavior in cryptographic operations.

PoC:

poc

       fn test_parse_zero_pubkey() {
              use near_sdk::PublicKey;
              let zero_pubkey_str = "ed25519:11111111111111111111111111111111";
              let result = zero_pubkey_str.parse::&lt;PublicKey&gt;();
              assert!(result.is_err());
              }

Impact:

Potential undefined behavior in cryptographic operations Potential injection of weak public keys that can lead to signature malleability

Recommendation

Implement comprehensive validation for public keys in all relevant functions.

Account Public Key Management (add_public_key, remove_public_key) Relayer Keys Management (do_add_relayer_key, delete_relayer_key) Full Access Keys Management (add_full_access_key, delete_key)

Remediation - Not Fixed

The Aurora team has not fixed the issue yet.

View this finding in the original PDF

GUV-4: Missing Event Emission For Critical Access Control Operations

Informational

The relayer keys operations lacks event emissions for access control operations in delete_relayer_key() and do_add_relayer_key() methods. This omission makes it difficult to track and audit changes to the relayer key set off-chain. Events are essential for maintaining transparency and allowing external systems to monitor and react to important state changes in the contract.

Recommendation

Implement event emissions for both adding and removing relayer keys

Remediation - Not Fixed

The Aurora team has not fixed the issue yet.

View this finding in the original PDF

Source: published GitHub report · 22 pages. The original PDF includes the source formatting, figures, and linked references.

Tell us what you need to secure.

Describe your system, main concern, and deadline. We will reply with scoping questions and a proposed next step.

Discuss your scope