Skip to content

[BUG] Datalog evaluator crashes on malformed query input #319

Closed

Description

@adityamukho

Describe the bug

The datalog_eval fuzzer discovered a crash in the datalog evaluator when processing malformed query inputs with invalid UTF-8 sequences and syntactic structures.

To reproduce

The crash can be reproduced using the failing input:

cargo fuzz run datalog_eval fuzz/artifacts/datalog_eval/crash-3e945c96e1e6b1d0eaa8ed9d5fb3eb2c3bc6e0e9

Or minimize the test case:

cargo +nightly fuzz tmin datalog_eval fuzz/artifacts/datalog_eval/crash-3e945c96e1e6b1d0eaa8ed9d5fb3eb2c3bc6e0e9

Minimal input

The crashing input (in hex):

28,71,75,65,114,121,32,91,58,102,58,97,115,45,111,102,32,34,61,61,61,61,61,61,61,61,89,217,164,63,114,61,61,1,0,0,0,91,0,0,1,0,65,11,108,105,99,101,34,91,63,101,32,32,63,110,93,93,32,58,97,115,107,102,41,10

Decoding to string (with non-UTF-8 bytes):

(query [:f:as-of "========Y\xd9\xa4?r==\x01\x00\x00\x00[\x00\x00\x01\x00A\x0blice"[?e  ?n]] :askf)\n

Expected behaviour

The datalog evaluator should either:

  1. Gracefully reject invalid inputs with a clear parse error, or
  2. Handle invalid UTF-8 sequences and malformed datalog syntax without crashing

Actual behaviour

The evaluator crashes with a deadly signal (exit status 77), causing libFuzzer to terminate.

NOTE: libFuzzer has rudimentary signal handlers.
      Combine libFuzzer with AddressSanitizer or similar for better crash reports.
SUMMARY: libFuzzer: deadly signal

Environment

  • Minigraf version: Latest (from commit e056905)
  • Build: Nightly fuzzer
  • OS: Ubuntu (runner environment)

Analysis

The crash occurs when the datalog parser/evaluator encounters:

  • Invalid UTF-8 byte sequences (\xd9\xa4 - incomplete UTF-8 multibyte sequence)
  • Malformed query structure with special characters and null bytes
  • Mixed invalid syntax tokens

The fuzzer was able to mutate valid input into this crash-inducing sequence through its dictionary-guided mutation process (indicated by MS: 1 PersAutoDict- DE: "Y\331\244?r").

Additional context

Fuzzer metadata:

  • Base unit: cc0b4e56ec223a334e85b318940db8c313894439
  • Crash artifact: /home/runner/work/minigraf/minigraf/fuzz/artifacts/datalog_eval/crash-3e945c96e1e6b1d0eaa8ed9d5fb3eb2c3bc6e0e9
  • Exit status: 77 (deadly signal)

This indicates a potential memory safety issue or panic that should be investigated and fixed to improve the robustness of the datalog evaluator against adversarial/malformed input.

Activity

  1. added theissue type on Aug 19, 2026
  2. adityamukho commented on Aug 22, 2026

    @adityamukho
    CollaboratorAuthor

    Another datalog_eval crash from the nightly fuzz run, likely the same underlying bug with a clearer diagnostic this time.

    Run: https://github.com/project-minigraf/minigraf/actions/runs/32551793746
    Commit: e056905
    Crash artifact: fuzz/artifacts/datalog_eval/crash-012232f88967026da67f1548a7d90910f6134d8a

    This time the panic location is captured:

    thread '<unnamed>' (5272) panicked at src/temporal.rs:19:45:
    start byte index 10 is not a char boundary; it is inside '\u{605}' (bytes 9..11 of string)
    

    Failing input bytes:

    [40, 113, 117, 101, 114, 121, 32, 91, 58, 58, 58, 97, 115, 45, 111, 102, 34, 102, 91, 114, 91, 89, 91, 91, 114, 91, 216, 133, 102, 34, 110, 95, 49, 93, 41, 10]
    

    Decoded: (query [:::as-of"f[r[Y[[r[\330\205f"n_1])\n

    Reproduce:

    cargo fuzz run datalog_eval fuzz/artifacts/datalog_eval/crash-012232f88967026da67f1548a7d90910f6134d8a

    Same shape as the original report: an :as-of query with a value containing a non-ASCII multi-byte UTF-8 char (\u{605} here vs \xd9\xa4 originally). The new evidence points at src/temporal.rs:19 doing a byte-index string slice (e.g. &s[..N]) that isn't validated against UTF-8 char boundaries before slicing — worth checking that as the root cause for both crashes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions