Skip to content

security: harden defaults for network-exposed deployments#69

Merged
RaghavChamadiya merged 2 commits intomainfrom
security/harden-defaults-v2
Apr 11, 2026
Merged

security: harden defaults for network-exposed deployments#69
RaghavChamadiya merged 2 commits intomainfrom
security/harden-defaults-v2

Conversation

@RaghavChamadiya
Copy link
Copy Markdown
Collaborator

Summary

Rebased and updated version of #26 by @phjlljp. Applied the 503 to 403 status code fix. All credit to the original author.

Addresses a chain of vulnerabilities that combine into unauthenticated root RCE when repowise is deployed via Docker with default settings.

Changes

  • deps.py: Fail-closed authentication when REPOWISE_HOST=0.0.0.0 and no API key is set (returns 403). Uses hmac.compare_digest() for constant-time key comparison. Localhost deployments remain open.
  • schemas.py: Pydantic validator on RepoCreate.local_path: rejects .. path segments, requires directory to exist and contain .git. Returns resolved absolute path.
  • tool_why.py: Sanitizes stem to [a-zA-Z0-9_\-.] before passing to git log --grep. Adds -- separator to prevent argument injection.
  • Dockerfile: Runs as non-root repowise user. Copies Node.js from builder stage instead of piping curl | bash.
  • docker-compose.yml: Binds ports to 127.0.0.1. Requires REPOWISE_API_KEY and REPO_PATH env vars. Mounts repos read-only.

Based on #26 by @phjlljp

phjlljp and others added 2 commits April 11, 2026 11:57
Addresses a chain of vulnerabilities that combine into unauthenticated
root RCE when repowise is deployed via Docker with default settings.

Changes:
- deps.py: fail-closed auth when binding 0.0.0.0 without API key,
  use hmac.compare_digest() for constant-time key comparison
- schemas.py: validate local_path in RepoCreate (must be a real git
  repo, no path traversal via '..')
- tool_why.py: sanitize stem passed to git log --grep, add '--'
  separator to prevent argument injection
- Dockerfile: run as non-root user, copy Node.js from builder stage
  instead of piping curl|bash
- docker-compose.yml: bind ports to 127.0.0.1, require REPOWISE_API_KEY
  and REPO_PATH, mount repos read-only

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@RaghavChamadiya RaghavChamadiya merged commit 1c2c8e7 into main Apr 11, 2026
2 of 5 checks passed
@RaghavChamadiya RaghavChamadiya deleted the security/harden-defaults-v2 branch April 11, 2026 06:29
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.

3 participants