Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

endure that direct bracket accesses are always safe (eg. buffer[i+3:] will panic if i is too big) #4556

Closed
Tracked by #4415
Leo-Besancon opened this issue Nov 22, 2023 · 20 comments · Fixed by #4560
Closed
Tracked by #4415
Assignees

Comments

@Leo-Besancon
Copy link
Contributor

No description provided.

@Leo-Besancon Leo-Besancon changed the title endure that direct bracket accesses are always safe (eg. buffer[i+3:] will panic if i is too big) @damip endure that direct bracket accesses are always safe (eg. buffer[i+3:] will panic if i is too big) Nov 22, 2023
@sydhds sydhds linked a pull request Nov 24, 2023 that will close this issue
@sydhds
Copy link
Contributor

sydhds commented Nov 24, 2023

Massa models

slot.rs

  • L.109 & 112: FIXED (use nom take)
  • L.153 &155: Ok (Len checked)
  • L.209: Array indexing with index 0 for &[u8; 32]
  • L.242,243: Ok (Array indexing with constant)
  • L.259,260: Ok (Array indexing with constant)

datastore.rs

  • line 158: get_prefix_bounds TODO TODO
  • line 187 & 188 & 210: N/A (Unit tests)

denunciation.rs

L.964: FIXED - no more indexing

block.rs

L.155,258,274,284: N/A (doctest)
L.389,390: commented code (impl Signable for BlockHeader)
L.644,706,813,872,948,1003,1102: N/A (unit tests)

block_header.rs

L.178,338,351,361: N/A (doctest)
L.400: N/A (tag(&[0]))
L.402: N/A (tag(&[1]))
L.462: FIXED (use nom take)
L.636,642,645,664: N/A (unit tests)

clique.rs

L.163,164: Not array indexing

block_id.rs

L.70: Array indexing with index 0 for &[u8; 32]

version.rs

L.221,222,223,232,235: Array indexing but length previously checked

operation.rs

L.261,270: Ok (Slicing &[u8; 32] with slice(0, 17))
L.1188: Ok (Len previously checks, should return empty &[u8])
L.1190: Ok (Len previously checks)
L.1446: N/A (Array type)
L.1565: N/A (vec! declaration)

serialization.rs

L.38,48: Ok (leading_zeros skip)
L.76, 95: Ok(length checked)
L.115: Ok (length checked)
L.127: Ok (length checked)
L.203,211: N/A (tag[XX])
L.656,665: Ok (length checked)
L.724,747,750: N/A (unit tests)

ledger.rs

L.265: Not array indexing

address.rs

L.343: Array indexing with index 0 for &[u8; 32]

@sydhds
Copy link
Contributor

sydhds commented Nov 27, 2023

Massa async pool

pool.rs

L.375: Ok (length checked)
L.439: Ok (length checked)

@sydhds
Copy link
Contributor

sydhds commented Nov 27, 2023

Massa bootstrap

lib.rs

L.93: Ok (length checked)

bindings/client.rs

L.210: Ok (type length in function argument type)

bindings/server.rs

L.301, 312: TODO (Should we check for leader_buf size?, expect ?)

bindings.rs

L.35: Ok (length checked)
L.92: Ok (length checked)

@sydhds
Copy link
Contributor

sydhds commented Nov 27, 2023

Massa consensus exports

export_active_block.rs

L.152, 168, 178, : N/A (doctest)
L.228, 230, 248: Ok (nom tag)

controller_trait.rs

L.38: Ok (function argument type)

@sydhds
Copy link
Contributor

sydhds commented Nov 27, 2023

Massa consensus worker

controller.rs

L.87: Ok (function argument type)

state/prune.rs

L.130: Ok (closure for_each index)

state/graph.rs

L.111: Ok (assume max_cliques len always >= 1)
L.118, 122, 123, 125, 206, 224, 225, 238: Ok (sort closure with previous length)

state/blocks_state.rs

L.131: Ok (vec definition)

state/clique_computation.rs

Not checked

state/process.rs

L.513: Ok (as long as self.compute_fitness_find_blockclique returns an ok index)
L.535: Ok (position_blockclique already used L.513)

@sydhds
Copy link
Contributor

sydhds commented Nov 27, 2023

Massa db worker

