Skip to content

fix: address potential panics, context leaks, and hash matching in oracle and txmonitor - #935

Open
Sahil-4555 wants to merge 4 commits into
primev:mainfrom
Sahil-4555:fix/security-auditor-pitfalls
Open

fix: address potential panics, context leaks, and hash matching in oracle and txmonitor#935
Sahil-4555 wants to merge 4 commits into
primev:mainfrom
Sahil-4555:fix/security-auditor-pitfalls

Conversation

@Sahil-4555

@Sahil-4555 Sahil-4555 commented Aug 13, 2026

Copy link
Copy Markdown

What are we repairing and for what reason?

  1. Gas Percentile Calculation (Protection From Division By Zero)

    • Problem: When calculating gas percentiles for position constraints, the node would crash with an unhandled panic of integer division by zero if a block or transaction had zero total gas (which can occur on testnets, custom rollups, or local emulators).
    • Fix: Added a quick zero check before division. If total gas is 0, it safely skips the constraint instead of crashing.
  2. Batch Receipt Error Logs (Nil Pointer Safety)

    • Problem: When a batch RPC request for a transaction receipt failed, the error logger tried to print the transaction hash directly from the receipt object. But because the receipt call failed, the receipt object itself was nil, causing a second nil-pointer panic that killed the service.
    • Fix: Added a null check on the receipt when handling errors. If the receipt is nil, it logs "unknown" for the hash instead of blowing up.
  3. Bid Options Evaluation (Fix Slice Aliasing & Memory Mutation)

    • Problem: When verifying positional constraints between bundle transactions, the code was changing the options array in-place with append(slice[:i], slice[i+1:]...). In Go, this mutates the underlying array memory inside the loop, causing constraint indices to shift mid-loop and skip or miscalculate remaining bid constraints.
    • Fix: Rebuilt the remaining options list into a new slice instead of mutating the original array memory in-place.
  4. Transaction Hash Prefixes Normalization (0x Matching)

    • Problem: Internal block transaction lookup maps store hashes without the 0x prefix, but incoming commitment events split hashes that included 0x. Because the string search failed, valid transactions did not pass the lookup check and were wrongly marked as missing—resulting in valid commitments being erroneously slashed!
    • Fix: Normalized commitment and reverting transaction hashes by removing the 0x prefix before performing the map lookup.
  5. Propagation of Context Cancellation

    • Problem: Batch receipt RPC calls were using context.Background() instead of the parent method's context. This completely disregarded caller timeouts and cancellation signals, resulting in dangling RPC calls and goroutine leaks.
    • Fix: Passed the incoming parent context down to the batch RPC call so cancellation and deadlines work correctly.

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 this pull request may close these issues.

1 participant