Skip to content

Eliminate Worker Panics via Strict Input Validation and Error Mapping - #64

Open
mertcano wants to merge 1 commit into
DelphinusLab:mainfrom
mertcano:mertcano-patch-1
Open

mertcano wants to merge 1 commit into
DelphinusLab:mainfrom
mertcano:mertcano-patch-1

Conversation

@mertcano

Copy link
Copy Markdown

Description

This pull request addresses a high-severity robustness and denial-of-service finding in zkwasm-mini-rollup (dbservice/src/main.rs) identified during the DelphinusLab workspace security audit (F25).

Previously, client-supplied inputs across JSON-RPC handlers (update_leaf, get_leaf, update_record, and get_record) were unwrapped directly using .unwrap(), and underlying storage-layer calls panicked on unexpected input states. An attacker submitting malformed index strings or invalid record arrays could trigger worker thread panics, leading to remote service crashes and DoS.

Key Changes & Remediations

Fallible Input Parsing & Safe Error Mapping (F25 - dbservice/src/main.rs)

  • Strict Parameter Parsing: Replaced unwrap calls on client-supplied index strings in update_leaf and get_leaf with u64::from_str_radix(..., 10).map_err(|_| Error::INVALID_PARAMS)?.
  • Record Validation: Pre-validated record data elements in update_record before dispatching to the blocking worker task, returning Error::INVALID_PARAMS on any invalid numeric string.
  • Graceful Storage Error Handling: Mapped storage failures (update_leaf_data_with_proof, get_leaf_with_proof, and get_record) to Error::INTERNAL_ERROR instead of permitting panics inside actix_web::web::block.

How to Review

  1. Inspect dbservice/src/main.rs to verify that all .unwrap() calls on client-supplied parameters and fallible database queries have been replaced with ? and mapped to JSON-RPC error types.
  2. Confirm that malformed requests now gracefully return JSON-RPC error responses rather than terminating the process.

### Description
This pull request addresses a high-severity robustness and denial-of-service finding in `zkwasm-mini-rollup` (`dbservice/src/main.rs`) identified during the DelphinusLab workspace security audit (**F25**).

Previously, client-supplied inputs across JSON-RPC handlers (`update_leaf`, `get_leaf`, `update_record`, and `get_record`) were unwrapped directly using `.unwrap()`, and underlying storage-layer calls panicked on unexpected input states. An attacker submitting malformed index strings or invalid record arrays could trigger worker thread panics, leading to remote service crashes and DoS.

### Key Changes & Remediations

#### Fallible Input Parsing & Safe Error Mapping (F25 - `dbservice/src/main.rs`)
* **Strict Parameter Parsing:** Replaced unwrap calls on client-supplied index strings in `update_leaf` and `get_leaf` with `u64::from_str_radix(..., 10).map_err(|_| Error::INVALID_PARAMS)?`.
* **Record Validation:** Pre-validated record data elements in `update_record` before dispatching to the blocking worker task, returning `Error::INVALID_PARAMS` on any invalid numeric string.
* **Graceful Storage Error Handling:** Mapped storage failures (`update_leaf_data_with_proof`, `get_leaf_with_proof`, and `get_record`) to `Error::INTERNAL_ERROR` instead of permitting panics inside `actix_web::web::block`.

### How to Review
1. Inspect `dbservice/src/main.rs` to verify that all `.unwrap()` calls on client-supplied parameters and fallible database queries have been replaced with `?` and mapped to JSON-RPC error types.
2. Confirm that malformed requests now gracefully return JSON-RPC error responses rather than terminating the process.
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