[MEDIUM] [CACHE-2] RedisCache Constructor Accepts No Authentication Parameters — Cannot Connect to Redis Configured with `requirepass` or ACL
Audit Finding: CACHE-2
- Severity:
MEDIUM - Category: Cache / Redis
- File:
/home/z/my-project/ownpay/src/Cache/RedisCache.php:20-31
Description
RedisCache::__construct() accepts only $host, $port, and $prefix — no $password, no $username (for Redis 6+ ACL), no $database index (hardcoded to 0 on line 30). It calls $this->redis->connect($host, $port, 2.0) and immediately $this->redis->select(0). If the Redis server is configured with requirepass 'secret' (the recommended baseline for any non-localhost Redis), the connect succeeds but every subsequent command returns NOAUTH Authentication required. The class has no $this->redis->auth(...) call. There is no fallback to FileCache if Redis is unconfigured — the constructor throws RuntimeException("Cannot connect to Redis...") which propagates up and crashes the request.
Impact
Operators who follow Redis security best practices (enabling requirepass or ACL) cannot use OwnPay's Redis cache driver at all. The practical outcome is that operators either (a) disable Redis authentication entirely (exposing the cache to the network — a real CVE-class misconfiguration that has led to ransomware attacks on exposed Redis instances), or (b) fall back to FileCache (which has the shared-hosting permissions issue in FINDING CACHE-1). The hardcoded DB index 0 also prevents sharing a Redis instance between OwnPay and other applications that use DB 0.
Reproduction
Configure Redis with requirepass foobar in redis.conf. Set CACHE_DRIVER=redis, REDIS_HOST=127.0.0.1, REDIS_PORT=6379 in OwnPay env. Boot the application: RedisCache::__construct calls connect (succeeds) then select(0) which throws RedisException: NOAUTH Authentication required. Application fails to boot.
Recommended Fix
Extend the constructor signature: __construct(string $host, int $port, string $prefix = 'op:', ?string $password = null, ?string $username = null, int $database = 0). After connect, if $password is non-null, call $this->redis->auth([$username, $password]) (Redis 6+ ACL form) or $this->redis->auth($password) (legacy). Then $this->redis->select($database). Read the values from env vars (REDIS_PASSWORD, REDIS_USERNAME, REDIS_DB) in the container factory that instantiates RedisCache.
Discovered during comprehensive codebase audit. See /home/z/my-project/worklog.md for full audit context.
Duplicate Issue — Closed
This issue is a duplicate of #445 (same audit finding CACHE-2 — both issues share the same title, file path, and description).
The fix has been implemented and is ready for review in PR #523: https://github.com/own-pay/OwnPay/pull/523
Tracking will continue under the canonical issue #445, which is referenced by the PR's Closes #445 line and will be auto-closed when the PR merges.
Closing this duplicate as not_planned to keep the audit tracker clean.