Skip to content

Conversation

@Mr-Neutr0n
Copy link

Summary

Security audit and fixes for multiple vulnerabilities in the Strix runtime and tool server components.

Security Fixes

1. Token Exposure Prevention (CWE-214)

The tool server previously accepted authentication tokens via --token CLI argument, which exposed tokens in process listings (ps aux).

Fix: Token is now read from TOOL_SERVER_TOKEN environment variable. CLI argument remains as fallback but env var takes precedence.

2. Health Endpoint Information Disclosure (CWE-200)

The /health endpoint exposed internal state including active agent IDs and count without authentication.

Fix:

  • /health now returns only {"status": "healthy"} (for load balancer probes)
  • New /health/detailed endpoint requires Bearer token authentication

3. Path Traversal Prevention (CWE-22)

_copy_local_directory_to_container() followed symlinks, enabling potential directory traversal attacks.

Fix:

  • Added _validate_path_safety() to detect symlink escape attempts
  • Blocks paths that resolve to sensitive system directories via symlinks
  • Skips symlinks during directory traversal

4. Port Allocation Race Condition (CWE-367)

_find_available_port() was vulnerable to TOCTOU race conditions.

Fix: Added retry logic with SO_REUSEADDR socket option.

5. TLS Verification Configuration

verify=False was hardcoded with no documentation.

Fix:

  • Added STRIX_VERIFY_TLS environment variable
  • Defaults to false (required for proxy interception in pen testing)
  • Suppresses urllib3 warnings when disabled
  • Documents security implications

Testing

  • Added 15 new security tests in tests/runtime/test_security.py
  • All 71 tests pass

Checklist

  • Security fixes with minimal code changes
  • Backward compatible (env var preferred, CLI still works)
  • Tests added for each fix
  • No breaking changes

## Security Fixes

### 1. Token Exposure Prevention (CWE-214)
- Tool server now reads auth token from TOOL_SERVER_TOKEN env var instead of CLI args
- Prevents token exposure in process listings (ps aux)
- CLI --token still works as fallback but env var is preferred

### 2. Health Endpoint Information Disclosure (CWE-200)
- Split /health into public and authenticated endpoints
- Public /health returns only {"status": "healthy"} for liveness probes
- New /health/detailed requires Bearer auth for internal state

### 3. Path Traversal Prevention (CWE-22)
- Added _validate_path_safety() to detect symlink escape attempts
- Blocks copying from sensitive system directories via symlinks
- Skips symlinks during directory traversal to prevent attacks

### 4. Port Allocation Race Condition (CWE-367)
- Added retry logic to _find_available_port()
- Uses SO_REUSEADDR for better port allocation
- Handles TOCTOU race conditions gracefully

### 5. TLS Verification Configuration
- Added STRIX_VERIFY_TLS env var to control TLS verification
- Defaults to false (required for pen testing proxy interception)
- Suppresses urllib3 warnings when disabled
- Documents security implications

## Tests
- Added 15 comprehensive security tests in tests/runtime/test_security.py
- All tests pass alongside existing 56 tests
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.

2 participants