Summary
Ciphey's Brainfuck decoder runs a Turing-complete interpreter on untrusted input with no execution bound:
// src/decoders/brainfuck_interpreter.rs:65
match Brainfuck::new(text).with_output_ref(&mut buf).execute() {
brainfuck-exe 0.2.4 exposes with_instructions_limit(usize) whose default is None = no limit (crate lib.rs:189), and Ciphey never sets it. The decoder's only guards (lines 53–62) are trivial to satisfy:
text.contains(',') → reject (no stdin reads)
!text.ends_with('.') || text.matches('.').count() < 5 → need ≥5 . and end with .
text.matches(|c| "+-<>[]".contains(c)).count() < 20 → need ≥20 command chars
A single crafted input passes all three and runs forever, producing unbounded output. Because the Brainfuck decoder is a registered, active decoder (src/decoders/mod.rs:252) that the A* searcher runs on every input node, feeding Ciphey such input — directly, or any input its search decodes into it at some layer — hangs the whole program at 100% CPU with unbounded memory growth. There is no per-input decoder gating that would spare it: filtration_system::filter_and_get_decoders(_text_struct) ignores the input entirely (its argument is unused), and Decoders::run calls .crack() on every component (src/filtration_system/mod.rs:61), so the Brainfuck decoder's own guards are the only thing standing between untrusted input and execute(). Ciphey's entire purpose is processing untrusted input (CTF, forensics, automated pipelines), so this is squarely in its threat model.
Proof of concept (input)
++++++++++++++++++++[.....].
- Passes the guards: 6
., 22 command chars (20×'+' + [ + ]), ends with ., no ,.
- Cell 0 = 20 and is never decremented inside
[.....], so the loop condition (cell 0 ≠ 0) never becomes false → infinite loop; the trailing . is never reached.
Verified on the exact crate Ciphey ships (brainfuck-exe = 0.2.4, default-features = false):
[control-hello] ">++++++++[<+++++++++>-]<. ...<+." -> TERMINATED in 42µs, output "Hello, World!"
[BOMB] "++++++++++++++++++++[.....]." -> SIGKILL'd at an 8s wall-clock timeout (never terminates)
The control proves the harness runs Brainfuck correctly, so the bomb's non-termination is attributable to the input, not a broken harness. Left running, the output Vec grows without limit (observed ~71 MB accumulated in ~13 s even under a loose 100M-instruction cap) → OOM in addition to the hang.
Why the global timeout does NOT mitigate it
Ciphey has a global config.timeout (src/searchers/mod.rs:46). It does not rescue this case. The search runs in a spawned thread; on timeout the main thread sets a stop flag and then calls:
// src/searchers/mod.rs:88
handle.join().unwrap();
A decoder stuck inside brainfuck-exe's execute() never returns to the search loop to observe stop, so handle.join() blocks forever — the program hangs permanently even after the timer "expires." A cooperative-cancellation flag cannot interrupt a non-cooperative infinite loop in a third-party interpreter.
Fix (one line; uses the crate's own API, existing error handling already catches it)
Set an instruction limit on the interpreter. When the cap trips, brainfuck-exe returns Err(BrainfuckError::… instructions reached the set limit) (crate error.rs:29), which the decoder's existing Err(e) => { … results } arm (line 74) already handles as "not Brainfuck" — no other change needed:
match Brainfuck::new(text)
.with_instructions_limit(BF_INSTRUCTION_CAP) // <-- the fix
.with_output_ref(&mut buf)
.execute()
{
Verified: with .with_instructions_limit(...) the PoC returns Err instead of hanging, and the decoder yields no result. Choose BF_INSTRUCTION_CAP tight enough that DoS is bounded to sub-second while real Brainfuck decodes still succeed — a legitimate decode is small (Hello-World ≈ hundreds of instructions); something on the order of low-millions is generous. Consider also with_mem_size(...) to bound the tape and capping the decoded-output length (a huge but finite output would still feed a giant string into the A* search). A private fix PR accompanies this report.
Scope / honest caveats
This is a denial-of-service finding only — no code execution, no data exposure. Impact is a permanent hang (and unbounded memory) of the Ciphey process on a crafted input; severity turns on A:H (a non-recoverable infinite loop, standard for a decode-bomb/ReDoS-class DoS). A maintainer who treats a killable CLI hang as A:L would score it ~3.3; the non-preemptible handle.join() and the unbounded allocation are why we score A:H. Verified against master @ bc65a71. Rust's regex-crate-based checkers are linear-time and were not found ReDoS-prone; this report is specifically the Brainfuck interpreter.
Reporter transparency
Found in review and verified with our own execution-based tooling, with AI assistance (Anthropic Claude/Opus). Every quantitative claim comes from running your own crate/code — please re-run the PoC. Happy to help land the fix or coordinate on timing.
Summary
Ciphey's Brainfuck decoder runs a Turing-complete interpreter on untrusted input with no execution bound:
brainfuck-exe0.2.4 exposeswith_instructions_limit(usize)whose default isNone= no limit (cratelib.rs:189), and Ciphey never sets it. The decoder's only guards (lines 53–62) are trivial to satisfy:text.contains(',')→ reject (no stdin reads)!text.ends_with('.') || text.matches('.').count() < 5→ need ≥5.and end with.text.matches(|c| "+-<>[]".contains(c)).count() < 20→ need ≥20 command charsA single crafted input passes all three and runs forever, producing unbounded output. Because the Brainfuck decoder is a registered, active decoder (
src/decoders/mod.rs:252) that the A* searcher runs on every input node, feeding Ciphey such input — directly, or any input its search decodes into it at some layer — hangs the whole program at 100% CPU with unbounded memory growth. There is no per-input decoder gating that would spare it:filtration_system::filter_and_get_decoders(_text_struct)ignores the input entirely (its argument is unused), andDecoders::runcalls.crack()on every component (src/filtration_system/mod.rs:61), so the Brainfuck decoder's own guards are the only thing standing between untrusted input andexecute(). Ciphey's entire purpose is processing untrusted input (CTF, forensics, automated pipelines), so this is squarely in its threat model.Proof of concept (input)
., 22 command chars (20×'+'+[+]), ends with., no,.[.....], so the loop condition (cell 0 ≠ 0) never becomes false → infinite loop; the trailing.is never reached.Verified on the exact crate Ciphey ships (
brainfuck-exe = 0.2.4, default-features = false):The control proves the harness runs Brainfuck correctly, so the bomb's non-termination is attributable to the input, not a broken harness. Left running, the output
Vecgrows without limit (observed ~71 MB accumulated in ~13 s even under a loose 100M-instruction cap) → OOM in addition to the hang.Why the global timeout does NOT mitigate it
Ciphey has a global
config.timeout(src/searchers/mod.rs:46). It does not rescue this case. The search runs in a spawned thread; on timeout the main thread sets astopflag and then calls:A decoder stuck inside
brainfuck-exe'sexecute()never returns to the search loop to observestop, sohandle.join()blocks forever — the program hangs permanently even after the timer "expires." A cooperative-cancellation flag cannot interrupt a non-cooperative infinite loop in a third-party interpreter.Fix (one line; uses the crate's own API, existing error handling already catches it)
Set an instruction limit on the interpreter. When the cap trips,
brainfuck-exereturnsErr(BrainfuckError::… instructions reached the set limit)(crateerror.rs:29), which the decoder's existingErr(e) => { … results }arm (line 74) already handles as "not Brainfuck" — no other change needed:Verified: with
.with_instructions_limit(...)the PoC returnsErrinstead of hanging, and the decoder yields no result. ChooseBF_INSTRUCTION_CAPtight enough that DoS is bounded to sub-second while real Brainfuck decodes still succeed — a legitimate decode is small (Hello-World ≈ hundreds of instructions); something on the order of low-millions is generous. Consider alsowith_mem_size(...)to bound the tape and capping the decoded-output length (a huge but finite output would still feed a giant string into the A* search). A private fix PR accompanies this report.Scope / honest caveats
This is a denial-of-service finding only — no code execution, no data exposure. Impact is a permanent hang (and unbounded memory) of the Ciphey process on a crafted input; severity turns on
A:H(a non-recoverable infinite loop, standard for a decode-bomb/ReDoS-class DoS). A maintainer who treats a killable CLI hang asA:Lwould score it ~3.3; the non-preemptiblehandle.join()and the unbounded allocation are why we scoreA:H. Verified againstmaster@bc65a71. Rust'sregex-crate-based checkers are linear-time and were not found ReDoS-prone; this report is specifically the Brainfuck interpreter.Reporter transparency
Found in review and verified with our own execution-based tooling, with AI assistance (Anthropic Claude/Opus). Every quantitative claim comes from running your own crate/code — please re-run the PoC. Happy to help land the fix or coordinate on timing.