Repository navigation
op-acceptance-tests,op-devstack: cover forkchoice updates with a stale safe or finalized hash - #23440
einar-oplabs wants to merge 1 commit into
Conversation
Wiz Scan Summary
To detect these findings earlier in the dev lifecycle, try the Wiz Code extension for VS Code, JetBrains, or Visual Studio. |
| n.p.Require().NotEmptyf(n.dataDirPath, "op-reth %s has no datadir to wipe", n.name) | ||
| n.p.Logger().Info("Wiping op-reth datadir", "name", n.name, "chain", n.chainID, "datadir", n.dataDirPath, "proofs_store", n.proofsHistoryDir) | ||
| n.p.Require().NoError(os.RemoveAll(n.dataDirPath), "must remove datadir") | ||
| n.p.Require().NoError(os.MkdirAll(n.dataDirPath, 0o755), "must create datadir") |
There was a problem hiding this comment.
Overly permissive directory permissions in Go (CWE-732)
More Details
This rule detects cases where Go applications create directories with overly permissive permissions, potentially allowing unauthorized access or modification of files within those directories. Assigning excessively open permissions to directories can lead to security vulnerabilities, as it may enable malicious actors or other processes to read, write, or execute files they should not have access to.
Consequences of this issue can include data leaks, data tampering, or even remote code execution, depending on the contents and purpose of the affected directories. To mitigate this risk, it is crucial to assign the least permissive access rights necessary for the application's intended functionality.
| Attribute | Value |
|---|---|
| Impact | |
| Likelihood |
Remediation
The vulnerability arises from assigning overly permissive permissions to directories created by the application. This can potentially allow unauthorized access or modification of files within those directories, leading to security risks such as data leaks, data tampering, or even remote code execution, depending on the contents and purpose of the affected directories.
To fix this issue securely, you should assign the least permissive access rights necessary for the application's intended functionality. Specifically, you should use the os.Mkdir or os.MkdirAll functions with a permission mask that restricts access to only the necessary users or processes.
Code examples
// VULNERABLE CODE - Assigns overly permissive permissions (0777) to the created directory
err := os.Mkdir("/path/to/dir", 0777)// SECURE CODE - Assigns more restrictive permissions (0750) to the created directory
err := os.Mkdir("/path/to/dir", 0750)Additional recommendations
- Follow the principle of least privilege and assign the minimum required permissions for the application's functionality.
- Consider using a more restrictive permission mask, such as 0700 (read, write, execute for the owner only), if the directory does not need to be accessed by other users or processes.
- Regularly review and audit directory permissions to ensure they remain appropriate for the application's security requirements.
- Adhere to relevant security standards and best practices, such as the OWASP Top 10 and CWE guidelines, which emphasize the importance of proper access control and resource protection.
- If the application requires more granular access control, consider implementing additional security measures, such as file system access control lists (ACLs) or mandatory access control (MAC) systems.
Rule ID: WS-I011-GO-00011
To ignore this finding as an exception, reply to this conversation with #wiz_ignore reason
If you'd like to ignore this finding in all future scans, add an exception in the .wiz file (learn more) or create an Ignore Rule (learn more).
To get more details on how to remediate this issue using AI, reply to this conversation with #wiz remediate
There was a problem hiding this comment.
Claude: #wiz_ignore Test harness code: this recreates a devstack op-reth datadir inside the test's temporary directory, and 0o755 matches every other devstack datadir (op-devstack/sysgo/l1_runtime.go, mixed_runtime.go). Nothing outside the test reads or writes it.
| "--datadir=" + dataDirPath, | ||
| "--chain=" + chainConfigPath, | ||
| } | ||
| initOut, err := exec.CommandContext(t.Ctx(), execPath, initArgs...).CombinedOutput() |
There was a problem hiding this comment.
OS Command Injection (CWE-78)
More Details
OS command injection is a critical vulnerability that allows an attacker to execute arbitrary commands on the system. This can lead to a full system compromise, as the attacker can potentially gain complete control over the application and the underlying system.
The vulnerability arises when user input is used to construct commands or command arguments that are then executed by the application. This can occur when user-supplied data is passed directly to functions that execute OS commands, such as exec.Command, exec.CommandContext, syscall.ForkExec, or syscall.StartProcess.
If an attacker can inject malicious code into these commands, they can potentially execute any command on the system, including installing malware, stealing data, or causing a denial of service. This vulnerability can have severe consequences, including data breaches, system compromise, and unauthorized access to sensitive information.
To avoid this vulnerability, user input should never be used directly in constructing commands or command arguments. Instead, the application should use a hardcoded set of arguments and validate any user input to ensure it does not contain malicious code.
| Attribute | Value |
|---|---|
| Impact | |
| Likelihood |
Remediation
OS command injection is a critical vulnerability that allows an attacker to execute arbitrary commands on the system. This can lead to a full system compromise, as the attacker can potentially gain complete control over the application and the underlying system. The vulnerability arises when user input is used to construct commands or command arguments that are then executed by the application.
To fix this issue, user input should never be used directly in constructing commands or command arguments. Instead, the application should use a hardcoded set of arguments and validate any user input to ensure it does not contain malicious code. Additionally, it is recommended to use language-specific facilities for executing commands, which provide better input validation and sanitization.
Code examples
// VULNERABLE CODE - User input is directly used in constructing the command
userInput := getInput() // Assume this comes from user input
cmd := exec.Command("/bin/sh", "-c", userInput)
err := cmd.Run()// SECURE CODE - Command and arguments are hardcoded, and user input is validated
userInput := getInput() // Assume this comes from user input
if !isValidInput(userInput) {
// Handle invalid input
return
}
cmd := exec.Command("/bin/sh", "-c", "echo", userInput)
err := cmd.Run()Additional recommendations
- Follow the principle of least privilege and run the application with the minimum required permissions.
- Use input validation and sanitization techniques to ensure that user input does not contain malicious code.
- Implement secure coding practices and follow security standards such as OWASP Top 10 and CWE.
- Consider using language-specific facilities for executing commands, such as os/exec in Go, which provide better input validation and sanitization.
- Regularly update and patch the application and its dependencies to address known vulnerabilities.
- Implement logging and monitoring mechanisms to detect and respond to potential security incidents.
Rule ID: WS-I011-GO-00026
To ignore this finding as an exception, reply to this conversation with #wiz_ignore reason
If you'd like to ignore this finding in all future scans, add an exception in the .wiz file (learn more) or create an Ignore Rule (learn more).
To get more details on how to remediate this issue using AI, reply to this conversation with #wiz remediate
There was a problem hiding this comment.
Claude: #wiz_ignore Test harness code: the command runs the op-reth binary the devstack resolved for this node, through exec.CommandContext without a shell, with flags the harness builds from its own generated datadir and chain config paths. No user or network input reaches the binary path or its arguments.
| "--chain=" + chainConfigPath, | ||
| "--proofs-history.storage-path=" + storagePath, | ||
| } | ||
| initOut, err := exec.CommandContext(t.Ctx(), execPath, initProofsArgs...).CombinedOutput() |
There was a problem hiding this comment.
OS Command Injection (CWE-78)
More Details
OS command injection is a critical vulnerability that allows an attacker to execute arbitrary commands on the system. This can lead to a full system compromise, as the attacker can potentially gain complete control over the application and the underlying system.
The vulnerability arises when user input is used to construct commands or command arguments that are then executed by the application. This can occur when user-supplied data is passed directly to functions that execute OS commands, such as exec.Command, exec.CommandContext, syscall.ForkExec, or syscall.StartProcess.
If an attacker can inject malicious code into these commands, they can potentially execute any command on the system, including installing malware, stealing data, or causing a denial of service. This vulnerability can have severe consequences, including data breaches, system compromise, and unauthorized access to sensitive information.
To avoid this vulnerability, user input should never be used directly in constructing commands or command arguments. Instead, the application should use a hardcoded set of arguments and validate any user input to ensure it does not contain malicious code.
| Attribute | Value |
|---|---|
| Impact | |
| Likelihood |
Remediation
OS command injection is a critical vulnerability that allows an attacker to execute arbitrary commands on the system. This can lead to a full system compromise, as the attacker can potentially gain complete control over the application and the underlying system. The vulnerability arises when user input is used to construct commands or command arguments that are then executed by the application.
To fix this issue, user input should never be used directly in constructing commands or command arguments. Instead, the application should use a hardcoded set of arguments and validate any user input to ensure it does not contain malicious code. Additionally, it is recommended to use language-specific facilities for executing commands, which provide better input validation and sanitization.
Code examples
// VULNERABLE CODE - User input is directly used in constructing the command
userInput := getInput() // Assume this comes from user input
cmd := exec.Command("/bin/sh", "-c", userInput)
err := cmd.Run()// SECURE CODE - Command and arguments are hardcoded, and user input is validated
userInput := getInput() // Assume this comes from user input
if !isValidInput(userInput) {
// Handle invalid input
return
}
cmd := exec.Command("/bin/sh", "-c", "echo", userInput)
err := cmd.Run()Additional recommendations
- Follow the principle of least privilege and run the application with the minimum required permissions.
- Use input validation and sanitization techniques to ensure that user input does not contain malicious code.
- Implement secure coding practices and follow security standards such as OWASP Top 10 and CWE.
- Consider using language-specific facilities for executing commands, such as os/exec in Go, which provide better input validation and sanitization.
- Regularly update and patch the application and its dependencies to address known vulnerabilities.
- Implement logging and monitoring mechanisms to detect and respond to potential security incidents.
Rule ID: WS-I011-GO-00026
To ignore this finding as an exception, reply to this conversation with #wiz_ignore reason
If you'd like to ignore this finding in all future scans, add an exception in the .wiz file (learn more) or create an Ignore Rule (learn more).
To get more details on how to remediate this issue using AI, reply to this conversation with #wiz remediate
There was a problem hiding this comment.
Claude: #wiz_ignore Test harness code: the command runs the op-reth binary the devstack resolved for this node, through exec.CommandContext without a shell, with flags the harness builds from its own generated datadir and chain config paths. No user or network input reaches the binary path or its arguments.
|
This pr has been automatically marked as stale and will be closed in 5 days if no updates |
… source A reset can lower the safe head below a finalization target that the node's own L2Finalizer requested from L1 finality, and the by-number target then failed with BlockNotSafe and stopped the node (seen in #23440's datadir-wipe CI run). Like op-node's promoteFinalized, skip a target above the safe head with a warning whatever its source; the next L1 finality update requests a newer block. Finality still never moves above the safe head. BREAKING CHANGE: FinalizeTaskError::BlockNotSafe is removed: a finalization target above the safe head, by hash or by number, is now logged and skipped instead of returning a Critical error. Remove any match arm for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A finalization target the engine cannot apply yet no longer stops kona-node. A target above the safe head is skipped with a warning, whatever its source, as op-node's promoteFinalized does: a delegate can run ahead of the local safe head, and a reset can lower the safe head below a target that was safe when requested (#23757, #23440). A hash-pinned target the execution layer has not downloaded yet is skipped the same way. Neither sends a forkchoice update; the delegate poll resubmits its target every 4s and the next L1 finality update requests a newer block, so unsafe imports keep running while the execution layer catches up. Pinned lookups still never fall back to the local block at the same height, and a returned block whose hash or number differs from the target fails with the new BlockIdentityMismatch. A by-number target whose block is missing still fails with BlockNotFound. Tests cover the finalize task over missing, present, mismatched and above-safe targets for both lookup kinds, recovery once a missing block arrives, a queue that keeps importing while a target is missing, the real EngineActor across two resets below a pending target, and the delegated derivation actor's polling and L1 validation. BREAKING CHANGE: This affects code that uses the kona-engine crate and matches FinalizeTaskError exhaustively. BlockNotSafe is removed: a target above the safe head is logged and skipped instead of returning a Critical error. BlockIdentityMismatch { actual, expected } is added, with Critical severity, for a pinned hash the engine answers with a different block, including a height mismatch that previously returned BlockNotFound. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A finalization target the engine cannot apply yet no longer stops kona-node. A target above the safe head is skipped with a warning, whatever its source, as op-node's promoteFinalized does: a delegate can run ahead of the local safe head, and a reset can lower the safe head below a target that was safe when requested (#23757, #23440). A hash-pinned target the execution layer has not downloaded yet is skipped the same way. Neither sends a forkchoice update; the delegate poll resubmits its target every 4s and the next L1 finality update requests a newer block, so unsafe imports keep running while the execution layer catches up. Pinned lookups still never fall back to the local block at the same height, and a returned block whose hash or number differs from the target fails with the new BlockIdentityMismatch. A by-number target whose block is missing still fails with BlockNotFound. Tests cover the finalize task over missing, present, mismatched and above-safe targets for both lookup kinds, recovery once a missing block arrives, a queue that keeps importing while a target is missing, the real EngineActor across two resets below a pending target, and the delegated derivation actor's polling and L1 validation. BREAKING CHANGE: This affects code that uses the kona-engine crate and matches FinalizeTaskError exhaustively. BlockNotSafe is removed: a target above the safe head is logged and skipped instead of returning a Critical error. BlockIdentityMismatch { actual, expected } is added, with Critical severity, for a pinned hash the engine answers with a different block, including a height mismatch that previously returned BlockNotFound. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A finalization target the engine cannot apply yet no longer stops kona-node or holds the engine queue. A target above the safe head fails with `BlockNotSafe`, now of `Skip` severity, whatever its source, as op-node's promoteFinalized does: a delegate can run ahead of the local safe head, and a reset can lower the safe head below a target that was safe when requested (#23757, #23440). A hash-pinned target the execution layer has no block for yet fails with the new skipped `NotYetAvailable`, whether the lookup returns null or an error response, so a retried lookup cannot hold the queue ahead of the imports that let the execution layer catch up. The delegate poll resubmits its target every 4s. A by-number target from L1 finality that a reset skipped is no longer lost until L1 finality moves again: like op-node's retry when derivation goes idle, the finalizer keeps the highest finalized L1 block and finalizes newly safe blocks against it on each L1 head update. A by-number target whose block is missing still fails with `BlockNotFound`. BREAKING CHANGE: `FinalizeTaskError` has a new variant, `NotYetAvailable { target }`; exhaustive matches must handle it. `BlockNotSafe` keeps its name but has `Skip` severity instead of `Critical`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A finalization target the engine cannot apply yet no longer stops kona-node or holds the engine queue. A target above the safe head fails with `BlockNotSafe`, now of `Skip` severity, whatever its source, as op-node's promoteFinalized does: a delegate can run ahead of the local safe head, and a reset can lower the safe head below a target that was safe when requested (#23757, #23440). A hash-pinned target the execution layer has no block for yet fails with the new skipped `NotYetAvailable`, which carries the answer, whether the lookup returned null or an error response, so a retried lookup cannot hold the queue ahead of the imports that let the execution layer catch up. The delegate poll resubmits its target every 4s. A by-number target from L1 finality that a reset skipped is no longer lost until L1 finality moves again: like op-node's retry when derivation goes idle, the finalizer keeps the highest finalized L1 number and finalizes newly safe blocks against it on each L1 head update, which batches the blocks confirmed since the last update. A by-number target whose block is missing still fails with `BlockNotFound`. Tests cover the finalizer, a block derived again after a reset, a delegated poll during execution-layer sync at the actor level, and the error variant of each unavailable-block answer; `test_utils::expect_sync_start` replaces two copies of the reset's RPC script. BREAKING CHANGE: `FinalizeTaskError` has a new variant, `NotYetAvailable { engine_answer, target }`; exhaustive matches must handle it. `BlockNotSafe` keeps its name but has `Skip` severity instead of `Critical`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
530218f to
458fd57
Compare
c7e6250 to
a3c78e4
Compare
458fd57 to
2fc40d6
Compare
|
Claude: Detail moved out of the PR description when the branch was squashed into a3c78e4. It is the description as it stood before the squash, unedited, so it describes the earlier commits. reth 2.6 (#23046) carries reth#27247 and reth#27429: a forkchoice update whose safe or finalized hash is not on the head's chain is refused with What the tests coverAll in
Matrix: sync mode {CL, EL} for 1 and 2, threshold {7, 50} for 4, CL {op-node, kona-node} through Local verificationDebug op-reth built from this branch's Rust tree (identical to #23438's), kona-node release binary from op-node (default): The three skipped cells, run on kona-node ( The kona-node datadir-wipe cell spends 52s reaching 60 blocks, 124s on the first finalized block, 17s on the resync and 223s on being finalized again (see CI follow-up). Against #23046's op-reth (reth 2.6.0, the debug binary built from the bump head 93d9ec9 for #23436), with the three develop-only skips neutralized, op-node: Against the bump the follower's op-node also resets on Against the bump under kona-node (same, The bump answered the persisted-head update Unit tests ( Skipped cells
Findings
Seams added
Notes on the issue text
CI follow-up
What the follower's kona-node does after the wipe (the CI per-test log carries only its WARN lines; a local run with its INFO lines fills in the rest):
Both look like kona-node bugs worth an issue: a reset after an EL datadir wipe restarts derivation at genesis and then loops on The change: #23399's criterion for this scenario is that the sync completes. The cell keeps requiring, under both consensus clients and bounded, that the follower holds the sequencer's unsafe head and is safe at least where it was before the wipe. Being finalized at least where it was before the wipe, which is the consensus client's finalization after its reset rather than the EL's sync, and the consensus-client in-sync check that follows it now run only under op-node; under kona-node the cell skips at that point with a message naming #23399 and quoting the failure (the kona-node defect needs an issue of its own, which the skip should then name instead). The op-node cells run the same sequence as before. The follower's op-reth is not blameless by inspection alone: in the CI log it answers null by number for block 348 at 07:04:00 while it had received payload 361, and its blocks become canonical in bursts of about six; op-node drives the same EL through the same scenario and passes, so the loop is kona-node's, but whoever takes the issue should know the EL answers null below the highest payload it has received. Local runs of the committed test (debug op-reth built from this branch, kona-node release binary from Under op-node the follower was finalized again about 70 s after the wipe in Stacked on #23438, #23436, #23431, #23427, #23421 and #23418. Closes #23399 |
2fc40d6 to
f4c7010
Compare
6cabe52 to
eb73ef7
Compare
f4c7010 to
be963b4
Compare
eb73ef7 to
574c473
Compare
5b3e133 to
63096fc
Compare
4b951df to
a6fb532
Compare
63096fc to
5fe7487
Compare
a6fb532 to
c4f5482
Compare
5fe7487 to
4c4f1fb
Compare
…e safe or finalized hash Four acceptance tests for the forkchoice updates a consensus client sends when its safe or finalized hash is not on the head's chain, which reth 2.6 rejects before applying anything (reth#27247, reth#27429): an L1 reorg that rewinds a running follower's safe head, a resync from an empty datadir under a consensus client that kept its heads, a raw update naming a reorged-out block as finalized, and a raw update back to a block reth reports persisted after a sibling reorged it out, where the reorg to the sibling must report the sibling as the latest valid block. Under kona-node the L1-reorg test skips naming #18676, and the datadir-wipe test requires the follower's unsafe and safe heads but skips the finalized requirement naming #24066. Devstack seams: an op-reth datadir wipe (stack.DatadirWipeable), engine_getPayload and a sibling-block builder on the L2 EL DSL, an assertion for the engine API's -38002 refusal, and non-fatal lookups inside WaitL1OriginHash's retry loop. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
c4f5482 to
9ac60ed
Compare
4c4f1fb to
19b45d1
Compare
reth 2.6 refuses a forkchoice update whose safe or finalized hash is off the head's chain before applying anything, and develop's suites only touched that path incidentally.
Four tests in
op_reth_stale_forkchoice: an L1 reorg rewinding a follower's safe head, a resync from a wiped datadir, a raw update finalizing a reorged-out block, and a raw update to a persisted block reorged out below the in-memory window. Adds a datadir wipe, a sibling-block builder and a-38002assertion to the devstack.Stacked on #23438. Closes #23399. Local verification, findings and notes: detail comment.
Breakdown
AI Reviews
<ISODATETIME><COMMITID>Fable 5.1 xhigh<ISODATETIME><COMMITID>GPT-6.1-Sol xhigh<ISODATETIME><COMMITID>Opus 5.5 xhigh🤖 Generated with Claude Code