massa_db.rs

L.653, 654, 657: Ok (length checked)
L.1094, 1096, 1098, ...: N/A (unit tests)

@sydhds
Copy link
Contributor

sydhds commented Nov 27, 2023

Massa executed ops

ops_changes.rs

L.141, 144: N/A (unit tests)

executed_denunciations.rs

L.286: N/A (unit tests)

executed_ops.rs

L.75: Ok (function argument type)
L.314, ...: N/A (unit tests)

@sydhds
Copy link
Contributor

sydhds commented Nov 27, 2023

Massa execution exports

event_sore.rs

L.126, ...: N/A (unit tests)

controller_traits.rs

L56, 66, 105: Ok (function argument type)

@sydhds
Copy link
Contributor

sydhds commented Nov 27, 2023

Massa execution worker

controller.rs

L.231, 249, : Ok (array creation)
L.351, 434, 471: Ok (function argument type)

interface_impl.rs

L.153: Ok (function argument type)
L.282: Ok (vec! declaration)
L.908: Ok (length checked)
L.932: Ok (length 65 expected by parse_slice, length 32 returned by digest)
L.951, 954: Ok (length checked)
L.1382: Ok (vec! init)
L.2036, ...: N/A (unit tests)

execution.rs

L.658, 697, 755, 805, 868, 874, 955, 961: Ok (vec! init)
L.1850: Ok (function argument type)

speculative_roll_state.rs

L.511: Ok (index returned by find_cycle_indices)

active_history.rs

L.327: Ok (function argument type)

@sydhds
Copy link
Contributor

sydhds commented Nov 27, 2023

Massa hash

hash_xof.rs

L.154, 155: Ok (length checked)

hash.rs

L.251, 252: Ok (length checked)

@sydhds
Copy link
Contributor

sydhds commented Nov 27, 2023

Massa ledger exports

types.rs

L.75, 77, 81, 84: FIXED (with nom take)
L.218, 220, 223: FIXED (with nom take)
L.302, 304, 307: FIXED (with nom take)

@sydhds
Copy link
Contributor

sydhds commented Nov 27, 2023

Massa ledger worker

ledger_db.rs

L.548: N/A (docstring)

@sydhds
Copy link
Contributor

sydhds commented Nov 27, 2023

Massa module cache

L.25, 33: Ok (macro called on Massa hash, len = 32 bytes)

@sydhds
Copy link
Contributor

sydhds commented Nov 27, 2023

Massa node

operation_injector.rs

N/A (testing tool)

@sydhds
Copy link
Contributor

sydhds commented Nov 27, 2023

Massa protocol worker

./handlers/operation_handler/retrieval.rs

L.173, 174, 176, 177: N/A (Code commented)

./handlers/peer_handler/messages.rs

L.241: Ok (length checked)

handlers/peer_handler/mod.rs

L.445: Ok (length defined as const on L.444)

@sydhds
Copy link
Contributor

sydhds commented Nov 27, 2023

Massa serialization

L.505, ...: N/A (unit tests)

@sydhds
Copy link
Contributor

sydhds commented Nov 27, 2023

Massa signature

signature_impl.rs

L.302, 711, 1055: Ok (length checked)
L.1241: Ok (length checked)

@sydhds
Copy link
Contributor

sydhds commented Nov 27, 2023

Nothing to check

  • massa-api: N/A
  • massa-api-exports: N/A
  • massa-channel: N/A
  • massa-cipher: N/A
  • massa-db-exports: N/A
  • massa-factory-exports: N/A
  • massa-factory-worker: N/A
  • massa-final-state: N/A
  • massa-grpc: N/A
  • massa-logging: N/A
  • massa-metrics: N/A
  • massa-pool-exports: N/A
  • massa-pool-worker: N/A
  • massa-protocol-exports: N/A
  • massa-sdk: N/A
  • massa-storage: N/A
  • massa-time: N/A
  • massa-wallet: N/A

NOT CHECKED

  • massa-client
  • massa-xtasks

@Leo-Besancon
Copy link
Contributor Author

Very comprehensive checks, thanks a lot! Not closing for now in case there are still some things to fix, but the main PR #4560 is merged!

@sydhds
Copy link
Contributor

sydhds commented Jan 11, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants