Redis: private access, ACLs and checking keys outside the allowed namespace

Separate runtime and maintenance access in local Redis, checking PHP commands, NOPERM, wrong-password refusal and a persisted AOF marker.

A red key and red stacks separated from black blocks.

Redis for an application starts with a concrete boundary: who connects, which keys they can access, and which commands they can run. In a manual run on a disposable Debian 13 VM, we started Redis 8.0.2 and exercised those boundaries with a real PHP client. This is a separate training environment, not a change to the working server.

A local service with a defined memory budget

The only Redis TCP listener is reachable through loopback on port 6379. The service runs as a dedicated system user without login, with a private data directory and an empty capability set. systemd uses Type=notify together with supervised systemd: startup waits for Redis to report readiness.

The maxmemory data budget is 64 MiB, while the service MemoryMax is 128 MiB. These are different limits: the process also needs memory for internal structures and buffers. The noeviction policy prevents automatic key eviction when maxmemory is reached; the application must handle rejected writes. Here is part of the actual configuration, omitting the loopback binding, paths and ACL file:

port 6379
protected-mode yes
daemonize no
supervised systemd
save ""
appendonly yes
appendfsync everysec
maxmemory 64mb
maxmemory-policy noeviction

Periodic RDB snapshots are disabled. AOF is enabled with appendfsync everysec, rather than always. The Redis persistence documentation explains the distinction. Everysec does not mean that each write is synchronized to disk before the client receives a response.

Separate runtime and maintenance accounts

The default user is disabled. The article_cache account has a separate password and a fixed command list. Passwords were created in the private environment, are not passed in process arguments, and are excluded from the examples. The following is only the permissions portion of an ACL rule; user creation, the on state and password fields are deliberately omitted. The lines represent one permission set:

resetkeys ~article_demo:cache:* resetchannels -@all
+ping +select|0 +get +mget +exists +set +setex
+del +unlink +expire +pexpire +ttl +pttl

The article_demo:cache:* prefix belongs to this example. It is not an automatically resolved Symfony namespace. The +select|0 permission admits only logical database zero; permission to connect does not open another database. Resetchannels grants no Pub/Sub access. The syntax is described in the Redis ACL documentation.

The article_maintenance account has the same key prefix, plus +scan and +info|server. This is trusted maintenance access. Key-pattern ACLs do not filter the names returned by SCAN: a client can change MATCH and discover other key names even though their values remain inaccessible. The ordinary runtime account therefore receives no SCAN permission.

Exercising the PHP commands

After authenticating through the Redis extension, we ran this excerpt. The $r variable already contains an article_cache connection; no secret appears in the code:

$r->select(0);
$r->set('article_demo:cache:persist', 'survives-normal-reboot');
$r->setex('article_demo:cache:ttl', 120, 'cache-control');
$values = $r->mget([
    'article_demo:cache:persist',
    'article_demo:cache:ttl',
]);

MGET returned the two expected strings: survives-normal-reboot and cache-control. The maintenance client ran SCAN with its own MATCH, removed the temporary key through UNLINK, and runtime EXISTS confirmed its absence. INFO Server returned version 8.0.2.

A separate control key under another prefix contained foreign-control. Runtime attempts to read, overwrite and delete it returned NOPERM; its value remained unchanged. SCAN, FLUSHALL, FLUSHDB, CONFIG, ACL, SELECT of another database and PUBLISH were also refused. Maintenance was denied access to the foreign value and FLUSHDB. Authentication with a wrong password returned WRONGPASS.

This exercises direct PHP client commands. The complete Symfony RedisAdapter, pool clearing and actual generated namespaces need their own integration and verification: the test prefix cannot be assigned to the application by assumption.

A record for a later reboot check

The persist key was written without a TTL for a future read after a normal reboot. Its text value is not the result of that test. At this step, the reboot has not happened and automatic service startup remains disabled. Readiness of the current process, configured AOF and recovery after a new boot are separate observations.

Later, we explicitly enabled the service and performed an ordinary joint reboot. Redis returned the persisted AOF persist marker; deleting a key outside the allowed namespace again received NOPERM and its value remained unchanged. This checks normal reboot, not zero-loss preservation of every write during a crash: appendfsync everysec provides no such guarantee.

Repeated ACL setup and control requests through the CLI

In a separate clean CLI run, Redis completed installation, configuration, startup and independent verification. site-apply created new app and maintenance users, saved the ACL and wrote an owned control marker. An actual write attempt outside the prefix was denied. Dangerous global commands were checked with ACL DRYRUN without executing them.

In the Debian package, redis-server is a symbolic link to redis-check-rdb, while redis-tools supplies the executable. The CLI checked authenticated package provenance, the exact link target and the separate ELF file; the actual process executed /usr/bin/redis-check-rdb. The executed site-verify below uses generalized protected paths and the already approved plan SHA:

deploy-cli host data redis80 site-verify \
  --env-file "$PRIVATE_DIR/administrator.env" \
  --request-file "$PRIVATE_DIR/request.json" \
  --data-file "$PRIVATE_DIR/redis80-profile.json" \
  --site-file "$PRIVATE_DIR/site.json" \
  --dependencies-file "$PRIVATE_DIR/redis80-site-deps.json" \
  --plan-file "$PRIVATE_DIR/redis80-site-plan.json" \
  --plan-sha256 "$APPROVED_PLAN_SHA256"

