Pattern Libraries

The repository ships one pattern library per front end in patterns/. They are ordinary SPL files of pattern declarations, so you can read them, copy them, or write your own and load it with --pattern-file.

LibraryFront endHow it is loaded
patterns/x86-cwe-v0.6.splx86-64Automatically with --pattern-set v0.6
patterns/aarch64-trace-v0.1.splAArch64Explicitly: --pattern-file patterns/aarch64-trace-v0.1.spl
Paths are relative to the working directory
--pattern-set v0.6 loads patterns/x86-cwe-v0.6.spl (and any patterns/generated-v6/ rules) relative to the directory saple runs in. Run from a checkout of the repository, or pass the file with --pattern-file. The release packages contain the binary only.

x86-64: x86-cwe-v0.6.spl#

The patterns that apply to x86-64 models carry the suffix _bv. They are written in the model's native bit-vector type: extract<31, 0>(r) takes the low 32 bits of a register, zero_extend(x, 32) widens a 32-bit value back to 64, and a 32-bit multiply wraps when the high half of the product of the zero-extended operands is non-zero.

PatternSignatureCondition
cwe_190_imul32_wraparound_before_malloc_bvimul32 . call_mallocThree-operand 32-bit imul wraps and the wrapped product is the malloc size
cwe_190_imul32_wraparound_before_calloc_bvimul32 . call_callocSame, product passed as either calloc argument
cwe_190_imul32_wraparound_alloc_then_copy_bvimul32 . call_malloc . call_memcpyWrapped size allocated, then a memcpy count above it
cwe_190_imul32_two_operand_wraparound_before_malloc_bv, …_calloc_bvimul(…, 32, 2) . call_malloc / call_callocTwo-operand form imul eax, esi
cwe_190_imul32_one_operand_wraparound_before_malloc_bv, …_calloc_bvimul_wide(…, 32) . call_malloc / call_callocOne-operand form imul ecx
cwe_476_null_deref_load_bvmov_memA load from address 0

All are CRITICAL. The same file also holds older patterns with the suffix _v6 (and cwe_476_null_deref_load), written for an integer schema. On an x86-64 model their constraints do not type; they are reported as undecided with a width mismatch note and do not affect the exit status.

AArch64: aarch64-trace-v0.1.spl#

67 patterns over the action names of AArch64 trace models. Memory actions are named <mnemonic>[_<x|w>]_<imm|pre|post|reg>, so most patterns come in one variant per addressing form. The memory patterns read the shadow attributes libc.last_alloc_ptr, libc.last_alloc_size, libc.last_free_ptr and libc.last_free_size, which call_malloc, call_calloc and call_free maintain. Comparisons are unsigned (<u, >=u, …).

GroupPatternsSeverity
CWE-190 size wrap into malloccwe_190_adds_w_into_malloc (32-bit adds wraps, the sum is the size); cwe_190_mul_x_into_malloc, cwe_190_umulh_x_into_malloc (64-bit multiply overflows: umulh high half non-zero next to the mul whose low half is the size)HIGH
CWE-190 overflow into a storecwe_190_overflow_into_store_w, …_x and their str_w_imm, strb_imm, strh_imm variants: a signed overflow whose sum is stored or used as the store baseHIGH
CWE-190 flag observationscwe_190_adds_signed_overflow_w/_x, cwe_190_subs_signed_overflow_w/_x (V == 1), cwe_190_adds_unsigned_carry_w/_x (C == 1)LOW
CWE-122 store past the allocationcwe_122_store_past_allocation and 15 variants (str_x, str_w, strb, strh × imm, pre, post, reg): a store at or past the end of the last allocation, within one page of itCRITICAL
CWE-416 use after freecwe_416_load_after_free and 15 load variants: a load through the freed pointer; cwe_416_load_in_freed_block: a load inside a released block of known sizeCRITICAL
CWE-476 null dereferencecwe_476_load_from_null and 15 load variants: a load whose base is below 0x1000HIGH
CWE-367 time-of-check/time-of-usecwe_367_store_after_load_same_address: a store to the address an earlier load read, with a different value (it also matches an ordinary read-modify-write, so it does not show that a race is real)MEDIUM

A flag observation records that V or C was set; on its own it is not a vulnerability (an addition of -8 sets C), hence LOW.

Chain patterns#

saple compose closes a set of patterns under composition and writes the composites as a new pattern file, applied with --pattern-file:

Shell
saple compose --rules patterns/aarch64-trace-v0.1.spl --out composed.spl --json composed.json
Output
compose: 67 seeds (67 composable) -> 588 composites (depth 1; Implied 210, Reachable 378); 2000 solver queries, 0 folded, 1970 cache hits, 209 subsumed, 2 duplicates, 0 below Reachable; budget exhausted

See CLI Tools for the options.

↑ ↓ to moveEnter to openEsc to close