Overview
Evolver executes validation commands specified in Gene definitions to verify evolution correctness. To prevent arbitrary command execution, all validation commands are gated by safety checks. Location:src/gep/solidify.js:569-601
Safety Checks
1. Prefix Whitelist
Only commands starting withnode, npm, or npx are allowed:
2. No Command Substitution
Backticks and$(...) are rejected anywhere in the command string:
3. No Shell Operators
After stripping quoted content,;, &, |, >, < are rejected:
4. No Eval Patterns
Directnode -e / node --eval is blocked to prevent arbitrary code execution:
5. Timeout
Each validation command is limited to 180 seconds (3 minutes):src/gep/solidify.js:596
6. Scoped Execution
Commands run withcwd set to the repository root, preventing path traversal:
src/gep/solidify.js:583-601
Implementation
isValidationCommandAllowed
runValidations
Gene Validation Examples
Safe Gene
Unsafe Gene (Rejected)
External Asset Promotion
When promoting external Genes viascripts/a2a_promote.js, all validation commands are audited before promotion:
README.md:214-216
Bypass Attempts
Attempt 1: Shell Escape via Arguments
; is outside quotes after stripping, detected by step 3.
Attempt 2: Pipe via Unquoted Args
| detected by step 3.
Attempt 3: Command Substitution in Args
$( detected by step 2.
Attempt 4: Eval Injection
node -e detected by step 4.
Custom Validation Scripts
If you need custom validation logic, wrap it in a Node.js script:Bad (Shell Script)
Good (Node.js Script)
Validation Report
Validation results are recorded in a machine-readable ValidationReport:src/gep/solidify.js:1133-1140
Timeout Handling
If a validation command exceeds 180 seconds, it is killed:Best Practices
-
Use npm scripts: Define complex validation in
package.jsonscripts:Then: - Keep validations fast: Target < 60 seconds for responsiveness
- Fail fast: If a critical check fails early, don’t waste time on subsequent checks
- No side effects: Validation commands should be read-only (no writes, no deployments)
- Explicit exit codes: Ensure scripts exit with code 0 (success) or non-zero (failure)
Troubleshooting
Validation command blocked
Symptom: Solidify fails with “BLOCKED: validation command rejected by safety check”. Cause: Command contains shell operators or non-whitelisted prefix. Solution: Rewrite command using Node.js:Validation timeout
Symptom: Validation hangs for 3 minutes then fails. Cause: Command is too slow or stuck. Solution: Optimize or split into smaller checks:External gene rejected during promotion
Symptom:a2a_promote.js rejects gene with unsafe validation command.
Cause: Gene contains shell scripts or dangerous commands.
Solution: Contact asset author to fix validation commands, or fork and fix locally.