Skip to content

Conversation

@fabiovincenzi
Copy link
Collaborator

No description provided.

jescalada and others added 30 commits October 10, 2025 22:25
This will be removed in a later PR once the new CLI tests are converted to Vitest
…tions

These functions relied on the deprecated 'proxyUrl' config field.
In current versions, the hostname is extracted directly from the repository URL path.
No code in the codebase was using these functions.
The db.findUserBySSHKey method is properly typed in src/db/index.ts,
so the (db as any) cast was unnecessary.
Remove users.js and config.js as they are superseded by the TypeScript versions (users.ts and config.ts).
Remove test SSH private keys that should not be committed.
Add test/.ssh/ to .gitignore to prevent future commits.

Note: These keys were previously pushed to origin in commit bc0b2f6
and should be considered compromised.
- Add '--' separator in git clone to prevent flag injection via repo names
- Validate SSH host key paths to prevent command injection in ssh-keygen
- Use strict equality for GitHub/GitLab hostname checks to prevent subdomain spoofing
- Add .gitignore entry for test/.ssh/ directory

Fixes CodeQL security alerts:
- Second order command injection (2 instances)
- Incomplete URL substring sanitization (2 instances)
- Uncontrolled command line (1 instance)
…cript

Converted pullRemote, performance, and SSH integration tests to TypeScript
for better type safety and consistency with the codebase migration.
…ents

This commit addresses multiple security concerns identified in the PR review:

**Security Enhancements:**
- Add SSH agent socket path validation to prevent command injection
- Implement repository path validation with stricter rules (hostname, no traversal, .git extension)
- Add host key verification using hardcoded trusted fingerprints (prevents MITM attacks)
- Add chunk count limit (10,000) to prevent memory fragmentation attacks
- Fix timeout cleanup in error paths to prevent memory leaks

**Type Safety Improvements:**
- Add SSH2ServerOptions interface for proper server configuration typing
- Add SSH2ConnectionInternals interface for internal ssh2 protocol types
- Replace Function type with proper signature in _handlers

**Configuration Changes:**
- Use fixed path for proxy host keys (.ssh/proxy_host_key)
- Ensure consistent host key location across all SSH operations

**Security Tests:**
- Add comprehensive security test suite (test/ssh/security.test.ts)
- Test repository path validation (traversal, special chars, invalid formats)
- Test command injection prevention
- Test pack data chunk limits

All 34 SSH tests passing (27 server + 7 security 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.

8 participants