This summarizes the process reader and ACL checks retained in completed journals. maintenance_scan_names_global describes the scope of allowed SCAN: an ACL key prefix does not filter the names that this command can return. Maintenance access therefore remains a separate role.

{
  "activation_phase": "committed",
  "site_phase": "committed",
  "executable": "/usr/bin/redis-check-rdb",
  "authenticated": true,
  "default_disabled": true,
  "version": "8.0.2",
  "wrong_password_denied": true,
  "maintenance_scan_names_global": true,
  "outside_control": "ok",
  "own_read": true,
  "runtime_global_commands_denied": true
}
Fresh reduced recheck after the joint reboot: the AOF marker is readable and keys outside the allowed namespace are protected; service settings are read separately.

A separate CLI step for starting and enabling the existing service

After rebooting the combined CLI fixture, this service was stopped and disabled. We did not replay its original activation: for MySQL that sequence also initializes the data directory and secures root. The new startup transaction uses existing data and checks the original completed journals, all nine package-history nodes, unchanged configuration and independently confirmed current boot.

Before starting, the CLI compares exact configuration and private-file images, including Elasticsearch TLS material. A new drop-in adds Requires and After dependencies on the owned firewall. The CLI starts the service once, verifies its actual process, signed binary, loopback listeners and authenticated native protocol, then creates the exact enable link after readiness succeeds.

The commands below use generalized private paths. PRIVATE_DIR is an absolute private directory; install-request retains the installation boot, while current-console-request independently confirms the current boot. The public PHP key admits the original combined history; data-service keys are retained in history-references. The plan SHA is checked before apply.

STARTUP_ARGS=(
  --env-file "$PRIVATE_DIR/administrator.env"
  --request-file "$PRIVATE_DIR/install-request.json"
  --fpm-file "$PRIVATE_DIR/php-profile.json"
  --key-file "$PRIVATE_DIR/php-archive-keyring.gpg"
  --key-sha256 "$PHP_PUBLIC_KEY_SHA256"
  --references-file "$PRIVATE_DIR/history-references.json"
  --current-request-file "$PRIVATE_DIR/current-console-request.json"
  --data-activations-file "$PRIVATE_DIR/data-activations.json"
  --firewall-pin-file "$PRIVATE_DIR/firewall-pin.json"
)

deploy-cli host runtime-startup redis80 plan \
  "${STARTUP_ARGS[@]}" --plan-file "$PRIVATE_DIR/redis80-startup-plan.json"

deploy-cli host runtime-startup redis80 apply \
  "${STARTUP_ARGS[@]}" --plan-file "$PRIVATE_DIR/redis80-startup-plan.json" \
  --plan-sha256 "$APPROVED_STARTUP_PLAN_SHA256" --approve-privileges

This is a reduced summary of the actual journal and independent verification over a new SSH connection, rather than the literal output of one command:

{
  "unit": "deploy-cli-redis80.service",
  "state": "active/running",
  "startup": "enabled",
  "journal_steps": 8,
  "protocol": {
    "authenticated": true,
    "configuration": {
      "aclfile": "/var/lib/deploy-cli-redis80/users.acl",
      "appendfsync": "everysec",
      "appendonly": "yes",
      "bind": "127.0.0.1",
      "dir": "/var/lib/deploy-cli-redis80",
      "maxmemory": "67108864",
      "maxmemory-policy": "noeviction",
      "port": "6379",
      "protected-mode": "yes",
      "save": ""
    },
    "default_disabled": true,
    "version": "8.0.2",
    "wrong_password_denied": true
  }
}

An action recorded as pending is never dispatched again on a subsequent invocation. A completed journal is verified through reads only. Original configuration, credentials, package state and previous journals remained unchanged after this step. This was the separate start/enable stage; acceptance of the combined reboot follows below.

Access controls and data after the combined reboot

After separate start/enable, we performed an ordinary reboot of the local educational VM together with PHP-FPM, Nginx and timers. An independent serial console confirmed the new boot. The CLI checked the original journal and configuration, then rebuilt current processes, listeners and protocol replies. The original STARTUP_ARGS are retained; the new console request is passed separately.

deploy-cli host runtime-startup redis80 boot-verify "${STARTUP_ARGS[@]}" \
  --plan-file "$PRIVATE_DIR/redis80-startup-plan.json" \
  --plan-sha256 "$APPROVED_STARTUP_PLAN_SHA256" \
  --manifest-sha256 "$COMMITTED_STARTUP_MANIFEST_SHA256" \
  --new-boot-request-file "$PRIVATE_DIR/new-boot-console-request.json" \
  --output-file "$PRIVATE_DIR/redis80-new-boot-proof.json"

Redis returned automatically as active/running and enabled and restored control keys from AOF. Data in both the allowed and unrelated namespaces were retained; ACL DRYRUN again denied three global operations. ACLs, passwords and initial writes were not recreated.

The frame below belongs to the earlier start/enable stage before the combined reboot. The new post-reboot result is described above; the two stages remain distinct.

Data-service startup before the combined reboot. Service state and sysctl were read live; explicitly reduced retained access-control results follow.
  1. Data & Infrastructure How to share VPS resources between several products
  2. Databases Four database access roles for one product
  3. Observability What the network can see: inventory before firewall rules
  4. Data & Infrastructure Elasticsearch: TLS and three roles for an owned index
  5. Data & Infrastructure MySQL 8.4: an owned server with separate migrator and runtime access