fix(security): replace variable-stored shell code with named function in verify.sh#3073
Merged
fix(security): replace variable-stored shell code with named function in verify.sh#3073
Conversation
… in verify.sh Fixes #3070 The port_check / port_check_r variables stored executable shell code as strings and expanded them via ${port_check} inside cloud_exec commands. This is an eval-equivalent pattern: if any part of the variable were ever derived from dynamic input, it would be directly exploitable as command injection. Replace the pattern with _check_port_18789() remote function definitions inside each cloud_exec call. The function is defined and called entirely on the remote side — no shell code is stored in local bash variables. Affected functions: - _openclaw_ensure_gateway (2 usages) - _openclaw_restart_gateway (1 usage) - _openclaw_verify_gateway_resilience (3 usages) Agent: security-auditor Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
louisgv
approved these changes
Mar 28, 2026
Member
louisgv
left a comment
There was a problem hiding this comment.
Security Review
Verdict: APPROVED
Commit: cdb1228
Findings
No security issues found. This change is a security improvement.
The PR replaces variable-stored shell code (local port_check='...' → ${port_check}) with inline function definitions (_check_port_18789() { ...; }; _check_port_18789), eliminating command injection risk vectors.
Specific improvements:
- ✅ Eliminates variable expansion-based command execution
- ✅ Maintains proper shell quoting (double quotes outer, single quotes inner)
- ✅ Preserves macOS bash 3.x compatibility
- ✅ No introduction of new security risks
Tests
- bash -n: PASS (syntax check clean)
- bun test: N/A (shell script, no TypeScript tests affected)
- curl|bash: N/A (E2E test library, not a bootstrap script)
- macOS compat: OK (uses portable function syntax, no bash 4+ features)
-- security/pr-reviewer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why: Removes a command injection risk pattern where shell code was stored in a variable and executed via
${port_check}— if this variable ever accepted dynamic input, it would be directly exploitable.Fixes #3070
Changes
port_check/port_check_rlocal variables into a_check_port_18789()function defined inside eachcloud_execremote commandif ${port_check}; thenusages withif _check_port_18789; then_openclaw_ensure_gateway,_openclaw_restart_gateway,_openclaw_verify_gateway_resilienceTesting
bash -n sh/e2e/lib/verify.shpasses (syntax check)-- refactor/security-auditor