-
Notifications
You must be signed in to change notification settings - Fork 3.8k
DAWN-47 ⁃ Prevent Access to Tables not Specified in ABI #642
Comments
➤ Kevin Heifner commented: This is in review. If it meets Dan's expectations it can be closed. |
➤ Kevin Heifner commented: I will review these changes for merge. Note the 1 story point is only for the review. |
➤ Joshua Lavin commented: [~kevin.heifner] [~corey.lederer] [~admin]] [~thomas.cox] Not clear on the QA for this issue (and others). Who will be writing the test cases for these issues? I had thought this would be with the developer responsible for fixing the issue? Just want to make sure we're not doubling our efforts. |
➤ Kevin Heifner commented: Unit tests were created as part of the development. All other additional testing, I understood was to be performed by HK. |
➤ Bezwada Satyapravin commented: If I understand correctly, validating this JIRA requires us to implement a test contract that performs actions mentioned in Acceptance Criteria and execute the contract. Please let me know if that is not the case. |
➤ Kevin Heifner commented: That is correct. Unittests that perform similar operations as the ATC have been created and are part of the build. You can see the tests by looking at the diff for this issue: |
➤ Andrianto Lie commented: I have written sample contracts to verify these 5 cases and assures that they are all working based on the ATC. |
➤ Andrianto Lie commented: The sample contracts behaves differently when we tested it on the testnet by the way.
However, I suspect it not to be the problem with the code but because the testnet doesn't have the latest version. |
➤ Kevin Heifner commented: From the line numbers in the previous comment, I can tell this is from the previous week build. This code is NOT the latest from master. |
Sync'd the issue back to JIRA and closing. |
(Replaces github issue #331)
Dan:
verify the table type matches
verify that a table name can only be used for a single index
verify that the ABI definition doesn't define multiple tables with the same name
These checks can be skipped during replay
Brian:
verify that the ABI definition doesn't define multiple tables with the same name
Already done by setcode call to AbiSerializer ctor, which calls setabi, which compares size of AbiSerializer map of tables to Abi vector of tables.
Brian:
@bytemaster
"verify the table type matches"
There are 2 ways I can see this being done. It could be checked in the store/read_*** wasm_interface intrinsic methods, but this would be a lot of wasted checks, since each wasm store/read only needs to be verified once.
So I am thinking that this needs to be done in the load, and the ModuleInstance analyzed.
"verify that a table name can only be used for a single index"
This really should be "verify that every code's table name can only be used for a single index", right? And then doesn't the fact that we verify that the ABI definition doesn't define multiple tables with the same name and that we "verify that the table type matches" already ensure this?
Also, I am presuming these are only performed if an ABI is provided, are there any checks we want to perform if there is no ABI? Like ensure that table reads and writes are consistent with each other?
Would think that this information has to be available in the processed WASM structure, but having a hard time identifying it. If it isn't we could identify it as we process the WASM.
Brian:
@bytemaster
Needs Clarification:
I am presuming the intent of this is safety (ensuring table access is consistent with ABI), not security, is that correct?
The statement about "these checks can be skipped during replay" sounds like these checks were planned to occur every time the code runs, but this seems to be a cost that shouldn't have to be incurred every time the code runs, vs. either using data in the existing loaded WASM structure (if it is possible) or else added to the WASM structure processing. If I don't get clarification on this I will plan to do the checks as the code is run, since that comment seems to assume this.
If the ABI is not provided, should a "lazy" ABI table definition be constructed as the code is run through, to ensure a table only has one type? Until I hear otherwise, I will assume the answer to this question is "yes".
For "verify that a table name can only be used for a single index", I will not do anything on this till I get clarification on exactly what it means.
Brian:
"verify the table type matches"
Assuming this means that the indextype matches, since that is available in the code, but actually identifying the type involved would require parsing the wast.
Working on tests.
ATC (Acceptance Test Criteria)
#1
#2
#3
#4
#5
The text was updated successfully, but these errors were encountered: