Vana
Data Access

The new Data Access System components were in scope: data refinement, the query engine, and the compute engine.
report id
0451-0503
category
Infra & Wallets
language
Solidity
final report
April 24, 2025
lines of code
1403
Content

Download audit report

1

Executive Summary

This document presents the security review conducted by Nethermind Security for Vana's Data Access contracts. The audit specifically focused on pull request #14, which introduces the three major components of the Data Access System: data refinement, query engine, and compute engine.

The audit comprised of 1403 lines of solidity code and was performed using (a) manual analysis of the codebase, (b) automated analysis tools, and (c) creation of test cases.

Audit assessment
Audit TypeSecurity Review
Initial ReportApril 11, 2025
Final ReportApril 24, 2025
Repositoriesvana-smart-contracts
Initial Commitb3045f9
Final Commit967896b
DocumentationProvided pull request #14 documentation
Documentation AssessmentMedium
Test Suite AssessmentMedium
Total findings
9
Fixed
8
Acknowledged
1
Mitigated
0
Unresolved
0

Findings by severity

  • Critical0
  • High0
  • Medium0
  • Low0
  • Informational2
  • Best Practices7

4

System Overview

4.1 Data Refinement

Vana's Data refinement process ascertains the security standards and verifiable quality of the ingested datasets before storage. The refinement process steps include data normalization to ensure the data is structured according to the on-chain schema, masking, which hides any information DLP owners do not want to provide access to, and encryption to prevent unauthorized access. The key contract components in Vana's Data refinement process include the DataRegistry, which adds refinements into data files, and the DataRefinerRegistry, which manages refiners that can be used to generate data refinements.

struct Refiner {
uint256 dlpId;
address owner;
string name;
string schemaDefinitionUrl;
string refinementInstructionUrl;
string publicKey;

struct ProofData {
uint256 score;
uint256 dlpId;
string metadata;
string proofUrl;
string instruction;
}

4.2 Query Engine

Vana's Query Engine handles query payments for data access and manages access and permissions to refined data. The Query Engine is only accessible through the Compute Engine via Compute Engine Jobs. Data requestors submit registered jobs to the Compute Engine with a query scoped to the authorized dataset. The Query Engine access control structure ensures only authorized data requestors can query refined data.

 struct Permission {
address grantee;
bool approved;
uint256 refinerId;
string tableName;
string columnName;
uint256 price;
}

struct PermissionInfo {
uint256 permissionId;
address grantee;
bool approved;
uint256 refinerId;
string tableName;
string columnName;
uint256 price;
}

4.3 Compute Engine

Vana's Compute Engine ensures safe operations on encrypted data through running containerized jobs and acts as a gateway to the Query Engine. The Compute Engine jobs are designed to be reusable and produce artifacts that are available for a defined period before expiration.

Additionally, the Compute Engine handles user deposits for data access and processes payment requests from the Query Engine.

struct PaymentInfo {
address payer;
mapping(address token => uint256 amount) paidAmounts;
}

4.4 Vana Data Access Protocol Diagram

The below diagram highlights various contract components and their interactions in Vana's Data Access Module.

Diagram from the audit report

5

Risk Rating Methodology

The risk rating methodology used by Nethermind Security follows the principles established by the OWASP Foundation. The severity of each finding is determined by two factors: Likelihood and Impact.

Likelihood measures how likely the finding is to be uncovered and exploited by an attacker. This factor will be one of the following values:

  1. High: the issue is trivial to exploit and has no specific conditions that need to be met;
  2. Medium: the issue is moderately complex and may have some conditions that need to be met;
  3. Low: the issue is very complex and requires very specific conditions to be met.

When defining the likelihood of a finding, other factors are also considered. These can include but are not limited to motive, opportunity, exploit accessibility, ease of discovery, and ease of exploit.

Impact is a measure of the damage that may be caused if an attacker exploits the finding. This factor will be one of the following values:

  1. High: the issue can cause significant damage, such as loss of funds or the protocol entering an unrecoverable state;
  2. Medium: the issue can cause moderate damage, such as impacts that only affect a small group of users or only a particular part of the protocol;
  3. Low: the issue can cause little to no damage, such as bugs that are easily recoverable or cause unexpected interactions that cause minor inconveniences.

When defining the impact of a finding, other factors are also considered. These can include but are not limited to data and state integrity, loss of availability, financial loss, and reputation damage. After defining the likelihood and impact of an issue, the severity is determined according to the table below.

Impact / LikelihoodLowMediumHigh
HighMediumHighCritical
MediumLowMediumHigh
LowInfo / Best PracticesLowMedium
UndeterminedUndeterminedUndeterminedUndetermined

To address issues that do not fit a High, Medium or Low severity, Nethermind Security also uses three more finding severities: Informational, Best Practices, and Undetermined.

  1. Informational findings do not pose any risk to the application, but they carry some information that the audit team intends to pass to the client formally;
  2. Best Practice findings are used when some piece of code does not conform with smart contract development best practices;
  3. Undetermined findings are used when we cannot predict the impact or likelihood of the issue.

6

Issues

6.1 Improper access control management of Refiner when DLP Ownership is transferred

FileFix commitTypeStatus
DataRefinerRegistryImplementation.solPR #14InfoFixed

In addRefiner(...) function, the owner is set to the current owner of the dlpId, but if the owner is transferred then Refiner will still correspond to the old owner. This is an issue given functions addPermission(...) and updatePermissionApproval from the Query Engine uses the owner field of the Refiner struct.

Recommendation

Consider updating Refiner ownership whenever there is a DLP ownership transfer. This behavior should also be properly documented and communicated to DLP owners.

6.2 Native token can be lost when depositing an ERC20 token

FileFix commitTypeStatus
ComputeEngineImplementation.solPR #14InfoFixed

In the deposit(...) function of the ComputeEngineImplementation contract, it is possible to deposit with a nonzero msg.value given the function is marked payable while using an ERC20 token. In that case, the contract accepts native asset funds, but the deposit will be registered under the token. As a result, the function will attempt to transfer that token from the user to itself and then to the treasury, which would be double paying. The native asset is not tracked in this case and can be lost.

Recommendation

Consider adding a check if the token is VANA, then the msg.value must be zero.

6.3 Inconsistent casting of maxTimeout

FileFix commitTypeStatus
ComputeEngineImplementation.solPR #14Best PracticesFixed

In the internal _registerJob (...) the passed parameter maxTimeout is of type uint256. However, in functions submitJob(...) and submitJobWithTee(...) where _registerJob(...) is called, the maxTimeout is passed as a uint80 data type. For consistency, the project should consider changing the maxTimeout type in _registerJob(...) to a uint80 and avoid silent casting.

Recommendation

Consider skipping the iteration for duplicate accounts to avoid double counting.

6.4 Owner address existence check can be optimized to save gas

FileFix commitTypeStatus
ComputeEngineImplementation.solPR #14Best PracticesFixed

In _registerJob() function, the instructions registry is queried just to check the owner's address as seen below:

function _registerJob(
uint256 maxTimeout,
bool gpuRequired,
uint256 computeInstructionId
) internal whenNotPaused returns (uint256 jobId) {
IComputeInstructionRegistry.ComputeInstructionInfo memory computeInstruction = instructionRegistry.instructions(
computeInstructionId
);
........
.......

This can be optimized further by adding a simple existence check directly in the instruction registry.

Recommendation

Consider directly adding a simple existence check in the instruction registry to optimize the code and save gas.

6.5 Inaccurate error emission

FileFix commitTypeStatus
ComputeEngineImplementation.solPR #14Best PracticesFixed

When updating job status via updateJobStatus(...) function, the contract checks the current job status if it is completed or Failed. If this is true, JobAlreadyDoneOrCanceled() error is emitted. The same inconsistency exists in cancelJob(...) function where the error of canceling a job is JobAlreadyDoneOrCanceled() but the code logic covers done, canceled and failed cases. Similarly, in _resubmitJobWithTee (...) the error message JobAlreadyDoneOrCanceled() would be incorrect if job.status is Submitted.

Recommendation

Consider ensuring consistent error emission with code logic.

6.6 Manual Initialization of TeePoolFactory could cause transaction revert when attempting bulk update

FileFix commitTypeStatus
ComputeEngineTeePoolFactoryImplementation.solPR #14Best PracticesFixed

After the TeePool is deployed via the beacon proxy, the user with maintainer role must manually set the teepoolFactory address without which, maxTimeout updates would fail. This could cause reverts when attempting to bulk update.

function updateTeePoolProxyFactory(
ComputeEngineTeePoolProxyFactory newTeePoolProxyFactory
) external override onlyRole(MAINTAINER_ROLE) {
teePoolProxyFactory = newTeePoolProxyFactory;
}

Recommendation

Consider setting the teepoolFactory address when initializing the contract.

6.7 The owner privileges can be permanently lost when updating contract custodian role

FileFix commitTypeStatus
DataAccessTreasuryImplementation.solPR #14Best PracticesFixed

When updating the contract custodian, there is no check to ensure the newCustodian is not the owner's address.

function updateCustodian(address newCustodian) external override onlyRole(DEFAULT_ADMIN_ROLE) {
_revokeRole(DEFAULT_ADMIN_ROLE, custodian);
custodian = newCustodian;
_grantRole(DEFAULT_ADMIN_ROLE, newCustodian);
}

Without this check, it is possible to set the custodian as the owner's address, effectively leaving the contract with only one custodian. If the custodian is changed again, the owner could lose privileges permanently.

Recommendation

Consider adding a check preventing the contract owner from becoming the contract's custodian.

6.8 Inconsistent key to value pair in _jobPayments mapping

FileFix commitTypeStatus
ComputeEngineStorageV1.solPR #14Best PracticesFixed

In ComputeEngineStorageV1 contract, the mapping _jobPayments has a mapping key provider seen as mapping(uint256 jobId => mapping(address provider => PaymentInfo paymentInfo)) internal _jobPayments;. However, the implementation logic in _executePaymentRequestFromQueryEngine (...) uses the token address as the key for this slot and then a token address again within a mapping from the resulting struct.

function _executePaymentRequestFromQueryEngine(address token, uint256 amount, bytes calldata metadata) internal {
...........
...........
PaymentInfo storage paymentInfo = _jobPayments[jobId][token];
paymentInfo.paidAmounts[token] += amount;
paymentInfo.payer = jobOwner;

emit PaymentExecuted(jobId, token, amount);

computeEngineTreasury.transfer(msg.sender, token, amount);
}

A token is not a provider. This inconsistency should be addressed by changing the provider to another mapping key.

Recommendation

Consider updating the provider to another key in the mapping.

6.9 Inconsistent code logic with code comments

FileFix commitTypeStatus
DataRegistryImplementation.sol—Best PracticesAcknowledged

In DataRegistryImplementation contract, the code comments within addRefinementWithPermission(...) permission states: "The permission for an account is not allowed to be changed once set".

function addRefinementWithPermission(
uint256 fileId,
uint256 refinerId,
string calldata url,
address account,
string calldata key) external override whenNotPaused onlyRole(REFINEMENT_SERVICE_ROLE) {

...........
...........
// @dev Add permission for the account to access the refinement.
// The permission for an account is not allowed to be changed once set,
// to prevent previous refinements from being inaccessible.
if (bytes(_file.permissions[account]).length == 0) {
_file.permissions[account] = key;
emit PermissionGranted(fileId, account);
}
}

However, the addFilePermission (...) function allows the account's permission to be updated.

Recommendation

Consider either updating the code logic, reflecting the code comments, or updating the code comments to reflect the code logic.

Resolution

This is acknowledged.

7

Documentation Evaluation

Software documentation refers to the written or visual information that describes the functionality, architecture, design, and implementation of software. It provides a comprehensive overview of the software system and helps users, developers, and stakeholders understand how the software works, how to use it, and how to maintain it. Software documentation can take different forms, such as user manuals, system manuals, technical specifications, requirements documents, design documents, and code comments. Software documentation is critical in software development, enabling effective communication between developers, testers, users, and other stakeholders. It helps to ensure that everyone involved in the development process has a shared understanding of the software system and its functionality. Moreover, software documentation can improve software maintenance by providing a clear and complete understanding of the software system, making it easier for developers to maintain, modify, and update the software over time. Smart contracts can use various types of software documentation. Some of the most common types include:

  • Technical whitepaper: A technical whitepaper is a comprehensive document describing the smart contract’s design and technical details. It includes information about the purpose of the contract, its architecture, its components, and how they interact with each other;
  • User manual: A user manual is a document that provides information about how to use the smart contract. It includes step-by-step instructions on how to perform various tasks and explains the different features and functionalities of the contract;
  • Code documentation: Code documentation is a document that provides details about the code of the smart contract. It includes information about the functions, variables, and classes used in the code, as well as explanations of how they work;
  • API documentation: API documentation is a document that provides information about the API (Application Programming Interface) of the smart contract. It includes details about the methods, parameters, and responses that can be used to interact with the contract;
  • Testing documentation: Testing documentation is a document that provides information about how the smart contract was tested. It includes details about the test cases that were used, the results of the tests, and any issues that were identified during testing;
  • Audit documentation: Audit documentation includes reports, notes, and other materials related to the security audit of the smart contract. This type of documentation is critical in ensuring that the smart contract is secure and free from vulnerabilities.

These types of documentation are essential for smart contract development and maintenance. They help ensure that the contract is properly designed, implemented, and tested, and they provide a reference for developers who need to modify or maintain the contract in the future.

8

Remarks & Test Suite

The Vana team has provided a comprehensive walkthrough of the project as well as documentation highlighting the pull request changes. Moreover, the team addressed all questions and concerns raised by the Nethermind Security team, providing valuable insights and a comprehensive understanding of the project's technical aspects.

All the relevant issues raised by the AuditAgent have been incorporated into this report. The AuditAgent is an AI-powered smart contract auditing tool that analyses code, detects vulnerabilities, and provides actionable fixes. It accelerates the security analysis process, complementing human expertise with advanced AI models to deliver efficient and comprehensive smart contract audits. Available at https://app.auditagent.nethermind.io.

Test suite
112Tests passed0Failed

The complete test output is in the full report.

As auditors, we recommend that any changes or updates made to the audited codebase undergo a re-audit or security review to address potential vulnerabilities or risks introduced by the modifications. By conducting a re-audit or security review of the modified codebase, you can significantly enhance the overall security of your system and reduce the likelihood of exploitation. However, we do not possess the authority or right to impose obligations or restrictions on our clients regarding codebase updates, modifications, or subsequent audits. Accordingly, the decision to seek a re-audit or security review lies solely with you.

This report is based on the scope of materials and documentation provided by you to Nethermind in order that Nethermind could conduct the security review outlined in 1. Executive Summary and 2. Audited Files. The results set out in this report may not be complete nor inclusive of all vulnerabilities. Nethermind has provided the review and this report on an as-is, where-is, and as-available basis. You agree that your access and/or use, including but not limited to any associated services, products, protocols, platforms, content, and materials, will be at your sole risk. Blockchain technology remains under development and is subject to unknown risks and flaws. The review does not extend to the compiler layer, or any other areas beyond the programming language, or other programming aspects that could present security risks. This report does not indicate the endorsement of any particular project or team, nor guarantee its security. No third party should rely on this report in any way, including for the purpose of making any decisions to buy or sell a product, service or any other asset. To the fullest extent permitted by law, Nethermind disclaims any liability in connection with this report, its content, and any related services and products and your use thereof, including, without limitation, the implied warranties of merchantability, fitness for a particular purpose, and non-infringement. Nethermind does not warrant, endorse, guarantee, or assume responsibility for any product or service advertised or offered by a third party through the product, any open source or third-party software, code, libraries, materials, or information linked to, called by, referenced by or accessible through the report, its content, and the related services and products, any hyperlinked websites, any websites or mobile applications appearing on any advertising, and Nethermind will not be a party to or in any way be responsible for monitoring any transaction between you and any third-party providers of products or services. As with the purchase or use of a product or service through any medium or in any environment, you should use your best judgment and exercise caution where appropriate. FOR AVOIDANCE OF DOUBT, THE REPORT, ITS CONTENT, ACCESS, AND/OR USAGE THEREOF, INCLUDING ANY ASSOCIATED SERVICES OR MATERIALS, SHALL NOT BE CONSIDERED OR RELIED UPON AS ANY FORM OF FINANCIAL, INVESTMENT, TAX, LEGAL, REGULATORY, OR OTHER ADVICE.