Skip to content

fix: security hardening, path traversal, code injection, auth bypass, repo hygiene, test cleanup#13

Merged
htafolla merged 1 commit intomasterfrom
fix/security-codebase-hygiene-test-cleanup
Mar 29, 2026
Merged

fix: security hardening, path traversal, code injection, auth bypass, repo hygiene, test cleanup#13
htafolla merged 1 commit intomasterfrom
fix/security-codebase-hygiene-test-cleanup

Conversation

@htafolla
Copy link
Copy Markdown
Owner

Summary

Comprehensive security audit and codebase cleanup addressing 3 critical, 3 high, and multiple medium-severity issues discovered during post-merge review.

Security Fixes

Critical

  • C1: Command injectionintelligent-commit-batcher.ts used exec() with string interpolation for git operations. Added runCommandSafe() using spawn() with args array, eliminating shell metacharacter interpretation entirely.
  • C2: Auth bypass/logs endpoint in cli/server.ts was not wrapped in requireAuth middleware while all other API routes were protected. Fixed.
  • C3: Timing attack — API key validation in openclaw/api-server.ts used === comparison. Now uses crypto.timingSafeEqual for constant-time comparison.

High

  • H1: Memory leak — Rate limiter in security-middleware.ts created a Map that never evicted stale IP entries. Added periodic TTL eviction via setInterval.
  • H3: Path traversalcreateDynamicConfig() in server-config-registry.ts interpolated serverName into file paths without validation. Now rejects path traversal characters.
  • H5: Path traversaltest-auto-creation-processor.ts wrote test files without validating paths stayed within expected directory. Added path resolution check.
  • H6: CORS + API key CSRF — OpenClaw API server set Access-Control-Allow-Origin: * with API key auth. Now restricts to localhost origins when apiKey is configured.

Code Quality

  • Replaced placeholder secrets with empty strings in OpenClaw sample config
  • Fixed req: any, res: any types to proper Request, Response types in CLI server

Repo Hygiene

  • Untracked 180 files from git that were gitignored but still tracked:
    • dist/ (33 files), logs/reports/ (14), ci-test-env/ (133), performance-baselines.json
  • Fixed enforcer-config.json framework version (1.0.0 → 1.15.18)
  • Added context-ses*.json, ci-test-env/ to .gitignore

Test Cleanup (27 files deleted, ~6,300 lines removed)

  • Deleted empty/stub test files and 6 non-vitest ad-hoc test scripts never run by npm test
  • Deleted backup files (.bak2, .backup)
  • Deleted entire scripts/archived/ directory (12 obsolete files)
  • Deleted 7 stale report .md files from scripts/
  • Fixed 2 broken vitest config references to nonexistent setup files

Verification

  • TypeScript: 0 errors
  • Tests: 2,399 pass, 0 failures
  • Build: Clean
  • Version: 1.15.18
    BODY; __hermes_rc=$?; printf 'HERMES_FENCE_a9f7b3'; exit $__hermes_rc

… repo hygiene, test cleanup (#13)

Security fixes (3 critical, 3 high):
- C1: Command injection in intelligent-commit-batcher.ts — replaced exec() string
  interpolation with spawn()-based runCommandSafe() for git add/commit operations
- C2: Auth bypass on /logs endpoint in cli/server.ts — added requireAuth middleware
- C3: Timing attack on API key validation in openclaw/api-server.ts — use
  crypto.timingSafeEqual for constant-time comparison
- H1: Rate limiter memory leak in security-middleware.ts — added TTL eviction via
  setInterval to prevent unbounded Map growth
- H3: Path traversal in server-config-registry.ts — validate serverName rejects
  path traversal characters (.., /, \\, null bytes)
- H5: Path traversal in test-auto-creation-processor.ts — validate resolved path
  stays within expected directory

Code quality:
- H6: CORS wildcard + API key CSRF risk — restrict origins to localhost when
  apiKey is configured in openclaw API server
- M5: Replace placeholder secrets with empty strings in openclaw sample config

Repo hygiene:
- Untrack dist/ (33 files), logs/reports/ (14 files), ci-test-env/ (133 files),
  performance-baselines.json from git — all were gitignored but still tracked
- Fix enforcer-config.json framework version (1.0.0 → 1.15.18)
- Add context-ses*.json, ci-test-env/ to .gitignore

Test cleanup (27 files deleted, ~6,300 lines removed):
- Delete empty/stub test files: test-integration.ts, test-processor.ts,
  marketplace.test.ts.skip
- Delete non-vitest ad-hoc test scripts never run by npm test (6 files)
- Delete backup files: .bak2, .backup
- Delete entire scripts/archived/ directory (12 obsolete files)
- Delete stale report .md files from scripts/ (7 files)
- Fix broken vitest config refs: integration-setup.ts, security-setup.ts → setup.ts

Version: 1.15.18
Tests: 2399 pass, 0 failures, 0 TS errors
@htafolla htafolla merged commit 0af058e into master Mar 29, 2026
11 checks passed
@htafolla htafolla deleted the fix/security-codebase-hygiene-test-cleanup branch March 31, 2026 15:40
htafolla added a commit that referenced this pull request Apr 2, 2026
- Add validators for terms #12, #19, #16, #3, #13 (early returns, small functions, DRY, over-engineering, error boundaries)
- Wire processor-pipeline MCP to use CodexLoader for richer validation
- Fix orchestrator config loading and conflict resolution wiring
- Total 16 active validators now (was 11)
htafolla added a commit that referenced this pull request Apr 2, 2026
- Add skipped tests for validators #12, #19, #16, #3, #13 (need real codex.json)
- Add MCP integration tests for codex-loader wiring
- Tests validate CodexLoader and processor-pipeline use the same rules
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