Skip to content

cactus-graph: op bounds-checks, IR-load validation & buffer-lifetime fixes - #701

Open
ncylich wants to merge 1 commit into
mainfrom
audit/graph-validation
Open

ncylich wants to merge 1 commit into
mainfrom
audit/graph-validation

Conversation

@ncylich

@ncylich ncylich commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Reduction/slice axis-bounds (builder, ops_math), MoE buffer allocation top_k factor (ops_nn), ADD_CLIPPED FP32/broadcast correctness (ops_math), TopK/seq-len underflow guards (ops_sample), output-slice shape (ops_tensor), image shape/size checks (ops_image), alias-root buffer-lifetime fix (execute), FFI null-cache-pointer guard (graph_ffi), malformed-graph overflow/precision/CQ-layout validation (io).

Signed-off-by: Noah Cylich noahcylich@gmail.com

…fixes

Reduction/slice axis-bounds (builder, ops_math), MoE buffer allocation top_k factor (ops_nn), ADD_CLIPPED FP32/broadcast correctness (ops_math), TopK/seq-len underflow guards (ops_sample), output-slice shape (ops_tensor), image shape/size checks (ops_image), alias-root buffer-lifetime fix (execute), FFI null-cache-pointer guard (graph_ffi), malformed-graph overflow/precision/CQ-layout validation (io).

Signed-off-by: Noah Cylich <noahcylich@gmail.com>
@kar-m

kar-m commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

@ncylich some fixes seem redundant
Cannot fire on any input:

  • io.cpp align_offset overflow (offset > SIZE_MAX - padding). All three call sites pass an offset bounded by file_size_ (a real mmap size): line 1024 is a small header constant; line 1029's scales_end is bounded by the PR's own new scales_bytes_ <= file_size_ check executed two lines earlier. To reach the overflow you'd need a ~16-exabyte file. This one is pure dead defense-in-depth.

Reachable only via malformed/crafted input (never fire for well-formed models — "hypothetical corruption" guards):

  • io.cpp prec_val > CQ4, scales extend beyond file, CQ mul_checked/add_checked overflow, footprint > scales_bytes_, and the underflow-safe data_offset_+byte_size_ rewrite — all reachable with a crafted/truncated weight file (group_size_, num_groups_, byte_size_ are raw header fields not otherwise bounded). Real hardening of the file parser.
  • ops_sample seq_len==0 and k > feature_size; ops_nn topk-shape and num_experts <= total; ops_image positive-dims / ch <= 3 / total_size match; ops_math compute_reduce_node axis — all reachable via malformed IR (file-supplied params/shape through add_node), unreachable through the normal transpiler which emits consistent values.

@ncylich
ncylich marked this pull request as ready for review June 12, 2026 06:38

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants