From 2c215e46e543f0589fdced604552ac8a845da157 Mon Sep 17 00:00:00 2001 From: "russell@unturf.com" Date: Tue, 31 Mar 2026 22:38:59 -0400 Subject: [PATCH] libvorbis+libopus: 5-MOAD scan; CLEAN both targets --- defects/libopus-scan/patch/CLEAN.md | 85 +++++++++++++++++++++++++++ defects/libvorbis-scan/patch/CLEAN.md | 78 ++++++++++++++++++++++++ 2 files changed, 163 insertions(+) create mode 100644 defects/libopus-scan/patch/CLEAN.md create mode 100644 defects/libvorbis-scan/patch/CLEAN.md diff --git a/defects/libopus-scan/patch/CLEAN.md b/defects/libopus-scan/patch/CLEAN.md new file mode 100644 index 000000000..014f7ffbc --- /dev/null +++ b/defects/libopus-scan/patch/CLEAN.md @@ -0,0 +1,85 @@ +# libopus (Opus audio codec) — 5-MOAD Scan Result: CLEAN + +**Target:** xiph/opus +**Source:** https://github.com/xiph/opus +**Scan Date:** 2026-03-31 +**Language:** C + +--- + +## MOAD-0001 — CWE-407: Algorithmic Complexity (list membership in loop) + +### Candidates investigated + +**`silk/sort.c` — `silk_insertion_sort_increasing_all_values_int16()` (lines 147–153)** + +Insertion sort O(L²) worst case. L = LPC order, which is spec-fixed: 10 (NB/MB) +or 16 (WB). Max 256 comparisons per call. Called only in `silk_NLSF_stabilize` +fallback path when iterative adjustment exceeds MAX_LOOPS=20, which is itself a +rare corner case. Bounded absolutely. Not actionable. + +**`silk/NLSF_stabilize.c` — main loop (lines 60–118)** + +Outer loop over MAX_LOOPS=20 iterations. Inner loops over L (10 or 16) elements +for min-diff search, plus two accumulation loops over kI (up to L). +Total: O(20 × L) = O(320) ops worst case. Spec-bounded. CLEAN. + +**`silk/NLSF_VQ.c` — `silk_NLSF_VQ()` codebook search (lines 54–75)** + +O(K × LPC_order) where K=nVectors. Both codebooks (WB and NB/MB) have K=32 +and LPC_order of 16 or 10. Max 512 ops per call. Spec-bounded. CLEAN. + +**`silk/NLSF_encode.c` — `silk_insertion_sort_increasing()` on K=32 errors (line 75)** + +Partial insertion sort to find nSurvivors best candidates from 32. K=32 is +spec-fixed. CLEAN. + +**`src/opus_multistream.c` — `get_left_channel()` / `get_right_channel()` / `get_mono_channel()` (lines 57–91)** + +Per-frame call inside the outer `for(s=0; sserialnos[link]` inside page-reading loop. `vf->links` is +the number of chained bitstreams in the file — typically 1–3 for real files. +Seek-path only, not hot decode path. CLEAN. + +### Verdict: CLEAN — no CWE-407 defects + +--- + +## MOAD-0002 — Intertangle: shared mutable global state / god object + +No mutable process-global state in the encode/decode path. All per-session state +lives in `vorbis_dsp_state`, `vorbis_block`, `vorbis_info` — caller-owned structs. +`lib/misc.c` global tracking (`pointers`, `global_bytes`) is `#ifdef DEBUG_MALLOC` +only — not compiled in production. `mapping0.c` `seq`/`total` statics are inside +`#if 0` dead code block. CLEAN. + +--- + +## MOAD-0003 — Leaked Context: ThreadLocal / thread-scoped request identity + +No `pthread_getspecific`, `__thread`, `thread_local`, or equivalent in any +encode/decode path. Pure C library with caller-owned state. CLEAN. + +--- + +## MOAD-0004 — CWE-312: credentials or keys logged verbatim + +Pure audio codec library. No auth flows, HTTP headers, API keys, or credential +handling anywhere in our codebase. CLEAN. + +--- + +## MOAD-0005 — Thundering Herd: unsynchronized cache get+null+compute+put + +No caching with unsynchronized double-checked access. `lib/floor0.c`/`floor1.c` +memo arrays are stack-local per-block, passed explicitly. `lib/smallft.c` +trigcache is computed once during `drft_init` in single-threaded setup, never +updated after initialization. CLEAN.